mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
@ -0,0 +1,115 @@
|
||||
#==========================================================================
|
||||
#
|
||||
# Program: ParaView
|
||||
#
|
||||
# Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# ParaView is a free software; you can redistribute it and/or modify it
|
||||
# under the terms of the ParaView license version 1.2.
|
||||
#
|
||||
# See License_v1.2.txt for the full ParaView license.
|
||||
# A copy of this license can be obtained by contacting
|
||||
# Kitware Inc.
|
||||
# 28 Corporate Drive
|
||||
# Clifton Park, NY 12065
|
||||
# USA
|
||||
#
|
||||
# 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 THE AUTHORS 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.
|
||||
#
|
||||
#==========================================================================
|
||||
set (Module_SRCS
|
||||
vtkPVCatalystSessionCore.cxx
|
||||
vtkPVProxyDefinitionIterator.cxx
|
||||
vtkPVSessionBase.cxx
|
||||
vtkPVSessionCore.cxx
|
||||
vtkPVSessionCoreInterpreterHelper.cxx
|
||||
vtkPVSessionServer.cxx
|
||||
vtkSIArraySelectionProperty.cxx
|
||||
vtkSIIndexSelectionProperty.cxx
|
||||
vtkSICollaborationManager.cxx
|
||||
vtkSICompoundSourceProxy.cxx
|
||||
vtkSIDataArrayProperty.cxx
|
||||
vtkSIDirectoryProxy.cxx
|
||||
vtkSIDoubleMapProperty.cxx
|
||||
vtkSIDoubleVectorProperty.cxx
|
||||
vtkSIMetaReaderProxy.cxx
|
||||
vtkSIIdTypeVectorProperty.cxx
|
||||
vtkSIInputProperty.cxx
|
||||
vtkSIIntVectorProperty.cxx
|
||||
vtkSIObject.cxx
|
||||
vtkSIProperty.cxx
|
||||
vtkSIProxy.cxx
|
||||
vtkSIProxyDefinitionManager.cxx
|
||||
vtkSIProxyProperty.cxx
|
||||
vtkSISILProperty.cxx
|
||||
vtkSISourceProxy.cxx
|
||||
vtkSIStringVectorProperty.cxx
|
||||
vtkSITimeLabelProperty.cxx
|
||||
vtkSITimeRangeProperty.cxx
|
||||
vtkSITimeStepsProperty.cxx
|
||||
vtkSIVectorProperty.cxx
|
||||
vtkSIWriterProxy.cxx
|
||||
vtkSMMessage.cxx
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
vtkSMMessage
|
||||
WRAP_EXCLUDE)
|
||||
|
||||
set_source_files_properties(
|
||||
vtkPVProxyDefinitionIterator.cxx
|
||||
vtkPVSessionBase.cxx
|
||||
vtkSIVectorProperty.cxx
|
||||
vtkSMMessage.cxx
|
||||
ABSTRACT)
|
||||
|
||||
# Add header-only files so they get installed correctly.
|
||||
set (${vtk-module}_HDRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkSMMessageMinimal.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/vtkPVMessage.pb.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkSIVectorPropertyTemplate.h
|
||||
)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Generate the protbuf message file.
|
||||
#------------------------------------------------------------------------------
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vtkPVMessage.pb.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/vtkPVMessage.pb.cc
|
||||
|
||||
COMMAND protoc_compiler
|
||||
"--cpp_out=dllexport_decl=VTKPVSERVERIMPLEMENTATIONCORE_EXPORT:${CMAKE_CURRENT_BINARY_DIR}"
|
||||
--proto_path "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vtkPVMessage.proto"
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vtkPVMessage.proto protoc_compiler
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
protobuf_code_generation
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/vtkPVMessage.pb.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/vtkPVMessage.pb.cc
|
||||
)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
if (WIN32 AND BUILD_SHARED_LIBS)
|
||||
add_definitions(-DPROTOBUF_USE_DLLS)
|
||||
endif()
|
||||
|
||||
vtk_module_library(vtkPVServerImplementationCore
|
||||
${Module_SRCS})
|
||||
|
||||
add_dependencies(vtkPVServerImplementationCore
|
||||
protobuf_code_generation)
|
||||
@ -0,0 +1,11 @@
|
||||
vtk_module(vtkPVServerImplementationCore
|
||||
GROUPS
|
||||
ParaViewCore
|
||||
DEPENDS
|
||||
vtkPVClientServerCoreCore
|
||||
vtkprotobuf
|
||||
PRIVATE_DEPENDS
|
||||
vtksys
|
||||
TEST_LABELS
|
||||
PARAVIEW
|
||||
)
|
||||
@ -0,0 +1,213 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVCatalystSessionCore.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkPVCatalystSessionCore.h"
|
||||
|
||||
#include "vtkCommand.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVDataInformation.h"
|
||||
#include "vtkPVInformation.h"
|
||||
#include "vtkPVSession.h"
|
||||
#include "vtkSISourceProxy.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
//****************************************************************************/
|
||||
// Internal Class
|
||||
//****************************************************************************/
|
||||
class vtkPVCatalystSessionCore::vtkInternal
|
||||
{
|
||||
public:
|
||||
vtkInternal(vtkPVCatalystSessionCore* parent)
|
||||
{
|
||||
this->Owner = parent;
|
||||
this->ObserverId = this->Owner->AddObserver(
|
||||
vtkCommand::UpdateDataEvent,
|
||||
this,
|
||||
&vtkPVCatalystSessionCore::vtkInternal::UpdateToCatalyseSourceProxy);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
~vtkInternal()
|
||||
{
|
||||
if(this->Owner)
|
||||
{
|
||||
this->Owner->RemoveObserver(this->ObserverId);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
vtkTypeUInt32 RegisterDataInformation(vtkTypeUInt32 globalid, unsigned int port, vtkPVInformation *info)
|
||||
{
|
||||
vtkTypeUInt32 correctId = this->GetMappedId(globalid);
|
||||
if(correctId != 0)
|
||||
{
|
||||
//cout << "RegisterDataInformation: " << correctId << " " << port << endl;
|
||||
std::string id = this->GenerateID(correctId, port, info);
|
||||
this->DataInformationMap[id] = info;
|
||||
}
|
||||
return correctId;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void UnRegisterDataInformation(vtkTypeUInt32 globalid)
|
||||
{
|
||||
std::string id = this->GenerateID(globalid, 0, NULL);
|
||||
std::vector<std::string> keysToDelete;
|
||||
std::map<std::string, vtkSmartPointer<vtkPVInformation> >::iterator iter;
|
||||
for( iter = this->DataInformationMap.begin();
|
||||
iter != this->DataInformationMap.end();
|
||||
iter++)
|
||||
{
|
||||
if(iter->first.find(id) == 0)
|
||||
{
|
||||
keysToDelete.push_back(iter->first);
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup the map
|
||||
std::vector<std::string>::iterator deleteIter;
|
||||
for( deleteIter = keysToDelete.begin();
|
||||
deleteIter != keysToDelete.end();
|
||||
deleteIter++)
|
||||
{
|
||||
this->DataInformationMap.erase(*deleteIter);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool GatherInformation(vtkTypeUInt32 globalid, unsigned int port, vtkPVInformation *info)
|
||||
{
|
||||
//cout << "GatherInformation: " << globalid << " " << port << endl;
|
||||
std::string id = this->GenerateID(globalid, port, info);
|
||||
vtkPVInformation *storedValue = this->DataInformationMap[id];
|
||||
|
||||
if(storedValue)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
storedValue->CopyToStream(&stream);
|
||||
info->CopyFromStream(&stream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
std::string GenerateID(vtkTypeUInt32 globalid, unsigned int port, vtkPVInformation *info)
|
||||
{
|
||||
std::ostringstream id;
|
||||
id << globalid << ":";
|
||||
if(info)
|
||||
{
|
||||
id << port << ":" << info->GetClassName();
|
||||
}
|
||||
return id.str();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void UpdateToCatalyseSourceProxy(vtkObject*, unsigned long, void* data)
|
||||
{
|
||||
vtkObject* obj = reinterpret_cast<vtkObject*>(data);
|
||||
vtkSISourceProxy* siSourceProxy = vtkSISourceProxy::SafeDownCast(obj);
|
||||
if(siSourceProxy)
|
||||
{
|
||||
siSourceProxy->SetDisablePipelineExecution(true);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void ResetIdMap()
|
||||
{
|
||||
this->IdMap.clear();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void UpdateIdMap(vtkTypeUInt32* data, int size)
|
||||
{
|
||||
for(int i=0; i < size; i += 2)
|
||||
{
|
||||
this->IdMap[data[i]] = data[i+1];
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
vtkTypeUInt32 GetMappedId(vtkTypeUInt32 originalId)
|
||||
{
|
||||
std::map<vtkTypeUInt32,vtkTypeUInt32>::iterator iter;
|
||||
iter = this->IdMap.find(originalId);
|
||||
if(iter != this->IdMap.end())
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkWeakPointer<vtkPVCatalystSessionCore> Owner;
|
||||
unsigned long ObserverId;
|
||||
std::map<std::string, vtkSmartPointer<vtkPVInformation> > DataInformationMap;
|
||||
std::map<vtkTypeUInt32,vtkTypeUInt32> IdMap;
|
||||
};
|
||||
//****************************************************************************/
|
||||
vtkStandardNewMacro(vtkPVCatalystSessionCore);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVCatalystSessionCore::vtkPVCatalystSessionCore()
|
||||
{
|
||||
this->CatalystInternal = new vtkInternal(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVCatalystSessionCore::~vtkPVCatalystSessionCore()
|
||||
{
|
||||
delete this->CatalystInternal;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVCatalystSessionCore::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVCatalystSessionCore::GatherInformation( vtkTypeUInt32 location,
|
||||
vtkPVInformation* information,
|
||||
vtkTypeUInt32 globalid)
|
||||
{
|
||||
if (globalid == 0)
|
||||
{
|
||||
information->CopyFromObject(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(vtkPVDataInformation* dataInfo = vtkPVDataInformation::SafeDownCast(information))
|
||||
{
|
||||
return this->CatalystInternal->GatherInformation(globalid, dataInfo->GetPortNumber(), information);
|
||||
}
|
||||
return this->Superclass::GatherInformation(location, information, globalid);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkTypeUInt32 vtkPVCatalystSessionCore::RegisterDataInformation(vtkTypeUInt32 globalid, unsigned int port, vtkPVInformation* info)
|
||||
{
|
||||
return this->CatalystInternal->RegisterDataInformation(globalid, port, info);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVCatalystSessionCore::UpdateIdMap(vtkTypeUInt32* idMapArray, int size)
|
||||
{
|
||||
this->CatalystInternal->UpdateIdMap(idMapArray, size);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVCatalystSessionCore::ResetIdMap()
|
||||
{
|
||||
this->CatalystInternal->ResetIdMap();
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVCatalystSessionCore.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkPVCatalystSessionCore
|
||||
// .SECTION Description
|
||||
// vtkPVCatalystSessionCore is used by vtkSMSession.
|
||||
// vtkPVCatalystSessionCore handle catalyst based proxy which don't contains any
|
||||
// real data and therefore are not allowed to execute the VTK pipeline.
|
||||
// @ingroup LiveInsitu
|
||||
|
||||
#ifndef vtkPVCatalystSessionCore_h
|
||||
#define vtkPVCatalystSessionCore_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkPVSessionCore.h"
|
||||
#include "vtkSMMessageMinimal.h" // needed for vtkSMMessage.
|
||||
#include "vtkWeakPointer.h" // needed for vtkMultiProcessController
|
||||
|
||||
class vtkPVInformation;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkPVCatalystSessionCore : public vtkPVSessionCore
|
||||
{
|
||||
public:
|
||||
static vtkPVCatalystSessionCore* New();
|
||||
vtkTypeMacro(vtkPVCatalystSessionCore, vtkPVSessionCore);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Gather information about an object referred by the \c globalid.
|
||||
// \c location identifies the processes to gather the information from.
|
||||
virtual bool GatherInformation( vtkTypeUInt32 location,
|
||||
vtkPVInformation* information,
|
||||
vtkTypeUInt32 globalid );
|
||||
|
||||
// Description:
|
||||
// Update the data information for a given proxy with the given globalid.
|
||||
// This will allow the GatherInformation to work with "fake" VTK pipeline.
|
||||
// Return the real corresponding proxy id
|
||||
vtkTypeUInt32 RegisterDataInformation(vtkTypeUInt32 globalid, unsigned int port,
|
||||
vtkPVInformation* information);
|
||||
|
||||
void UpdateIdMap(vtkTypeUInt32* idMapArray, int size);
|
||||
void ResetIdMap();
|
||||
//BTX
|
||||
protected:
|
||||
vtkPVCatalystSessionCore();
|
||||
~vtkPVCatalystSessionCore();
|
||||
|
||||
private:
|
||||
vtkPVCatalystSessionCore(const vtkPVCatalystSessionCore&); // Not implemented
|
||||
void operator=(const vtkPVCatalystSessionCore&); // Not implemented
|
||||
|
||||
class vtkInternal;
|
||||
vtkInternal* CatalystInternal;
|
||||
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,263 @@
|
||||
// ****************************************************************************
|
||||
// vtkInternalDataStreamIO.proto
|
||||
// ****************************************************************************
|
||||
package paraview_protobuf;
|
||||
|
||||
// Type of generated code : [SPEED, CODE_SIZE, LITE_RUNTIME]
|
||||
//option optimize_for = LITE_RUNTIME;
|
||||
|
||||
// Variant type ***************************************************************
|
||||
|
||||
message Variant {
|
||||
enum Type
|
||||
{
|
||||
INT = 0;
|
||||
FLOAT64 = 1;
|
||||
IDTYPE = 2;
|
||||
STRING = 3;
|
||||
PROXY = 4; // proxy_global_id + port_number
|
||||
INPUT = 5; // proxy_global_id + port_number
|
||||
BYTES = 6;
|
||||
MAP = 7;
|
||||
}
|
||||
|
||||
required Type type = 1;
|
||||
repeated sint64 idtype = 3;
|
||||
repeated sint32 integer = 4;
|
||||
repeated double float64 = 5;
|
||||
repeated uint64 proxy_global_id = 6;
|
||||
repeated int32 port_number = 7;
|
||||
repeated string txt = 8;
|
||||
repeated bytes binary = 9;
|
||||
}
|
||||
|
||||
message VariantList {
|
||||
repeated Variant variant = 1;
|
||||
}
|
||||
|
||||
// Generic message Collection type ********************************************
|
||||
|
||||
message MessageCollection
|
||||
{
|
||||
// This defines an item in the collection.
|
||||
repeated Message item = 1;
|
||||
}
|
||||
|
||||
// Generic message type ******************************************* [1-5 :> 10]
|
||||
|
||||
message Message
|
||||
{
|
||||
required uint64 global_id = 1;
|
||||
required uint32 location = 2;
|
||||
optional bool share_only = 3 [default = false];
|
||||
optional bool req_def = 4 [default = false];
|
||||
optional uint32 client_id = 5 [default = 0];
|
||||
|
||||
extensions 10 to max;
|
||||
}
|
||||
|
||||
// Extension DefinitionHeader ***************************************** [10-11]
|
||||
|
||||
message DefinitionHeader
|
||||
{
|
||||
extend Message {
|
||||
// The classname for the driver process i.e. the client, typically
|
||||
optional string client_class = 10;
|
||||
|
||||
// The classname for the process where the processing occurs
|
||||
optional string server_class = 11;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension ProxyState *********************************************** [20-27]
|
||||
|
||||
message ProxyState
|
||||
{
|
||||
|
||||
message SubProxy
|
||||
{
|
||||
required string name = 1;
|
||||
required uint32 global_id = 2;
|
||||
}
|
||||
|
||||
message Annotation
|
||||
{
|
||||
required string key = 1;
|
||||
required string value = 2;
|
||||
}
|
||||
|
||||
message UserData
|
||||
{
|
||||
required string key = 1;
|
||||
repeated Variant variant = 2;
|
||||
}
|
||||
|
||||
message Property
|
||||
{
|
||||
required string name = 1;
|
||||
optional Variant value = 2;
|
||||
repeated UserData user_data = 3;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
optional string xml_group = 20;
|
||||
optional string xml_name = 21;
|
||||
optional string xml_sub_proxy_name = 22;
|
||||
repeated Property property = 23;
|
||||
repeated SubProxy subproxy = 24;
|
||||
repeated Annotation annotation = 25;
|
||||
optional bool has_annotation = 26 [default = false];
|
||||
repeated UserData user_data = 27;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension PXMState ************************************************* [30-32]
|
||||
|
||||
message PXMRegistrationState
|
||||
{
|
||||
message Entry
|
||||
{
|
||||
optional string group = 1;
|
||||
required string name = 2;
|
||||
required uint64 global_id = 3;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
repeated Entry registered_proxy = 30;
|
||||
repeated Entry registered_selection_model = 31;
|
||||
repeated Entry registered_link = 32;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension ProxyDefinitionState ************************************* [35-36]
|
||||
|
||||
message ProxyDefinitionState
|
||||
{
|
||||
message ProxyXMLDefinition
|
||||
{
|
||||
required string group = 1;
|
||||
required string name = 2;
|
||||
required string xml = 3;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
repeated ProxyXMLDefinition xml_definition_proxy = 35;
|
||||
repeated ProxyXMLDefinition xml_custom_definition_proxy = 36;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension PullRequest ************************************************* [40]
|
||||
|
||||
message PullRequest {
|
||||
extend Message {
|
||||
repeated Variant arguments = 40;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension ProxySelectionModel State ******************************** [50-53]
|
||||
|
||||
message ProxySelectionModelState {
|
||||
|
||||
extend Message {
|
||||
optional uint32 current_proxy = 52 [default = 0];
|
||||
optional int32 current_port = 53 [default = -1];
|
||||
|
||||
repeated uint32 proxy = 50;
|
||||
repeated int32 port = 51;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension Link State *********************************************** [60-64]
|
||||
|
||||
message LinkState {
|
||||
|
||||
message LinkDescription
|
||||
{
|
||||
// Need to be in sync with the enum in vtkSMLink.h
|
||||
enum Direction
|
||||
{
|
||||
NONE = 0;
|
||||
INPUT = 1;
|
||||
OUTPUT = 2;
|
||||
}
|
||||
|
||||
required uint32 proxy = 1;
|
||||
optional string property_name = 2;
|
||||
required Direction direction = 3;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
optional bool propagate_update = 60 [default = true];
|
||||
optional bool enabled = 61 [default = true];
|
||||
optional bool sync_interactive_renders = 62 [default = true];
|
||||
repeated LinkDescription link = 63;
|
||||
repeated string exception_property = 64;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension MousePointer Event *************************************** [70-73]
|
||||
|
||||
message MousePointer {
|
||||
|
||||
enum Ratio {
|
||||
BOTH = 0;
|
||||
HEIGHT = 1;
|
||||
WIDTH = 2;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
optional uint32 view = 70;
|
||||
optional double x = 71 [default = 0];
|
||||
optional double y = 72 [default = 0];
|
||||
optional bool forceShow = 73 [default = false];
|
||||
optional Ratio ratioType = 74 [default = HEIGHT];
|
||||
}
|
||||
}
|
||||
|
||||
// Extension ChartViewBounds Event ************************************ [75-76]
|
||||
|
||||
message ChartViewBounds {
|
||||
|
||||
extend Message {
|
||||
optional uint32 view = 75;
|
||||
repeated double range = 76;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension ClientsInformation State ********************************* [80-85]
|
||||
|
||||
message ClientsInformation {
|
||||
|
||||
message ClientInfo {
|
||||
required uint32 user = 1;
|
||||
optional string name = 2;
|
||||
optional bool is_master = 3 [default = false];
|
||||
optional bool follow_cam = 4 [default = false];
|
||||
}
|
||||
|
||||
extend Message {
|
||||
repeated ClientInfo user = 80;
|
||||
}
|
||||
}
|
||||
|
||||
message ChatMessage {
|
||||
extend Message {
|
||||
optional uint32 author = 84;
|
||||
optional string txt = 85;
|
||||
}
|
||||
}
|
||||
|
||||
// Extension Qt Events ************************************************ [98-99]
|
||||
|
||||
message QtEvent {
|
||||
enum QtEventType {
|
||||
CHAT = 1;
|
||||
OTHER = 3;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
optional QtEventType type = 98;
|
||||
}
|
||||
}
|
||||
|
||||
// End of Messages definitions ************************************************
|
||||
@ -0,0 +1,32 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVProxyDefinitionIterator.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkPVProxyDefinitionIterator.h"
|
||||
|
||||
#include "vtkObjectFactory.h"
|
||||
class vtkPVXMLElement;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
vtkPVProxyDefinitionIterator::vtkPVProxyDefinitionIterator()
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
vtkPVProxyDefinitionIterator::~vtkPVProxyDefinitionIterator()
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void vtkPVProxyDefinitionIterator::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVProxyDefinitionIterator.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkPVProxyDefinitionIterator - iterates over all proxy definitions
|
||||
// from which the vtkSMProxyManager can use to create new proxy.
|
||||
// It can also iterate over registered compound proxy definitions.
|
||||
// .SECTION Description
|
||||
// vtkPVProxyDefinitionIterator iterates over all proxy definitions known to
|
||||
// the proxy manager. The iterator allow to filter the iteration on a
|
||||
// subset of group and/or on the global or custom proxies.
|
||||
// Custom and Compound proxy are exactly the same thing. We should stick with
|
||||
// only one name.
|
||||
// .SECTION See Also
|
||||
// vtkSMProxyManager
|
||||
|
||||
#ifndef vtkPVProxyDefinitionIterator_h
|
||||
#define vtkPVProxyDefinitionIterator_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkObject.h"
|
||||
|
||||
class vtkPVXMLElement;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkPVProxyDefinitionIterator : public vtkObject
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkPVProxyDefinitionIterator, vtkObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// ********* Iterator Commom methods **********
|
||||
|
||||
// Description:
|
||||
// Move the iterator to the beginning.
|
||||
virtual void GoToFirstItem() = 0;
|
||||
|
||||
// Description:
|
||||
// Reset the iterator and move it to the head.
|
||||
virtual void InitTraversal()
|
||||
{ this->GoToFirstItem(); }
|
||||
|
||||
// Description:
|
||||
// Move the iterator to the next item. This will also move to next group
|
||||
// automatically if needed.
|
||||
virtual void GoToNextItem() = 0;
|
||||
|
||||
// Description:
|
||||
// Move the iterator to the next group.
|
||||
virtual void GoToNextGroup() = 0;
|
||||
|
||||
// Description:
|
||||
// Test whether the iterator is currently pointing to a valid
|
||||
// item.
|
||||
virtual bool IsDoneWithTraversal() = 0;
|
||||
|
||||
|
||||
// ********* Configuration methods **********
|
||||
|
||||
virtual void AddTraversalGroupName(const char* groupName) = 0;
|
||||
|
||||
// ********* Access methods **********
|
||||
|
||||
// Access methods
|
||||
/// Return the current group name or NULL if Next() was never called.
|
||||
virtual const char* GetGroupName() = 0;
|
||||
/// Return the current proxy name or NULL if Next() was never called.
|
||||
virtual const char* GetProxyName() = 0;
|
||||
/// Return true if the current definition has been defined in the Custom scope
|
||||
virtual bool IsCustom() { return false; };
|
||||
/// Return the current XML proxy definition
|
||||
virtual vtkPVXMLElement* GetProxyDefinition() = 0;
|
||||
/// Return the current XML proxy hints
|
||||
virtual vtkPVXMLElement* GetProxyHints() = 0;
|
||||
|
||||
protected:
|
||||
vtkPVProxyDefinitionIterator();
|
||||
virtual ~vtkPVProxyDefinitionIterator();
|
||||
|
||||
private:
|
||||
vtkPVProxyDefinitionIterator(const vtkPVProxyDefinitionIterator&); // Not implemented.
|
||||
void operator=(const vtkPVProxyDefinitionIterator&); // Not implemented.
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,382 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionBase.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkPVSessionBase.h"
|
||||
|
||||
#include "vtkCommand.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVServerInformation.h"
|
||||
#include "vtkPVMultiClientsInformation.h"
|
||||
#include "vtkProcessModule.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkPVSessionCore.h"
|
||||
#include "vtkWeakPointer.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <assert.h>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionBase::vtkPVSessionBase()
|
||||
{
|
||||
this->InitSessionBase(vtkPVSessionCore::New());
|
||||
this->SessionCore->UnRegister(NULL);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionBase::vtkPVSessionBase(vtkPVSessionCore* coreToUse )
|
||||
{
|
||||
this->InitSessionBase(coreToUse);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::InitSessionBase(vtkPVSessionCore* coreToUse)
|
||||
{
|
||||
this->ProcessingRemoteNotification = false;
|
||||
this->SessionCore = coreToUse;
|
||||
if(this->SessionCore)
|
||||
{
|
||||
this->SessionCore->Register(NULL);
|
||||
}
|
||||
|
||||
// initialize local process information.
|
||||
this->LocalServerInformation = vtkPVServerInformation::New();
|
||||
this->LocalServerInformation->CopyFromObject(NULL);
|
||||
|
||||
// This ensure that whenever a message is received on the parallel
|
||||
// controller, this session is marked active. This is essential for
|
||||
// satellites when running in parallel.
|
||||
vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController();
|
||||
this->ActivateObserverTag = this->DesactivateObserverTag = 0;
|
||||
|
||||
if(!controller)
|
||||
{
|
||||
vtkWarningMacro("No vtkMultiProcessController for Session. The session won't work correctly.");
|
||||
return;
|
||||
}
|
||||
|
||||
this->ActivateObserverTag = controller->AddObserver(vtkCommand::StartEvent,
|
||||
this, &vtkPVSessionBase::Activate);
|
||||
this->DesactivateObserverTag = controller->AddObserver(vtkCommand::EndEvent,
|
||||
this, &vtkPVSessionBase::DeActivate);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionBase::~vtkPVSessionBase()
|
||||
{
|
||||
// Make sure we disable Activate/Desactivate observer
|
||||
vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController();
|
||||
if(controller && this->ActivateObserverTag && this->DesactivateObserverTag)
|
||||
{
|
||||
controller->RemoveObserver(this->ActivateObserverTag);
|
||||
controller->RemoveObserver(this->DesactivateObserverTag);
|
||||
}
|
||||
|
||||
if (this->SessionCore)
|
||||
{
|
||||
this->SessionCore->Delete();
|
||||
this->SessionCore = NULL;
|
||||
}
|
||||
|
||||
this->LocalServerInformation->Delete();
|
||||
this->LocalServerInformation = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxyDefinitionManager* vtkPVSessionBase::GetProxyDefinitionManager()
|
||||
{
|
||||
return this->SessionCore->GetProxyDefinitionManager();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionBase::ServerFlags vtkPVSessionBase::GetProcessRoles()
|
||||
{
|
||||
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
|
||||
assert(pm != NULL);
|
||||
|
||||
int process_id = pm->GetPartitionId();
|
||||
switch (pm->GetProcessType())
|
||||
{
|
||||
case vtkProcessModule::PROCESS_SERVER:
|
||||
return vtkPVSession::SERVERS;
|
||||
|
||||
case vtkProcessModule::PROCESS_DATA_SERVER:
|
||||
return vtkPVSession::DATA_SERVER;
|
||||
|
||||
case vtkProcessModule::PROCESS_RENDER_SERVER:
|
||||
return vtkPVSession::RENDER_SERVER;
|
||||
|
||||
case vtkProcessModule::PROCESS_BATCH:
|
||||
return (process_id == 0)?
|
||||
vtkPVSession::CLIENT_AND_SERVERS :
|
||||
vtkPVSession::SERVERS;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return this->Superclass::GetProcessRoles();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVServerInformation* vtkPVSessionBase::GetServerInformation()
|
||||
{
|
||||
return this->LocalServerInformation;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::PushState(vtkSMMessage* msg)
|
||||
{
|
||||
this->Activate();
|
||||
|
||||
// This class does not handle remote sessions, so all messages are directly
|
||||
// processes locally.
|
||||
this->SessionCore->PushState(msg);
|
||||
|
||||
this->DeActivate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::PullState(vtkSMMessage* msg)
|
||||
{
|
||||
this->Activate();
|
||||
|
||||
// This class does not handle remote sessions, so all messages are directly
|
||||
// processes locally.
|
||||
this->SessionCore->PullState(msg);
|
||||
|
||||
this->DeActivate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::ExecuteStream(
|
||||
vtkTypeUInt32 location, const vtkClientServerStream& stream,
|
||||
bool ignore_errors/*=false*/)
|
||||
{
|
||||
this->Activate();
|
||||
|
||||
// This class does not handle remote sessions, so all messages are directly
|
||||
// processes locally.
|
||||
this->SessionCore->ExecuteStream(location, stream, ignore_errors);
|
||||
|
||||
this->DeActivate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const vtkClientServerStream& vtkPVSessionBase::GetLastResult(
|
||||
vtkTypeUInt32 vtkNotUsed(location))
|
||||
{
|
||||
// This class does not handle remote sessions, so all messages are directly
|
||||
// processes locally.
|
||||
return this->SessionCore->GetLastResult();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::UnRegisterSIObject(vtkSMMessage* msg)
|
||||
{
|
||||
this->Activate();
|
||||
|
||||
// This class does not handle remote sessions, so all messages are directly
|
||||
// processes locally.
|
||||
this->SessionCore->UnRegisterSIObject(msg);
|
||||
|
||||
this->DeActivate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::RegisterSIObject(vtkSMMessage* msg)
|
||||
{
|
||||
this->Activate();
|
||||
|
||||
// This class does not handle remote sessions, so all messages are directly
|
||||
// processes locally.
|
||||
this->SessionCore->RegisterSIObject(msg);
|
||||
|
||||
this->DeActivate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIObject* vtkPVSessionBase::GetSIObject(vtkTypeUInt32 globalid)
|
||||
{
|
||||
return this->SessionCore? this->SessionCore->GetSIObject(globalid) : NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::PrepareProgressInternal()
|
||||
{
|
||||
vtkClientServerStream substream;
|
||||
substream << vtkClientServerStream::Invoke
|
||||
<< vtkClientServerID(1) // ID for vtkPVSessionCore helper.
|
||||
<< "GetActiveProgressHandler"
|
||||
<< vtkClientServerStream::End;
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< substream
|
||||
<< "PrepareProgress"
|
||||
<< vtkClientServerStream::End;
|
||||
this->ExecuteStream(vtkPVSession::CLIENT_AND_SERVERS, stream, false);
|
||||
//this->Superclass::PrepareProgressInternal();
|
||||
//FIXME_COLLABORATION - I don't like code that skips superclass implentations.
|
||||
//Rethink this.
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::CleanupPendingProgressInternal()
|
||||
{
|
||||
vtkClientServerStream substream;
|
||||
substream << vtkClientServerStream::Invoke
|
||||
<< vtkClientServerID(1) // ID for vtkPVSessionCore helper.
|
||||
<< "GetActiveProgressHandler"
|
||||
<< vtkClientServerStream::End;
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< substream
|
||||
<< "CleanupPendingProgress"
|
||||
<< vtkClientServerStream::End;
|
||||
this->ExecuteStream(vtkPVSession::CLIENT_AND_SERVERS, stream, false);
|
||||
//this->Superclass::CleanupPendingProgressInternal();
|
||||
//FIXME_COLLABORATION
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVSessionBase::GatherInformation(vtkTypeUInt32 location,
|
||||
vtkPVInformation* information, vtkTypeUInt32 globalid)
|
||||
{
|
||||
return this->SessionCore->GatherInformation(location, information, globalid);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkObject* vtkPVSessionBase::GetRemoteObject(vtkTypeUInt32 globalid)
|
||||
{
|
||||
return this->SessionCore->GetRemoteObject(globalid);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::RegisterRemoteObject(vtkTypeUInt32 gid,
|
||||
vtkTypeUInt32 location, vtkObject* obj)
|
||||
{
|
||||
this->SessionCore->RegisterRemoteObject(gid, obj);
|
||||
|
||||
// Also tell the remote resources that it is used
|
||||
vtkSMMessage registerMsg;
|
||||
registerMsg.set_global_id(gid);
|
||||
registerMsg.set_location(location);
|
||||
this->RegisterSIObject(®isterMsg);
|
||||
|
||||
this->InvokeEvent(vtkPVSessionBase::RegisterRemoteObjectEvent, &gid);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::UnRegisterRemoteObject(vtkTypeUInt32 gid, vtkTypeUInt32 location)
|
||||
{
|
||||
this->SessionCore->UnRegisterRemoteObject(gid);
|
||||
|
||||
// Also delete remote resources as well
|
||||
vtkSMMessage deleteMsg;
|
||||
deleteMsg.set_global_id(gid);
|
||||
deleteMsg.set_location(location);
|
||||
this->UnRegisterSIObject(&deleteMsg);
|
||||
|
||||
this->InvokeEvent(vtkPVSessionBase::UnRegisterRemoteObjectEvent, &gid);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::GetAllRemoteObjects(vtkCollection* collection)
|
||||
{
|
||||
this->SessionCore->GetAllRemoteObjects(collection);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkMPIMToNSocketConnection* vtkPVSessionBase::GetMPIMToNSocketConnection()
|
||||
{
|
||||
return this->SessionCore->GetMPIMToNSocketConnection();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkTypeUInt32 vtkPVSessionBase::GetNextGlobalUniqueIdentifier()
|
||||
{
|
||||
vtkTypeUInt32 id = this->SessionCore->GetNextGlobalUniqueIdentifier();
|
||||
return id;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkTypeUInt32 vtkPVSessionBase::GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< vtkClientServerID(1) // ID for the vtkSMSessionCore helper.
|
||||
<< "GetNextGlobalIdChunk"
|
||||
<< chunkSize
|
||||
<< vtkClientServerStream::End;
|
||||
this->ExecuteStream(vtkPVSession::DATA_SERVER_ROOT, stream);
|
||||
|
||||
// Extract the first id of the new chunk
|
||||
vtkTypeUInt32 id;
|
||||
this->GetLastResult(vtkPVSession::DATA_SERVER_ROOT).GetArgument(0,0, &id);
|
||||
return id;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVSessionBase::StartProcessingRemoteNotification()
|
||||
{
|
||||
bool tmp = this->ProcessingRemoteNotification;
|
||||
this->ProcessingRemoteNotification = true;
|
||||
return tmp;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::StopProcessingRemoteNotification(bool previousValue)
|
||||
{
|
||||
this->ProcessingRemoteNotification = previousValue;
|
||||
if(!previousValue)
|
||||
{
|
||||
this->InvokeEvent(vtkPVSessionBase::ProcessingRemoteEnd);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVSessionBase::IsProcessingRemoteNotification()
|
||||
{
|
||||
return this->ProcessingRemoteNotification;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::UseSessionCoreOf(vtkPVSessionBase* other)
|
||||
{
|
||||
if(other)
|
||||
{
|
||||
this->SetSessionCore(other->GetSessionCore());
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkErrorMacro("No vtkPVSessionBase provided");
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionCore* vtkPVSessionBase::GetSessionCore() const
|
||||
{
|
||||
return this->SessionCore;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionBase::SetSessionCore(vtkPVSessionCore* other)
|
||||
{
|
||||
if(this->SessionCore)
|
||||
{
|
||||
this->SessionCore->Delete();
|
||||
}
|
||||
this->SessionCore = other;
|
||||
if(this->SessionCore)
|
||||
{
|
||||
this->SessionCore->Register(this);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,250 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionBase.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkPVSessionBase
|
||||
// .SECTION Description
|
||||
// Abstract class used to provide the main implementation of the ParaView
|
||||
// session methods for the following classes: vtkSMSession,
|
||||
// vtkSMSessionClient,
|
||||
// vtkSMSessionServer
|
||||
|
||||
#ifndef vtkPVSessionBase_h
|
||||
#define vtkPVSessionBase_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkPVSession.h"
|
||||
#include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
|
||||
|
||||
class vtkClientServerStream;
|
||||
class vtkCollection;
|
||||
class vtkSIObject;
|
||||
class vtkPVInformation;
|
||||
class vtkPVServerInformation;
|
||||
class vtkSIProxyDefinitionManager;
|
||||
class vtkPVSessionCore;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkPVSessionBase : public vtkPVSession
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkPVSessionBase, vtkPVSession);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
enum EventIds
|
||||
{
|
||||
RegisterRemoteObjectEvent = 1234,
|
||||
UnRegisterRemoteObjectEvent = 4321,
|
||||
ProcessingRemoteEnd = 2143,
|
||||
ConnectionLost = 6789
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Superclass Implementations
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Description:
|
||||
// Returns a ServerFlags indicate the nature of the current processes. e.g. if
|
||||
// the current processes acts as a data-server and a render-server, it returns
|
||||
// DATA_SERVER | RENDER_SERVER. The implementation provided is suitable for
|
||||
// server processes such as pvserver, pvdataserver (both root and satellites).
|
||||
virtual ServerFlags GetProcessRoles();
|
||||
|
||||
// Description:
|
||||
// vtkPVServerInformation is an information-object that provides information
|
||||
// about the server processes. These include server-side capabilities as well
|
||||
// as server-side command line arguments e.g. tile-display parameters. Use
|
||||
// this method to obtain the server-side information.
|
||||
// Overridden to provide support for non-remote-server case. We simply read
|
||||
// the local process information and return it.
|
||||
virtual vtkPVServerInformation* GetServerInformation();
|
||||
|
||||
// Description:
|
||||
// This is socket connection, if any to communicate between the data-server
|
||||
// and render-server nodes. Forwarded for vtkPVSessionCore.
|
||||
virtual vtkMPIMToNSocketConnection* GetMPIMToNSocketConnection();
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Remote communication API. This API is used for communication in the
|
||||
// CLIENT -> SERVER(s) direction.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Push the state message.
|
||||
virtual void PushState(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Pull the state message.
|
||||
virtual void PullState(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Execute a command on the given processes. Use GetLastResult() to obtain the
|
||||
// last result after the command stream is evaluated. Once can set
|
||||
// \c ignore_errors to true, to ignore any interpreting errors.
|
||||
virtual void ExecuteStream( vtkTypeUInt32 location,
|
||||
const vtkClientServerStream& stream,
|
||||
bool ignore_errors = false );
|
||||
|
||||
// Description:
|
||||
// Returns the response of the ExecuteStream() call from the location. Note if
|
||||
// location refers to multiple processes, then the reply is only fetched from
|
||||
// the "closest" process.
|
||||
virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
|
||||
//ETX
|
||||
|
||||
// Description:
|
||||
// Gather information about an object referred by the \c globalid.
|
||||
// \c location identifies the processes to gather the information from.
|
||||
virtual bool GatherInformation(vtkTypeUInt32 location,
|
||||
vtkPVInformation* information, vtkTypeUInt32 globalid);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Remote communication API. This API is used for communication in the
|
||||
// SERVER -> CLIENT direction. Since satellite nodes cannot communicate with
|
||||
// the client, these methods have no effect on the satellite nodes and must
|
||||
// only the called on the root-nodes for the server processes.
|
||||
// If these methods are called on a process acting as a client, then it is
|
||||
// processed on that process immediately, as appropriate.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Sends the message to all clients.
|
||||
virtual void NotifyAllClients(const vtkSMMessage*)=0;
|
||||
|
||||
// Description:
|
||||
// Sends the message to all but the active client-session.
|
||||
virtual void NotifyOtherClients(const vtkSMMessage*)=0;
|
||||
//ETX
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// API dealing with/forwarded to vtkPVSessionCore dealing with SIObjects and
|
||||
// SMObjects.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Description:
|
||||
// Provides access to the session core.
|
||||
vtkGetObjectMacro(SessionCore, vtkPVSessionCore);
|
||||
|
||||
// Description:
|
||||
// Get the ProxyDefinitionManager.
|
||||
vtkSIProxyDefinitionManager* GetProxyDefinitionManager();
|
||||
|
||||
// Description:
|
||||
// Returns a vtkSIObject or subclass given its global id, if any.
|
||||
vtkSIObject* GetSIObject(vtkTypeUInt32 globalid);
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Unregister server side object. (SIObject)
|
||||
virtual void UnRegisterSIObject(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Register server side object. (SIObject)
|
||||
virtual void RegisterSIObject(vtkSMMessage* msg);
|
||||
//ETX
|
||||
|
||||
// Description:
|
||||
// Return a vtkSMRemoteObject given its global id if any otherwise return NULL;
|
||||
vtkObject* GetRemoteObject(vtkTypeUInt32 globalid);
|
||||
|
||||
// Description:
|
||||
// Allow the user to fill its vtkCollection with all RemoteObject
|
||||
// This could be usefull when you want to hold a reference to them to
|
||||
// prevent any deletion across several method call.
|
||||
virtual void GetAllRemoteObjects(vtkCollection* collection);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// API for GlobalId management
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Description:
|
||||
// Provides the next available identifier. This implementation works locally.
|
||||
// without any code distribution. To support the distributed architecture
|
||||
// the vtkSMSessionClient overide those method to call them on the DATA_SERVER
|
||||
// vtkPVSessionBase instance.
|
||||
virtual vtkTypeUInt32 GetNextGlobalUniqueIdentifier();
|
||||
|
||||
// Description:
|
||||
// Return the first Id of the requested chunk.
|
||||
// 1 = ReverveNextIdChunk(10); | Reserved ids [1,2,3,4,5,6,7,8,9,10]
|
||||
// 11 = ReverveNextIdChunk(10);| Reserved ids [11,12,13,14,15,16,17,18,19,20]
|
||||
// b = a + 10;
|
||||
virtual vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize);
|
||||
|
||||
// Description:
|
||||
// This propertie is used to discard ignore_synchronization proxy property
|
||||
// when we load protobuf states.
|
||||
// Therefore, if we load any camera state while that property is true, this
|
||||
// won't affect the proxy/property state at all. It will simply remain the same.
|
||||
virtual bool IsProcessingRemoteNotification();
|
||||
|
||||
// Description:
|
||||
// Update internal session core in order to use the one used in another session
|
||||
virtual void UseSessionCoreOf(vtkPVSessionBase* other);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkPVSessionBase();
|
||||
vtkPVSessionBase(vtkPVSessionCore* coreToUse);
|
||||
~vtkPVSessionBase();
|
||||
|
||||
// Description:
|
||||
// Method used to migrate from one Session type to another by keeping the same
|
||||
// vtkPVSessionCore
|
||||
vtkPVSessionCore* GetSessionCore() const;
|
||||
void SetSessionCore(vtkPVSessionCore*);
|
||||
|
||||
// Description:
|
||||
// Should be called to begin/end receiving progresses on this session.
|
||||
// Overridden to relay to the server(s).
|
||||
virtual void PrepareProgressInternal();
|
||||
virtual void CleanupPendingProgressInternal();
|
||||
|
||||
friend class vtkSMRemoteObject;
|
||||
friend class vtkSMSessionProxyManager;
|
||||
friend class vtkSMLiveInsituLinkProxy; // Needed to get access to vtkPVCatalystSessionCore
|
||||
|
||||
// Description:
|
||||
// Methods used to monitor if we are currently processing a server notification
|
||||
// Only vtkSMSessionClient use the flag to disable ignore_synchronization
|
||||
// properties from beeing updated.
|
||||
virtual bool StartProcessingRemoteNotification();
|
||||
virtual void StopProcessingRemoteNotification(bool previousValue);
|
||||
bool ProcessingRemoteNotification;
|
||||
|
||||
// Description:
|
||||
// Register a remote object
|
||||
void RegisterRemoteObject(vtkTypeUInt32 globalid, vtkTypeUInt32 location,
|
||||
vtkObject* obj);
|
||||
|
||||
// Description:
|
||||
// Unregister a remote object
|
||||
void UnRegisterRemoteObject(vtkTypeUInt32 globalid, vtkTypeUInt32 location);
|
||||
|
||||
vtkPVSessionCore* SessionCore;
|
||||
|
||||
private:
|
||||
vtkPVSessionBase(const vtkPVSessionBase&); // Not implemented
|
||||
void operator=(const vtkPVSessionBase&); // Not implemented
|
||||
|
||||
// Shared constructor method
|
||||
void InitSessionBase(vtkPVSessionCore* coreToUse);
|
||||
|
||||
vtkPVServerInformation* LocalServerInformation;
|
||||
unsigned long ActivateObserverTag;
|
||||
unsigned long DesactivateObserverTag;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,236 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionCore.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkPVSessionCore
|
||||
// .SECTION Description
|
||||
// vtkPVSessionCore is used by vtkSMSession.
|
||||
// vtkPVSessionCore handle the communication to MPI satellites and
|
||||
// ServerImplementation code instanciation and execution.
|
||||
// On the other hand, the vtkSMSession dispatch the request to the right
|
||||
// process and therefore to the right vtkPVSessionCore instance.
|
||||
|
||||
#ifndef vtkPVSessionCore_h
|
||||
#define vtkPVSessionCore_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkObject.h"
|
||||
#include "vtkSMMessageMinimal.h" // needed for vtkSMMessage.
|
||||
#include "vtkWeakPointer.h" // needed for vtkMultiProcessController
|
||||
|
||||
class vtkClientServerInterpreter;
|
||||
class vtkClientServerStream;
|
||||
class vtkCollection;
|
||||
class vtkMPIMToNSocketConnection;
|
||||
class vtkMultiProcessController;
|
||||
class vtkPVInformation;
|
||||
class vtkSIObject;
|
||||
class vtkSIProxyDefinitionManager;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkPVSessionCore : public vtkObject
|
||||
{
|
||||
public:
|
||||
static vtkPVSessionCore* New();
|
||||
vtkTypeMacro(vtkPVSessionCore, vtkObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Provides access to the interpreter.
|
||||
vtkGetObjectMacro(Interpreter, vtkClientServerInterpreter);
|
||||
|
||||
// Description:
|
||||
// Provides access to the proxy definition manager.
|
||||
vtkGetObjectMacro(ProxyDefinitionManager, vtkSIProxyDefinitionManager);
|
||||
|
||||
// Description:
|
||||
// Push the state message.
|
||||
// This might forward the message to the MPI statellites if needed.
|
||||
virtual void PushState(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Pull the state message from the local SI object instances.
|
||||
virtual void PullState(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Execute a command on the given processes. Use GetLastResult() to obtain the
|
||||
// last result after the command stream is evaluated. Once can set
|
||||
// \c ignore_errors to true, to ignore any interpreting errors.
|
||||
virtual void ExecuteStream( vtkTypeUInt32 location,
|
||||
const vtkClientServerStream& stream,
|
||||
bool ignore_errors = false );
|
||||
|
||||
// Description:
|
||||
// Returns the response of the ExecuteStream() call from the location. Note if
|
||||
// location refers to multiple processes, then the reply is only fetched from
|
||||
// the "closest" process.
|
||||
virtual const vtkClientServerStream& GetLastResult();
|
||||
|
||||
// Description:
|
||||
// Notify that the given SIObject is not used anymore .
|
||||
// This does not necessary delete the SIObject specially if this one is
|
||||
// used by other local SIObject. It only decrease its reference count.
|
||||
virtual void UnRegisterSIObject(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Notify that the given SIObject is used.
|
||||
// It only increase its reference count.
|
||||
virtual void RegisterSIObject(vtkSMMessage* message);
|
||||
|
||||
//ETX
|
||||
|
||||
// Description:
|
||||
// Returns a vtkSIObject or subclass given its global id, if any otherwise
|
||||
// return NULL;
|
||||
vtkSIObject* GetSIObject(vtkTypeUInt32 globalid);
|
||||
|
||||
// Description:
|
||||
// Return a vtkObject given its global id if any otherwise return NULL;
|
||||
vtkObject* GetRemoteObject(vtkTypeUInt32 globalid);
|
||||
|
||||
// Description:
|
||||
// Register a remote object
|
||||
void RegisterRemoteObject(vtkTypeUInt32 globalid, vtkObject* obj);
|
||||
|
||||
// Description:
|
||||
// Unregister a remote object
|
||||
void UnRegisterRemoteObject(vtkTypeUInt32 globalid);
|
||||
|
||||
// Description:
|
||||
// Gather information about an object referred by the \c globalid.
|
||||
// \c location identifies the processes to gather the information from.
|
||||
virtual bool GatherInformation( vtkTypeUInt32 location,
|
||||
vtkPVInformation* information,
|
||||
vtkTypeUInt32 globalid );
|
||||
|
||||
// Description:
|
||||
// Returns the number of processes. This simply calls the
|
||||
// GetNumberOfProcesses() on this->ParallelController
|
||||
int GetNumberOfProcesses();
|
||||
|
||||
// Description:
|
||||
// Get/Set the socket connection used to communicate betweeen data=server and
|
||||
// render-server processes. This is valid only on data-server and
|
||||
// render-server processes.
|
||||
void SetMPIMToNSocketConnection(vtkMPIMToNSocketConnection*);
|
||||
vtkGetObjectMacro(MPIMToNSocketConnection, vtkMPIMToNSocketConnection);
|
||||
|
||||
// Description:
|
||||
// Provides the next available identifier. This implementation works locally.
|
||||
// without any code distribution. To support the distributed architecture
|
||||
// the vtkSMSessionClient overide those method to call them on the DATA_SERVER
|
||||
// vtkPVSessionBase instance.
|
||||
virtual vtkTypeUInt32 GetNextGlobalUniqueIdentifier();
|
||||
|
||||
// Description:
|
||||
// Return the first Id of the requested chunk.
|
||||
// 1 = ReverveNextIdChunk(10); | Reserved ids [1,2,3,4,5,6,7,8,9,10]
|
||||
// 11 = ReverveNextIdChunk(10);| Reserved ids [11,12,13,14,15,16,17,18,19,20]
|
||||
// b = a + 10;
|
||||
virtual vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize);
|
||||
|
||||
//BTX
|
||||
|
||||
enum MessageTypes
|
||||
{
|
||||
PUSH_STATE = 12,
|
||||
PULL_STATE = 13,
|
||||
EXECUTE_STREAM = 14,
|
||||
GATHER_INFORMATION = 15,
|
||||
REGISTER_SI = 16,
|
||||
UNREGISTER_SI = 17,
|
||||
};
|
||||
// Methods used to managed MPI satellite
|
||||
void PushStateSatelliteCallback();
|
||||
void ExecuteStreamSatelliteCallback();
|
||||
void GatherInformationStatelliteCallback();
|
||||
void RegisterSIObjectSatelliteCallback();
|
||||
void UnRegisterSIObjectSatelliteCallback();
|
||||
|
||||
// Description:
|
||||
// Allow the user to fill a vtkCollection with all RemoteObjects
|
||||
// This is usefull when you want to hold a reference to them to
|
||||
// prevent any deletion across several method call.
|
||||
virtual void GetAllRemoteObjects(vtkCollection* collection);
|
||||
|
||||
// Description:
|
||||
// Delete SIObject that are held by clients that disapeared
|
||||
// from the given list.
|
||||
void GarbageCollectSIObject(int* clientIds, int nbClients);
|
||||
|
||||
protected:
|
||||
vtkPVSessionCore();
|
||||
~vtkPVSessionCore();
|
||||
|
||||
// Description:
|
||||
// This will create a vtkSIObject and/or execute some update on the
|
||||
// vtkObject that it own.
|
||||
virtual void PushStateInternal(vtkSMMessage*);
|
||||
|
||||
// Description:
|
||||
// This will execute localy the given vtkClientServerStream either by
|
||||
// calling method on the vtkSIObject or its internal vtkObject.
|
||||
virtual void ExecuteStreamInternal( const vtkClientServerStream& stream,
|
||||
bool ignore_errors );
|
||||
|
||||
// Description:
|
||||
// This will gather informations on the local vtkObjects
|
||||
// through the local vtkSIObjects.
|
||||
bool GatherInformationInternal( vtkPVInformation* information,
|
||||
vtkTypeUInt32 globalid );
|
||||
|
||||
// Description:
|
||||
// Gather informations across MPI satellites.
|
||||
bool CollectInformation(vtkPVInformation*);
|
||||
|
||||
// Description:
|
||||
// Increment reference count of a local vtkSIObject.
|
||||
virtual void RegisterSIObjectInternal(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Decrement reference count of a local vtkSIObject. This might not result
|
||||
// in an actual deletion of the object if this one is used by another
|
||||
// SIObject.
|
||||
virtual void UnRegisterSIObjectInternal(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Callback for reporting interpreter errors.
|
||||
void OnInterpreterError(vtkObject*, unsigned long, void* calldata);
|
||||
|
||||
enum
|
||||
{
|
||||
ROOT_SATELLITE_RMI_TAG = 887822,
|
||||
ROOT_SATELLITE_INFO_TAG = 887823
|
||||
};
|
||||
|
||||
vtkSIProxyDefinitionManager* ProxyDefinitionManager;
|
||||
vtkWeakPointer<vtkMultiProcessController> ParallelController;
|
||||
vtkClientServerInterpreter* Interpreter;
|
||||
vtkMPIMToNSocketConnection* MPIMToNSocketConnection;
|
||||
|
||||
private:
|
||||
vtkPVSessionCore(const vtkPVSessionCore&); // Not implemented
|
||||
void operator=(const vtkPVSessionCore&); // Not implemented
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
bool SymmetricMPIMode;
|
||||
|
||||
// Local counter for global Ids
|
||||
vtkTypeUInt32 LocalGlobalID;
|
||||
|
||||
ostream *LogStream;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,104 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionCoreInterpreterHelper.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkPVSessionCoreInterpreterHelper.h"
|
||||
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSIProxy.h"
|
||||
#include "vtkPVProgressHandler.h"
|
||||
#include "vtkPVSession.h"
|
||||
#include "vtkProcessModule.h"
|
||||
#include "vtkPVSessionCore.h"
|
||||
|
||||
vtkStandardNewMacro(vtkPVSessionCoreInterpreterHelper);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionCoreInterpreterHelper::vtkPVSessionCoreInterpreterHelper()
|
||||
{
|
||||
this->LogLevel = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionCoreInterpreterHelper::~vtkPVSessionCoreInterpreterHelper()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionCoreInterpreterHelper::SetCore(vtkPVSessionCore* core)
|
||||
{
|
||||
this->Core = core;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIObject* vtkPVSessionCoreInterpreterHelper::GetSIObject(vtkTypeUInt32 gid)
|
||||
{
|
||||
return this->Core->GetSIObject(gid);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkTypeUInt32 vtkPVSessionCoreInterpreterHelper::GetNextGlobalIdChunk(vtkTypeUInt32 chunkSize)
|
||||
{
|
||||
return this->Core->GetNextChunkGlobalUniqueIdentifier(chunkSize);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkObjectBase* vtkPVSessionCoreInterpreterHelper::GetVTKObject(vtkTypeUInt32 gid)
|
||||
{
|
||||
vtkSIProxy* siProxy = vtkSIProxy::SafeDownCast(
|
||||
this->Core->GetSIObject(gid));
|
||||
if (!siProxy)
|
||||
{
|
||||
switch(this->LogLevel)
|
||||
{
|
||||
case 0:
|
||||
vtkErrorMacro("No vtkSIProxy for id : " << gid);
|
||||
break;
|
||||
default:
|
||||
vtkWarningMacro("No vtkSIProxy for id : " << gid);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return siProxy->GetVTKObject();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkProcessModule* vtkPVSessionCoreInterpreterHelper::GetProcessModule()
|
||||
{
|
||||
return vtkProcessModule::GetProcessModule();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVProgressHandler* vtkPVSessionCoreInterpreterHelper::GetActiveProgressHandler()
|
||||
{
|
||||
vtkPVSession* session = vtkPVSession::SafeDownCast(
|
||||
vtkProcessModule::GetProcessModule()->GetActiveSession());
|
||||
if (!session)
|
||||
{
|
||||
session = vtkPVSession::SafeDownCast(
|
||||
vtkProcessModule::GetProcessModule()->GetSession());
|
||||
}
|
||||
|
||||
return session? session->GetProgressHandler() : NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionCoreInterpreterHelper::SetMPIMToNSocketConnection(
|
||||
vtkMPIMToNSocketConnection* m2n)
|
||||
{
|
||||
this->Core->SetMPIMToNSocketConnection(m2n);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionCoreInterpreterHelper::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionCoreInterpreterHelper.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkPVSessionCoreInterpreterHelper
|
||||
// .SECTION Description
|
||||
// vtkPVSessionCoreInterpreterHelper is used by vtkPVSessionCore to avoid a
|
||||
// circular reference between the vtkPVSessionCore instance and its Interpreter.
|
||||
|
||||
#ifndef vtkPVSessionCoreInterpreterHelper_h
|
||||
#define vtkPVSessionCoreInterpreterHelper_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkObject.h"
|
||||
#include "vtkWeakPointer.h" // needed for vtkWeakPointer.
|
||||
|
||||
class vtkObject;
|
||||
class vtkSIObject;
|
||||
class vtkPVProgressHandler;
|
||||
class vtkProcessModule;
|
||||
class vtkPVSessionCore;
|
||||
class vtkMPIMToNSocketConnection;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkPVSessionCoreInterpreterHelper : public vtkObject
|
||||
{
|
||||
public:
|
||||
static vtkPVSessionCoreInterpreterHelper* New();
|
||||
vtkTypeMacro(vtkPVSessionCoreInterpreterHelper, vtkObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Returns the vtkSIObject for the global-id. This is used by SIOBJECT() and
|
||||
// SIPROXY() stream (vtkClientServerStream) manipulator macros.
|
||||
vtkSIObject* GetSIObject(vtkTypeUInt32 gid);
|
||||
|
||||
// Description:
|
||||
// Returns the vtkObject corresponding to the global id. This is used by the
|
||||
// VTKOBJECT() stream (vtkClientServerStream) manipulator macros.
|
||||
vtkObjectBase* GetVTKObject(vtkTypeUInt32 gid);
|
||||
|
||||
// Description:
|
||||
// Reserve a global id block.
|
||||
vtkTypeUInt32 GetNextGlobalIdChunk(vtkTypeUInt32 chunkSize);
|
||||
|
||||
// Description:
|
||||
// Provides access to the process module.
|
||||
vtkProcessModule* GetProcessModule();
|
||||
|
||||
// Description:
|
||||
// Provides access to the progress handler.
|
||||
vtkPVProgressHandler* GetActiveProgressHandler();
|
||||
|
||||
// Description:
|
||||
// Sets and initializes the MPIMToNSocketConnection for communicating between
|
||||
// data-server and render-server.
|
||||
void SetMPIMToNSocketConnection(vtkMPIMToNSocketConnection*);
|
||||
|
||||
// Description:
|
||||
// Used by vtkPVSessionCore to pass the core. This is not reference counted.
|
||||
void SetCore(vtkPVSessionCore*);
|
||||
|
||||
// Description:
|
||||
// Switch from 0:vtkErrorMacro to 1:vtkWarningMacro
|
||||
vtkSetMacro(LogLevel, int);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkPVSessionCoreInterpreterHelper();
|
||||
~vtkPVSessionCoreInterpreterHelper();
|
||||
|
||||
vtkWeakPointer<vtkPVSessionCore> Core;
|
||||
int LogLevel;
|
||||
private:
|
||||
vtkPVSessionCoreInterpreterHelper(const vtkPVSessionCoreInterpreterHelper&); // Not implemented
|
||||
void operator=(const vtkPVSessionCoreInterpreterHelper&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,655 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionServer.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkPVSessionServer.h"
|
||||
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkCommand.h"
|
||||
#include "vtkCompositeMultiProcessController.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkMultiProcessStream.h"
|
||||
#include "vtkNetworkAccessManager.h"
|
||||
#include "vtkNew.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkProcessModule.h"
|
||||
#include "vtkPVConfig.h"
|
||||
#include "vtkPVInformation.h"
|
||||
#include "vtkPVInstantiator.h"
|
||||
#include "vtkPVServerOptions.h"
|
||||
#include "vtkPVSessionCore.h"
|
||||
#include "vtkReservedRemoteObjectIds.h"
|
||||
#include "vtkSIProxyDefinitionManager.h"
|
||||
#include "vtkSIProxy.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkSocketCommunicator.h"
|
||||
#include "vtkSocketController.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vtksys/RegularExpression.hxx>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
//****************************************************************************/
|
||||
// Internal Classes and typedefs
|
||||
//****************************************************************************/
|
||||
namespace
|
||||
{
|
||||
void RMICallback(void *localArg,
|
||||
void *remoteArg, int remoteArgLength, int vtkNotUsed(remoteProcessId))
|
||||
{
|
||||
vtkPVSessionServer* self = reinterpret_cast<vtkPVSessionServer*>(localArg);
|
||||
self->OnClientServerMessageRMI(remoteArg, remoteArgLength);
|
||||
}
|
||||
|
||||
void CloseSessionCallback(void *localArg,
|
||||
void *vtkNotUsed(remoteArg), int vtkNotUsed(remoteArgLength),
|
||||
int vtkNotUsed(remoteProcessId))
|
||||
{
|
||||
vtkPVSessionServer* self = reinterpret_cast<vtkPVSessionServer*>(localArg);
|
||||
self->OnCloseSessionRMI();
|
||||
}
|
||||
};
|
||||
//****************************************************************************/
|
||||
class vtkPVSessionServer::vtkInternals
|
||||
{
|
||||
public:
|
||||
vtkInternals(vtkPVSessionServer* owner)
|
||||
{
|
||||
this->SatelliteServerSession =
|
||||
(vtkProcessModule::GetProcessModule()->GetPartitionId() > 0);
|
||||
this->Owner = owner;
|
||||
|
||||
// Attach callbacks
|
||||
this->CompositeMultiProcessController->AddRMICallback(
|
||||
&RMICallback, this->Owner,
|
||||
vtkPVSessionServer::CLIENT_SERVER_MESSAGE_RMI);
|
||||
|
||||
this->CompositeMultiProcessController->AddRMICallback(
|
||||
&CloseSessionCallback, this->Owner,
|
||||
vtkPVSessionServer::CLOSE_SESSION);
|
||||
|
||||
this->CompositeMultiProcessController->AddObserver(
|
||||
vtkCompositeMultiProcessController::CompositeMultiProcessControllerChanged,
|
||||
this, &vtkPVSessionServer::vtkInternals::ReleaseDeadClientSIObjects);
|
||||
|
||||
this->Owner->GetSessionCore()->GetProxyDefinitionManager()->AddObserver(
|
||||
vtkCommand::RegisterEvent, this,
|
||||
&vtkPVSessionServer::vtkInternals::CallBackProxyDefinitionManagerHasChanged);
|
||||
this->Owner->GetSessionCore()->GetProxyDefinitionManager()->AddObserver(
|
||||
vtkCommand::UnRegisterEvent, this,
|
||||
&vtkPVSessionServer::vtkInternals::CallBackProxyDefinitionManagerHasChanged);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void CloseActiveController()
|
||||
{
|
||||
// FIXME: Maybe we want to keep listening even if no more client is
|
||||
// connected.
|
||||
if(this->CompositeMultiProcessController->UnRegisterActiveController() == 0)
|
||||
{
|
||||
vtkProcessModule::GetProcessModule()->GetNetworkAccessManager()
|
||||
->AbortPendingConnection();
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void CreateController(vtkObject* vtkNotUsed(src), unsigned long vtkNotUsed(event), void* vtkNotUsed(data))
|
||||
{
|
||||
vtkNetworkAccessManager* nam =
|
||||
vtkProcessModule::GetProcessModule()->GetNetworkAccessManager();
|
||||
vtkSocketController* ccontroller =
|
||||
vtkSocketController::SafeDownCast(
|
||||
nam->NewConnection(this->ClientURL.c_str()));
|
||||
if (ccontroller)
|
||||
{
|
||||
ccontroller->GetCommunicator()->AddObserver(
|
||||
vtkCommand::WrongTagEvent, this->Owner,
|
||||
&vtkPVSessionServer::OnWrongTagEvent);
|
||||
|
||||
this->CompositeMultiProcessController->RegisterController(ccontroller);
|
||||
ccontroller->FastDelete();
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void SetClientURL(const char* client_url)
|
||||
{
|
||||
this->ClientURL = client_url;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void NotifyOtherClients(const vtkSMMessage* msgToBroadcast)
|
||||
{
|
||||
std::string data = msgToBroadcast->SerializeAsString();
|
||||
this->CompositeMultiProcessController->TriggerRMI2All(
|
||||
1, (void*)data.c_str(), static_cast<int>(data.size()),
|
||||
vtkPVSessionServer::SERVER_NOTIFICATION_MESSAGE_RMI, false);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void NotifyAllClients(const vtkSMMessage* msgToBroadcast)
|
||||
{
|
||||
std::string data = msgToBroadcast->SerializeAsString();
|
||||
this->CompositeMultiProcessController->TriggerRMI2All(
|
||||
1, (void*)data.c_str(), static_cast<int>(data.size()),
|
||||
vtkPVSessionServer::SERVER_NOTIFICATION_MESSAGE_RMI, true);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
vtkCompositeMultiProcessController* GetActiveController()
|
||||
{
|
||||
if(this->SatelliteServerSession)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return this->CompositeMultiProcessController.GetPointer();
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// Manage share_only message and return true if no processing should occurs
|
||||
bool StoreShareOnly(vtkSMMessage* msg)
|
||||
{
|
||||
if(msg && msg->share_only())
|
||||
{
|
||||
vtkTypeUInt32 id = msg->global_id();
|
||||
this->ShareOnlyCache[id].CopyFrom(*msg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
bool IsSatelliteSession()
|
||||
{
|
||||
return this->SatelliteServerSession;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Return true if the message was updated by the ShareOnlyCache
|
||||
bool RetreiveShareOnly(vtkSMMessage* msg)
|
||||
{
|
||||
std::map<vtkTypeUInt32, vtkSMMessage>::iterator iter =
|
||||
this->ShareOnlyCache.find(msg->global_id());
|
||||
if(iter != this->ShareOnlyCache.end())
|
||||
{
|
||||
msg->CopyFrom(iter->second);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void ReleaseDeadClientSIObjects(vtkObject* vtkNotUsed(src), unsigned long vtkNotUsed(event), void* vtkNotUsed(data))
|
||||
{
|
||||
int nbCtrls = this->CompositeMultiProcessController->GetNumberOfControllers();
|
||||
|
||||
std::vector<int> alivedClients(nbCtrls);
|
||||
for(int i = 0; i < nbCtrls; i++)
|
||||
{
|
||||
alivedClients.push_back(this->CompositeMultiProcessController->GetControllerId(i));
|
||||
}
|
||||
if(alivedClients.size() > 0)
|
||||
{
|
||||
this->Owner->SessionCore->GarbageCollectSIObject(&alivedClients[0], static_cast<int>(alivedClients.size()));
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void CallBackProxyDefinitionManagerHasChanged(vtkObject* vtkNotUsed(src), unsigned long vtkNotUsed(event), void* vtkNotUsed(data))
|
||||
{
|
||||
vtkSMMessage proxyDefinitionManagerState;
|
||||
this->Owner->GetSessionCore()->GetSIObject(
|
||||
vtkReservedRemoteObjectIds::RESERVED_PROXY_DEFINITION_MANAGER_ID)
|
||||
->Pull(&proxyDefinitionManagerState);
|
||||
this->NotifyOtherClients(&proxyDefinitionManagerState);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkNew<vtkCompositeMultiProcessController> CompositeMultiProcessController;
|
||||
vtkWeakPointer<vtkPVSessionServer> Owner;
|
||||
std::string ClientURL;
|
||||
std::map<vtkTypeUInt32, vtkSMMessage> ShareOnlyCache;
|
||||
bool SatelliteServerSession;
|
||||
};
|
||||
//****************************************************************************/
|
||||
vtkStandardNewMacro(vtkPVSessionServer);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionServer::vtkPVSessionServer() : vtkPVSessionBase()
|
||||
{
|
||||
this->Internal = new vtkInternals(this);
|
||||
|
||||
// By default we act as a server for a single client
|
||||
this->MultipleConnection = false;
|
||||
|
||||
// On server side only one session is available so we just set it Active()
|
||||
// forever
|
||||
if(vtkProcessModule::GetProcessModule())
|
||||
{
|
||||
this->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkPVSessionServer::~vtkPVSessionServer()
|
||||
{
|
||||
delete this->Internal;
|
||||
this->Internal = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkMultiProcessController* vtkPVSessionServer::GetController(ServerFlags processType)
|
||||
{
|
||||
switch (processType)
|
||||
{
|
||||
case CLIENT:
|
||||
return this->Internal->GetActiveController();
|
||||
|
||||
default:
|
||||
// we shouldn't warn.
|
||||
// vtkWarningMacro("Invalid processtype of GetController(): " << processType);
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVSessionServer::Connect()
|
||||
{
|
||||
std::ostringstream url;
|
||||
|
||||
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
|
||||
|
||||
if (this->Internal->IsSatelliteSession())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkPVServerOptions* options = vtkPVServerOptions::SafeDownCast(pm->GetOptions());
|
||||
if (!options)
|
||||
{
|
||||
vtkErrorMacro("Missing vtkPVServerOptions. "
|
||||
"Process must use vtkPVServerOptions (or subclass).");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (pm->GetProcessType())
|
||||
{
|
||||
case vtkProcessModule::PROCESS_SERVER:
|
||||
if (options->GetReverseConnection())
|
||||
{
|
||||
url << "csrc://";
|
||||
url << options->GetClientHostName() << ":" << options->GetServerPort();
|
||||
}
|
||||
else
|
||||
{
|
||||
url << "cs://";
|
||||
url << options->GetHostName() << ":" << options->GetServerPort();
|
||||
}
|
||||
break;
|
||||
|
||||
case vtkProcessModule::PROCESS_RENDER_SERVER:
|
||||
if (options->GetReverseConnection())
|
||||
{
|
||||
url << "cdsrsrc://"
|
||||
<< options->GetClientHostName() << ":11111" // default ds-port
|
||||
<< "/"
|
||||
<< options->GetClientHostName() << ":" << options->GetServerPort();
|
||||
}
|
||||
else
|
||||
{
|
||||
url << "cdsrs://"
|
||||
<< "<data-server-hostname>:11111"
|
||||
<< "/"
|
||||
<< options->GetHostName() << ":" << options->GetServerPort();
|
||||
}
|
||||
break;
|
||||
|
||||
case vtkProcessModule::PROCESS_DATA_SERVER:
|
||||
if (options->GetReverseConnection())
|
||||
{
|
||||
url << "cdsrsrc://"
|
||||
<< options->GetClientHostName() << ":" << options->GetServerPort()
|
||||
<< "/"
|
||||
<< options->GetClientHostName() << ":22221"; // default rs-port
|
||||
}
|
||||
else
|
||||
{
|
||||
url << "cdsrs://"
|
||||
<< options->GetHostName() << ":" << options->GetServerPort()
|
||||
<< "/"
|
||||
<< "<render-server-hostname>:22221";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
vtkErrorMacro("vtkPVSessionServer cannot be created on this process type.");
|
||||
return false;
|
||||
}
|
||||
|
||||
cout << "Connection URL: " << url.str() << endl;
|
||||
return this->Connect(url.str().c_str());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVSessionServer::Connect(const char* url)
|
||||
{
|
||||
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
|
||||
if (pm->GetPartitionId() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkNetworkAccessManager* nam = pm->GetNetworkAccessManager();
|
||||
vtkPVOptions* options = pm->GetOptions();
|
||||
|
||||
vtksys::RegularExpression pvserver("^cs://([^:]+)?(:([0-9]+))?");
|
||||
vtksys::RegularExpression pvserver_reverse ("^csrc://([^:]+)(:([0-9]+))?");
|
||||
vtksys::RegularExpression pvrenderserver(
|
||||
"^cdsrs://([^:]+)(:([0-9]+))?/([^:]+)(:([0-9]+))?");
|
||||
vtksys::RegularExpression pvrenderserver_reverse (
|
||||
"^cdsrsrc://([^:]+)?(:([0-9]+))?/([^:]+)?(:([0-9]+))?");
|
||||
|
||||
std::ostringstream handshake;
|
||||
handshake << "handshake=paraview." << PARAVIEW_VERSION;
|
||||
// Add connect-id if needed. The connect-id is added to the handshake that
|
||||
// must match on client and server processes.
|
||||
if (options->GetConnectID() != 0)
|
||||
{
|
||||
handshake << ".connect_id." << options->GetConnectID();
|
||||
}
|
||||
|
||||
// for forward connections, port number 0 is acceptable, while for
|
||||
// reverse-connections it's not.
|
||||
std::string client_url;
|
||||
if (pvserver.find(url))
|
||||
{
|
||||
int port = atoi(pvserver.match(3).c_str());
|
||||
port = (port < 0)? 11111: port;
|
||||
|
||||
std::ostringstream stream;
|
||||
stream << "tcp://localhost:" << port << "?listen=true&" << handshake.str();
|
||||
stream << (this->MultipleConnection ? "&multiple=true" : "");
|
||||
client_url = stream.str();
|
||||
}
|
||||
else if (pvserver_reverse.find(url))
|
||||
{
|
||||
std::string hostname = pvserver_reverse.match(1);
|
||||
int port = atoi(pvserver_reverse.match(3).c_str());
|
||||
port = (port <= 0)? 11111: port;
|
||||
std::ostringstream stream;
|
||||
stream << "tcp://" << hostname.c_str() << ":" << port << "?" << handshake.str();
|
||||
client_url = stream.str();
|
||||
}
|
||||
else if (pvrenderserver.find(url))
|
||||
{
|
||||
int dsport = atoi(pvrenderserver.match(3).c_str());
|
||||
dsport = (dsport < 0)? 11111 : dsport;
|
||||
|
||||
int rsport = atoi(pvrenderserver.match(6).c_str());
|
||||
rsport = (rsport < 0)? 22221 : rsport;
|
||||
|
||||
if (vtkProcessModule::GetProcessType() ==
|
||||
vtkProcessModule::PROCESS_RENDER_SERVER)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "tcp://localhost:" << rsport << "?listen=true&" << handshake.str();
|
||||
client_url = stream.str();
|
||||
}
|
||||
else if (vtkProcessModule::GetProcessType() ==
|
||||
vtkProcessModule::PROCESS_DATA_SERVER)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "tcp://localhost:" << dsport << "?listen=true&" << handshake.str();
|
||||
stream << (this->MultipleConnection ? "&multiple=true" : "");
|
||||
client_url = stream.str();
|
||||
}
|
||||
}
|
||||
else if (pvrenderserver_reverse.find(url))
|
||||
{
|
||||
std::string dataserverhost = pvrenderserver_reverse.match(1);
|
||||
int dsport = atoi(pvrenderserver_reverse.match(3).c_str());
|
||||
dsport = (dsport <= 0)? 11111 : dsport;
|
||||
|
||||
std::string renderserverhost = pvrenderserver_reverse.match(4);
|
||||
int rsport = atoi(pvrenderserver_reverse.match(6).c_str());
|
||||
rsport = (rsport <= 0)? 22221 : rsport;
|
||||
|
||||
if (vtkProcessModule::GetProcessType() ==
|
||||
vtkProcessModule::PROCESS_RENDER_SERVER)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "tcp://" << dataserverhost.c_str() << ":" << rsport << "?" << handshake.str();
|
||||
client_url = stream.str();
|
||||
}
|
||||
else if (vtkProcessModule::GetProcessType() ==
|
||||
vtkProcessModule::PROCESS_DATA_SERVER)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "tcp://" << renderserverhost.c_str() << ":" << dsport << "?" << handshake.str();
|
||||
client_url = stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
vtkMultiProcessController* ccontroller =
|
||||
nam->NewConnection(client_url.c_str());
|
||||
this->Internal->SetClientURL(client_url.c_str());
|
||||
if (ccontroller)
|
||||
{
|
||||
this->Internal->GetActiveController()->RegisterController(ccontroller);
|
||||
ccontroller->FastDelete();
|
||||
cout << "Client connected." << endl;
|
||||
}
|
||||
|
||||
if(this->MultipleConnection && this->Internal->GetActiveController())
|
||||
{
|
||||
// Listen for new client controller creation
|
||||
nam->AddObserver( vtkCommand::ConnectionCreatedEvent, this->Internal,
|
||||
&vtkInternals::CreateController);
|
||||
}
|
||||
|
||||
return (this->Internal->GetActiveController() != NULL);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkPVSessionServer::GetIsAlive()
|
||||
{
|
||||
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
|
||||
if (pm->GetPartitionId() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: check for validity
|
||||
return (this->Internal->GetActiveController() != NULL);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::OnClientServerMessageRMI(void* message, int message_length)
|
||||
{
|
||||
vtkMultiProcessStream stream;
|
||||
stream.SetRawData( reinterpret_cast<const unsigned char*>(message),
|
||||
message_length);
|
||||
int type;
|
||||
stream >> type;
|
||||
switch (type)
|
||||
{
|
||||
case vtkPVSessionServer::PUSH:
|
||||
{
|
||||
std::string string;
|
||||
stream >> string;
|
||||
vtkSMMessage msg;
|
||||
msg.ParseFromString(string);
|
||||
|
||||
// cout << "=================================" << endl;
|
||||
// msg.PrintDebugString();
|
||||
// cout << "=================================" << endl;
|
||||
|
||||
// Do we skip the processing ?
|
||||
if(!this->Internal->StoreShareOnly(&msg))
|
||||
{
|
||||
this->PushState(&msg);
|
||||
}
|
||||
|
||||
// Notify when ProxyManager state has changed
|
||||
// or any other state change
|
||||
this->NotifyOtherClients(&msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case vtkPVSessionServer::PULL:
|
||||
{
|
||||
std::string string;
|
||||
stream >> string;
|
||||
vtkSMMessage msg;
|
||||
msg.ParseFromString(string);
|
||||
|
||||
// Use cache or process the call
|
||||
if(!this->Internal->RetreiveShareOnly(&msg))
|
||||
{
|
||||
this->PullState(&msg);
|
||||
}
|
||||
|
||||
// Send the result back to client
|
||||
vtkMultiProcessStream css;
|
||||
css << msg.SerializeAsString();
|
||||
this->Internal->GetActiveController()->Send( css, 1, vtkPVSessionServer::REPLY_PULL);
|
||||
}
|
||||
break;
|
||||
case vtkPVSessionServer::REGISTER_SI:
|
||||
{
|
||||
std::string string;
|
||||
stream >> string;
|
||||
vtkSMMessage msg;
|
||||
msg.ParseFromString(string);
|
||||
this->RegisterSIObject(&msg);
|
||||
}
|
||||
break;
|
||||
case vtkPVSessionServer::UNREGISTER_SI:
|
||||
{
|
||||
std::string string;
|
||||
stream >> string;
|
||||
vtkSMMessage msg;
|
||||
msg.ParseFromString(string);
|
||||
this->UnRegisterSIObject(&msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case vtkPVSessionServer::EXECUTE_STREAM:
|
||||
{
|
||||
int ignore_errors, size;
|
||||
stream >> ignore_errors >> size;
|
||||
unsigned char* css_data = new unsigned char[size+1];
|
||||
this->Internal->GetActiveController()->Receive(css_data, size, 1,
|
||||
vtkPVSessionServer::EXECUTE_STREAM_TAG);
|
||||
vtkClientServerStream cssStream;
|
||||
cssStream.SetData(css_data, size);
|
||||
this->ExecuteStream(vtkPVSession::CLIENT_AND_SERVERS,
|
||||
cssStream, ignore_errors != 0);
|
||||
delete [] css_data;
|
||||
}
|
||||
break;
|
||||
|
||||
case vtkPVSessionServer::LAST_RESULT:
|
||||
{
|
||||
this->SendLastResultToClient();
|
||||
}
|
||||
break;
|
||||
|
||||
case vtkPVSessionServer::GATHER_INFORMATION:
|
||||
{
|
||||
std::string classname;
|
||||
vtkTypeUInt32 location, globalid;
|
||||
stream >> location >> classname >> globalid;
|
||||
this->GatherInformationInternal(location, classname.c_str(), globalid,
|
||||
stream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::SendLastResultToClient()
|
||||
{
|
||||
const vtkClientServerStream& reply = this->GetLastResult(
|
||||
vtkPVSession::CLIENT_AND_SERVERS);
|
||||
|
||||
const unsigned char* data; size_t size_size_t;
|
||||
int size;
|
||||
|
||||
reply.GetData(&data, &size_size_t);
|
||||
size = static_cast<int>(size_size_t);
|
||||
|
||||
this->Internal->GetActiveController()->Send(&size, 1, 1,
|
||||
vtkPVSessionServer::REPLY_LAST_RESULT);
|
||||
this->Internal->GetActiveController()->Send(data, size, 1,
|
||||
vtkPVSessionServer::REPLY_LAST_RESULT);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::GatherInformationInternal(
|
||||
vtkTypeUInt32 location, const char* classname, vtkTypeUInt32 globalid,
|
||||
vtkMultiProcessStream& stream)
|
||||
{
|
||||
vtkSmartPointer<vtkObject> o;
|
||||
o.TakeReference(vtkPVInstantiator::CreateInstance(classname));
|
||||
|
||||
vtkPVInformation* info = vtkPVInformation::SafeDownCast(o);
|
||||
if (info)
|
||||
{
|
||||
// ensures that the vtkPVInformation has the same ivars locally as on the
|
||||
// client.
|
||||
info->CopyParametersFromStream(stream);
|
||||
|
||||
this->GatherInformation(location, info, globalid);
|
||||
|
||||
vtkClientServerStream css;
|
||||
info->CopyToStream(&css);
|
||||
size_t length;
|
||||
const unsigned char* data;
|
||||
css.GetData(&data, &length);
|
||||
int len = static_cast<int>(length);
|
||||
this->Internal->GetActiveController()->Send(&len, 1, 1,
|
||||
vtkPVSessionServer::REPLY_GATHER_INFORMATION_TAG);
|
||||
this->Internal->GetActiveController()->Send(const_cast<unsigned char*>(data),
|
||||
length, 1, vtkPVSessionServer::REPLY_GATHER_INFORMATION_TAG);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkErrorMacro("Could not create information object.");
|
||||
// let client know that gather failed.
|
||||
int len = 0;
|
||||
this->Internal->GetActiveController()->Send(&len, 1, 1,
|
||||
vtkPVSessionServer::REPLY_GATHER_INFORMATION_TAG);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::OnCloseSessionRMI()
|
||||
{
|
||||
if (this->GetIsAlive())
|
||||
{
|
||||
this->Internal->CloseActiveController();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::NotifyOtherClients(const vtkSMMessage* msg)
|
||||
{
|
||||
this->Internal->NotifyOtherClients(msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkPVSessionServer::NotifyAllClients(const vtkSMMessage* msg)
|
||||
{
|
||||
this->Internal->NotifyAllClients(msg);
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkPVSessionServer.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkPVSessionServer
|
||||
// .SECTION Description
|
||||
// vtkSMSessionServer is a session used on data and/or render servers. It's
|
||||
// designed for a process that works with a separate client process that acts as
|
||||
// the visualization driver.
|
||||
// .SECTION See Also
|
||||
// vtkSMSessionClient
|
||||
|
||||
#ifndef vtkPVSessionServer_h
|
||||
#define vtkPVSessionServer_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkPVSessionBase.h"
|
||||
|
||||
class vtkMultiProcessController;
|
||||
class vtkMultiProcessStream;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkPVSessionServer : public vtkPVSessionBase
|
||||
{
|
||||
public:
|
||||
static vtkPVSessionServer* New();
|
||||
vtkTypeMacro(vtkPVSessionServer, vtkPVSessionBase);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Returns the active controller used to communicate with the process.
|
||||
// Value must be DATA_SERVER_ROOT or RENDER_SERVER_ROOT or CLIENT.
|
||||
// But only the CLIENT do return something different than NULL;
|
||||
virtual vtkMultiProcessController* GetController(ServerFlags processType);
|
||||
|
||||
// Description:
|
||||
// Connects a remote server. URL can be of the following format:
|
||||
// cs://<pvserver-host>:<pvserver-port>
|
||||
// cdsrs://<pvdataserver-host>:<pvdataserver-port>/<pvrenderserver-host>:<pvrenderserver-port>
|
||||
// In both cases the port is optional. When not provided default
|
||||
// pvserver/pvdataserver port // is 11111, while default pvrenderserver port
|
||||
// is 22221.
|
||||
// For reverse connect i.e. the client waits for the server to connect back,
|
||||
// simply add "rc" to the protocol e.g.
|
||||
// csrc://<pvserver-host>:<pvserver-port>
|
||||
// cdsrsrc://<pvdataserver-host>:<pvdataserver-port>/<pvrenderserver-host>:<pvrenderserver-port>
|
||||
// In this case, the hostname is irrelevant and is ignored.
|
||||
virtual bool Connect(const char* url);
|
||||
|
||||
// Description:
|
||||
// Overload that constructs the url using the command line parameters
|
||||
// specified and then calls Connect(url).
|
||||
bool Connect();
|
||||
|
||||
// Description:
|
||||
// Returns true is this session is active/alive/valid.
|
||||
virtual bool GetIsAlive();
|
||||
|
||||
// Description:
|
||||
// Client-Server Communication tags.
|
||||
enum {
|
||||
PUSH = 12,
|
||||
PULL = 13,
|
||||
EXECUTE_STREAM = 14,
|
||||
GATHER_INFORMATION = 15,
|
||||
REGISTER_SI = 16,
|
||||
UNREGISTER_SI = 17,
|
||||
LAST_RESULT = 18,
|
||||
SERVER_NOTIFICATION_MESSAGE_RMI = 55624,
|
||||
CLIENT_SERVER_MESSAGE_RMI = 55625,
|
||||
CLOSE_SESSION = 55626,
|
||||
REPLY_GATHER_INFORMATION_TAG = 55627,
|
||||
REPLY_PULL = 55628,
|
||||
REPLY_LAST_RESULT = 55629,
|
||||
EXECUTE_STREAM_TAG = 55630
|
||||
};
|
||||
|
||||
// Description:
|
||||
// Enable or Disable multi-connection support.
|
||||
// The MultipleConnection is only used inside the DATA_SERVER to support
|
||||
// several clients to connect to it.
|
||||
// By default we allow collaboration (this->MultipleConnection = true)
|
||||
vtkBooleanMacro(MultipleConnection, bool);
|
||||
vtkSetMacro(MultipleConnection, bool);
|
||||
vtkGetMacro(MultipleConnection, bool);
|
||||
|
||||
//BTX
|
||||
void OnClientServerMessageRMI(void* message, int message_length);
|
||||
void OnCloseSessionRMI();
|
||||
|
||||
// Description:
|
||||
// Sends the message to all clients.
|
||||
virtual void NotifyAllClients(const vtkSMMessage*);
|
||||
|
||||
// Description:
|
||||
// Sends the message to all but the active client-session.
|
||||
virtual void NotifyOtherClients(const vtkSMMessage*);
|
||||
|
||||
protected:
|
||||
vtkPVSessionServer();
|
||||
~vtkPVSessionServer();
|
||||
|
||||
// Description:
|
||||
// Called when client triggers GatherInformation().
|
||||
void GatherInformationInternal(
|
||||
vtkTypeUInt32 location, const char* classname, vtkTypeUInt32 globalid,
|
||||
vtkMultiProcessStream&);
|
||||
|
||||
// Description:
|
||||
// Sends the last result to client.
|
||||
void SendLastResultToClient();
|
||||
|
||||
vtkMPIMToNSocketConnection* MPIMToNSocketConnection;
|
||||
|
||||
bool MultipleConnection;
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internal;
|
||||
friend class vtkInternals;
|
||||
|
||||
private:
|
||||
vtkPVSessionServer(const vtkPVSessionServer&); // Not implemented
|
||||
void operator=(const vtkPVSessionServer&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,148 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIArraySelectionProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIArraySelectionProperty.h"
|
||||
|
||||
#include "vtkArrayIterator.h"
|
||||
#include "vtkDataArray.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkIdTypeArray.h"
|
||||
#include "vtkIntArray.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSIProperty.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStringArray.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
vtkStandardNewMacro(vtkSIArraySelectionProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIArraySelectionProperty::vtkSIArraySelectionProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIArraySelectionProperty::~vtkSIArraySelectionProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIArraySelectionProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIArraySelectionProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!this->GetCommand()) // Hold the arraName
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *result = prop->mutable_value();
|
||||
result->set_type(Variant::STRING);
|
||||
|
||||
// Get the ID for the reader.
|
||||
vtkObjectBase *reader = this->GetVTKObject();
|
||||
if (reader != NULL)
|
||||
{
|
||||
std::ostringstream aname;
|
||||
aname << "GetNumberOf" << this->Command << "Arrays" << ends;
|
||||
|
||||
// Get the number of arrays.
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< aname.str().c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ProcessMessage(stream);
|
||||
stream.Reset();
|
||||
int numArrays = 0;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &numArrays))
|
||||
{
|
||||
vtkErrorMacro("Error getting number of arrays from reader.");
|
||||
}
|
||||
|
||||
// For each array, get its name and status.
|
||||
for(int i=0; i < numArrays; ++i)
|
||||
{
|
||||
std::ostringstream naname;
|
||||
naname << "Get" << this->Command << "ArrayName" << ends;
|
||||
|
||||
// Get the array name.
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< naname.str().c_str()
|
||||
<< i
|
||||
<< vtkClientServerStream::End;
|
||||
if(!this->ProcessMessage(stream))
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream.Reset();
|
||||
const char* pname;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &pname))
|
||||
{
|
||||
vtkErrorMacro("Error getting array name from reader.");
|
||||
break;
|
||||
}
|
||||
if (!pname)
|
||||
{
|
||||
// Initializing a std::string to NULL does not have a defined
|
||||
// behavior.
|
||||
break;
|
||||
}
|
||||
std::string name = pname;
|
||||
|
||||
std::ostringstream saname;
|
||||
saname << "Get" << this->Command << "ArrayStatus" << ends;
|
||||
// Get the array status.
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< saname.str().c_str()
|
||||
<< name.c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
if(!this->ProcessMessage(stream))
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream.Reset();
|
||||
int status = 0;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &status))
|
||||
{
|
||||
vtkErrorMacro("Error getting array status from reader.");
|
||||
break;
|
||||
}
|
||||
|
||||
// Store the name/status pair in the result message.
|
||||
result->add_txt(name.c_str());
|
||||
result->add_txt( (status == 0) ? "0" : "1" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkErrorMacro("GetArraySettings called on NULL vtkObject");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIArraySelectionProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIArraySelectionProperty - InformationOnly property
|
||||
// .SECTION Description
|
||||
// SIProperty that deals with ArraySelection object
|
||||
|
||||
#ifndef vtkSIArraySelectionProperty_h
|
||||
#define vtkSIArraySelectionProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIArraySelectionProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIArraySelectionProperty* New();
|
||||
vtkTypeMacro(vtkSIArraySelectionProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIArraySelectionProperty();
|
||||
~vtkSIArraySelectionProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
private:
|
||||
vtkSIArraySelectionProperty(const vtkSIArraySelectionProperty&); // Not implemented
|
||||
void operator=(const vtkSIArraySelectionProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,185 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSICollaborationManager.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSICollaborationManager.h"
|
||||
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkPVSession.h"
|
||||
#include "vtkPVSessionServer.h"
|
||||
#include "vtkPVMultiClientsInformation.h"
|
||||
#include "vtkReservedRemoteObjectIds.h"
|
||||
#include "vtkProcessModule.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkCompositeMultiProcessController.h"
|
||||
#include "vtkCommand.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
#include <vtkNew.h>
|
||||
#include <vtkWeakPointer.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
//****************************************************************************
|
||||
// Internal class
|
||||
//****************************************************************************
|
||||
class vtkSICollaborationManager::vtkInternal : public vtkCommand
|
||||
{
|
||||
public:
|
||||
static vtkInternal* New(vtkSICollaborationManager* owner)
|
||||
{
|
||||
return new vtkInternal(owner);
|
||||
}
|
||||
|
||||
vtkInternal(vtkSICollaborationManager* owner)
|
||||
{
|
||||
this->Owner = owner;
|
||||
this->DisableBroadcast = false;
|
||||
this->ServerState.set_location(vtkPVSession::DATA_SERVER_ROOT);
|
||||
this->ServerState.set_global_id(vtkReservedRemoteObjectIds::RESERVED_COLLABORATION_COMMUNICATOR_ID);
|
||||
this->ServerState.SetExtension(DefinitionHeader::client_class, "vtkSMCollaborationManager");
|
||||
this->ServerState.SetExtension(DefinitionHeader::server_class, "vtkSICollaborationManager");
|
||||
|
||||
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
|
||||
this->ServerSession = vtkPVSessionServer::SafeDownCast(pm->GetSession());
|
||||
if(this->ServerSession)
|
||||
{
|
||||
this->MultiProcessController =
|
||||
vtkCompositeMultiProcessController::SafeDownCast(this->ServerSession->GetController(vtkPVSession::CLIENT));
|
||||
if(this->MultiProcessController)
|
||||
{
|
||||
// We don't need to remove it later the vtkCommand take care of that when
|
||||
// the object get deleted
|
||||
this->MultiProcessController->AddObserver(
|
||||
vtkCompositeMultiProcessController::CompositeMultiProcessControllerChanged, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UpdateUserNamesAndMaster(vtkSMMessage* msg)
|
||||
{
|
||||
bool findChanges = false;
|
||||
this->DisableBroadcast = true;
|
||||
int size = msg->ExtensionSize(ClientsInformation::user);
|
||||
for(int i=0; i < size; ++i)
|
||||
{
|
||||
const ClientsInformation_ClientInfo* user =
|
||||
&msg->GetExtension(ClientsInformation::user, i);
|
||||
int id = user->user();
|
||||
findChanges = findChanges || (this->UserNames[id] != user->name());
|
||||
this->UserNames[id] = user->name().c_str();
|
||||
if(user->is_master() && this->MultiProcessController)
|
||||
{
|
||||
findChanges = findChanges ||
|
||||
(this->MultiProcessController->GetMasterController() != id);
|
||||
this->MultiProcessController->SetMasterController(id);
|
||||
}
|
||||
}
|
||||
this->DisableBroadcast = false;
|
||||
return findChanges;
|
||||
}
|
||||
|
||||
vtkSMMessage* BuildServerStateMessage()
|
||||
{
|
||||
this->ServerInformations->CopyFromObject(NULL);
|
||||
int master = this->ServerInformations->GetMasterId();
|
||||
|
||||
this->ServerState.ClearExtension(ClientsInformation::user);
|
||||
this->ServerState.ExtensionSize(ClientsInformation::user); // force the clear to work
|
||||
for(int i=0; i < this->ServerInformations->GetNumberOfClients(); i++)
|
||||
{
|
||||
ClientsInformation_ClientInfo* user =
|
||||
this->ServerState.AddExtension(ClientsInformation::user);
|
||||
int userId = this->ServerInformations->GetClientId(i);
|
||||
user->set_user(userId);
|
||||
if(this->UserNames[userId].empty())
|
||||
{
|
||||
std::ostringstream newUserName;
|
||||
newUserName << "User " << userId;
|
||||
this->UserNames[userId] = newUserName.str().c_str();
|
||||
}
|
||||
user->set_name(this->UserNames[userId]);
|
||||
if(userId == master)
|
||||
{
|
||||
user->set_is_master(true);
|
||||
}
|
||||
}
|
||||
|
||||
return &this->ServerState;
|
||||
}
|
||||
|
||||
bool CanBroadcast()
|
||||
{
|
||||
return (this->ServerSession && !this->DisableBroadcast);
|
||||
}
|
||||
|
||||
void Execute(vtkObject* vtkNotUsed(caller), unsigned long vtkNotUsed(eventId), void* vtkNotUsed(callData))
|
||||
{
|
||||
// A client has disconnect, let's notify the clients left
|
||||
if(this->Owner)
|
||||
{
|
||||
this->Owner->BroadcastToClients(this->BuildServerStateMessage());
|
||||
}
|
||||
}
|
||||
|
||||
vtkWeakPointer<vtkPVSessionServer> ServerSession;
|
||||
vtkNew<vtkPVMultiClientsInformation> ServerInformations;
|
||||
vtkSMMessage ServerState;
|
||||
std::map<int, std::string> UserNames;
|
||||
bool DisableBroadcast;
|
||||
vtkWeakPointer<vtkSICollaborationManager> Owner;
|
||||
vtkWeakPointer<vtkCompositeMultiProcessController> MultiProcessController;
|
||||
};
|
||||
|
||||
//****************************************************************************
|
||||
vtkStandardNewMacro(vtkSICollaborationManager);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSICollaborationManager::vtkSICollaborationManager()
|
||||
{
|
||||
this->Internal = vtkInternal::New(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSICollaborationManager::~vtkSICollaborationManager()
|
||||
{
|
||||
this->Internal->Delete();
|
||||
this->Internal = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSICollaborationManager::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSICollaborationManager::Push(vtkSMMessage* msg)
|
||||
{
|
||||
if(this->Internal->UpdateUserNamesAndMaster(msg) && this->Internal->CanBroadcast() )
|
||||
{
|
||||
this->BroadcastToClients(this->Internal->BuildServerStateMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSICollaborationManager::Pull(vtkSMMessage* msg)
|
||||
{
|
||||
msg->CopyFrom(*this->Internal->BuildServerStateMessage());
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSICollaborationManager::BroadcastToClients(vtkSMMessage* msg)
|
||||
{
|
||||
this->Internal->ServerSession->NotifyAllClients(msg);
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSICollaborationManager.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSICollaborationManager
|
||||
// .SECTION Description
|
||||
// Object that managed multi-client communication and provide the group awareness
|
||||
|
||||
#ifndef vtkSICollaborationManager_h
|
||||
#define vtkSICollaborationManager_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIObject.h"
|
||||
#include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSICollaborationManager : public vtkSIObject
|
||||
{
|
||||
public:
|
||||
static vtkSICollaborationManager* New();
|
||||
vtkTypeMacro(vtkSICollaborationManager, vtkSIObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
// The provided implementation just store the message
|
||||
// and return it at the Pull one.
|
||||
virtual void Push(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
// The provided implementation update the given message with the one
|
||||
// that has been previously pushed
|
||||
virtual void Pull(vtkSMMessage* msg);
|
||||
|
||||
protected:
|
||||
vtkSICollaborationManager();
|
||||
virtual ~vtkSICollaborationManager();
|
||||
|
||||
friend class vtkInternal;
|
||||
void BroadcastToClients(vtkSMMessage* msg);
|
||||
|
||||
private:
|
||||
vtkSICollaborationManager(const vtkSICollaborationManager&); // Not implemented
|
||||
void operator=(const vtkSICollaborationManager&); // Not implemented
|
||||
|
||||
class vtkInternal;
|
||||
vtkInternal* Internal;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif // #ifndef vtkSICollaborationManager_h
|
||||
@ -0,0 +1,198 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSICompoundSourceProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSICompoundSourceProxy.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkAlgorithmOutput.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//*****************************************************************************
|
||||
class vtkSICompoundSourceProxy::vtkInternals
|
||||
{
|
||||
public:
|
||||
struct PortInfo
|
||||
{
|
||||
std::string ProxyName;
|
||||
std::string ExposedName;
|
||||
std::string PortName;
|
||||
unsigned int PortIndex;
|
||||
PortInfo()
|
||||
{
|
||||
this->PortIndex = VTK_UNSIGNED_INT_MAX;
|
||||
}
|
||||
|
||||
bool HasPortIndex()
|
||||
{
|
||||
return this->PortIndex != VTK_UNSIGNED_INT_MAX;
|
||||
}
|
||||
|
||||
bool HasPortName()
|
||||
{
|
||||
return !this->HasPortIndex();
|
||||
}
|
||||
};
|
||||
|
||||
void RegisterExposedPort(const char* proxyName, const char* exposedName, int portIndex)
|
||||
{
|
||||
PortInfo info;
|
||||
info.PortIndex = portIndex;
|
||||
info.ProxyName = proxyName;
|
||||
info.ExposedName = exposedName;
|
||||
this->ExposedPorts.push_back(info);
|
||||
this->NeedOutputPortCreation = true;
|
||||
}
|
||||
|
||||
void RegisterExposedPort(const char* proxyName, const char* exposedName, const char* portName)
|
||||
{
|
||||
PortInfo info;
|
||||
info.PortName = portName;
|
||||
info.ProxyName = proxyName;
|
||||
info.ExposedName = exposedName;
|
||||
this->ExposedPorts.push_back(info);
|
||||
this->NeedOutputPortCreation = true;
|
||||
}
|
||||
|
||||
int GetNumberOfOutputPorts()
|
||||
{
|
||||
return static_cast<int>(this->ExposedPorts.size());
|
||||
}
|
||||
|
||||
typedef std::vector<PortInfo> VectorOfPortInfo;
|
||||
VectorOfPortInfo ExposedPorts;
|
||||
std::vector<vtkSmartPointer<vtkAlgorithmOutput> > OutputPorts;
|
||||
bool NeedOutputPortCreation;
|
||||
};
|
||||
//*****************************************************************************
|
||||
vtkStandardNewMacro(vtkSICompoundSourceProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSICompoundSourceProxy::vtkSICompoundSourceProxy()
|
||||
{
|
||||
this->Internals = new vtkInternals();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSICompoundSourceProxy::~vtkSICompoundSourceProxy()
|
||||
{
|
||||
delete this->Internals;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkAlgorithmOutput* vtkSICompoundSourceProxy::GetOutputPort(int port)
|
||||
{
|
||||
if(this->Internals->NeedOutputPortCreation)
|
||||
{
|
||||
this->CreateOutputPorts();
|
||||
}
|
||||
|
||||
if (static_cast<int>(this->Internals->OutputPorts.size()) > port)
|
||||
{
|
||||
return this->Internals->OutputPorts[port];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSICompoundSourceProxy::CreateOutputPorts()
|
||||
{
|
||||
if(this->Internals->NeedOutputPortCreation)
|
||||
{
|
||||
int ports = this->Internals->GetNumberOfOutputPorts();
|
||||
this->Internals->OutputPorts.resize(ports);
|
||||
|
||||
for (int cc=0; cc < ports; cc++)
|
||||
{
|
||||
vtkSISourceProxy* subProxy = vtkSISourceProxy::SafeDownCast(
|
||||
this->GetSubSIProxy(
|
||||
this->Internals->ExposedPorts[cc].ProxyName.c_str()));
|
||||
if (!subProxy)
|
||||
{
|
||||
vtkErrorMacro("Failed to locate subproxy: " <<
|
||||
this->Internals->ExposedPorts[cc].ProxyName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
this->Internals->OutputPorts[cc] = subProxy->GetOutputPort(
|
||||
this->Internals->ExposedPorts[cc].PortIndex);
|
||||
}
|
||||
this->Internals->NeedOutputPortCreation = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSICompoundSourceProxy::ReadXMLAttributes(vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialise exposed output port -------------------------------------------
|
||||
int index=0;
|
||||
unsigned int numElems = element->GetNumberOfNestedElements();
|
||||
for (unsigned int i=0; i < numElems; i++)
|
||||
{
|
||||
vtkPVXMLElement* currentElement = element->GetNestedElement(i);
|
||||
if ( currentElement->GetName() &&
|
||||
strcmp(currentElement->GetName(), "OutputPort") == 0)
|
||||
{
|
||||
const char* exposed_name = currentElement->GetAttribute("name");
|
||||
const char* proxy_name = currentElement->GetAttribute("proxy");
|
||||
const char* port_name = currentElement->GetAttribute("port_name");
|
||||
if (!port_name && !currentElement->GetScalarAttribute("port_index", &index))
|
||||
{
|
||||
vtkErrorMacro("Missing output port 'index'.");
|
||||
return 0;
|
||||
}
|
||||
if (!exposed_name)
|
||||
{
|
||||
vtkErrorMacro("Missing output port 'name'.");
|
||||
return 0;
|
||||
}
|
||||
if (!proxy_name)
|
||||
{
|
||||
vtkErrorMacro("Missing output port 'proxy'.");
|
||||
return 0;
|
||||
}
|
||||
if (port_name)
|
||||
{
|
||||
this->Internals->RegisterExposedPort(proxy_name, exposed_name, port_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->Internals->RegisterExposedPort(proxy_name, exposed_name, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSICompoundSourceProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSICompoundSourceProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSICompoundSourceProxy
|
||||
// .SECTION Description
|
||||
// vtkSICompoundSourceProxy is the server-side helper for a
|
||||
// vtkSMCompoundSourceProxy.
|
||||
// It provides the mapping to the exposed output port to the underneath
|
||||
// internal sub-proxy.
|
||||
|
||||
#ifndef vtkSICompoundSourceProxy_h
|
||||
#define vtkSICompoundSourceProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSISourceProxy.h"
|
||||
|
||||
class vtkAlgorithm;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSICompoundSourceProxy : public vtkSISourceProxy
|
||||
{
|
||||
public:
|
||||
static vtkSICompoundSourceProxy* New();
|
||||
vtkTypeMacro(vtkSICompoundSourceProxy, vtkSISourceProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Returns the vtkAlgorithmOutput for an output port, if valid.
|
||||
virtual vtkAlgorithmOutput* GetOutputPort(int port);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSICompoundSourceProxy();
|
||||
~vtkSICompoundSourceProxy();
|
||||
|
||||
// Description:
|
||||
// Read xml-attributes.
|
||||
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Create the output ports and add post filters for each output port.
|
||||
virtual bool CreateOutputPorts();
|
||||
|
||||
private:
|
||||
vtkSICompoundSourceProxy(const vtkSICompoundSourceProxy&); // Not implemented
|
||||
void operator=(const vtkSICompoundSourceProxy&); // Not implemented
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,141 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDataArrayProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIDataArrayProperty.h"
|
||||
|
||||
#include "vtkArrayIterator.h"
|
||||
#include "vtkDataArray.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkIdTypeArray.h"
|
||||
#include "vtkIntArray.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSIProperty.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStringArray.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSIDataArrayProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDataArrayProperty::vtkSIDataArrayProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDataArrayProperty::~vtkSIDataArrayProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIDataArrayProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIDataArrayProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->GetCommand())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Invoke property's method on the root node of the server
|
||||
vtkClientServerStream str;
|
||||
str << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << this->GetCommand()
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ProcessMessage(str);
|
||||
|
||||
// Get the result
|
||||
vtkAbstractArray* abstractArray = NULL;
|
||||
if (!this->GetLastResult().GetArgument(0, 0, (vtkObjectBase**)&abstractArray))
|
||||
{
|
||||
vtkErrorMacro( "Error getting return value of command: "
|
||||
<< this->GetCommand());
|
||||
return false;
|
||||
}
|
||||
vtkStringArray* stringArray = vtkStringArray::SafeDownCast(abstractArray);
|
||||
vtkDataArray* dataArray = vtkDataArray::SafeDownCast(abstractArray);
|
||||
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *var = prop->mutable_value();
|
||||
|
||||
// If no values, then just return OK with an empty content
|
||||
if(!dataArray && !stringArray)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Need to fill the property content with the proper type
|
||||
// Right now only those types are supported
|
||||
// - vtkDoubleArray
|
||||
// - vtkIntArray
|
||||
// - vtkIdTypeArray
|
||||
// - vtkStringArray
|
||||
vtkIdType numValues = abstractArray->GetNumberOfComponents()
|
||||
* abstractArray->GetNumberOfTuples();
|
||||
if(dataArray)
|
||||
{
|
||||
vtkDoubleArray *dataDouble = NULL;
|
||||
vtkIntArray *dataInt = NULL;
|
||||
vtkIdTypeArray *dataIdType = NULL;
|
||||
switch (dataArray->GetDataType())
|
||||
{
|
||||
case VTK_DOUBLE:
|
||||
var->set_type(Variant::FLOAT64);
|
||||
dataDouble = vtkDoubleArray::SafeDownCast(dataArray);
|
||||
for (vtkIdType cc=0; cc < numValues; cc++)
|
||||
{
|
||||
var->add_float64(dataDouble->GetValue(cc));
|
||||
}
|
||||
break;
|
||||
case VTK_INT:
|
||||
var->set_type(Variant::INT);
|
||||
dataInt = vtkIntArray::SafeDownCast(dataArray);
|
||||
for (vtkIdType cc=0; cc < numValues; cc++)
|
||||
{
|
||||
var->add_integer(dataInt->GetValue(cc));
|
||||
}
|
||||
break;
|
||||
case VTK_ID_TYPE:
|
||||
var->set_type(Variant::IDTYPE);
|
||||
dataIdType = vtkIdTypeArray::SafeDownCast(dataArray);
|
||||
for (vtkIdType cc=0; cc < numValues; cc++)
|
||||
{
|
||||
var->add_idtype(dataIdType->GetValue(cc));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
vtkWarningMacro("The Pull method of vtkSIDataArrayProperty do not support "
|
||||
<< dataArray->GetDataTypeAsString() << " array type.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(stringArray)
|
||||
{
|
||||
var->set_type(Variant::STRING);
|
||||
for (vtkIdType cc=0; cc < numValues; cc++)
|
||||
{
|
||||
var->add_txt(stringArray->GetValue(cc));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDataArrayProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIDataArrayProperty - InformationOnly property
|
||||
// .SECTION Description
|
||||
// SIProperty that deals with vtkDataArray object type
|
||||
|
||||
#ifndef vtkSIDataArrayProperty_h
|
||||
#define vtkSIDataArrayProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIDataArrayProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIDataArrayProperty* New();
|
||||
vtkTypeMacro(vtkSIDataArrayProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIDataArrayProperty();
|
||||
~vtkSIDataArrayProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
private:
|
||||
vtkSIDataArrayProperty(const vtkSIDataArrayProperty&); // Not implemented
|
||||
void operator=(const vtkSIDataArrayProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,154 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDirectoryProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIDirectoryProxy.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVInstantiator.h"
|
||||
#include "vtkPVSessionCore.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
//****************************************************************************
|
||||
vtkStandardNewMacro(vtkSIDirectoryProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDirectoryProxy::vtkSIDirectoryProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDirectoryProxy::~vtkSIDirectoryProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIDirectoryProxy::Pull(vtkSMMessage* message)
|
||||
{
|
||||
if (!this->ObjectsCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We just fill the SMMessage with our 2 fake properties
|
||||
message->ClearExtension(PullRequest::arguments);
|
||||
if(message->req_def())
|
||||
{
|
||||
// Add definition
|
||||
message->SetExtension(ProxyState::xml_group, this->XMLGroup);
|
||||
message->SetExtension(ProxyState::xml_name, this->XMLName);
|
||||
if(this->XMLSubProxyName)
|
||||
{
|
||||
message->SetExtension(ProxyState::xml_sub_proxy_name, this->XMLSubProxyName);
|
||||
}
|
||||
}
|
||||
|
||||
// Extract file informations
|
||||
// for idx in GetNumberOfFiles
|
||||
// name = GetFile(idx)
|
||||
// isDir = FileIsDirectory(name)
|
||||
// (isDir ? dirList : fileList).push(name)
|
||||
vtkClientServerStream str;
|
||||
str << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << "GetNumberOfFiles"
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->GetInterpreter()->ProcessStream(str);
|
||||
|
||||
// Get the result
|
||||
vtkIdType nbFiles = 0;
|
||||
if (!this->GetInterpreter()->GetLastResult().GetArgument(0,0, &nbFiles))
|
||||
{
|
||||
vtkErrorMacro( "Error getting return value of command: GetNumberOfFiles()");
|
||||
}
|
||||
|
||||
vtkStdString fileName;
|
||||
int isDirectory;
|
||||
std::vector<std::string> fileList;
|
||||
std::vector<std::string> directoryList;
|
||||
for(vtkIdType idx = 0; idx < nbFiles; ++idx)
|
||||
{
|
||||
vtkClientServerStream css;
|
||||
css << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << "GetFile" << idx
|
||||
<< vtkClientServerStream::End;
|
||||
this->GetInterpreter()->ProcessStream(css);
|
||||
if (!this->GetInterpreter()->GetLastResult().GetArgument(0, 0, &fileName))
|
||||
{
|
||||
vtkErrorMacro( "Error getting return value of command: GetFile(" << idx << ")");
|
||||
return;
|
||||
}
|
||||
css << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << "FileIsDirectory" << fileName.c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
this->GetInterpreter()->ProcessStream(css);
|
||||
if (!this->GetInterpreter()->GetLastResult().GetArgument(0, 0, &isDirectory))
|
||||
{
|
||||
vtkErrorMacro( "Error getting return value of command: FileIsDirectory(" << fileName.c_str() << ")");
|
||||
return;
|
||||
}
|
||||
if(isDirectory == 0)
|
||||
{
|
||||
fileList.push_back(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
directoryList.push_back(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill message response
|
||||
// Files...
|
||||
ProxyState_Property *prop = message->AddExtension(ProxyState::property);
|
||||
prop->set_name("FileList");
|
||||
Variant *var = prop->mutable_value();
|
||||
var->set_type(Variant::STRING);
|
||||
for (size_t cc=0; cc < fileList.size(); ++cc)
|
||||
{
|
||||
var->add_txt(fileList[cc]);
|
||||
}
|
||||
// Directories
|
||||
prop = message->AddExtension(ProxyState::property);
|
||||
prop->set_name("DirectoryList");
|
||||
var = prop->mutable_value();
|
||||
var->set_type(Variant::STRING);
|
||||
for (size_t cc=0; cc < directoryList.size(); ++cc)
|
||||
{
|
||||
var->add_txt(directoryList[cc]);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIDirectoryProxy::ReadXMLProperty(vtkPVXMLElement* propElement)
|
||||
{
|
||||
// We skip fake properties ;-)
|
||||
std::string name = propElement->GetAttributeOrEmpty("name");
|
||||
if(strcmp(name.c_str(), "FileList") == 0 || strcmp(name.c_str(), "DirectoryList"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return this->Superclass::ReadXMLProperty(propElement);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIDirectoryProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDirectoryProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIDirectoryProxy
|
||||
// .SECTION Description
|
||||
// vtkSIDirectoryProxy is the server-implementation for a vtkSMDirectory
|
||||
// which will customly handle server file listing for the pull request
|
||||
|
||||
|
||||
#ifndef vtkSIDirectoryProxy_h
|
||||
#define vtkSIDirectoryProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProxy.h"
|
||||
|
||||
class vtkAlgorithmOutput;
|
||||
class vtkSIProperty;
|
||||
class vtkPVXMLElement;
|
||||
class vtkSIProxyDefinitionManager;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIDirectoryProxy : public vtkSIProxy
|
||||
{
|
||||
public:
|
||||
static vtkSIDirectoryProxy* New();
|
||||
vtkTypeMacro(vtkSIDirectoryProxy, vtkSIProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual void Pull(vtkSMMessage* msg);
|
||||
//ETX
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIDirectoryProxy();
|
||||
~vtkSIDirectoryProxy();
|
||||
|
||||
// We override it to skip the fake properties (DirectoryList, FileList)
|
||||
virtual bool ReadXMLProperty(vtkPVXMLElement* property_element);
|
||||
|
||||
private:
|
||||
vtkSIDirectoryProxy(const vtkSIDirectoryProxy&); // Not implemented
|
||||
void operator=(const vtkSIDirectoryProxy&); // Not implemented
|
||||
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,113 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDoubleMapProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIDoubleMapProperty.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSIDoubleMapProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDoubleMapProperty::vtkSIDoubleMapProperty()
|
||||
{
|
||||
this->CleanCommand = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDoubleMapProperty::~vtkSIDoubleMapProperty()
|
||||
{
|
||||
this->SetCleanCommand(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIDoubleMapProperty::Push(vtkSMMessage *message, int offset)
|
||||
{
|
||||
if (this->InformationOnly || !this->Command)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkClientServerStream stream;
|
||||
vtkObjectBase* object = this->GetVTKObject();
|
||||
|
||||
if (this->CleanCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object << this->CleanCommand
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
assert(message->ExtensionSize(ProxyState::property) > offset);
|
||||
|
||||
const ProxyState_Property *prop = &message->GetExtension(ProxyState::property,
|
||||
offset);
|
||||
assert(strcmp(prop->name().c_str(), this->GetXMLName()) == 0);
|
||||
|
||||
// Save to cache when pulled for collaboration
|
||||
this->SaveValueToCache(message, offset);
|
||||
|
||||
const Variant *variant = &prop->value();
|
||||
|
||||
std::vector<double> values(variant->float64_size());
|
||||
for(size_t i = 0; i < values.size(); i++)
|
||||
{
|
||||
values[i] = variant->float64(static_cast<int>(i));
|
||||
}
|
||||
|
||||
int size = variant->idtype_size();
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
vtkIdType id = variant->idtype(i);
|
||||
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< this->Command
|
||||
<< id
|
||||
<< vtkClientServerStream::InsertArray(
|
||||
&values[i*this->NumberOfComponents],
|
||||
this->NumberOfComponents
|
||||
)
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
return this->ProcessMessage(stream);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool vtkSIDoubleMapProperty::ReadXMLAttributes(vtkSIProxy* parent,
|
||||
vtkPVXMLElement* element)
|
||||
{
|
||||
if(!this->Superclass::ReadXMLAttributes(parent, element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int number_of_components = 0;
|
||||
if (element->GetScalarAttribute("number_of_components", &number_of_components))
|
||||
{
|
||||
this->NumberOfComponents = number_of_components;
|
||||
}
|
||||
|
||||
this->SetCleanCommand(element->GetAttribute("clean_command"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIDoubleMapProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDoubleMapProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIDoubleMapProperty
|
||||
// .SECTION Description
|
||||
// Map property that manage double value to be set through a method
|
||||
// on a vtkObject.
|
||||
|
||||
#ifndef vtkSIDoubleMapProperty_h
|
||||
#define vtkSIDoubleMapProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIDoubleMapProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIDoubleMapProperty* New();
|
||||
vtkTypeMacro(vtkSIDoubleMapProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
vtkGetStringMacro(CleanCommand)
|
||||
vtkSetStringMacro(CleanCommand)
|
||||
|
||||
protected:
|
||||
vtkSIDoubleMapProperty();
|
||||
~vtkSIDoubleMapProperty();
|
||||
|
||||
virtual bool Push(vtkSMMessage*, int);
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* parent, vtkPVXMLElement* element);
|
||||
|
||||
unsigned int NumberOfComponents;
|
||||
char *CleanCommand;
|
||||
|
||||
private:
|
||||
vtkSIDoubleMapProperty(const vtkSIDoubleMapProperty&); // Not implemented
|
||||
void operator=(const vtkSIDoubleMapProperty&); // Not implemented
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,34 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDoubleVectorProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIDoubleVectorProperty.h"
|
||||
#include "vtkSIVectorPropertyTemplate.txx"
|
||||
#include "vtkObjectFactory.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSIDoubleVectorProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDoubleVectorProperty::vtkSIDoubleVectorProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIDoubleVectorProperty::~vtkSIDoubleVectorProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIDoubleVectorProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIDoubleVectorProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIDoubleVectorProperty
|
||||
// .SECTION Description
|
||||
// Vector property that manage double value to be set through a method
|
||||
// on a vtkObject.
|
||||
|
||||
#ifndef vtkSIDoubleVectorProperty_h
|
||||
#define vtkSIDoubleVectorProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIVectorProperty.h"
|
||||
#include "vtkSIVectorPropertyTemplate.h" // real superclass
|
||||
|
||||
#ifndef __WRAP__
|
||||
#define vtkSIVectorProperty vtkSIVectorPropertyTemplate<double>
|
||||
#endif
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIDoubleVectorProperty : public vtkSIVectorProperty
|
||||
#ifndef __WRAP__
|
||||
#undef vtkSIVectorProperty
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
static vtkSIDoubleVectorProperty* New();
|
||||
vtkTypeMacro(vtkSIDoubleVectorProperty, vtkSIVectorProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIDoubleVectorProperty();
|
||||
~vtkSIDoubleVectorProperty();
|
||||
|
||||
private:
|
||||
vtkSIDoubleVectorProperty(const vtkSIDoubleVectorProperty&); // Not implemented
|
||||
void operator=(const vtkSIDoubleVectorProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,35 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIIdTypeVectorProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIIdTypeVectorProperty.h"
|
||||
#include "vtkSIVectorPropertyTemplate.txx"
|
||||
#include "vtkObjectFactory.h"
|
||||
|
||||
|
||||
vtkStandardNewMacro(vtkSIIdTypeVectorProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIIdTypeVectorProperty::vtkSIIdTypeVectorProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIIdTypeVectorProperty::~vtkSIIdTypeVectorProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIIdTypeVectorProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIIdTypeVectorProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIIdTypeVectorProperty
|
||||
// .SECTION Description
|
||||
// IdType ServerSide Property use to set IdType array as method parameter.
|
||||
|
||||
#ifndef vtkSIIdTypeVectorProperty_h
|
||||
#define vtkSIIdTypeVectorProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIVectorProperty.h"
|
||||
#include "vtkSIVectorPropertyTemplate.h" // real superclass
|
||||
|
||||
#ifndef __WRAP__
|
||||
#define vtkSIVectorProperty vtkSIVectorPropertyTemplate<vtkIdType, bool>
|
||||
#endif
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIIdTypeVectorProperty : public vtkSIVectorProperty
|
||||
#ifndef __WRAP__
|
||||
#undef vtkSIVectorProperty
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
static vtkSIIdTypeVectorProperty* New();
|
||||
vtkTypeMacro(vtkSIIdTypeVectorProperty, vtkSIVectorProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIIdTypeVectorProperty();
|
||||
~vtkSIIdTypeVectorProperty();
|
||||
|
||||
private:
|
||||
vtkSIIdTypeVectorProperty(const vtkSIIdTypeVectorProperty&); // Not implemented
|
||||
void operator=(const vtkSIIdTypeVectorProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,177 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIIndexSelectionProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIIndexSelectionProperty.h"
|
||||
|
||||
#include "vtkArrayIterator.h"
|
||||
#include "vtkDataArray.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkIdTypeArray.h"
|
||||
#include "vtkIntArray.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSIProperty.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStringArray.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
vtkStandardNewMacro(vtkSIIndexSelectionProperty)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIIndexSelectionProperty::vtkSIIndexSelectionProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIIndexSelectionProperty::~vtkSIIndexSelectionProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIIndexSelectionProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIIndexSelectionProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!this->GetCommand())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *result = prop->mutable_value();
|
||||
result->set_type(Variant::STRING);
|
||||
|
||||
// Get the ID for the reader.
|
||||
vtkObjectBase *reader = this->GetVTKObject();
|
||||
if (reader != NULL)
|
||||
{
|
||||
std::ostringstream aname;
|
||||
aname << "GetNumberOf" << this->Command << "s" << ends;
|
||||
|
||||
// Get the number of arrays.
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< aname.str().c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ProcessMessage(stream);
|
||||
stream.Reset();
|
||||
int numArrays = 0;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &numArrays))
|
||||
{
|
||||
vtkErrorMacro("Error getting number of " << this->Command
|
||||
<< "s from reader.");
|
||||
}
|
||||
|
||||
// For each array, get its name and status.
|
||||
for (int i = 0; i < numArrays; ++i)
|
||||
{
|
||||
std::ostringstream naname;
|
||||
naname << "Get" << this->Command << "Name" << ends;
|
||||
|
||||
// Get the array name.
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< naname.str().c_str()
|
||||
<< i
|
||||
<< vtkClientServerStream::End;
|
||||
if(!this->ProcessMessage(stream))
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream.Reset();
|
||||
const char* pname;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &pname))
|
||||
{
|
||||
vtkErrorMacro("Error getting " << this->Command << " name from reader.");
|
||||
break;
|
||||
}
|
||||
if (!pname)
|
||||
{
|
||||
// Initializing a std::string to NULL does not have a defined
|
||||
// behavior.
|
||||
break;
|
||||
}
|
||||
std::string name = pname;
|
||||
|
||||
std::ostringstream caname;
|
||||
caname << "Get" << this->Command << "CurrentIndex" << ends;
|
||||
// Get the array status.
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< caname.str().c_str()
|
||||
<< name.c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
if(!this->ProcessMessage(stream))
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream.Reset();
|
||||
int currIdx = 0;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &currIdx))
|
||||
{
|
||||
vtkErrorMacro("Error getting index from reader.");
|
||||
break;
|
||||
}
|
||||
|
||||
std::ostringstream saname;
|
||||
saname << "Get" << this->Command << "Size" << ends;
|
||||
// Get the array status.
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< saname.str().c_str()
|
||||
<< name.c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
if(!this->ProcessMessage(stream))
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream.Reset();
|
||||
int dimSize = 0;
|
||||
if(!this->GetLastResult().GetArgument(0, 0, &dimSize))
|
||||
{
|
||||
vtkErrorMacro("Error getting size from reader.");
|
||||
break;
|
||||
}
|
||||
|
||||
// Store the name/status pair in the result message.
|
||||
result->add_txt(name.c_str());
|
||||
std::ostringstream str;
|
||||
str << currIdx;
|
||||
result->add_txt(str.str());
|
||||
|
||||
str.str("");
|
||||
str << dimSize;
|
||||
result->add_txt(str.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkErrorMacro("Called on NULL vtkObject");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIIndexSelectionProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIIndexSelectionProperty - Select names from an indexed string list.
|
||||
// .SECTION Description
|
||||
// Expected Methods on reader (assuming command="Dimension"):
|
||||
// int GetNumberOfDimensions()
|
||||
// std::string GetDimensionName(int)
|
||||
// int GetCurrentDimensionIndex(std::string)
|
||||
// int GetDimensionSize(std::string)
|
||||
// void SetCurrentDimensionIndex(std::string, int)
|
||||
|
||||
#ifndef vtkSIIndexSelectionProperty_h
|
||||
#define vtkSIIndexSelectionProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" // needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIIndexSelectionProperty :
|
||||
public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIIndexSelectionProperty* New();
|
||||
vtkTypeMacro(vtkSIIndexSelectionProperty, vtkSIProperty)
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIIndexSelectionProperty();
|
||||
~vtkSIIndexSelectionProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
private:
|
||||
vtkSIIndexSelectionProperty(const vtkSIIndexSelectionProperty&); // Not implemented
|
||||
void operator=(const vtkSIIndexSelectionProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,130 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: $RCSfile$
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIInputProperty.h"
|
||||
|
||||
#include "vtkAlgorithmOutput.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSISourceProxy.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
vtkStandardNewMacro(vtkSIInputProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIInputProperty::vtkSIInputProperty()
|
||||
{
|
||||
this->PortIndex = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIInputProperty::~vtkSIInputProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIInputProperty::ReadXMLAttributes(
|
||||
vtkSIProxy* proxyhelper, vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(proxyhelper, element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int port_index;
|
||||
if (element->GetScalarAttribute("port_index", &port_index))
|
||||
{
|
||||
this->SetPortIndex(port_index);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIInputProperty::Push(vtkSMMessage* message, int offset)
|
||||
{
|
||||
if(!this->GetCommand())
|
||||
{
|
||||
// It is fine to have a property without command but then we do nothing
|
||||
// here at the server side...
|
||||
return true;
|
||||
}
|
||||
|
||||
assert(message->ExtensionSize(ProxyState::property) > offset);
|
||||
const ProxyState_Property *prop = &message->GetExtension(ProxyState::property,
|
||||
offset);
|
||||
assert(strcmp(prop->name().c_str(), this->GetXMLName()) == 0);
|
||||
|
||||
const Variant *variant = &prop->value();
|
||||
assert(variant->proxy_global_id_size() == variant->port_number_size());
|
||||
|
||||
std::vector<vtkTypeUInt32> proxy_ids;
|
||||
std::vector<int> output_ports;
|
||||
|
||||
proxy_ids.resize(variant->proxy_global_id_size());
|
||||
output_ports.resize(proxy_ids.size());
|
||||
for (int cc=0; cc < variant->proxy_global_id_size(); cc++)
|
||||
{
|
||||
proxy_ids[cc] = variant->proxy_global_id(cc);
|
||||
output_ports[cc] = variant->port_number(cc);
|
||||
}
|
||||
|
||||
vtkClientServerStream stream;
|
||||
if (this->CleanCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->SIProxyObject
|
||||
<< "CleanInputs"
|
||||
<< this->CleanCommand
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
for (size_t cc=0; cc < proxy_ids.size(); cc++)
|
||||
{
|
||||
vtkSISourceProxy* siProxy = vtkSISourceProxy::SafeDownCast(
|
||||
this->GetSIObject(proxy_ids[cc]));
|
||||
vtkAlgorithmOutput* input_connection =
|
||||
(siProxy? siProxy->GetOutputPort(output_ports[cc]) : NULL);
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->SIProxyObject
|
||||
<< "AddInput"
|
||||
<< this->PortIndex
|
||||
<< input_connection
|
||||
<< this->GetCommand()
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
if (this->NullOnEmpty && this->CleanCommand == NULL && proxy_ids.size() == 0)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->SIProxyObject
|
||||
<< "AddInput"
|
||||
<< this->PortIndex
|
||||
<< static_cast<vtkObjectBase*>(NULL)
|
||||
<< this->GetCommand()
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
// Save to cache when pulled for collaboration
|
||||
this->SaveValueToCache(message, offset);
|
||||
|
||||
return this->ProcessMessage(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIInputProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIInputProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIInputProperty
|
||||
// .SECTION Description
|
||||
// ServerSide Property use to set vtkOutputPort as method parameter.
|
||||
// For that we need the object on which we should get the Port and its port
|
||||
// number.
|
||||
|
||||
#ifndef vtkSIInputProperty_h
|
||||
#define vtkSIInputProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProxyProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIInputProperty : public vtkSIProxyProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIInputProperty* New();
|
||||
vtkTypeMacro(vtkSIInputProperty, vtkSIProxyProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Controls which input port this property uses when making connections.
|
||||
// By default, this is 0.
|
||||
vtkGetMacro(PortIndex, int);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIInputProperty();
|
||||
~vtkSIInputProperty();
|
||||
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
virtual bool Push(vtkSMMessage*, int);
|
||||
|
||||
// Description:
|
||||
// Parse the xml for the property.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper, vtkPVXMLElement* element);
|
||||
|
||||
vtkSetMacro(PortIndex, int);
|
||||
int PortIndex;
|
||||
private:
|
||||
vtkSIInputProperty(const vtkSIInputProperty&); // Not implemented
|
||||
void operator=(const vtkSIInputProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,34 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIIntVectorProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIIntVectorProperty.h"
|
||||
#include "vtkSIVectorPropertyTemplate.txx"
|
||||
#include "vtkObjectFactory.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSIIntVectorProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIIntVectorProperty::vtkSIIntVectorProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIIntVectorProperty::~vtkSIIntVectorProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIIntVectorProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIIntVectorProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIIntVectorProperty
|
||||
// .SECTION Description
|
||||
// ServerSide Property use to set int array as method argument.
|
||||
|
||||
|
||||
#ifndef vtkSIIntVectorProperty_h
|
||||
#define vtkSIIntVectorProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIVectorProperty.h"
|
||||
#include "vtkSIVectorPropertyTemplate.h" // real superclass
|
||||
|
||||
#ifndef __WRAP__
|
||||
#define vtkSIVectorProperty vtkSIVectorPropertyTemplate<int>
|
||||
#endif
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIIntVectorProperty : public vtkSIVectorProperty
|
||||
#ifndef __WRAP__
|
||||
#undef vtkSIVectorProperty
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
static vtkSIIntVectorProperty* New();
|
||||
vtkTypeMacro(vtkSIIntVectorProperty, vtkSIVectorProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIIntVectorProperty();
|
||||
~vtkSIIntVectorProperty();
|
||||
|
||||
private:
|
||||
vtkSIIntVectorProperty(const vtkSIIntVectorProperty&); // Not implemented
|
||||
void operator=(const vtkSIIntVectorProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,95 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIMetaReaderProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIMetaReaderProxy.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
vtkStandardNewMacro(vtkSIMetaReaderProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIMetaReaderProxy::vtkSIMetaReaderProxy()
|
||||
{
|
||||
this->FileNameMethod = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIMetaReaderProxy::~vtkSIMetaReaderProxy()
|
||||
{
|
||||
this->SetFileNameMethod(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIMetaReaderProxy::CreateVTKObjects(vtkSMMessage* message)
|
||||
{
|
||||
if(!this->Superclass::CreateVTKObjects(message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Connect reader and set filename method
|
||||
vtkObjectBase *reader = this->GetSubSIProxy("Reader")->GetVTKObject();
|
||||
if (!reader)
|
||||
{
|
||||
vtkErrorMacro("Missing subproxy: Reader");
|
||||
return false;
|
||||
}
|
||||
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << "SetReader" << reader
|
||||
<< vtkClientServerStream::End;
|
||||
if (this->GetFileNameMethod())
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< "SetFileNameMethod"
|
||||
<< this->GetFileNameMethod()
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
if (!this->Interpreter->ProcessStream(stream))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIMetaReaderProxy::ReadXMLAttributes(vtkPVXMLElement* element)
|
||||
{
|
||||
bool ret = this->Superclass::ReadXMLAttributes(element);
|
||||
const char* fileNameMethod = element->GetAttribute("file_name_method");
|
||||
if(fileNameMethod && ret)
|
||||
{
|
||||
this->SetFileNameMethod(fileNameMethod);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIMetaReaderProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIMetaReaderProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIMetaReaderProxy
|
||||
// .SECTION Description
|
||||
// vtkSISourceProxy is the server-side helper for a vtkSMSourceProxy.
|
||||
// It adds support to handle various vtkAlgorithm specific Invoke requests
|
||||
// coming from the client. vtkSISourceProxy also inserts post-processing filters
|
||||
// for each output port from the vtkAlgorithm. These post-processing filters
|
||||
// deal with things like parallelizing the data etc.
|
||||
|
||||
#ifndef vtkSIMetaReaderProxy_h
|
||||
#define vtkSIMetaReaderProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSISourceProxy.h"
|
||||
|
||||
class vtkAlgorithm;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIMetaReaderProxy : public vtkSISourceProxy
|
||||
{
|
||||
public:
|
||||
static vtkSIMetaReaderProxy* New();
|
||||
vtkTypeMacro(vtkSIMetaReaderProxy, vtkSISourceProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
|
||||
protected:
|
||||
vtkSIMetaReaderProxy();
|
||||
~vtkSIMetaReaderProxy();
|
||||
|
||||
// Description:
|
||||
// Creates the VTKObjects. Overridden to add post-filters to the pipeline.
|
||||
virtual bool CreateVTKObjects(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Read xml-attributes.
|
||||
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
|
||||
|
||||
// This is the name of the method used to set the file name on the
|
||||
// internal reader. See vtkFileSeriesReader for details.
|
||||
vtkSetStringMacro(FileNameMethod);
|
||||
vtkGetStringMacro(FileNameMethod);
|
||||
|
||||
char* FileNameMethod;
|
||||
|
||||
private:
|
||||
vtkSIMetaReaderProxy(const vtkSIMetaReaderProxy&); // Not implemented
|
||||
void operator=(const vtkSIMetaReaderProxy&); // Not implemented
|
||||
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,89 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIObject.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIObject.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkPVSessionCore.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
vtkStandardNewMacro(vtkSIObject);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIObject::vtkSIObject()
|
||||
{
|
||||
this->Interpreter = 0;
|
||||
this->SessionCore = 0;
|
||||
this->GlobalID = 0;
|
||||
this->LastPushedMessage = new vtkSMMessage();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIObject::~vtkSIObject()
|
||||
{
|
||||
delete this->LastPushedMessage;
|
||||
this->LastPushedMessage = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIObject::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIObject::Initialize(vtkPVSessionCore* session)
|
||||
{
|
||||
assert(session != NULL);
|
||||
this->SessionCore = session;
|
||||
this->Interpreter = session->GetInterpreter();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIObject* vtkSIObject::GetSIObject(vtkTypeUInt32 globalid) const
|
||||
{
|
||||
if (this->SessionCore)
|
||||
{
|
||||
return this->SessionCore->GetSIObject(globalid);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkObject* vtkSIObject::GetRemoteObject(vtkTypeUInt32 globalid)
|
||||
{
|
||||
if (this->SessionCore)
|
||||
{
|
||||
return this->SessionCore->GetRemoteObject(globalid);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkClientServerInterpreter* vtkSIObject::GetInterpreter()
|
||||
{
|
||||
return this->Interpreter;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIObject::Push(vtkSMMessage* msg)
|
||||
{
|
||||
this->LastPushedMessage->CopyFrom(*msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIObject::Pull(vtkSMMessage* msg)
|
||||
{
|
||||
msg->CopyFrom(*this->LastPushedMessage);
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIObject.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIObject
|
||||
// .SECTION Description
|
||||
// Object that is managed by vtkPVSessionCore which wrap concrete class such as
|
||||
// the vtk ones.
|
||||
|
||||
#ifndef vtkSIObject_h
|
||||
#define vtkSIObject_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkObject.h"
|
||||
#include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
|
||||
#include "vtkWeakPointer.h" // needed for vtkWeakPointer
|
||||
|
||||
class vtkClientServerInterpreter;
|
||||
class vtkPVSessionCore;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIObject : public vtkObject
|
||||
{
|
||||
public:
|
||||
static vtkSIObject* New();
|
||||
vtkTypeMacro(vtkSIObject,vtkObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// This method is called before the deletion of the SIObject.
|
||||
// Basically this is used to remove all dependency with other SIObject so after
|
||||
// a first pass on all SIObject with a AboutToDelete() we can simply delete the
|
||||
// remaining SIObjects.
|
||||
virtual void AboutToDelete() {};
|
||||
|
||||
// Description:
|
||||
// Initializes the instance. Session is the session to which this instance
|
||||
// belongs to. During initialization, the SIObject basically obtains ivars for
|
||||
// necessary components.
|
||||
virtual void Initialize(vtkPVSessionCore* session);
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
// The provided implementation just store the message
|
||||
// and return it at the Pull one.
|
||||
virtual void Push(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
// The provided implementation update the given message with the one
|
||||
// that has been previously pushed
|
||||
virtual void Pull(vtkSMMessage* msg);
|
||||
//ETX
|
||||
|
||||
//BTX
|
||||
|
||||
// Description:
|
||||
// Provides access to the Interpreter.
|
||||
vtkClientServerInterpreter* GetInterpreter();
|
||||
|
||||
// Description:
|
||||
// Convenience method to obtain a vtkSIObject subclass given its global id.
|
||||
vtkSIObject* GetSIObject(vtkTypeUInt32 globalid) const;
|
||||
|
||||
// Description:
|
||||
// Convenience method to obtain a vtkObject subclass given its
|
||||
// global id.
|
||||
vtkObject* GetRemoteObject(vtkTypeUInt32 globalid);
|
||||
|
||||
// Description:
|
||||
// Get/Set the global id for this object.
|
||||
vtkSetMacro(GlobalID, vtkTypeUInt32);
|
||||
vtkGetMacro(GlobalID, vtkTypeUInt32);
|
||||
|
||||
protected:
|
||||
vtkSIObject();
|
||||
virtual ~vtkSIObject();
|
||||
|
||||
vtkWeakPointer<vtkClientServerInterpreter> Interpreter;
|
||||
vtkWeakPointer<vtkPVSessionCore> SessionCore;
|
||||
|
||||
vtkSMMessage* LastPushedMessage;
|
||||
|
||||
vtkTypeUInt32 GlobalID;
|
||||
private:
|
||||
vtkSIObject(const vtkSIObject&); // Not implemented
|
||||
void operator=(const vtkSIObject&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif // #ifndef vtkSIObject_h
|
||||
@ -0,0 +1,213 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSIProxy.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
|
||||
//****************************************************************************/
|
||||
// Internal Classes and typedefs
|
||||
//****************************************************************************/
|
||||
class vtkSIProperty::vtkInternals
|
||||
{
|
||||
public:
|
||||
vtkInternals()
|
||||
{
|
||||
this->CacheValue = NULL;
|
||||
}
|
||||
~vtkInternals()
|
||||
{
|
||||
this->ClearCache();
|
||||
}
|
||||
|
||||
void ClearCache()
|
||||
{
|
||||
if(this->CacheValue)
|
||||
{
|
||||
delete this->CacheValue;
|
||||
this->CacheValue = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool HasCache()
|
||||
{
|
||||
return this->CacheValue != NULL;
|
||||
}
|
||||
|
||||
void SaveToCache(const ProxyState_Property *newValue)
|
||||
{
|
||||
this->ClearCache();
|
||||
this->CacheValue = new ProxyState_Property();
|
||||
this->CacheValue->CopyFrom(*newValue);
|
||||
}
|
||||
|
||||
ProxyState_Property *CacheValue;
|
||||
};
|
||||
|
||||
//****************************************************************************/
|
||||
vtkStandardNewMacro(vtkSIProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProperty::vtkSIProperty()
|
||||
{
|
||||
this->Command = NULL;
|
||||
this->XMLName = NULL;
|
||||
this->IsInternal = false;
|
||||
this->InformationOnly = false;
|
||||
this->Repeatable = false;
|
||||
this->SIProxyObject = NULL;
|
||||
this->Internals = new vtkInternals();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProperty::~vtkSIProperty()
|
||||
{
|
||||
this->SetCommand(NULL);
|
||||
this->SetXMLName(NULL);
|
||||
delete this->Internals;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProperty::ReadXMLAttributes(
|
||||
vtkSIProxy* proxyhelper, vtkPVXMLElement* element)
|
||||
{
|
||||
this->SIProxyObject = proxyhelper;
|
||||
|
||||
const char* xmlname = element->GetAttribute("name");
|
||||
if(xmlname)
|
||||
{
|
||||
this->SetXMLName(xmlname);
|
||||
}
|
||||
|
||||
const char* command = element->GetAttribute("command");
|
||||
if (command)
|
||||
{
|
||||
this->SetCommand(command);
|
||||
}
|
||||
|
||||
int repeatable;
|
||||
if (element->GetScalarAttribute("repeatable", &repeatable))
|
||||
{
|
||||
this->Repeatable = (repeatable != 0);
|
||||
}
|
||||
|
||||
// Yup, both mean the same thing :).
|
||||
int repeat_command;
|
||||
if (element->GetScalarAttribute("repeat_command", &repeat_command))
|
||||
{
|
||||
this->Repeatable = (repeat_command != 0);
|
||||
}
|
||||
|
||||
int information_only;
|
||||
if (element->GetScalarAttribute("information_only", &information_only))
|
||||
{
|
||||
this->InformationOnly = (information_only != 0);
|
||||
}
|
||||
|
||||
int is_internal;
|
||||
if (element->GetScalarAttribute("is_internal", &is_internal))
|
||||
{
|
||||
this->SetIsInternal(is_internal != 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIObject* vtkSIProperty::GetSIObject(vtkTypeUInt32 globalid)
|
||||
{
|
||||
if (this->SIProxyObject)
|
||||
{
|
||||
return this->SIProxyObject->GetSIObject(globalid);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProperty::ProcessMessage(vtkClientServerStream& stream)
|
||||
{
|
||||
if (this->SIProxyObject && this->SIProxyObject->GetVTKObject())
|
||||
{
|
||||
return this->SIProxyObject->GetInterpreter()->ProcessStream(stream) != 0;
|
||||
}
|
||||
return this->SIProxyObject ? true : false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkObjectBase* vtkSIProperty::GetVTKObject()
|
||||
{
|
||||
if (this->SIProxyObject)
|
||||
{
|
||||
return this->SIProxyObject->GetVTKObject();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const vtkClientServerStream& vtkSIProperty::GetLastResult()
|
||||
{
|
||||
if (this->SIProxyObject)
|
||||
{
|
||||
return this->SIProxyObject->GetInterpreter()->GetLastResult();
|
||||
}
|
||||
|
||||
static vtkClientServerStream stream;
|
||||
return stream;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
// CAUTION: This method should only be called for Command property only
|
||||
// and not for value property.
|
||||
bool vtkSIProperty::Push(vtkSMMessage*, int)
|
||||
{
|
||||
if (this->InformationOnly || !this->Command || this->GetVTKObject() == NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke;
|
||||
stream << this->GetVTKObject() << this->Command;
|
||||
stream << vtkClientServerStream::End;
|
||||
return this->ProcessMessage(stream);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
// CAUTION: This method should only be called to retreive the cache value of the
|
||||
// property.
|
||||
bool vtkSIProperty::Pull(vtkSMMessage* msg)
|
||||
{
|
||||
if(!this->InformationOnly && this->Internals->HasCache())
|
||||
{
|
||||
ProxyState_Property *newProp = msg->AddExtension(ProxyState::property);
|
||||
newProp->CopyFrom(*this->Internals->CacheValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProperty::SaveValueToCache(vtkSMMessage* message, int offset)
|
||||
{
|
||||
const ProxyState_Property *prop =
|
||||
&message->GetExtension(ProxyState::property, offset);
|
||||
this->Internals->SaveToCache(prop);
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIProperty
|
||||
// .SECTION Description
|
||||
// Basic ServerImplementation property used to call a method with no argument
|
||||
// on a VTK object. If overriden, we naturally allow to call a method either
|
||||
// to set or get a set of values.
|
||||
|
||||
#ifndef vtkSIProperty_h
|
||||
#define vtkSIProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkObject.h"
|
||||
#include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
|
||||
#include "vtkWeakPointer.h" // needed for vtkWeakPointer.
|
||||
|
||||
class vtkClientServerStream;
|
||||
class vtkSIObject;
|
||||
class vtkSIProxy;
|
||||
class vtkPVXMLElement;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIProperty : public vtkObject
|
||||
{
|
||||
public:
|
||||
static vtkSIProperty* New();
|
||||
vtkTypeMacro(vtkSIProperty, vtkObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// The name assigned by the xml parser. Used to get the property
|
||||
// from a proxy.
|
||||
vtkGetStringMacro(XMLName);
|
||||
|
||||
// Description:
|
||||
// The command name used to set the value on the server object.
|
||||
// For example: SetThetaResolution
|
||||
vtkGetStringMacro(Command);
|
||||
|
||||
// Description:
|
||||
// Is InformationOnly is set to true, this property is used to
|
||||
// get information from server instead of setting values.
|
||||
vtkGetMacro(InformationOnly, bool);
|
||||
|
||||
// Description:
|
||||
// If repeatable, a property can have 1 or more values of the same kind.
|
||||
// This ivar is configured when the xml file is read and is mainly useful
|
||||
// for information (for example from python).
|
||||
vtkGetMacro(Repeatable, bool);
|
||||
|
||||
// Description:
|
||||
// This ivar is configured when the xml file is read and is mainly useful
|
||||
// to trigger a method call.
|
||||
// Internal properties are not saved in state
|
||||
vtkSetMacro(IsInternal, bool);
|
||||
vtkGetMacro(IsInternal, bool);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIProperty();
|
||||
~vtkSIProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Convenience method to obtain a vtkSIObject subclass given its global id.
|
||||
vtkSIObject* GetSIObject(vtkTypeUInt32 globalid);
|
||||
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
virtual bool Push(vtkSMMessage*, int);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
// Description:
|
||||
// Parse the xml for the property.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper, vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Interprets the message.
|
||||
bool ProcessMessage(vtkClientServerStream& stream);
|
||||
const vtkClientServerStream& GetLastResult();
|
||||
vtkObjectBase* GetVTKObject();
|
||||
|
||||
vtkSetStringMacro(Command);
|
||||
vtkSetStringMacro(XMLName);
|
||||
|
||||
char* XMLName;
|
||||
char* Command;
|
||||
bool InformationOnly;
|
||||
bool Repeatable;
|
||||
bool IsInternal;
|
||||
|
||||
vtkWeakPointer<vtkSIProxy> SIProxyObject;
|
||||
|
||||
// Allow subclass to save the property value as a state part
|
||||
void SaveValueToCache(vtkSMMessage* proxyStateUpdate, int offset);
|
||||
|
||||
private:
|
||||
vtkSIProperty(const vtkSIProperty&); // Not implemented
|
||||
void operator=(const vtkSIProperty&); // Not implemented
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,599 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIProxy.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkAlgorithmOutput.h"
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVInstantiator.h"
|
||||
#include "vtkPVSessionCore.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSIProperty.h"
|
||||
#include "vtkSIProxyDefinitionManager.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
//****************************************************************************
|
||||
struct SubProxyInfo
|
||||
{
|
||||
SubProxyInfo(std::string name, vtkTypeUInt32 id)
|
||||
{
|
||||
this->Name = name;
|
||||
this->GlobalID = id;
|
||||
}
|
||||
|
||||
std::string Name;
|
||||
vtkTypeUInt32 GlobalID;
|
||||
};
|
||||
//****************************************************************************
|
||||
class vtkSIProxy::vtkInternals
|
||||
{
|
||||
public:
|
||||
|
||||
void ClearDependencies()
|
||||
{
|
||||
this->SIProperties.clear();
|
||||
this->SubSIProxies.clear();
|
||||
}
|
||||
|
||||
typedef std::map<std::string, vtkSmartPointer<vtkSIProperty> >
|
||||
SIPropertiesMapType;
|
||||
SIPropertiesMapType SIProperties;
|
||||
|
||||
typedef std::map<std::string, vtkSmartPointer<vtkSIProxy> >
|
||||
SubSIProxiesMapType;
|
||||
SubSIProxiesMapType SubSIProxies;
|
||||
|
||||
typedef std::vector<SubProxyInfo> SubProxiesVectorType;
|
||||
SubProxiesVectorType SubProxyInfoVector;
|
||||
|
||||
typedef std::map<std::string, std::string> SubProxyCommandMapType;
|
||||
SubProxyCommandMapType SubProxyCommands;
|
||||
};
|
||||
|
||||
//****************************************************************************
|
||||
vtkStandardNewMacro(vtkSIProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxy::vtkSIProxy()
|
||||
{
|
||||
this->Internals = new vtkInternals();
|
||||
this->VTKObject = NULL;
|
||||
this->ObjectsCreated = false;
|
||||
|
||||
this->XMLGroup = 0;
|
||||
this->XMLName = 0;
|
||||
this->XMLSubProxyName = 0;
|
||||
this->VTKClassName = 0;
|
||||
this->PostPush = 0;
|
||||
this->PostCreation = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxy::~vtkSIProxy()
|
||||
{
|
||||
this->DeleteVTKObjects();
|
||||
|
||||
delete this->Internals;
|
||||
this->Internals = 0;
|
||||
|
||||
this->SetXMLGroup(0);
|
||||
this->SetXMLName(0);
|
||||
this->SetXMLSubProxyName(0);
|
||||
this->SetVTKClassName(0);
|
||||
this->SetPostPush(0);
|
||||
this->SetPostCreation(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::SetVTKObject(vtkObjectBase* obj)
|
||||
{
|
||||
this->VTKObject = obj;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::Push(vtkSMMessage* message)
|
||||
{
|
||||
if (!this->CreateVTKObjects(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle properties
|
||||
int cc = 0;
|
||||
int size = message->ExtensionSize(ProxyState::property);
|
||||
for (;cc < size; cc++)
|
||||
{
|
||||
const ProxyState_Property &propMsg =
|
||||
message->GetExtension(ProxyState::property, cc);
|
||||
|
||||
// Convert state to interpretor stream
|
||||
vtkSIProperty* prop = this->GetSIProperty(propMsg.name().c_str());
|
||||
if (prop)
|
||||
{
|
||||
if (prop->Push(message, cc) == false)
|
||||
{
|
||||
vtkErrorMacro("Error pushing property state: " << propMsg.name());
|
||||
message->PrintDebugString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute post_push if any
|
||||
if(this->PostPush != NULL)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< this->PostPush
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::Pull(vtkSMMessage* message)
|
||||
{
|
||||
if (!this->ObjectsCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Return a set of Pull only property (information_only props)
|
||||
// In fact Pushed Property can not be fetch at the same time as Pull
|
||||
// property with the current implementation
|
||||
std::set<std::string> prop_names;
|
||||
if (message->ExtensionSize(PullRequest::arguments) > 0)
|
||||
{
|
||||
const Variant *propList = &message->GetExtension(PullRequest::arguments, 0);
|
||||
for(int i=0; i < propList->txt_size(); ++i)
|
||||
{
|
||||
const char* propertyName = propList->txt(i).c_str();
|
||||
prop_names.insert(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
message->ClearExtension(PullRequest::arguments);
|
||||
|
||||
vtkInternals::SIPropertiesMapType::iterator iter;
|
||||
for (iter = this->Internals->SIProperties.begin(); iter !=
|
||||
this->Internals->SIProperties.end(); ++iter)
|
||||
{
|
||||
if (prop_names.size() == 0 ||
|
||||
prop_names.find(iter->first) != prop_names.end())
|
||||
{
|
||||
if(!iter->second->GetIsInternal())
|
||||
{
|
||||
if(message->req_def())
|
||||
{
|
||||
// We just want the cached push property
|
||||
if( !iter->second->GetInformationOnly() &&
|
||||
!iter->second->Pull(message))
|
||||
{
|
||||
vtkErrorMacro("Error pulling property state: " << iter->first);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!iter->second->Pull(message))
|
||||
{
|
||||
vtkErrorMacro("Error pulling property state: " << iter->first);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(message->req_def())
|
||||
{
|
||||
// Add definition
|
||||
message->SetExtension(ProxyState::xml_group, this->XMLGroup);
|
||||
message->SetExtension(ProxyState::xml_name, this->XMLName);
|
||||
if(this->XMLSubProxyName)
|
||||
{
|
||||
message->SetExtension(ProxyState::xml_sub_proxy_name, this->XMLSubProxyName);
|
||||
}
|
||||
|
||||
// Add subproxy information to the message.
|
||||
vtkInternals::SubProxiesVectorType::iterator it2 =
|
||||
this->Internals->SubProxyInfoVector.begin();
|
||||
for( ; it2 != this->Internals->SubProxyInfoVector.end(); it2++)
|
||||
{
|
||||
ProxyState_SubProxy *subproxy = message->AddExtension(ProxyState::subproxy);
|
||||
subproxy->set_name(it2->Name.c_str());
|
||||
subproxy->set_global_id(it2->GlobalID);
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxyDefinitionManager* vtkSIProxy::GetProxyDefinitionManager()
|
||||
{
|
||||
if (this->SessionCore)
|
||||
{
|
||||
return this->SessionCore->GetProxyDefinitionManager();
|
||||
}
|
||||
|
||||
vtkWarningMacro("No valid session provided. "
|
||||
"This class may not have been initialized yet.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProperty* vtkSIProxy::GetSIProperty(const char* name)
|
||||
{
|
||||
vtkInternals::SIPropertiesMapType::iterator iter =
|
||||
this->Internals->SIProperties.find(name);
|
||||
if (iter != this->Internals->SIProperties.end())
|
||||
{
|
||||
return iter->second.GetPointer();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::AddSIProperty(const char* name, vtkSIProperty* property)
|
||||
{
|
||||
this->Internals->SIProperties[name] = property;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxy::CreateVTKObjects(vtkSMMessage* message)
|
||||
{
|
||||
if (this->ObjectsCreated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!message->HasExtension(ProxyState::xml_group) ||
|
||||
!message->HasExtension(ProxyState::xml_name))
|
||||
{
|
||||
vtkErrorMacro("Incorrect message received. "
|
||||
<< "Missing xml_group and xml_name information." << endl
|
||||
<< message->DebugString().c_str() << endl);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store definition informations
|
||||
this->SetXMLGroup(message->GetExtension(ProxyState::xml_group).c_str());
|
||||
this->SetXMLName(message->GetExtension(ProxyState::xml_name).c_str());
|
||||
this->SetXMLSubProxyName(
|
||||
message->HasExtension(ProxyState::xml_sub_proxy_name) ?
|
||||
message->GetExtension(ProxyState::xml_sub_proxy_name).c_str() : NULL);
|
||||
|
||||
vtkSIProxyDefinitionManager* pdm = this->GetProxyDefinitionManager();
|
||||
vtkPVXMLElement* element = pdm->GetCollapsedProxyDefinition(
|
||||
message->GetExtension(ProxyState::xml_group).c_str(),
|
||||
message->GetExtension(ProxyState::xml_name).c_str(),
|
||||
(message->HasExtension(ProxyState::xml_sub_proxy_name) ?
|
||||
message->GetExtension(ProxyState::xml_sub_proxy_name).c_str() :
|
||||
NULL));
|
||||
|
||||
if (!element)
|
||||
{
|
||||
vtkErrorMacro("Definition not found for xml_group: "
|
||||
<< message->GetExtension(ProxyState::xml_group).c_str()
|
||||
<< " and xml_name: "
|
||||
<< message->GetExtension(ProxyState::xml_name).c_str()
|
||||
<< endl << message->DebugString().c_str() << endl );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and setup the VTK object, if needed before parsing the property
|
||||
// helpers. This is needed so that the property helpers can push their default
|
||||
// values as they are reading the xml-attributes.
|
||||
const char* className = element->GetAttribute("class");
|
||||
if (className && className[0])
|
||||
{
|
||||
this->SetVTKClassName(className);
|
||||
vtkObjectBase* obj = this->Interpreter->NewInstance(className);
|
||||
if (!obj)
|
||||
{
|
||||
vtkErrorMacro("Failed to create " << className
|
||||
<< ". Aborting for debugging purposes.");
|
||||
abort();
|
||||
}
|
||||
this->VTKObject.TakeReference(obj);
|
||||
}
|
||||
|
||||
if (this->VTKClassName && this->VTKClassName[0] != '\0')
|
||||
{
|
||||
vtkClientServerStream substream;
|
||||
substream << vtkClientServerStream::Invoke
|
||||
<< vtkClientServerID(1)
|
||||
<< "GetActiveProgressHandler"
|
||||
<< vtkClientServerStream::End;
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< substream
|
||||
<< "RegisterProgressEvent"
|
||||
<< this->VTKObject
|
||||
<< static_cast<int>(this->GetGlobalID())
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
this->SetXMLGroup(message->GetExtension(ProxyState::xml_group).c_str());
|
||||
this->SetXMLName(message->GetExtension(ProxyState::xml_name).c_str());
|
||||
|
||||
// Locate sub-proxies.
|
||||
for (int cc=0; cc < message->ExtensionSize(ProxyState::subproxy); cc++)
|
||||
{
|
||||
const ProxyState_SubProxy& subproxyMsg =
|
||||
message->GetExtension(ProxyState::subproxy, cc);
|
||||
vtkSIProxy* subproxy = vtkSIProxy::SafeDownCast(
|
||||
this->GetSIObject(subproxyMsg.global_id()));
|
||||
this->Internals->SubProxyInfoVector.push_back(
|
||||
SubProxyInfo(subproxyMsg.name(), subproxyMsg.global_id()));
|
||||
if (subproxy == NULL)
|
||||
{
|
||||
// This code has been commented to support ImplicitPlaneWidgetRepresentation
|
||||
// which as a widget as SubProxy which stay on the client side.
|
||||
// Therefore, when ParaView is running on Client/Server mode, that SubProxy
|
||||
// does NOT exist on the Server side. This case should not fail the current
|
||||
// proxy creation.
|
||||
|
||||
// vtkErrorMacro("Failed to locate subproxy with global-id: "
|
||||
// << subproxyMsg.global_id() << endl
|
||||
// << message->DebugString().c_str());
|
||||
// return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->Internals->SubSIProxies[subproxyMsg.name()] = subproxy;
|
||||
}
|
||||
}
|
||||
|
||||
// Add hook for post_push and post_creation. This is processed before
|
||||
// ReadXMLAttributes() is even called.
|
||||
this->SetPostPush(element->GetAttribute("post_push"));
|
||||
this->SetPostCreation(element->GetAttribute("post_creation"));
|
||||
|
||||
// Allow subclasses to do some initialization if needed. Note this is called
|
||||
// before properties are created.
|
||||
this->OnCreateVTKObjects();
|
||||
|
||||
// Execute post-creation if any
|
||||
if(this->PostCreation != NULL)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< this->PostCreation
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
// Process the XML and update properties etc.
|
||||
if (!this->ReadXMLAttributes(element))
|
||||
{
|
||||
this->DeleteVTKObjects();
|
||||
return false;
|
||||
}
|
||||
|
||||
this->ObjectsCreated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::DeleteVTKObjects()
|
||||
{
|
||||
this->VTKObject = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::OnCreateVTKObjects()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkObjectBase* vtkSIProxy::GetVTKObject()
|
||||
{
|
||||
return this->VTKObject.GetPointer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxy::ReadXMLAttributes(vtkPVXMLElement* element)
|
||||
{
|
||||
for(unsigned int i=0; i < element->GetNumberOfNestedElements(); ++i)
|
||||
{
|
||||
vtkPVXMLElement* propElement = element->GetNestedElement(i);
|
||||
|
||||
if (strcmp(propElement->GetName(), "SubProxy") == 0)
|
||||
{
|
||||
// read subproxy xml.
|
||||
if (!this->ReadXMLSubProxy(propElement))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process sub-proxy commands.
|
||||
for (vtkInternals::SubProxyCommandMapType::iterator iter=this->Internals->SubProxyCommands.begin();
|
||||
iter != this->Internals->SubProxyCommands.end(); ++iter)
|
||||
{
|
||||
if (vtkSIProxy* subProxy = this->GetSubSIProxy(iter->first.c_str()))
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< iter->second.c_str()
|
||||
<< subProxy->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i < element->GetNumberOfNestedElements(); ++i)
|
||||
{
|
||||
vtkPVXMLElement* propElement = element->GetNestedElement(i);
|
||||
// read property xml
|
||||
const char* name = propElement->GetAttribute("name");
|
||||
std::string tagName = propElement->GetName();
|
||||
if (name && tagName.find("Property") == (tagName.size()-8))
|
||||
{
|
||||
if (!this->ReadXMLProperty(propElement))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxy::ReadXMLSubProxy(vtkPVXMLElement* subproxyElement)
|
||||
{
|
||||
// Process "command" for the sub proxy, if any. These are used in
|
||||
// CreateVTKObjects() to pass the sub proxy's VTK object to this proxy's VTK
|
||||
// object.
|
||||
const char* command = subproxyElement? subproxyElement->GetAttribute("command") : NULL;
|
||||
if (command)
|
||||
{
|
||||
vtkPVXMLElement* proxyElement = subproxyElement->GetNestedElement(0);
|
||||
const char* name = proxyElement? proxyElement->GetAttribute("name") : NULL;
|
||||
if (name)
|
||||
{
|
||||
this->Internals->SubProxyCommands[name] = command;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxy::ReadXMLProperty(vtkPVXMLElement* propElement)
|
||||
{
|
||||
// Since the XML is "cleaned" out, we are assured that there are no duplicate
|
||||
// properties.
|
||||
std::string name = propElement->GetAttributeOrEmpty("name");
|
||||
assert(!name.empty() && this->GetSIProperty(name.c_str()) == NULL);
|
||||
|
||||
// Patch XML to remove InformationHelper and set right si_class
|
||||
vtkSIProxyDefinitionManager::PatchXMLProperty(propElement);
|
||||
|
||||
vtkSmartPointer<vtkObject> object;
|
||||
std::string classname;
|
||||
if (propElement->GetAttribute("si_class"))
|
||||
{
|
||||
classname = propElement->GetAttribute("si_class");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream cname;
|
||||
cname << "vtkSI" << propElement->GetName() << ends;
|
||||
classname = cname.str();
|
||||
}
|
||||
|
||||
object.TakeReference(vtkPVInstantiator::CreateInstance(classname.c_str()));
|
||||
if (!object)
|
||||
{
|
||||
vtkErrorMacro("Failed to create helper for property: " << classname);
|
||||
return false;
|
||||
}
|
||||
vtkSIProperty* property = vtkSIProperty::SafeDownCast(object);
|
||||
if (!property)
|
||||
{
|
||||
vtkErrorMacro(<< classname << " must be a vtkSIProperty subclass.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!property->ReadXMLAttributes(this, propElement))
|
||||
{
|
||||
vtkErrorMacro("Could not parse property: " << name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
this->AddSIProperty(name.c_str(), property);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxy* vtkSIProxy::GetSubSIProxy(const char* name)
|
||||
{
|
||||
return this->Internals->SubSIProxies[name];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
unsigned int vtkSIProxy::GetNumberOfSubSIProxys()
|
||||
{
|
||||
return static_cast<unsigned int>(this->Internals->SubSIProxies.size());
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxy* vtkSIProxy::GetSubSIProxy(unsigned int cc)
|
||||
{
|
||||
if (cc >= this->GetNumberOfSubSIProxys())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int index=0;
|
||||
vtkInternals::SubSIProxiesMapType::iterator iter;
|
||||
for (iter = this->Internals->SubSIProxies.begin();
|
||||
iter != this->Internals->SubSIProxies.end();
|
||||
++iter, ++index)
|
||||
{
|
||||
if (index == cc)
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::AddInput(
|
||||
int inputPort, vtkAlgorithmOutput* connection, const char* method)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< method;
|
||||
if (inputPort > 0)
|
||||
{
|
||||
stream << inputPort;
|
||||
}
|
||||
stream << connection << vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::CleanInputs(const char* method)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< method
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxy::AboutToDelete()
|
||||
{
|
||||
// Remove all proxy/input property that still old other SIProxy reference...
|
||||
this->Internals->ClearDependencies();
|
||||
}
|
||||
@ -0,0 +1,171 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIProxy
|
||||
// .SECTION Description
|
||||
// vtkSIProxy is the server-implementation for a vtkSMProxy that helps the
|
||||
// vtkSMProxy with managing/updating VTK objects.
|
||||
|
||||
#ifndef vtkSIProxy_h
|
||||
#define vtkSIProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIObject.h"
|
||||
#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
|
||||
|
||||
class vtkAlgorithmOutput;
|
||||
class vtkSIProperty;
|
||||
class vtkPVXMLElement;
|
||||
class vtkSIProxyDefinitionManager;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIProxy : public vtkSIObject
|
||||
{
|
||||
public:
|
||||
static vtkSIProxy* New();
|
||||
vtkTypeMacro(vtkSIProxy, vtkSIObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// This method is called before the deletion of the SIObject.
|
||||
// Basically this is used to remove all dependency with other SIObject so after
|
||||
// a first pass on all SIObject with a AboutToDelete() we can simply delete the
|
||||
// remaining SIObjects.
|
||||
virtual void AboutToDelete();
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
virtual void Push(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual void Pull(vtkSMMessage* msg);
|
||||
//ETX
|
||||
|
||||
// Description:
|
||||
// Returns access to the VTKObject pointer, if any.
|
||||
// Note this is a raw pointer to the local instance of the VTK object. Any
|
||||
// changes you make directly using this object pointer will not be reflected
|
||||
// on other processes.
|
||||
vtkObjectBase* GetVTKObject();
|
||||
void SetVTKObject(vtkObjectBase*);
|
||||
|
||||
// Description:
|
||||
// Provides access to the property helper.
|
||||
vtkSIProperty* GetSIProperty(const char* name);
|
||||
|
||||
// Description:
|
||||
// Returns the VTKClassName.
|
||||
vtkGetStringMacro(VTKClassName);
|
||||
|
||||
// Description:
|
||||
// Assigned by the XML parser. The name assigned in the XML
|
||||
// configuration. Can be used to figure out the origin of the
|
||||
// proxy.
|
||||
vtkGetStringMacro(XMLName);
|
||||
|
||||
// Description:
|
||||
// Assigned by the XML parser. The group in the XML configuration that
|
||||
// this proxy belongs to. Can be used to figure out the origin of the
|
||||
// proxy.
|
||||
vtkGetStringMacro(XMLGroup);
|
||||
|
||||
// Description:
|
||||
// Return true if that Proxy is supposed to have NO vtk class, which means
|
||||
// its a NullProxy.
|
||||
bool IsNullProxy() { return (VTKClassName == NULL); };
|
||||
|
||||
// Description:
|
||||
// These methods are called to add/remove input connections by
|
||||
// vtkSIInputProperty. This indirection makes it possible for subclasses to
|
||||
// insert VTK-algorithms in the input pipeline.
|
||||
virtual void AddInput(int input_port,
|
||||
vtkAlgorithmOutput* connection, const char* method);
|
||||
virtual void CleanInputs(const char* method);
|
||||
|
||||
// Description:
|
||||
// Triggers UpdateInformation() on vtkObject if possible.
|
||||
// Default implementation does pretty much nothing.
|
||||
virtual void UpdatePipelineInformation() { }
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIProxy();
|
||||
~vtkSIProxy();
|
||||
|
||||
// Description:
|
||||
// Returns the subproxy helper for the subproxy with the given name, if any.
|
||||
vtkSIProxy* GetSubSIProxy(const char* name);
|
||||
|
||||
// Description:
|
||||
// API to iterate over subproxy helpers.
|
||||
unsigned int GetNumberOfSubSIProxys();
|
||||
vtkSIProxy* GetSubSIProxy(unsigned int cc);
|
||||
|
||||
// Description:
|
||||
// Provides access to the vtkSIProxyDefinitionManager held by the session.
|
||||
vtkSIProxyDefinitionManager* GetProxyDefinitionManager();
|
||||
|
||||
// Description:
|
||||
// Creates the VTK objects. This also parses the xml definition for proxy to
|
||||
// create property-handlers.
|
||||
// Returns true if object are (or have been) created successfully.
|
||||
// \c message is used to obtain information about what proxy helper this is if
|
||||
// the objects need to be created.
|
||||
virtual bool CreateVTKObjects(vtkSMMessage* message);
|
||||
void DeleteVTKObjects();
|
||||
|
||||
// Description;
|
||||
// Called in CreateVTKObjects() after the vtk-object has been created and
|
||||
// subproxy-information has been processed, but before the XML is parsed to
|
||||
// generate properties and initialize their values.
|
||||
virtual void OnCreateVTKObjects();
|
||||
|
||||
// Description:
|
||||
// Parses the XML to create property/subproxy helpers.
|
||||
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
|
||||
virtual bool ReadXMLProperty(vtkPVXMLElement* property_element);
|
||||
virtual bool ReadXMLSubProxy(vtkPVXMLElement* subproxy_element);
|
||||
|
||||
// Description:
|
||||
// Adds a vtkSMProperty's server-implementation.
|
||||
void AddSIProperty(const char* name, vtkSIProperty*);
|
||||
|
||||
vtkSetStringMacro(VTKClassName);
|
||||
vtkSetStringMacro(XMLGroup);
|
||||
vtkSetStringMacro(XMLName);
|
||||
vtkSetStringMacro(XMLSubProxyName);
|
||||
vtkSetStringMacro(PostPush);
|
||||
vtkSetStringMacro(PostCreation);
|
||||
|
||||
char* VTKClassName;
|
||||
char* XMLGroup;
|
||||
char* XMLName;
|
||||
char* XMLSubProxyName;
|
||||
char* PostPush;
|
||||
char* PostCreation;
|
||||
|
||||
vtkSmartPointer<vtkObjectBase> VTKObject;
|
||||
bool ObjectsCreated;
|
||||
|
||||
private:
|
||||
vtkSIProxy(const vtkSIProxy&); // Not implemented
|
||||
void operator=(const vtkSIProxy&); // Not implemented
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,297 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProxyDefinitionManager.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIProxyDefinitionManager - object responsible for managing XML
|
||||
// proxies definitions
|
||||
// .SECTION Description
|
||||
// vtkSIProxyDefinitionManager is a class that manages XML proxies definition.
|
||||
// It maintains a map of vtkPVXMLElement (populated by the XML parser) from
|
||||
// which it can extract Hint, Documentation, Properties, Domains definition.
|
||||
//
|
||||
// This class fires the following events:
|
||||
// \li \c vtkSIProxyDefinitionManager::ProxyDefinitionsUpdated - Fired any time
|
||||
// any definitions are updated. If a group of definitions are being updated (i.e.
|
||||
// a new definition is registered, or unregistred, or modified)
|
||||
// then this event gets fired after all of them are updated.
|
||||
// \li \c vtkSIProxyDefinitionManager::CompoundProxyDefinitionsUpdated - Fired
|
||||
// when a custom proxy definition is updated. Similar to
|
||||
// ProxyDefinitionsUpdated this is fired after collective updates, if
|
||||
// applicable. Note whenever CompoundProxyDefinitionsUpdated is fired,
|
||||
// ProxyDefinitionsUpdated is also fired.
|
||||
// \li \c vtkCommand::RegisterEvent - Fired when a new proxy definition is
|
||||
// registered or an old one modified (through extensions). This is fired for
|
||||
// regular proxies as well as custom proxy definitions.
|
||||
// \li \c vtkCommand::UnRegisterEvent - Fired when a proxy definition is
|
||||
// removed. Since this class only support removing custom proxies, this event is
|
||||
// fired only when a custom proxy is removed.
|
||||
|
||||
#ifndef vtkSIProxyDefinitionManager_h
|
||||
#define vtkSIProxyDefinitionManager_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIObject.h"
|
||||
|
||||
class vtkPVPlugin;
|
||||
class vtkPVProxyDefinitionIterator;
|
||||
class vtkPVXMLElement;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIProxyDefinitionManager : public vtkSIObject
|
||||
{
|
||||
public:
|
||||
static vtkSIProxyDefinitionManager* New();
|
||||
vtkTypeMacro(vtkSIProxyDefinitionManager, vtkSIObject);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Returns the ID reserved for the proxy definition manager.
|
||||
static vtkTypeUInt32 GetReservedGlobalID();
|
||||
|
||||
// Description:
|
||||
// For now we dynamically convert InformationHelper
|
||||
// into the correct si_class and attribute sets.
|
||||
// THIS CODE SHOULD BE REMOVED once InformationHelper have been removed
|
||||
// from legacy XML
|
||||
static void PatchXMLProperty(vtkPVXMLElement* propElement);
|
||||
|
||||
// Description:
|
||||
// Returns a registered proxy definition or return a NULL otherwise.
|
||||
// Moreover, error can be throw if the definition was not found if the
|
||||
// flag throwError is true.
|
||||
vtkPVXMLElement* GetProxyDefinition( const char* group, const char* name,
|
||||
bool throwError );
|
||||
vtkPVXMLElement* GetProxyDefinition(const char* group, const char* name)
|
||||
{
|
||||
// We do throw an error by default
|
||||
return this->GetProxyDefinition(group, name, true);
|
||||
}
|
||||
|
||||
// Description:
|
||||
// Return true if the XML Definition was found
|
||||
bool HasDefinition( const char* groupName, const char* proxyName );
|
||||
|
||||
// Description:
|
||||
// Returns the same thing as GetProxyDefinition in a flatten manner.
|
||||
// By flatten, we mean that the class hierarchy has been walked and merged
|
||||
// into a single vtkPVXMLElement definition.
|
||||
vtkPVXMLElement* GetCollapsedProxyDefinition(const char* group,
|
||||
const char* name,
|
||||
const char* subProxyName,
|
||||
bool throwError);
|
||||
vtkPVXMLElement* GetCollapsedProxyDefinition(const char* group,
|
||||
const char* name,
|
||||
const char* subProxyName)
|
||||
{
|
||||
return this->GetCollapsedProxyDefinition(group, name, subProxyName, true);
|
||||
}
|
||||
|
||||
// Description:
|
||||
// Add a custom proxy definition. Custom definitions are NOT ALLOWED to
|
||||
// overrive or overlap any ProxyDefinition that has been defined by parsing
|
||||
// server manager proxy configuration files.
|
||||
// This can be a compound proxy definition (look at
|
||||
// vtkSMCompoundSourceProxy.h) or a regular proxy definition.
|
||||
// For all practical purposes, there's no difference between a proxy
|
||||
// definition added using this method or by parsing a server manager
|
||||
// configuration file.
|
||||
void AddCustomProxyDefinition( const char* group, const char* name,
|
||||
vtkPVXMLElement* top );
|
||||
void AddCustomProxyDefinition(
|
||||
const char* groupName, const char* proxyName, const char* xmlcontents);
|
||||
|
||||
// Description:
|
||||
// Given its name, remove a custom proxy definition.
|
||||
// Note that this can only be used to remove definitions added using
|
||||
// AddCustomProxyDefinition(), cannot be used to remove definitions
|
||||
// loaded using vtkSMXMLParser.
|
||||
void RemoveCustomProxyDefinition(const char* group, const char* name);
|
||||
|
||||
// Description:
|
||||
// Remove all registered custom proxy definitions.
|
||||
// Note that this can only be used to remove definitions added using
|
||||
// AddCustomProxyDefinition(), cannot be used to remove definitions
|
||||
// loaded using vtkSMXMLParser.
|
||||
void ClearCustomProxyDefinitions();
|
||||
|
||||
// Description:
|
||||
// Load custom proxy definitions and register them.
|
||||
void LoadCustomProxyDefinitions(vtkPVXMLElement* root);
|
||||
void LoadCustomProxyDefinitionsFromString(const char* xmlContent);
|
||||
|
||||
// Description:
|
||||
// Save registered custom proxy definitions. The caller must release the
|
||||
// reference to the returned vtkPVXMLElement.
|
||||
void SaveCustomProxyDefinitions(vtkPVXMLElement* root);
|
||||
|
||||
// Description:
|
||||
// Loads server-manager configuration xml.
|
||||
bool LoadConfigurationXML(vtkPVXMLElement* root);
|
||||
bool LoadConfigurationXMLFromString(const char* xmlContent);
|
||||
|
||||
enum Events
|
||||
{
|
||||
ProxyDefinitionsUpdated=2000,
|
||||
CompoundProxyDefinitionsUpdated=2001
|
||||
};
|
||||
|
||||
// Description
|
||||
// Return a new configured iterator for traversing a set of proxy definition
|
||||
// for all the available groups.
|
||||
// Scope values:
|
||||
// 0 : ALL (default in case)
|
||||
// 1 : CORE_DEFINITIONS
|
||||
// 2 : CUSTOM_DEFINITIONS
|
||||
|
||||
enum
|
||||
{
|
||||
ALL_DEFINITIONS = 0,
|
||||
CORE_DEFINITIONS = 1,
|
||||
CUSTOM_DEFINITIONS = 2
|
||||
};
|
||||
|
||||
// Description:
|
||||
// Return a NEW instance of vtkPVProxyDefinitionIterator configured to
|
||||
// get through all the definition available for the requested scope.
|
||||
// Possible scope defined as enum inside vtkSIProxyDefinitionManager:
|
||||
// ALL_DEFINITIONS=0 / CORE_DEFINITIONS=1 / CUSTOM_DEFINITIONS=2
|
||||
// Some extra restriction can be set directly on the iterator itself
|
||||
// by setting a set of GroupName...
|
||||
vtkPVProxyDefinitionIterator* NewIterator( int scope=ALL_DEFINITIONS );
|
||||
|
||||
// Description
|
||||
// Return a new configured iterator for traversing a set of proxy definition
|
||||
// for only one GroupName.
|
||||
// Possible scope defined as enum inside vtkSIProxyDefinitionManager:
|
||||
// ALL_DEFINITIONS=0 / CORE_DEFINITIONS=1 / CUSTOM_DEFINITIONS=2
|
||||
vtkPVProxyDefinitionIterator* NewSingleGroupIterator(const char* groupName,
|
||||
int scope=ALL_DEFINITIONS);
|
||||
|
||||
// Description:
|
||||
// Desactivate the modification of the ProxyDefinitions for that given
|
||||
// vtkSIProxyDefinitionManager to make sure update only come from the
|
||||
// remote server and not plugin loaded on the client.
|
||||
void EnableXMLProxyDefnitionUpdate(bool);
|
||||
|
||||
//BTX
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
// The provided implementation just store the message
|
||||
// and return it at the Pull one.
|
||||
virtual void Push(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
// The provided implementation update the given message with the one
|
||||
// that has been previously pushed
|
||||
virtual void Pull(vtkSMMessage* msg);
|
||||
|
||||
// Description:
|
||||
// Information object used in Event notification
|
||||
struct RegisteredDefinitionInformation
|
||||
{
|
||||
const char* GroupName;
|
||||
const char* ProxyName;
|
||||
bool CustomDefinition;
|
||||
RegisteredDefinitionInformation(const char* groupName,
|
||||
const char* proxyName,
|
||||
bool isCustom=false)
|
||||
{
|
||||
this->GroupName = groupName;
|
||||
this->ProxyName = proxyName;
|
||||
this->CustomDefinition = isCustom;
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
vtkSIProxyDefinitionManager();
|
||||
~vtkSIProxyDefinitionManager();
|
||||
|
||||
// Description:
|
||||
// Helper method that add a ShowInMenu Hint for a proxy definition.
|
||||
// This allow that given proxy to show up inside the Sources/Filters menu
|
||||
// inside the UI.
|
||||
void AttachShowInMenuHintsToProxy(vtkPVXMLElement* proxy);
|
||||
|
||||
// Description:
|
||||
// Helper method that add a ShowInMenu Hint for any proxy definition that lie
|
||||
// in a sources or filters group.
|
||||
// @See method AttachShowInMenuHintsToProxy
|
||||
void AttachShowInMenuHintsToProxyFromProxyGroups(vtkPVXMLElement* root);
|
||||
|
||||
// Description:
|
||||
// Loads server-manager configuration xml. Those method are protected
|
||||
// as they allow to automatically add some extra hints for those loaded
|
||||
// definition set. This is essentially used when proxy get loaded as
|
||||
// legacy proxy don't have those expected Hints.
|
||||
// FIXME: Once those pluging get updated, this extra hint attachement
|
||||
// might be removed.
|
||||
bool LoadConfigurationXML(vtkPVXMLElement* root, bool attachShowInMenuHints);
|
||||
bool LoadConfigurationXMLFromString(const char* xmlContent, bool attachShowInMenuHints);
|
||||
|
||||
// Description:
|
||||
// Callback called when a plugin is loaded.
|
||||
void OnPluginLoaded(vtkObject* caller, unsigned long event, void* calldata);
|
||||
void HandlePlugin(vtkPVPlugin*);
|
||||
|
||||
// Description:
|
||||
// Called by the XML parser to add an element from which a proxy
|
||||
// can be created. Called during parsing.
|
||||
void AddElement(const char* groupName,
|
||||
const char* proxyName, vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Implementation for add custom proxy definition.
|
||||
bool AddCustomProxyDefinitionInternal(
|
||||
const char* group, const char* name, vtkPVXMLElement* top );
|
||||
|
||||
// Description
|
||||
// Integrate a ProxyDefinition into another ProxyDefinition by merging them.
|
||||
// If properties are overriden is the last property that will last. So when we build
|
||||
// a merged definition hierarchy, we should start from the root and go down.
|
||||
void MergeProxyDefinition(vtkPVXMLElement* element, vtkPVXMLElement* elementToFill);
|
||||
|
||||
// Description:
|
||||
// Method used to clear the Flatten version of the definition. This will
|
||||
// force its recomputation when needed. This should be called each time
|
||||
// new definition get added. (Not the Custom one since those should NOT
|
||||
// conflict with the core definitions.)
|
||||
void InvalidateCollapsedDefinition();
|
||||
|
||||
// Description:
|
||||
// Given the proxy name and group name, returns the XML element for
|
||||
// the proxy.
|
||||
vtkPVXMLElement* GetProxyElement(const char* groupName,
|
||||
const char* proxyName);
|
||||
|
||||
// Description:
|
||||
// Convenient method used to extract sub-proxy definition inside a proxy
|
||||
// definition. If (subProxyName == NULL) return proxyDefinition;
|
||||
vtkPVXMLElement* ExtractSubProxy(vtkPVXMLElement* proxyDefinition,
|
||||
const char* subProxyName);
|
||||
|
||||
|
||||
// Description:
|
||||
// Called when custom definitions are updated. Fires appropriate events.
|
||||
void InvokeCustomDefitionsUpdated();
|
||||
|
||||
private:
|
||||
vtkSIProxyDefinitionManager(const vtkSIProxyDefinitionManager&); // Not implemented
|
||||
void operator=(const vtkSIProxyDefinitionManager&); // Not implemented
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
vtkInternals* InternalsFlatten;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,258 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProxyProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIProxyProperty.h"
|
||||
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSIObject.h"
|
||||
#include "vtkSIProxy.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
|
||||
//****************************************************************************/
|
||||
// Internal Classes and typedefs
|
||||
//****************************************************************************/
|
||||
class vtkSIProxyProperty::InternalCache : public std::set<vtkTypeUInt32>
|
||||
{
|
||||
};
|
||||
|
||||
class vtkSIProxyProperty::vtkObjectCache :
|
||||
public std::map<vtkTypeUInt32, vtkSmartPointer<vtkObjectBase> > {};
|
||||
|
||||
//****************************************************************************/
|
||||
vtkStandardNewMacro(vtkSIProxyProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxyProperty::vtkSIProxyProperty()
|
||||
{
|
||||
this->Cache = new InternalCache();
|
||||
this->ObjectCache = new vtkObjectCache();
|
||||
|
||||
this->CleanCommand = NULL;
|
||||
this->RemoveCommand = NULL;
|
||||
this->ArgumentType = vtkSIProxyProperty::VTK;
|
||||
this->NullOnEmpty = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIProxyProperty::~vtkSIProxyProperty()
|
||||
{
|
||||
this->SetCleanCommand(NULL);
|
||||
this->SetRemoveCommand(NULL);
|
||||
delete this->Cache;
|
||||
delete this->ObjectCache;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxyProperty::ReadXMLAttributes(
|
||||
vtkSIProxy* proxyhelper, vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(proxyhelper, element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this->SetCleanCommand(element->GetAttribute("clean_command"));
|
||||
|
||||
this->SetRemoveCommand(element->GetAttribute("remove_command"));
|
||||
|
||||
// Allow to choose the kind of object to pass as argument based on
|
||||
// its global id.
|
||||
const char* arg_type = element->GetAttribute("argument_type");
|
||||
if(arg_type != NULL && arg_type[0] != 0)
|
||||
{
|
||||
if(strcmp(arg_type, "VTK") == 0)
|
||||
{
|
||||
this->ArgumentType = VTK;
|
||||
}
|
||||
else if(strcmp(arg_type, "SMProxy") == 0)
|
||||
{
|
||||
this->ArgumentType = SMProxy;
|
||||
}
|
||||
else if(strcmp(arg_type, "SIProxy") == 0)
|
||||
{
|
||||
this->ArgumentType = SIProxy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not set, DEFAULT value
|
||||
this->ArgumentType = VTK;
|
||||
}
|
||||
|
||||
int null_on_empty;
|
||||
if (element->GetScalarAttribute("null_on_empty", &null_on_empty))
|
||||
{
|
||||
this->SetNullOnEmpty(null_on_empty != 0);
|
||||
}
|
||||
|
||||
if (this->InformationOnly)
|
||||
{
|
||||
vtkErrorMacro("InformationOnly proxy properties are not supported!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxyProperty::Push(vtkSMMessage* message, int offset)
|
||||
{
|
||||
assert(message->ExtensionSize(ProxyState::property) > offset);
|
||||
const ProxyState_Property *prop = &message->GetExtension(ProxyState::property,
|
||||
offset);
|
||||
assert(strcmp(prop->name().c_str(), this->GetXMLName()) == 0);
|
||||
|
||||
std::set<vtkTypeUInt32> new_value;
|
||||
for (int cc=0; cc < prop->value().proxy_global_id_size(); cc++)
|
||||
{
|
||||
new_value.insert( prop->value().proxy_global_id(cc) );
|
||||
}
|
||||
|
||||
std::set<vtkTypeUInt32> to_add = new_value;
|
||||
|
||||
vtkClientServerStream stream;
|
||||
vtkObjectBase* object = this->GetVTKObject();
|
||||
|
||||
// Deal with previous values to remove
|
||||
if (this->CleanCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< this->CleanCommand
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ObjectCache->clear();
|
||||
}
|
||||
else if(this->RemoveCommand)
|
||||
{
|
||||
std::set<vtkTypeUInt32> to_remove;
|
||||
std::set_difference(this->Cache->begin(), this->Cache->end(),
|
||||
new_value.begin(), new_value.end(),
|
||||
std::inserter(to_remove, to_remove.begin()));
|
||||
|
||||
for (std::set<vtkTypeUInt32>::iterator iter = to_remove.begin();
|
||||
iter != to_remove.end(); ++iter)
|
||||
{
|
||||
vtkObjectBase* arg = this->GetObjectBase(*iter);
|
||||
if (arg == NULL)
|
||||
{
|
||||
arg = (*this->ObjectCache)[*iter].GetPointer();
|
||||
}
|
||||
if(arg != NULL)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< this->GetRemoveCommand()
|
||||
<< arg
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ObjectCache->erase(*iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkWarningMacro("Failed to locate vtkObjectBase for id : " << *iter);
|
||||
}
|
||||
}
|
||||
|
||||
to_add.clear();
|
||||
std::set_difference(new_value.begin(), new_value.end(),
|
||||
this->Cache->begin(), this->Cache->end(),
|
||||
std::inserter(to_add, to_add.begin()));
|
||||
}
|
||||
|
||||
// Deal with proxy to add
|
||||
for (std::set<vtkTypeUInt32>::iterator iter = to_add.begin();
|
||||
iter != to_add.end(); ++iter)
|
||||
{
|
||||
vtkObjectBase* arg = this->GetObjectBase(*iter);
|
||||
if(arg != NULL || this->IsValidNull(*iter))
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< this->GetCommand()
|
||||
<< arg
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
// we keep an object cache so that even if the object gets unregistered
|
||||
// before the property is pushed, we have a reference to it.
|
||||
(*this->ObjectCache)[*iter] = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkWarningMacro("Try to ADD a Proxy to a ProxyProperty but the proxy was not found");
|
||||
}
|
||||
}
|
||||
|
||||
// Take care of the Empty case
|
||||
if (this->NullOnEmpty && this->CleanCommand == NULL && new_value.size() == 0)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< this->GetCommand()
|
||||
<< vtkClientServerID(0)
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ObjectCache->clear();
|
||||
}
|
||||
|
||||
this->Cache->clear();
|
||||
std::copy(new_value.begin(), new_value.end(),
|
||||
std::inserter(*this->Cache, this->Cache->begin()));
|
||||
|
||||
// Save to cache when pulled for collaboration
|
||||
this->SaveValueToCache(message, offset);
|
||||
|
||||
return this->ProcessMessage(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIProxyProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
vtkObjectBase* vtkSIProxyProperty::GetObjectBase(vtkTypeUInt32 globalId)
|
||||
{
|
||||
vtkSIProxy* siProxy = NULL;
|
||||
switch(this->ArgumentType)
|
||||
{
|
||||
case VTK:
|
||||
siProxy = vtkSIProxy::SafeDownCast(this->GetSIObject(globalId));
|
||||
return (siProxy == NULL) ? NULL : siProxy->GetVTKObject();
|
||||
case SMProxy:
|
||||
return this->SIProxyObject->GetRemoteObject(globalId);
|
||||
case SIProxy:
|
||||
return this->SIProxyObject->GetSIObject(globalId);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIProxyProperty::IsValidNull(vtkTypeUInt32 globalId)
|
||||
{
|
||||
if(globalId == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkSIProxy* siProxy = vtkSIProxy::SafeDownCast(this->GetSIObject(globalId));
|
||||
assert("SIProxy shouldn't be null otherwise it's a Proxy location issue in the XML" && siProxy != 0);
|
||||
return siProxy->IsNullProxy();
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIProxyProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIProxyProperty
|
||||
// .SECTION Description
|
||||
// ServerSide Property use to set Object array as method argument.
|
||||
// Those object could be either SMProxy instance or their SIProxy instance
|
||||
// or the VTK object managed by the SIProxy instance. The type of object is
|
||||
// specified inside the XML definition of the property with the attribute
|
||||
// argument_type=[VTK, SMProxy, SIProxy].
|
||||
|
||||
#ifndef vtkSIProxyProperty_h
|
||||
#define vtkSIProxyProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIProxyProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIProxyProperty* New();
|
||||
vtkTypeMacro(vtkSIProxyProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Command that can be used to remove inputs. If set, this
|
||||
// command is called before the main Command is called with
|
||||
// all the arguments.
|
||||
vtkGetStringMacro(CleanCommand);
|
||||
|
||||
// Description:
|
||||
// Remove command is the command called to remove the VTK
|
||||
// object on the server-side. If set, CleanCommand is ignored.
|
||||
// Instead for every proxy that was absent from the proxies
|
||||
// previously pushed, the RemoveCommand is invoked.
|
||||
vtkGetStringMacro(RemoveCommand);
|
||||
|
||||
// When set to true, the property will push a NULL i.e. 0 when there are no
|
||||
// proxies in the property. Not used when CleanCommand or RemoveCommand is
|
||||
// set. Default is false.
|
||||
vtkGetMacro(NullOnEmpty, bool);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIProxyProperty();
|
||||
~vtkSIProxyProperty();
|
||||
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
virtual bool Push(vtkSMMessage*, int);
|
||||
|
||||
// Description:
|
||||
// Parse the xml for the property.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper, vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Command that can be used to remove inputs. If set, this
|
||||
// command is called before the main Command is called with
|
||||
// all the arguments.
|
||||
vtkSetStringMacro(CleanCommand);
|
||||
char* CleanCommand;
|
||||
|
||||
// Description:
|
||||
// Remove command is the command called to remove the VTK
|
||||
// object on the server-side. If set, CleanCommand is ignored.
|
||||
// Instead for every proxy that was absent from the proxies
|
||||
// previously pushed, the RemoveCommand is invoked.
|
||||
vtkSetStringMacro(RemoveCommand);
|
||||
char* RemoveCommand;
|
||||
|
||||
// When set to true, the property will push a NULL i.e. 0 when there are no
|
||||
// proxies in the property. Not used when CleanCommand or RemoveCommand is
|
||||
// set. Default is false.
|
||||
vtkSetMacro(NullOnEmpty, bool);
|
||||
bool NullOnEmpty;
|
||||
|
||||
|
||||
enum TypeArg {
|
||||
VTK, SMProxy, SIProxy
|
||||
};
|
||||
|
||||
// Proxy type: VTK (default), SMProxy, Kernel,
|
||||
// In the XML we expect argument_type="VTK" (default value if not set)
|
||||
// argument_type="SMProxy"
|
||||
// argument_type="SIProxy"
|
||||
TypeArg ArgumentType;
|
||||
|
||||
// Base on the ArgumentType will return either the VTK object or the SMProxy object
|
||||
vtkObjectBase* GetObjectBase(vtkTypeUInt32 globalId);
|
||||
|
||||
// Allow to detect if a null argument is really meant to be null
|
||||
bool IsValidNull(vtkTypeUInt32 globalId);
|
||||
|
||||
private:
|
||||
vtkSIProxyProperty(const vtkSIProxyProperty&); // Not implemented
|
||||
void operator=(const vtkSIProxyProperty&); // Not implemented
|
||||
class InternalCache;
|
||||
InternalCache *Cache;
|
||||
|
||||
class vtkObjectCache;
|
||||
vtkObjectCache* ObjectCache;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,218 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSISILProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSISILProperty.h"
|
||||
|
||||
#include "vtkAdjacentVertexIterator.h"
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkDataArray.h"
|
||||
#include "vtkDataSetAttributes.h"
|
||||
#include "vtkExecutive.h"
|
||||
#include "vtkGraph.h"
|
||||
#include "vtkInEdgeIterator.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkOutEdgeIterator.h"
|
||||
#include "vtkSIProxy.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStdString.h"
|
||||
#include "vtkStringArray.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
class vtkSISILProperty::vtkIdTypeSet : public std::set<vtkIdType> {};
|
||||
|
||||
vtkStandardNewMacro(vtkSISILProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSISILProperty::vtkSISILProperty()
|
||||
{
|
||||
this->SubTree = 0;
|
||||
this->OutputPort = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSISILProperty::~vtkSISILProperty()
|
||||
{
|
||||
this->SetSubTree(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISILProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSISILProperty::ReadXMLAttributes( vtkSIProxy* proxyhelper,
|
||||
vtkPVXMLElement* element)
|
||||
{
|
||||
bool retValue = this->Superclass::ReadXMLAttributes(proxyhelper, element);
|
||||
|
||||
// Parse extra attribute
|
||||
this->SetSubTree(element->GetAttribute("subtree")); // if none => set NULL
|
||||
if(!this->SubTree)
|
||||
{
|
||||
std::ostringstream proxyDefinition;
|
||||
element->PrintXML(proxyDefinition, vtkIndent(3));
|
||||
vtkWarningMacro("No subtree attribute has been set in the following XML: "
|
||||
<< proxyDefinition.str().c_str() );
|
||||
}
|
||||
|
||||
// If error we reset it to 0
|
||||
if(!element->GetScalarAttribute("output_port", &this->OutputPort))
|
||||
{
|
||||
this->OutputPort = 0;
|
||||
}
|
||||
return retValue;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSISILProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build SIL vtkGraph object
|
||||
vtkAlgorithm *reader = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
if(!reader)
|
||||
{
|
||||
vtkWarningMacro("Could not get the reader.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we should use the executive or a method to retreive the SIL
|
||||
vtkSmartPointer<vtkGraph> graphSIL;
|
||||
if(this->GetCommand())
|
||||
{
|
||||
// Use method call
|
||||
vtkClientServerStream css;
|
||||
css << vtkClientServerStream::Invoke
|
||||
<< reader
|
||||
<< this->GetCommand()
|
||||
<< vtkClientServerStream::End;
|
||||
if(this->ProcessMessage(css))
|
||||
{
|
||||
vtkObjectBase* graphResult;
|
||||
this->GetLastResult().GetArgumentObject(0,0,&graphResult,"vtkGraph");
|
||||
graphSIL = vtkGraph::SafeDownCast(graphResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkWarningMacro("No SIL infornation on the reader.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use executive
|
||||
vtkInformation* info =
|
||||
reader->GetExecutive()->GetOutputInformation(this->OutputPort);
|
||||
if (!info || !info->Has(vtkDataObject::SIL()))
|
||||
{
|
||||
vtkWarningMacro("No SIL infornation on the reader.");
|
||||
return false;
|
||||
}
|
||||
graphSIL = vtkGraph::SafeDownCast(info->Get(vtkDataObject::SIL()));
|
||||
}
|
||||
|
||||
|
||||
// Build the meta-data
|
||||
vtkIdType numVertices = graphSIL->GetNumberOfVertices();
|
||||
std::map<std::string, vtkIdType> vertexNameMap;
|
||||
vtkStringArray* names =
|
||||
vtkStringArray::SafeDownCast(
|
||||
graphSIL->GetVertexData()->GetAbstractArray("Names"));
|
||||
for (vtkIdType kk=0; kk < numVertices; kk++)
|
||||
{
|
||||
vertexNameMap[names->GetValue(kk)] = kk;
|
||||
}
|
||||
|
||||
// Search for specific subtree if any
|
||||
vtkIdType subTreeVertexId = 0;
|
||||
if(this->SubTree)
|
||||
{
|
||||
std::map<std::string, vtkIdType>::iterator iter;
|
||||
iter = vertexNameMap.find(this->SubTree);
|
||||
if (iter != vertexNameMap.end())
|
||||
{
|
||||
subTreeVertexId = iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkWarningMacro("Failed to locate requested subtree");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the leaves
|
||||
vtkIdTypeSet leaves;
|
||||
vtkSISILProperty::GetLeaves(graphSIL.GetPointer(), subTreeVertexId, leaves, false);
|
||||
|
||||
// Build property
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *var = prop->mutable_value();
|
||||
var->set_type(Variant::STRING);
|
||||
|
||||
// Fill property
|
||||
vtkIdTypeSet::iterator iter;
|
||||
for (iter = leaves.begin(); iter != leaves.end(); ++iter)
|
||||
{
|
||||
if((*iter) >= 0 && (*iter) < numVertices)
|
||||
{
|
||||
var->add_txt(names->GetValue(*iter));
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkErrorMacro("Invalid index: " << *iter);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISILProperty::GetLeaves( vtkGraph *sil, vtkIdType vertexid,
|
||||
vtkIdTypeSet& list,
|
||||
bool traverse_cross_edges)
|
||||
{
|
||||
vtkDataArray* crossEdgesArray =
|
||||
vtkDataArray::SafeDownCast(
|
||||
sil->GetEdgeData()->GetAbstractArray("CrossEdges"));
|
||||
|
||||
bool has_child_edge = false;
|
||||
vtkOutEdgeIterator* iter = vtkOutEdgeIterator::New();
|
||||
sil->GetOutEdges(vertexid, iter);
|
||||
while (iter->HasNext())
|
||||
{
|
||||
vtkOutEdgeType edge = iter->Next();
|
||||
if (traverse_cross_edges || crossEdgesArray->GetTuple1(edge.Id) == 0)
|
||||
{
|
||||
has_child_edge = true;
|
||||
vtkSISILProperty::GetLeaves(sil, edge.Target, list, traverse_cross_edges);
|
||||
}
|
||||
}
|
||||
iter->Delete();
|
||||
|
||||
if (!has_child_edge)
|
||||
{
|
||||
list.insert(vertexid);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSISILProperty
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSISILProperty
|
||||
// .SECTION Description
|
||||
// SIProperty that deals with SIL data extraction to get the property value
|
||||
|
||||
#ifndef vtkSISILProperty_h
|
||||
#define vtkSISILProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class vtkGraph;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSISILProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSISILProperty* New();
|
||||
vtkTypeMacro(vtkSISILProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSISILProperty();
|
||||
~vtkSISILProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Parse the xml for the property and specially the "subtree" extra attribute
|
||||
// and the "output_port" if this one is different than the default one which
|
||||
// is 0.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper, vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
vtkSetStringMacro(SubTree);
|
||||
|
||||
class vtkIdTypeSet;
|
||||
static void GetLeaves( vtkGraph *sil, vtkIdType vertexid,
|
||||
vtkIdTypeSet& list,
|
||||
bool traverse_cross_edges);
|
||||
|
||||
private:
|
||||
vtkSISILProperty(const vtkSISILProperty&); // Not implemented
|
||||
void operator=(const vtkSISILProperty&); // Not implemented
|
||||
|
||||
char* SubTree;
|
||||
int OutputPort;
|
||||
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,338 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSISourceProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSISourceProxy.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkAlgorithmOutput.h"
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkCommand.h"
|
||||
#include "vtkCompositeDataPipeline.h"
|
||||
#include "vtkCompositeDataSet.h"
|
||||
//#include "vtkGeometryRepresentation.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkProcessModule.h"
|
||||
#include "vtkPVInstantiator.h"
|
||||
#include "vtkPVPostFilter.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
#include "vtkTimerLog.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//*****************************************************************************
|
||||
class vtkSISourceProxy::vtkInternals
|
||||
{
|
||||
public:
|
||||
std::vector<vtkSmartPointer<vtkAlgorithmOutput> > OutputPorts;
|
||||
std::vector<vtkSmartPointer<vtkAlgorithm> > ExtractPieces;
|
||||
std::vector<vtkSmartPointer<vtkPVPostFilter> > PostFilters;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
vtkStandardNewMacro(vtkSISourceProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSISourceProxy::vtkSISourceProxy()
|
||||
{
|
||||
this->ExecutiveName = 0;
|
||||
this->SetExecutiveName("vtkPVCompositeDataPipeline");
|
||||
this->Internals = new vtkInternals();
|
||||
this->PortsCreated = false;
|
||||
this->DisablePipelineExecution = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSISourceProxy::~vtkSISourceProxy()
|
||||
{
|
||||
this->SetExecutiveName(0);
|
||||
delete this->Internals;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkAlgorithmOutput* vtkSISourceProxy::GetOutputPort(int port)
|
||||
{
|
||||
this->CreateOutputPorts();
|
||||
if (static_cast<int>(this->Internals->OutputPorts.size()) > port)
|
||||
{
|
||||
return this->Internals->OutputPorts[port];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSISourceProxy::CreateVTKObjects(vtkSMMessage* message)
|
||||
{
|
||||
if (this->ObjectsCreated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this->Superclass::CreateVTKObjects(message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vtkAlgorithm* algorithm = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
if (algorithm == NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this->ExecutiveName &&
|
||||
!this->GetVTKObject()->IsA("vtkPVDataRepresentation"))
|
||||
{
|
||||
if(!algorithm->GetExecutive()->IsA(this->ExecutiveName))
|
||||
{
|
||||
vtkExecutive* executive = vtkExecutive::SafeDownCast(
|
||||
vtkPVInstantiator::CreateInstance(this->ExecutiveName));
|
||||
if (executive)
|
||||
{
|
||||
algorithm->SetExecutive(executive);
|
||||
executive->FastDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register observer to record the execution time for each algorithm in the
|
||||
// local timer-log.
|
||||
algorithm->AddObserver(
|
||||
vtkCommand::StartEvent, this, &vtkSISourceProxy::MarkStartEvent);
|
||||
algorithm->AddObserver(
|
||||
vtkCommand::EndEvent, this, &vtkSISourceProxy::MarkEndEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSISourceProxy::CreateOutputPorts()
|
||||
{
|
||||
if (this->PortsCreated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
this->PortsCreated = true;
|
||||
vtkAlgorithm* algo = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
if (!algo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int ports = algo->GetNumberOfOutputPorts();
|
||||
this->Internals->OutputPorts.resize(ports);
|
||||
this->Internals->ExtractPieces.resize(ports);
|
||||
this->Internals->PostFilters.resize(ports);
|
||||
|
||||
for (int cc=0; cc < ports; cc++)
|
||||
{
|
||||
if (!this->InitializeOutputPort(algo, cc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSISourceProxy::InitializeOutputPort(vtkAlgorithm* algo, int port)
|
||||
{
|
||||
// Save the output port in internal data-structure.
|
||||
this->Internals->OutputPorts[port] = algo->GetOutputPort(port);
|
||||
|
||||
if (strcmp("vtkPVCompositeDataPipeline", this->ExecutiveName) == 0)
|
||||
{
|
||||
//add the post filters to the source proxy
|
||||
//so that we can do automatic conversion of properties.
|
||||
this->InsertPostFilterIfNecessary(algo, port);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::InsertPostFilterIfNecessary(vtkAlgorithm*, int port)
|
||||
{
|
||||
vtkPVPostFilter* postFilter = vtkPVPostFilter::New();
|
||||
this->Internals->PostFilters[port] = postFilter;
|
||||
postFilter->FastDelete();
|
||||
|
||||
postFilter->SetInputConnection(this->Internals->OutputPorts[port]);
|
||||
|
||||
// Now substitute port to point to the post-filter.
|
||||
this->Internals->OutputPorts[port] = postFilter->GetOutputPort(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSISourceProxy::ReadXMLAttributes(vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* executiveName = element->GetAttribute("executive");
|
||||
if (executiveName)
|
||||
{
|
||||
this->SetExecutiveName(executiveName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// FIXME: avoid code-duplication with vtkGeometryRepresentation. However I
|
||||
// cannot add dependecy on vtkGeometryRepresentation here. Fix it!!!
|
||||
namespace
|
||||
{
|
||||
bool vtkGeometryRepresentationDoRequestGhostCells(vtkInformation* info)
|
||||
{
|
||||
vtkMultiProcessController* controller =
|
||||
vtkMultiProcessController::GetGlobalController();
|
||||
if (controller == NULL || controller->GetNumberOfProcesses() <= 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vtkUnstructuredGrid::GetData(info) != NULL ||
|
||||
vtkCompositeDataSet::GetData(info) != NULL)
|
||||
{
|
||||
// ensure that there's no WholeExtent to ensure
|
||||
// that this UG was never born out of a structured dataset.
|
||||
bool has_whole_extent = (info->Has(
|
||||
vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()) != 0);
|
||||
if (!has_whole_extent)
|
||||
{
|
||||
//cout << "Need ghosts" << endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::UpdatePipeline(int port, double time, bool doTime)
|
||||
{
|
||||
if(this->DisablePipelineExecution)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int processid =
|
||||
vtkMultiProcessController::GetGlobalController()->GetLocalProcessId();
|
||||
int numprocs =
|
||||
vtkMultiProcessController::GetGlobalController()->GetNumberOfProcesses();
|
||||
|
||||
// This will create the output ports if needed.
|
||||
vtkAlgorithmOutput* output_port = this->GetOutputPort(port);
|
||||
if (!output_port)
|
||||
{
|
||||
return;
|
||||
}
|
||||
vtkAlgorithm* algo = output_port->GetProducer();
|
||||
assert(algo);
|
||||
|
||||
|
||||
vtkStreamingDemandDrivenPipeline* sddp =
|
||||
vtkStreamingDemandDrivenPipeline::SafeDownCast(
|
||||
algo->GetExecutive());
|
||||
|
||||
sddp->UpdateInformation();
|
||||
sddp->UpdateDataObject();
|
||||
|
||||
int real_port = output_port->GetIndex();
|
||||
|
||||
// Refer to BUG #11811 and BUG #12546. vtkGeometryRepresentation needs
|
||||
// ghost-cells if available (11811), but not asking for ghost-cells earlier than the
|
||||
// representation results in multiple executes (12546). Hence, we request
|
||||
// ghost-cells in UpdatePipeline().
|
||||
bool req_ghost_cells = vtkGeometryRepresentationDoRequestGhostCells(
|
||||
sddp->GetOutputInformation(real_port));
|
||||
|
||||
sddp->SetUpdateExtent(real_port, processid, numprocs, /*ghost level*/
|
||||
req_ghost_cells?1 : 0);
|
||||
if (doTime)
|
||||
{
|
||||
sddp->SetUpdateTimeStep(real_port, time);
|
||||
}
|
||||
sddp->Update(real_port);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::UpdatePipelineInformation()
|
||||
{
|
||||
if(this->DisablePipelineExecution)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->GetVTKObject())
|
||||
{
|
||||
vtkAlgorithm* algo = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
if(algo)
|
||||
{
|
||||
algo->UpdateInformation();
|
||||
}
|
||||
}
|
||||
|
||||
// Call UpdatePipelineInformation() on all subproxies.
|
||||
for (unsigned int cc=0; cc < this->GetNumberOfSubSIProxys(); cc++)
|
||||
{
|
||||
vtkSISourceProxy* src = vtkSISourceProxy::SafeDownCast(this->GetSubSIProxy(cc));
|
||||
if (src)
|
||||
{
|
||||
src->UpdatePipelineInformation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::SetupSelectionProxy(int port, vtkSIProxy* extractSelection)
|
||||
{
|
||||
vtkAlgorithm* algo = vtkAlgorithm::SafeDownCast(
|
||||
extractSelection->GetVTKObject());
|
||||
algo->SetInputConnection(this->GetOutputPort(port));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::MarkStartEvent()
|
||||
{
|
||||
std::ostringstream filterName;
|
||||
filterName
|
||||
<< "Execute "
|
||||
<< (this->GetVTKClassName()? this->GetVTKClassName() : this->GetClassName())
|
||||
<< " id: " << this->GetGlobalID();
|
||||
vtkTimerLog::MarkStartEvent(filterName.str().c_str());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::MarkEndEvent()
|
||||
{
|
||||
std::ostringstream filterName;
|
||||
filterName
|
||||
<< "Execute "
|
||||
<< (this->GetVTKClassName()? this->GetVTKClassName() : this->GetClassName())
|
||||
<< " id: " << this->GetGlobalID();
|
||||
vtkTimerLog::MarkEndEvent(filterName.str().c_str());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSISourceProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSISourceProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSISourceProxy
|
||||
// .SECTION Description
|
||||
// vtkSISourceProxy is the server-side helper for a vtkSMSourceProxy.
|
||||
// It adds support to handle various vtkAlgorithm specific Invoke requests
|
||||
// coming from the client. vtkSISourceProxy also inserts post-processing filters
|
||||
// for each output port from the vtkAlgorithm. These post-processing filters
|
||||
// deal with things like parallelizing the data etc.
|
||||
|
||||
#ifndef vtkSISourceProxy_h
|
||||
#define vtkSISourceProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProxy.h"
|
||||
|
||||
class vtkAlgorithm;
|
||||
class vtkAlgorithmOutput;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSISourceProxy : public vtkSIProxy
|
||||
{
|
||||
public:
|
||||
static vtkSISourceProxy* New();
|
||||
vtkTypeMacro(vtkSISourceProxy, vtkSIProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// Returns the vtkAlgorithmOutput for an output port, if valid.
|
||||
virtual vtkAlgorithmOutput* GetOutputPort(int port);
|
||||
|
||||
// Description:
|
||||
// Triggers UpdateInformation() on vtkObject if possible.
|
||||
virtual void UpdatePipelineInformation();
|
||||
|
||||
// Description:
|
||||
// Triggers UpdatePipeline().
|
||||
// Called from client.
|
||||
virtual void UpdatePipeline(int port, double time, bool doTime);
|
||||
|
||||
// Description:
|
||||
// setups extract selection proxies.
|
||||
virtual void SetupSelectionProxy(int port, vtkSIProxy* extractSelection);
|
||||
|
||||
// Description:
|
||||
// Allow to shut down pipeline execution. This is particulary useful for
|
||||
// a Catalyst session that does not contains any real data.
|
||||
virtual void SetDisablePipelineExecution(bool value)
|
||||
{ this->DisablePipelineExecution = value; }
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSISourceProxy();
|
||||
~vtkSISourceProxy();
|
||||
|
||||
// Description:
|
||||
// Creates the VTKObjects. Overridden to add post-filters to the pipeline.
|
||||
virtual bool CreateVTKObjects(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Read xml-attributes.
|
||||
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Create the output ports and add post filters for each output port.
|
||||
// CreateOutputPorts is only called when an output-port is requested, i.e.
|
||||
// GetOutputPort() is called.
|
||||
virtual bool CreateOutputPorts();
|
||||
|
||||
// Description:
|
||||
// Called to initialize a single output port. This assigns each output port an
|
||||
// interpreter id and then initializes the translator/extract pieces/post
|
||||
// filters.
|
||||
virtual bool InitializeOutputPort(vtkAlgorithm* alo, int port);
|
||||
|
||||
// Description:
|
||||
// Insert a filter to create the Post Filter
|
||||
// so that filters can request data conversions
|
||||
void InsertPostFilterIfNecessary(vtkAlgorithm* algo, int port);
|
||||
|
||||
// Description:
|
||||
// Callbacks to add start/end events to the timer log.
|
||||
void MarkStartEvent();
|
||||
void MarkEndEvent();
|
||||
|
||||
char *ExecutiveName;
|
||||
vtkSetStringMacro(ExecutiveName);
|
||||
bool DisablePipelineExecution;
|
||||
|
||||
friend class vtkSICompoundSourceProxy;
|
||||
private:
|
||||
vtkSISourceProxy(const vtkSISourceProxy&); // Not implemented
|
||||
void operator=(const vtkSISourceProxy&); // Not implemented
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
bool PortsCreated;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,285 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIStringVectorProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIStringVectorProperty.h"
|
||||
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
class vtkSIStringVectorProperty::vtkVectorOfStrings :
|
||||
public std::vector <std::string> {};
|
||||
class vtkSIStringVectorProperty::vtkVectorOfInts :
|
||||
public std::vector<int> {};
|
||||
|
||||
vtkStandardNewMacro(vtkSIStringVectorProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIStringVectorProperty::vtkSIStringVectorProperty()
|
||||
{
|
||||
this->ElementTypes = new vtkVectorOfInts();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIStringVectorProperty::~vtkSIStringVectorProperty()
|
||||
{
|
||||
delete this->ElementTypes;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool vtkSIStringVectorProperty::Push(vtkSMMessage* message, int offset)
|
||||
{
|
||||
assert(message->ExtensionSize(ProxyState::property) > offset);
|
||||
|
||||
const ProxyState_Property *prop = &message->GetExtension(ProxyState::property,
|
||||
offset);
|
||||
assert(strcmp(prop->name().c_str(), this->GetXMLName()) == 0);
|
||||
|
||||
// Save to cache when pulled for collaboration
|
||||
this->SaveValueToCache(message, offset);
|
||||
|
||||
const Variant *variant = &prop->value();
|
||||
int num_elems = variant->txt_size();
|
||||
vtkVectorOfStrings values;
|
||||
values.resize(num_elems);
|
||||
for (int cc=0; cc < num_elems; cc++)
|
||||
{
|
||||
values[cc] = variant->txt(cc).c_str();
|
||||
}
|
||||
return this->Push(values);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool vtkSIStringVectorProperty::Pull(vtkSMMessage* message)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return this->Superclass::Pull(message);
|
||||
}
|
||||
|
||||
if (!this->GetCommand())
|
||||
{
|
||||
// I would say that we should return false since an InformationOnly property
|
||||
// as no meaning if no command is set, but for some legacy reason we just
|
||||
// skip the processing if no command is provided.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invoke property's method on the root node of the server
|
||||
vtkClientServerStream str;
|
||||
str << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << this->GetCommand()
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ProcessMessage(str);
|
||||
|
||||
// Get the result
|
||||
const vtkClientServerStream& res = this->GetLastResult();
|
||||
|
||||
int numMsgs = res.GetNumberOfMessages();
|
||||
if (numMsgs < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int numArgs = res.GetNumberOfArguments(0);
|
||||
if (numArgs < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// now add the single 'value' to the message.
|
||||
ProxyState_Property *prop = message->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant* var = prop->mutable_value();
|
||||
var->set_type(Variant_Type_STRING);
|
||||
|
||||
const char* arg = NULL;
|
||||
int retVal = res.GetArgument(0, 0, &arg);
|
||||
var->add_txt(arg ? arg : "Invalid result");
|
||||
|
||||
return (retVal != 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool vtkSIStringVectorProperty::ReadXMLAttributes(
|
||||
vtkSIProxy* proxy, vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(proxy, element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int number_of_elements = 1; // By default there must be at least one element
|
||||
int number_of_elements_per_command = 0;
|
||||
element->GetScalarAttribute("number_of_elements", &number_of_elements);
|
||||
number_of_elements_per_command = number_of_elements;
|
||||
if (this->Repeatable)
|
||||
{
|
||||
number_of_elements_per_command = this->GetNumberOfElementsPerCommand();
|
||||
}
|
||||
this->ElementTypes->resize(number_of_elements_per_command, STRING);
|
||||
|
||||
element->GetVectorAttribute("element_types",
|
||||
number_of_elements_per_command, &(*this->ElementTypes)[0]);
|
||||
vtkVectorOfStrings values;
|
||||
bool hasDefaultValues = false;
|
||||
if (number_of_elements > 0)
|
||||
{
|
||||
values.resize(number_of_elements);
|
||||
const char* tmp = element->GetAttribute("default_values");
|
||||
const char* delimiter = element->GetAttribute("default_values_delimiter");
|
||||
hasDefaultValues = (tmp != NULL);
|
||||
if (tmp && delimiter)
|
||||
{
|
||||
std::string initVal = tmp;
|
||||
std::string delim = delimiter;
|
||||
std::string::size_type pos1 = 0;
|
||||
std::string::size_type pos2 = 0;
|
||||
for (int i=0; i<number_of_elements && pos2 != std::string::npos; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
pos1 += delim.size();
|
||||
}
|
||||
pos2 = initVal.find(delimiter, pos1);
|
||||
std::string value = (pos1 == pos2) ? "" : initVal.substr(pos1, pos2-pos1);
|
||||
values[i] = value;
|
||||
pos1 = pos2;
|
||||
}
|
||||
}
|
||||
else if(tmp)
|
||||
{
|
||||
values[0] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// We only push if a default value has been set otherwise we might trigger
|
||||
// unwanted behaviour underneath.
|
||||
if(hasDefaultValues)
|
||||
{
|
||||
return this->Push(values);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIStringVectorProperty::Push(const vtkVectorOfStrings &values)
|
||||
{
|
||||
if (this->InformationOnly || !this->Command)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkClientServerStream stream;
|
||||
vtkObjectBase* object = this->GetVTKObject();
|
||||
if (this->CleanCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->CleanCommand;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
stream << vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
if (!this->Repeatable)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->Command;
|
||||
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << InitialString;
|
||||
}
|
||||
|
||||
vtkVectorOfStrings::const_iterator iter;
|
||||
int i=0;
|
||||
for (iter = values.begin(); iter != values.end(); ++iter, ++i)
|
||||
{
|
||||
// Convert to the appropriate type and add to stream
|
||||
int type = (i < static_cast<int>(this->ElementTypes->size()))?
|
||||
(*this->ElementTypes)[i] : STRING;
|
||||
switch (type)
|
||||
{
|
||||
case INT:
|
||||
stream << atoi(values[i].c_str());
|
||||
break;
|
||||
case DOUBLE:
|
||||
stream << atof(values[i].c_str());
|
||||
break;
|
||||
case STRING:
|
||||
stream << values[i].c_str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
stream << vtkClientServerStream::End;
|
||||
}
|
||||
else
|
||||
{
|
||||
int numCommands = static_cast<int>(values.size()) / this->NumberOfElementsPerCommand;
|
||||
if (this->SetNumberCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->SetNumberCommand;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
stream << numCommands << vtkClientServerStream::End;
|
||||
}
|
||||
for (int i=0; i<numCommands; i++)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->Command;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
if (this->UseIndex)
|
||||
{
|
||||
stream << i;
|
||||
}
|
||||
for (int j=0; j<this->NumberOfElementsPerCommand; j++)
|
||||
{
|
||||
// Convert to the appropriate type and add to stream
|
||||
int type = (j < static_cast<int>(this->ElementTypes->size()))?
|
||||
(*this->ElementTypes)[j] : STRING;
|
||||
switch (type)
|
||||
{
|
||||
case INT:
|
||||
stream << atoi(values[i*this->NumberOfElementsPerCommand+j].c_str());
|
||||
break;
|
||||
case DOUBLE:
|
||||
stream << atof(values[i*this->NumberOfElementsPerCommand+j].c_str());
|
||||
break;
|
||||
case STRING:
|
||||
stream << values[i*this->NumberOfElementsPerCommand+j].c_str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
stream << vtkClientServerStream::End;
|
||||
}
|
||||
}
|
||||
|
||||
return this->ProcessMessage(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIStringVectorProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIStringVectorProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIStringVectorProperty
|
||||
// .SECTION Description
|
||||
// ServerImplementation Property to deal with String array as method arguments.
|
||||
|
||||
#ifndef vtkSIStringVectorProperty_h
|
||||
#define vtkSIStringVectorProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIVectorProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIStringVectorProperty : public vtkSIVectorProperty
|
||||
{
|
||||
public:
|
||||
static vtkSIStringVectorProperty* New();
|
||||
vtkTypeMacro(vtkSIStringVectorProperty, vtkSIVectorProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIStringVectorProperty();
|
||||
~vtkSIStringVectorProperty();
|
||||
|
||||
enum ElementTypes{ INT, DOUBLE, STRING };
|
||||
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
virtual bool Push(vtkSMMessage*, int);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
// Description:
|
||||
// Parse the xml for the property.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper, vtkPVXMLElement* element);
|
||||
|
||||
private:
|
||||
vtkSIStringVectorProperty(const vtkSIStringVectorProperty&); // Not implemented
|
||||
void operator=(const vtkSIStringVectorProperty&); // Not implemented
|
||||
|
||||
class vtkVectorOfStrings;
|
||||
class vtkVectorOfInts;
|
||||
|
||||
bool Push(const vtkVectorOfStrings &values);
|
||||
vtkVectorOfInts* ElementTypes;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,83 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSITimeLabelProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSITimeLabelProperty.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVInformationKeys.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSITimeLabelProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSITimeLabelProperty::vtkSITimeLabelProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSITimeLabelProperty::~vtkSITimeLabelProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSITimeLabelProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSITimeLabelProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get reference to the algorithm
|
||||
vtkAlgorithm *algo = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
|
||||
if(!algo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vtkInformation* outInfo = algo->GetExecutive()->GetOutputInformation(0);
|
||||
|
||||
// If no information just exit
|
||||
if (!outInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *var = prop->mutable_value();
|
||||
var->set_type(Variant::STRING);
|
||||
|
||||
// Else find out
|
||||
if (outInfo->Has(vtkPVInformationKeys::TIME_LABEL_ANNOTATION()))
|
||||
{
|
||||
const char* label =
|
||||
outInfo->Get(vtkPVInformationKeys::TIME_LABEL_ANNOTATION());
|
||||
var->add_txt(label);
|
||||
return true;
|
||||
}
|
||||
|
||||
// No value does not mean failure. So just return true
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSITimeLabelProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSITimeLabelProperty
|
||||
// .SECTION Description
|
||||
// SIProperty that deals with TimeLabel annotation on Algorithm object type
|
||||
|
||||
#ifndef vtkSITimeLabelProperty_h
|
||||
#define vtkSITimeLabelProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSITimeLabelProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSITimeLabelProperty* New();
|
||||
vtkTypeMacro(vtkSITimeLabelProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSITimeLabelProperty();
|
||||
~vtkSITimeLabelProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
private:
|
||||
vtkSITimeLabelProperty(const vtkSITimeLabelProperty&); // Not implemented
|
||||
void operator=(const vtkSITimeLabelProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,112 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSITimeRangeProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSITimeRangeProperty.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkExecutive.h"
|
||||
#include "vtkInformationDoubleVectorKey.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSITimeRangeProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSITimeRangeProperty::vtkSITimeRangeProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSITimeRangeProperty::~vtkSITimeRangeProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSITimeRangeProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSITimeRangeProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get reference to the algorithm
|
||||
vtkAlgorithm *algo = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
|
||||
if(!algo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vtkInformation* outInfo = algo->GetExecutive()->GetOutputInformation(0);
|
||||
|
||||
// If no information just exit
|
||||
if (!outInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Else find out
|
||||
if (outInfo->Has(vtkStreamingDemandDrivenPipeline::TIME_STEPS()))
|
||||
{
|
||||
const double* timeSteps =
|
||||
outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||
int len = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||
double timeRange[2];
|
||||
if (len > 0)
|
||||
{
|
||||
timeRange[0] = timeSteps[0];
|
||||
timeRange[1] = timeSteps[len-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
timeRange[0] = timeRange[1] = 0;
|
||||
}
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *var = prop->mutable_value();
|
||||
var->set_type(Variant::FLOAT64);
|
||||
var->add_float64(timeRange[0]);
|
||||
var->add_float64(timeRange[1]);
|
||||
}
|
||||
else if (outInfo->Has(vtkStreamingDemandDrivenPipeline::TIME_RANGE()))
|
||||
{
|
||||
const double *timeRange =
|
||||
outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_RANGE());
|
||||
int len = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_RANGE());
|
||||
if (len != 2)
|
||||
{
|
||||
vtkWarningMacro(<< "Filter reports inappropriate time range.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *var = prop->mutable_value();
|
||||
var->set_type(Variant::FLOAT64);
|
||||
var->add_float64(timeRange[0]);
|
||||
var->add_float64(timeRange[1]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSITimeRangeProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSITimeRangeProperty
|
||||
// .SECTION Description
|
||||
// SIProperty that deals with TimeRange on Algorithm object type
|
||||
|
||||
#ifndef vtkSITimeRangeProperty_h
|
||||
#define vtkSITimeRangeProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSITimeRangeProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSITimeRangeProperty* New();
|
||||
vtkTypeMacro(vtkSITimeRangeProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSITimeRangeProperty();
|
||||
~vtkSITimeRangeProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
private:
|
||||
vtkSITimeRangeProperty(const vtkSITimeRangeProperty&); // Not implemented
|
||||
void operator=(const vtkSITimeRangeProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,87 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSITimeStepsProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSITimeStepsProperty.h"
|
||||
|
||||
#include "vtkAlgorithm.h"
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSMMessage.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSITimeStepsProperty);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSITimeStepsProperty::vtkSITimeStepsProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSITimeStepsProperty::~vtkSITimeStepsProperty()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSITimeStepsProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSITimeStepsProperty::Pull(vtkSMMessage* msgToFill)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get reference to the algorithm
|
||||
vtkAlgorithm *algo = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
|
||||
if(!algo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vtkInformation* outInfo = algo->GetExecutive()->GetOutputInformation(0);
|
||||
|
||||
// If no information just exit
|
||||
if (!outInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create property and add it to the message
|
||||
ProxyState_Property *prop = msgToFill->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
Variant *var = prop->mutable_value();
|
||||
var->set_type(Variant::FLOAT64);
|
||||
|
||||
// Else find out
|
||||
if (outInfo->Has(vtkStreamingDemandDrivenPipeline::TIME_STEPS()))
|
||||
{
|
||||
const double* timeSteps =
|
||||
outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||
int len = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
var->add_float64(timeSteps[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// No value does not mean failure. So just return true
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSITimeStepsProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSITimeRangeProperty
|
||||
// .SECTION Description
|
||||
// SIProperty that deals with TimeRange on Algorithm object type
|
||||
|
||||
#ifndef vtkSITimeStepsProperty_h
|
||||
#define vtkSITimeStepsProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSITimeStepsProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
static vtkSITimeStepsProperty* New();
|
||||
vtkTypeMacro(vtkSITimeStepsProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSITimeStepsProperty();
|
||||
~vtkSITimeStepsProperty();
|
||||
|
||||
friend class vtkSIProxy;
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
private:
|
||||
vtkSITimeStepsProperty(const vtkSITimeStepsProperty&); // Not implemented
|
||||
void operator=(const vtkSITimeStepsProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,86 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIVectorProperty.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIVectorProperty.h"
|
||||
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIVectorProperty::vtkSIVectorProperty()
|
||||
{
|
||||
this->NumberOfElementsPerCommand = 1;
|
||||
this->UseIndex = false;
|
||||
this->CleanCommand = NULL;
|
||||
this->SetNumberCommand = NULL;
|
||||
this->InitialString = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIVectorProperty::~vtkSIVectorProperty()
|
||||
{
|
||||
this->SetCleanCommand(0);
|
||||
this->SetSetNumberCommand(0);
|
||||
this->SetInitialString(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool vtkSIVectorProperty::ReadXMLAttributes(
|
||||
vtkSIProxy* proxyhelper, vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(proxyhelper, element))
|
||||
{
|
||||
return false;;
|
||||
|
||||
}
|
||||
|
||||
const char* numCommand = element->GetAttribute("set_number_command");
|
||||
if (numCommand)
|
||||
{
|
||||
this->SetSetNumberCommand(numCommand);
|
||||
}
|
||||
|
||||
int use_index;
|
||||
if (element->GetScalarAttribute("use_index", &use_index))
|
||||
{
|
||||
this->UseIndex = (use_index != 0);
|
||||
}
|
||||
|
||||
int numElsPerCommand;
|
||||
if (element->GetScalarAttribute(
|
||||
"number_of_elements_per_command", &numElsPerCommand))
|
||||
{
|
||||
this->NumberOfElementsPerCommand = numElsPerCommand;
|
||||
}
|
||||
|
||||
const char* clean_command = element->GetAttribute("clean_command");
|
||||
if (clean_command)
|
||||
{
|
||||
this->SetCleanCommand(clean_command);
|
||||
}
|
||||
|
||||
const char* initial_string = element->GetAttribute("initial_string");
|
||||
if (initial_string)
|
||||
{
|
||||
this->SetInitialString(initial_string);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIVectorProperty::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIVectorProperty.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIVectorProperty
|
||||
// .SECTION Description
|
||||
// Abstract class for SIProperty that hold an array of values.
|
||||
// Define the array management API
|
||||
|
||||
#ifndef vtkSIVectorProperty_h
|
||||
#define vtkSIVectorProperty_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIProperty.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIVectorProperty : public vtkSIProperty
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkSIVectorProperty, vtkSIProperty);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// If RepeatCommand is true, the command is invoked multiple times,
|
||||
// each time with NumberOfElementsPerCommand values. For example, if
|
||||
// RepeatCommand is true, NumberOfElementsPerCommand is 2, the
|
||||
// command is SetFoo and the values are 1 2 3 4 5 6, the resulting
|
||||
// stream will have:
|
||||
// @verbatim
|
||||
// * Invoke obj SetFoo 1 2
|
||||
// * Invoke obj SetFoo 3 4
|
||||
// * Invoke obj SetFoo 5 6
|
||||
// @endverbatim
|
||||
vtkGetMacro(NumberOfElementsPerCommand, int);
|
||||
|
||||
// Description:
|
||||
// If UseIndex and RepeatCommand are true, the property will add
|
||||
// an index integer before each command. For example, if UseIndex and
|
||||
// RepeatCommand are true, NumberOfElementsPerCommand is 2, the
|
||||
// command is SetFoo and the values are 5 6 7 8 9 10, the resulting
|
||||
// stream will have:
|
||||
// @verbatim
|
||||
// * Invoke obj SetFoo 0 5 6
|
||||
// * Invoke obj SetFoo 1 7 8
|
||||
// * Invoke obj SetFoo 2 9 10
|
||||
// @endverbatim
|
||||
vtkGetMacro(UseIndex, bool);
|
||||
|
||||
// Description:
|
||||
// Command that can be used to remove all values.
|
||||
// Typically used when RepeatCommand = 1. If set, the clean command
|
||||
// is called before the main Command.
|
||||
vtkGetStringMacro(CleanCommand);
|
||||
|
||||
// Description:
|
||||
// If SetNumberCommand is set, it is called before Command
|
||||
// with the number of arguments as the parameter.
|
||||
vtkGetStringMacro(SetNumberCommand);
|
||||
|
||||
vtkGetStringMacro(InitialString);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIVectorProperty();
|
||||
~vtkSIVectorProperty();
|
||||
vtkSetStringMacro(CleanCommand);
|
||||
vtkSetStringMacro(SetNumberCommand);
|
||||
vtkSetStringMacro(InitialString);
|
||||
|
||||
char* SetNumberCommand;
|
||||
char* CleanCommand;
|
||||
bool UseIndex;
|
||||
int NumberOfElementsPerCommand;
|
||||
char *InitialString;
|
||||
|
||||
// Description:
|
||||
// Set the appropriate ivars from the xml element.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper,
|
||||
vtkPVXMLElement* element);
|
||||
|
||||
private:
|
||||
vtkSIVectorProperty(const vtkSIVectorProperty&); // Not implemented
|
||||
void operator=(const vtkSIVectorProperty&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,76 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: $RCSfile$
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIVectorPropertyTemplate
|
||||
// .SECTION Description
|
||||
//
|
||||
|
||||
#ifndef vtkSIVectorPropertyTemplate_h
|
||||
#define vtkSIVectorPropertyTemplate_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSIVectorProperty.h"
|
||||
|
||||
template <class T, class force_idtype=int>
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIVectorPropertyTemplate : public vtkSIVectorProperty
|
||||
{
|
||||
public:
|
||||
typedef vtkSIVectorProperty Superclass;
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// If ArgumentIsArray is true, multiple elements are passed in as
|
||||
// array arguments. For example, For example, if
|
||||
// RepeatCommand is true, NumberOfElementsPerCommand is 2, the
|
||||
// command is SetFoo and the values are 1 2 3 4 5 6, the resulting
|
||||
// stream will have:
|
||||
// @verbatim
|
||||
// * Invoke obj SetFoo array(1, 2)
|
||||
// * Invoke obj SetFoo array(3, 4)
|
||||
// * Invoke obj SetFoo array(5, 6)
|
||||
// @endverbatim
|
||||
vtkGetMacro(ArgumentIsArray, bool);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIVectorPropertyTemplate();
|
||||
~vtkSIVectorPropertyTemplate();
|
||||
|
||||
// Description:
|
||||
// Push a new state to the underneath implementation
|
||||
virtual bool Push(vtkSMMessage*, int);
|
||||
|
||||
// Description:
|
||||
// Pull the current state of the underneath implementation
|
||||
virtual bool Pull(vtkSMMessage*);
|
||||
|
||||
// Description:
|
||||
// Parse the xml for the property.
|
||||
virtual bool ReadXMLAttributes(vtkSIProxy* proxyhelper, vtkPVXMLElement* element);
|
||||
|
||||
// Description:
|
||||
// Implements the actual push.
|
||||
bool Push(T* values, int number_of_elements);
|
||||
|
||||
bool ArgumentIsArray;
|
||||
|
||||
private:
|
||||
vtkSIVectorPropertyTemplate(const vtkSIVectorPropertyTemplate&); // Not implemented
|
||||
void operator=(const vtkSIVectorPropertyTemplate&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// VTK-HeaderTest-Exclude: vtkSIVectorPropertyTemplate.h
|
||||
@ -0,0 +1,544 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: $RCSfile$
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIVectorPropertyTemplate.h"
|
||||
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSIProxy.h"
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
{
|
||||
// ********* INT *************
|
||||
vtkMaybeUnused("not used for non-int specializations")
|
||||
std::vector<int>&
|
||||
operator<< (std::vector<int>& values, const Variant& variant)
|
||||
{
|
||||
int num_elems = variant.integer_size();
|
||||
values.resize(values.size() + num_elems);
|
||||
for (int cc=0; cc < num_elems; cc++)
|
||||
{
|
||||
values[cc] = variant.integer(cc);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-int specializations")
|
||||
Variant& operator << (Variant& variant, const std::vector<int> &values)
|
||||
{
|
||||
variant.set_type(Variant::INT);
|
||||
std::vector<int>::const_iterator iter;
|
||||
for (iter = values.begin(); iter!= values.end(); ++iter)
|
||||
{
|
||||
variant.add_integer(*iter);
|
||||
}
|
||||
return variant;
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-int specializations")
|
||||
bool operator << (std::vector<int>& values, const vtkClientServerStream& stream)
|
||||
{
|
||||
size_t cur_size = values.size();
|
||||
int argType = stream.GetArgumentType(0, 0);
|
||||
|
||||
// If single value, all int types
|
||||
if (
|
||||
argType == vtkClientServerStream::int64_value ||
|
||||
argType == vtkClientServerStream::uint64_value ||
|
||||
argType == vtkClientServerStream::int32_value ||
|
||||
argType == vtkClientServerStream::int16_value ||
|
||||
argType == vtkClientServerStream::int8_value ||
|
||||
argType == vtkClientServerStream::uint32_value ||
|
||||
argType == vtkClientServerStream::uint16_value ||
|
||||
argType == vtkClientServerStream::uint8_value ||
|
||||
argType == vtkClientServerStream::bool_value)
|
||||
{
|
||||
int ires;
|
||||
int retVal = stream.GetArgument(0, 0, &ires);
|
||||
if (!retVal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
values.resize(cur_size + 1);
|
||||
values[cur_size] = ires;
|
||||
return true;
|
||||
}
|
||||
// if array, only 32 bit ints work
|
||||
else if (argType == vtkClientServerStream::int32_array)
|
||||
{
|
||||
vtkTypeUInt32 length;
|
||||
stream.GetArgumentLength(0, 0, &length);
|
||||
values.resize(cur_size + length);
|
||||
int retVal = stream.GetArgument(0, 0, &values[cur_size], length);
|
||||
if (!retVal)
|
||||
{
|
||||
values.resize(cur_size);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define copy_to_vector(type) \
|
||||
do \
|
||||
{ \
|
||||
vtkTypeUInt32 length; \
|
||||
stream.GetArgumentLength(0, 0, &length); \
|
||||
std::vector<type> tmp_vec(length); \
|
||||
int retVal = stream.GetArgument(0, 0, &tmp_vec[0], length); \
|
||||
if (!retVal) \
|
||||
{ \
|
||||
return false; \
|
||||
} \
|
||||
values.resize(cur_size + length); \
|
||||
std::copy(tmp_vec.begin(), tmp_vec.end(), &values[cur_size]); \
|
||||
return true; \
|
||||
} while (0)
|
||||
|
||||
// match the type for uint32
|
||||
else if (argType == vtkClientServerStream::uint32_array)
|
||||
{
|
||||
copy_to_vector(vtkTypeUInt32);
|
||||
}
|
||||
// if 64 bit array, squash into 32 bit
|
||||
else if (argType == vtkClientServerStream::int64_array)
|
||||
{
|
||||
copy_to_vector(vtkTypeInt64);
|
||||
}
|
||||
else if (argType == vtkClientServerStream::uint64_array)
|
||||
{
|
||||
copy_to_vector(vtkTypeUInt64);
|
||||
}
|
||||
|
||||
#undef copy_to_vector
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ********* DOUBLE *************
|
||||
vtkMaybeUnused("not used for non-double specializations")
|
||||
std::vector<double>&
|
||||
operator<< (std::vector<double>& values, const Variant& variant)
|
||||
{
|
||||
int num_elems = variant.float64_size();
|
||||
values.resize(values.size() + num_elems);
|
||||
for (int cc=0; cc < num_elems; cc++)
|
||||
{
|
||||
values[cc] = variant.float64(cc);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-double specializations")
|
||||
Variant& operator << (Variant& variant, const std::vector<double> &values)
|
||||
{
|
||||
variant.set_type(Variant::FLOAT64);
|
||||
std::vector<double>::const_iterator iter;
|
||||
for (iter = values.begin(); iter!= values.end(); ++iter)
|
||||
{
|
||||
variant.add_float64(*iter);
|
||||
}
|
||||
return variant;
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-double specializations")
|
||||
bool operator << (std::vector<double>& values, const vtkClientServerStream& stream)
|
||||
{
|
||||
size_t cur_size = values.size();
|
||||
int argType = stream.GetArgumentType(0, 0);
|
||||
|
||||
// If single value, both float and double works
|
||||
if (argType == vtkClientServerStream::float64_value ||
|
||||
argType == vtkClientServerStream::float32_value)
|
||||
{
|
||||
double ires;
|
||||
int retVal = stream.GetArgument(0, 0, &ires);
|
||||
if (!retVal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
values.resize(cur_size + 1);
|
||||
values[cur_size] = ires;
|
||||
}
|
||||
// If array, handle 32 bit and 64 bit separately
|
||||
else if (argType == vtkClientServerStream::float64_array)
|
||||
{
|
||||
vtkTypeUInt32 length;
|
||||
stream.GetArgumentLength(0, 0, &length);
|
||||
values.resize(cur_size + length);
|
||||
int retVal = stream.GetArgument(0, 0, &values[cur_size], length);
|
||||
if (!retVal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (argType == vtkClientServerStream::float32_array)
|
||||
{
|
||||
vtkTypeUInt32 length;
|
||||
stream.GetArgumentLength(0, 0, &length);
|
||||
float *fvalues = new float[length+1];
|
||||
int retVal = stream.GetArgument(0, 0, fvalues, length);
|
||||
if (!retVal)
|
||||
{
|
||||
delete [] fvalues;
|
||||
return false;
|
||||
}
|
||||
|
||||
values.resize(cur_size + length);
|
||||
delete [] fvalues;
|
||||
std::copy(fvalues, fvalues + length, &values[cur_size]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ********* vtkIdType *************
|
||||
vtkMaybeUnused("not used for non-vtkIdType specializations")
|
||||
void OperatorIdType(std::vector<vtkIdType>& values, const Variant& variant)
|
||||
{
|
||||
int num_elems = variant.idtype_size();
|
||||
values.resize(values.size() + num_elems);
|
||||
for (int cc=0; cc < num_elems; cc++)
|
||||
{
|
||||
values[cc] = variant.idtype(cc);
|
||||
}
|
||||
}
|
||||
vtkMaybeUnused("not used for non-vtkIdType specializations")
|
||||
void OperatorIdType(Variant& variant, const std::vector<vtkIdType> &values)
|
||||
{
|
||||
variant.set_type(Variant::IDTYPE);
|
||||
std::vector<vtkIdType>::const_iterator iter;
|
||||
for (iter = values.begin(); iter!= values.end(); ++iter)
|
||||
{
|
||||
variant.add_idtype(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-vtkIdType specializations")
|
||||
bool OperatorIdType(std::vector<vtkIdType>& values, const vtkClientServerStream& stream)
|
||||
{
|
||||
size_t cur_size = values.size();
|
||||
int argType = stream.GetArgumentType(0, 0);
|
||||
|
||||
// If single value, all int types
|
||||
if (argType == vtkClientServerStream::int32_value ||
|
||||
argType == vtkClientServerStream::int64_value)
|
||||
{
|
||||
vtkIdType ires;
|
||||
int retVal = stream.GetArgument(0, 0, &ires);
|
||||
if (!retVal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
values.resize(cur_size + 1);
|
||||
values[cur_size] = ires;
|
||||
return true;
|
||||
}
|
||||
// if array, only 32 or 64 bit ints work
|
||||
else if (argType == vtkClientServerStream::int32_array ||
|
||||
argType == vtkClientServerStream::int64_value)
|
||||
{
|
||||
vtkTypeUInt32 length;
|
||||
stream.GetArgumentLength(0, 0, &length);
|
||||
values.resize(cur_size + length);
|
||||
int retVal = stream.GetArgument(0, 0, &values[cur_size], length);
|
||||
if (!retVal)
|
||||
{
|
||||
values.resize(cur_size);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if VTK_SIZEOF_ID_TYPE != VTK_SIZEOF_INT
|
||||
vtkMaybeUnused("not used for non-vtkIdType specializations")
|
||||
std::vector<vtkIdType>&
|
||||
operator<< (std::vector<vtkIdType>& values, const Variant& variant)
|
||||
{
|
||||
OperatorIdType(values, variant);
|
||||
return values;
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-vtkIdType specializations")
|
||||
Variant& operator << (Variant& variant, const std::vector<vtkIdType> &values)
|
||||
{
|
||||
OperatorIdType(variant, values);
|
||||
return variant;
|
||||
}
|
||||
|
||||
vtkMaybeUnused("not used for non-vtkIdType specializations")
|
||||
bool operator << (std::vector<vtkIdType>& values, const vtkClientServerStream& stream)
|
||||
{
|
||||
return OperatorIdType(values, stream);
|
||||
}
|
||||
#endif
|
||||
|
||||
// This absurdity is needed for cases where vtkIdType == int.
|
||||
template <class TARG1, class TARG2, class force_idtype>
|
||||
void AppendValues(TARG1& arg1, const TARG2& arg2, const force_idtype&)
|
||||
{
|
||||
arg1 << arg2;
|
||||
}
|
||||
|
||||
template<class TARG1, class TARG2>
|
||||
void AppendValues(TARG1& arg1, const TARG2& arg2, const bool&)
|
||||
{
|
||||
OperatorIdType(arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
vtkSIVectorPropertyTemplate<T, force_idtype>::vtkSIVectorPropertyTemplate()
|
||||
{
|
||||
this->ArgumentIsArray = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
vtkSIVectorPropertyTemplate<T, force_idtype>::~vtkSIVectorPropertyTemplate()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
bool vtkSIVectorPropertyTemplate<T, force_idtype>::Push(vtkSMMessage* message, int offset)
|
||||
{
|
||||
assert(message->ExtensionSize(ProxyState::property) > offset);
|
||||
|
||||
const ProxyState_Property *prop = &message->GetExtension(ProxyState::property,
|
||||
offset);
|
||||
assert(strcmp(prop->name().c_str(), this->GetXMLName()) == 0);
|
||||
|
||||
// Save to cache when pulled for collaboration
|
||||
this->SaveValueToCache(message, offset);
|
||||
|
||||
const Variant *variant = &prop->value();
|
||||
std::vector<T> values;
|
||||
|
||||
AppendValues(values, *variant, force_idtype());
|
||||
|
||||
return (values.size() > 0) ?
|
||||
this->Push(&values[0], static_cast<int>(values.size())) :
|
||||
this->Push(static_cast<T*>(NULL), static_cast<int>(values.size()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
bool vtkSIVectorPropertyTemplate<T, force_idtype>::Pull(vtkSMMessage* message)
|
||||
{
|
||||
if (!this->InformationOnly)
|
||||
{
|
||||
return this->Superclass::Pull(message);
|
||||
}
|
||||
|
||||
if (!this->GetCommand())
|
||||
{
|
||||
// I would say that we should return false since an InformationOnly property
|
||||
// as no meaning if no command is set, but for some legacy reason we just
|
||||
// skip the processing if no command is provided.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invoke property's method on the root node of the server
|
||||
vtkClientServerStream str;
|
||||
str << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject() << this->GetCommand()
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
this->ProcessMessage(str);
|
||||
|
||||
// Get the result
|
||||
const vtkClientServerStream& res = this->GetLastResult();
|
||||
|
||||
int numMsgs = res.GetNumberOfMessages();
|
||||
if (numMsgs < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int numArgs = res.GetNumberOfArguments(0);
|
||||
if (numArgs < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<T> values;
|
||||
AppendValues(values, res, force_idtype());
|
||||
|
||||
// now add 'values' to the message.
|
||||
ProxyState_Property *prop = message->AddExtension(ProxyState::property);
|
||||
prop->set_name(this->GetXMLName());
|
||||
|
||||
AppendValues(*prop->mutable_value(), values, force_idtype());
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
bool vtkSIVectorPropertyTemplate<T, force_idtype>::Push(T* values, int number_of_elements)
|
||||
{
|
||||
if (this->InformationOnly || !this->Command)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkClientServerStream stream;
|
||||
vtkObjectBase* object = this->GetVTKObject();
|
||||
|
||||
if (this->CleanCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->CleanCommand;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
stream << vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
if (this->SetNumberCommand)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< this->SetNumberCommand;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
stream << number_of_elements / this->NumberOfElementsPerCommand
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
|
||||
if (!this->Repeatable && number_of_elements > 0)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->Command;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
if (this->ArgumentIsArray)
|
||||
{
|
||||
stream << vtkClientServerStream::InsertArray(values, number_of_elements);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<number_of_elements; i++)
|
||||
{
|
||||
stream << values[i];
|
||||
}
|
||||
}
|
||||
stream << vtkClientServerStream::End;
|
||||
}
|
||||
else if (this->Repeatable)
|
||||
{
|
||||
int numCommands = number_of_elements / this->NumberOfElementsPerCommand;
|
||||
for(int i=0; i<numCommands; i++)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke << object << this->Command;
|
||||
if (this->InitialString)
|
||||
{
|
||||
stream << this->InitialString;
|
||||
}
|
||||
if (this->UseIndex)
|
||||
{
|
||||
stream << i;
|
||||
}
|
||||
if (this->ArgumentIsArray)
|
||||
{
|
||||
stream << vtkClientServerStream::InsertArray(
|
||||
&(values[i*this->NumberOfElementsPerCommand]),
|
||||
this->NumberOfElementsPerCommand);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j=0; j<this->NumberOfElementsPerCommand; j++)
|
||||
{
|
||||
stream << values[i*this->NumberOfElementsPerCommand+j];
|
||||
}
|
||||
}
|
||||
stream << vtkClientServerStream::End;
|
||||
}
|
||||
}
|
||||
return this->ProcessMessage(stream);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
bool vtkSIVectorPropertyTemplate<T, force_idtype>::ReadXMLAttributes(
|
||||
vtkSIProxy* proxy, vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(proxy, element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int number_of_elements = 0;
|
||||
element->GetScalarAttribute("number_of_elements", &number_of_elements);
|
||||
|
||||
int arg_is_array;
|
||||
if (element->GetScalarAttribute("argument_is_array", &arg_is_array))
|
||||
{
|
||||
this->ArgumentIsArray = (arg_is_array != 0);
|
||||
}
|
||||
|
||||
if (number_of_elements > 0)
|
||||
{
|
||||
std::vector<T> values;
|
||||
values.resize(number_of_elements);
|
||||
if (element->GetAttribute("default_values") &&
|
||||
strcmp("none", element->GetAttribute("default_values")) == 0 )
|
||||
{
|
||||
// initialized to nothing.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int numRead = element->GetVectorAttribute("default_values",
|
||||
number_of_elements, &values[0]);
|
||||
if (numRead > 0)
|
||||
{
|
||||
if (numRead != number_of_elements)
|
||||
{
|
||||
vtkErrorMacro("The number of default values does not match the "
|
||||
"number of elements. Initialization failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkErrorMacro("No default value is specified for property: "
|
||||
<< this->GetXMLName()
|
||||
<< ". This might lead to stability problems");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// don't push the values if the property in "internal".
|
||||
return this->GetIsInternal() ? true :
|
||||
this->Push(&values[0], number_of_elements);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template <class T, class force_idtype>
|
||||
void vtkSIVectorPropertyTemplate<T, force_idtype>::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,218 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIWriterProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIWriterProxy.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkCompleteArrays.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkMultiProcessController.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSIInputProperty.h"
|
||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||
#include "vtkProcessModule.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSIWriterProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIWriterProxy::vtkSIWriterProxy()
|
||||
{
|
||||
this->FileNameMethod = NULL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIWriterProxy::~vtkSIWriterProxy()
|
||||
{
|
||||
this->SetFileNameMethod(NULL);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIWriterProxy::ReadXMLAttributes(vtkPVXMLElement* element)
|
||||
{
|
||||
if (!this->Superclass::ReadXMLAttributes(element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* setFileNameMethod = element->GetAttribute("file_name_method");
|
||||
if (setFileNameMethod)
|
||||
{
|
||||
this->SetFileNameMethod(setFileNameMethod);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIWriterProxy::CreateVTKObjects(vtkSMMessage* message)
|
||||
{
|
||||
if (this->ObjectsCreated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this->Superclass::CreateVTKObjects(message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vtkObjectBase* object = this->GetVTKObject();
|
||||
vtkSIProxy* writerProxy = this->GetSubSIProxy("Writer");
|
||||
if (writerProxy)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetWriter"
|
||||
<< writerProxy->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
if (this->FileNameMethod)
|
||||
{
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetFileNameMethod"
|
||||
<< this->FileNameMethod
|
||||
<< vtkClientServerStream::End;
|
||||
}
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
vtkSIProxy* helper = this->GetSubSIProxy("PreGatherHelper");
|
||||
if (helper)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetPreGatherHelper" << helper->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
helper = this->GetSubSIProxy("PostGatherHelper");
|
||||
if (helper)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetPostGatherHelper" << helper->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
// Pass piece/process information to the writer if it needs it.
|
||||
vtkProcessModule::GetProcessModule()->ReportInterpreterErrorsOff();
|
||||
vtkMultiProcessController* controller =
|
||||
vtkMultiProcessController::GetGlobalController();
|
||||
int numProcs = controller->GetNumberOfProcesses();
|
||||
int procId = controller->GetLocalProcessId();
|
||||
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetNumberOfPieces"
|
||||
<< numProcs
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
stream.Reset();
|
||||
|
||||
// ALTERNATIVE: 1
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetStartPiece"
|
||||
<< procId
|
||||
<< vtkClientServerStream::End;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetEndPiece"
|
||||
<< procId
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
stream.Reset();
|
||||
|
||||
// ALTERNATIVE: 2
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< object
|
||||
<< "SetPiece"
|
||||
<< procId
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
vtkProcessModule::GetProcessModule()->ReportInterpreterErrorsOn();
|
||||
stream.Reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIWriterProxy::AddInput(
|
||||
int input_port, vtkAlgorithmOutput* connection, const char* method)
|
||||
{
|
||||
vtkSIProxy* completeArraysSI = this->GetSubSIProxy("CompleteArrays");
|
||||
vtkCompleteArrays* completeArrays =
|
||||
completeArraysSI ?
|
||||
vtkCompleteArrays::SafeDownCast(completeArraysSI->GetVTKObject()) : NULL;
|
||||
if (completeArrays)
|
||||
{
|
||||
completeArrays->SetInputConnection(connection);
|
||||
this->Superclass::AddInput(input_port, completeArrays->GetOutputPort(),
|
||||
method);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->Superclass::AddInput(input_port, connection, method);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIWriterProxy::CleanInputs(const char* method)
|
||||
{
|
||||
vtkSIProxy* completeArraysSI = this->GetSubSIProxy("CompleteArrays");
|
||||
vtkCompleteArrays* completeArrays =
|
||||
completeArraysSI ?
|
||||
vtkCompleteArrays::SafeDownCast(completeArraysSI->GetVTKObject()) : NULL;
|
||||
if (completeArrays)
|
||||
{
|
||||
completeArrays->SetInputConnection(NULL);
|
||||
}
|
||||
this->Superclass::CleanInputs(method);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIWriterProxy::UpdatePipelineTime(double time)
|
||||
{
|
||||
vtkAlgorithm* writer = vtkAlgorithm::SafeDownCast(this->GetVTKObject());
|
||||
if(!writer)
|
||||
{
|
||||
vtkErrorMacro("Unexpected VTK object " <<
|
||||
(this->GetVTKObject() ?
|
||||
this->GetVTKObject()->GetClassName() : "(NULL"));
|
||||
return;
|
||||
}
|
||||
for(int port=0;port<writer->GetNumberOfInputPorts();port++)
|
||||
{
|
||||
for(int c=0;c<writer->GetNumberOfInputConnections(port);c++)
|
||||
{
|
||||
vtkInformation* info = writer->GetInputInformation(port, c);
|
||||
info->Set(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP(),time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIWriterProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
os << indent << "FileNameMethod: "
|
||||
<< (this->FileNameMethod ? this->FileNameMethod : "(none)") << endl;
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIWriterProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIWriterProxy
|
||||
// .SECTION Description
|
||||
// ServerImplementation for WriterProxy
|
||||
|
||||
#ifndef vtkSIWriterProxy_h
|
||||
#define vtkSIWriterProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSISourceProxy.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONCORE_EXPORT vtkSIWriterProxy : public vtkSISourceProxy
|
||||
{
|
||||
public:
|
||||
static vtkSIWriterProxy* New();
|
||||
vtkTypeMacro(vtkSIWriterProxy, vtkSISourceProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
// Description:
|
||||
// These methods are called to add/remove input connections by
|
||||
// vtkSIInputProperty. This indirection makes it possible for subclasses to
|
||||
// insert VTK-algorithms in the input pipeline.
|
||||
// Overridden to insert "CompleteArrays" filter in the pipeline.
|
||||
virtual void AddInput(int input_port,
|
||||
vtkAlgorithmOutput* connection, const char* method);
|
||||
virtual void CleanInputs(const char* method);
|
||||
|
||||
// Description:
|
||||
// Update the requested time for the pipeline. This needs to be
|
||||
// separate than vtkSISourceProxy because there are no output
|
||||
// ports to do this on.
|
||||
virtual void UpdatePipelineTime(double time);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIWriterProxy();
|
||||
~vtkSIWriterProxy();
|
||||
|
||||
// Description:
|
||||
// Creates the VTKObjects. Overridden to add post-filters to the pipeline.
|
||||
virtual bool CreateVTKObjects(vtkSMMessage* message);
|
||||
|
||||
// Description:
|
||||
// Read xml-attributes.
|
||||
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
|
||||
|
||||
char* FileNameMethod;
|
||||
vtkSetStringMacro(FileNameMethod);
|
||||
|
||||
private:
|
||||
vtkSIWriterProxy(const vtkSIWriterProxy&); // Not implemented
|
||||
void operator=(const vtkSIWriterProxy&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,20 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSMMessage.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// bring in the definition for VTK_PROTOBUF_EXPORT.
|
||||
#include "vtkPVServerImplementationCoreModule.h" //needed for exports
|
||||
#include "vtkSMMessage.h"
|
||||
|
||||
// The actual implementation is the file generated from "protoc".
|
||||
#include "vtkPVMessage.pb.cc"
|
||||
@ -0,0 +1,80 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSMMessage.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSMMessage
|
||||
// .SECTION Description
|
||||
// Header class that setup every thing in order to use Protobuf messages in
|
||||
// a transparent manner
|
||||
|
||||
#ifndef vtkSMMessage_h
|
||||
#define vtkSMMessage_h
|
||||
|
||||
#include "vtkSMMessageMinimal.h"
|
||||
|
||||
#include <string>
|
||||
#if __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#endif
|
||||
#include "vtkSystemIncludes.h"
|
||||
#include "vtk_protobuf.h"
|
||||
#include "vtkPVMessage.pb.h"
|
||||
#if __GNUC__
|
||||
# pragma GCC diagnostic warning "-Wsign-compare"
|
||||
#endif
|
||||
|
||||
#include "vtkClientServerStream.h"
|
||||
|
||||
inline vtkClientServerStream& operator << (vtkClientServerStream& stream,
|
||||
const paraview_protobuf::Variant& variant)
|
||||
{
|
||||
switch (variant.type())
|
||||
{
|
||||
case paraview_protobuf::Variant::INT:
|
||||
for (int cc=0; cc < variant.integer_size(); cc++)
|
||||
{
|
||||
stream << variant.integer(cc);
|
||||
}
|
||||
break;
|
||||
|
||||
case paraview_protobuf::Variant::FLOAT64:
|
||||
for (int cc=0; cc < variant.float64_size(); cc++)
|
||||
{
|
||||
stream << variant.float64(cc);
|
||||
}
|
||||
break;
|
||||
|
||||
case paraview_protobuf::Variant::IDTYPE:
|
||||
for (int cc=0; cc < variant.idtype_size(); cc++)
|
||||
{
|
||||
stream << variant.idtype(cc);
|
||||
}
|
||||
break;
|
||||
|
||||
case paraview_protobuf::Variant::STRING:
|
||||
for (int cc=0; cc < variant.txt_size(); cc++)
|
||||
{
|
||||
stream << variant.txt(cc).c_str();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
using namespace paraview_protobuf;
|
||||
#endif
|
||||
|
||||
// VTK-HeaderTest-Exclude: vtkSMMessage.h
|
||||
@ -0,0 +1,38 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: $RCSfile$
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// Include this header in your header files where you are referring to
|
||||
// vtkSMMessage or vtkSMMessageCollection. It simply forward declares these
|
||||
// without including any protobuf headers. In your cxx files, you need to
|
||||
// include vtkSMMessage.h to see the full definition of the protobuf message
|
||||
// classes as well as other operators.
|
||||
|
||||
#ifndef vtkSMMessageMinimal_h
|
||||
#define vtkSMMessageMinimal_h
|
||||
|
||||
#include "vtkSystemIncludes.h"
|
||||
#include "vtkPVServerImplementationCoreModule.h"
|
||||
|
||||
namespace paraview_protobuf
|
||||
{
|
||||
class Message;
|
||||
class MessageCollection;
|
||||
}
|
||||
|
||||
typedef paraview_protobuf::Message vtkSMMessage;
|
||||
typedef paraview_protobuf::MessageCollection vtkSMMessageCollection;
|
||||
|
||||
#endif
|
||||
|
||||
// VTK-HeaderTest-Exclude: vtkSMMessageMinimal.h
|
||||
@ -0,0 +1,44 @@
|
||||
#==========================================================================
|
||||
#
|
||||
# Program: ParaView
|
||||
#
|
||||
# Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# ParaView is a free software; you can redistribute it and/or modify it
|
||||
# under the terms of the ParaView license version 1.2.
|
||||
#
|
||||
# See License_v1.2.txt for the full ParaView license.
|
||||
# A copy of this license can be obtained by contacting
|
||||
# Kitware Inc.
|
||||
# 28 Corporate Drive
|
||||
# Clifton Park, NY 12065
|
||||
# USA
|
||||
#
|
||||
# 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 THE AUTHORS 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.
|
||||
#
|
||||
#==========================================================================
|
||||
set (Module_SRCS
|
||||
vtkSIImageTextureProxy.cxx
|
||||
vtkSIPVRepresentationProxy.cxx
|
||||
vtkSIUnstructuredGridVolumeRepresentationProxy.cxx
|
||||
)
|
||||
|
||||
# OpenGL2 specific definitions
|
||||
if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
|
||||
add_definitions(-DVTKGL2)
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
vtk_module_library(vtkPVServerImplementationRendering
|
||||
${Module_SRCS})
|
||||
@ -0,0 +1,11 @@
|
||||
vtk_module(vtkPVServerImplementationRendering
|
||||
GROUPS
|
||||
ParaViewRendering
|
||||
DEPENDS
|
||||
vtkPVServerImplementationCore
|
||||
vtkPVClientServerCoreRendering
|
||||
TEST_LABELS
|
||||
PARAVIEW
|
||||
KIT
|
||||
vtkPVServerImplementation
|
||||
)
|
||||
@ -0,0 +1,73 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIImageTextureProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIImageTextureProxy.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
|
||||
vtkStandardNewMacro(vtkSIImageTextureProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIImageTextureProxy::vtkSIImageTextureProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIImageTextureProxy::~vtkSIImageTextureProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIImageTextureProxy::CreateVTKObjects(vtkSMMessage* message)
|
||||
{
|
||||
if (this->ObjectsCreated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this->Superclass::CreateVTKObjects(message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do the binding between the SubProxy source to the local input
|
||||
vtkSIProxy* reader = this->GetSubSIProxy("Source");
|
||||
|
||||
if(reader)
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< reader->GetVTKObject()
|
||||
<< "GetOutputPort"
|
||||
<< vtkClientServerStream::End;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< this->GetVTKObject()
|
||||
<< "SetInputConnection"
|
||||
<< vtkClientServerStream::LastResult
|
||||
<< vtkClientServerStream::End;
|
||||
|
||||
if (!this->Interpreter->ProcessStream(stream))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIImageTextureProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIImageTextureProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIImageTextureProxy - proxy for a vtkTexture.
|
||||
// .SECTION Description
|
||||
// Combines vtkTexture and vtkNetworkImageSource. This makes it simple for
|
||||
// applications to create textures from image files where the image file is
|
||||
// present on only one process, say client, but is needed for rendering on the
|
||||
// render server and the data server.
|
||||
#ifndef vtkSIImageTextureProxy_h
|
||||
#define vtkSIImageTextureProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
|
||||
#include "vtkSISourceProxy.h"
|
||||
|
||||
class vtkImageData;
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSIImageTextureProxy : public vtkSISourceProxy
|
||||
{
|
||||
public:
|
||||
static vtkSIImageTextureProxy* New();
|
||||
vtkTypeMacro(vtkSIImageTextureProxy, vtkSISourceProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIImageTextureProxy();
|
||||
~vtkSIImageTextureProxy();
|
||||
|
||||
// Description:
|
||||
// Creates the VTKObjects. Overridden to add post-filters to the pipeline.
|
||||
virtual bool CreateVTKObjects(vtkSMMessage* message);
|
||||
|
||||
private:
|
||||
vtkSIImageTextureProxy(const vtkSIImageTextureProxy&); // Not implemented
|
||||
void operator=(const vtkSIImageTextureProxy&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,161 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIPVRepresentationProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIPVRepresentationProxy.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkCommand.h"
|
||||
#include "vtkCubeAxesRepresentation.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkPVCompositeRepresentation.h"
|
||||
#include "vtkPVXMLElement.h"
|
||||
#include "vtkSelectionRepresentation.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSISourceProxy.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
class vtkSIPVRepresentationProxy::vtkInternals
|
||||
{
|
||||
public:
|
||||
struct vtkValue
|
||||
{
|
||||
vtkSmartPointer<vtkSIProxy> SubProxy;
|
||||
std::string SubText;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, vtkValue> RepresentationProxiesType;
|
||||
RepresentationProxiesType RepresentationProxies;
|
||||
};
|
||||
|
||||
vtkStandardNewMacro(vtkSIPVRepresentationProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIPVRepresentationProxy::vtkSIPVRepresentationProxy()
|
||||
{
|
||||
this->Internals = new vtkInternals();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIPVRepresentationProxy::~vtkSIPVRepresentationProxy()
|
||||
{
|
||||
delete this->Internals;
|
||||
this->Internals = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool vtkSIPVRepresentationProxy::ReadXMLAttributes(vtkPVXMLElement* element)
|
||||
{
|
||||
vtkPVCompositeRepresentation* pvrepresentation =
|
||||
vtkPVCompositeRepresentation::SafeDownCast(this->GetVTKObject());
|
||||
|
||||
// Pass on the cube-axes and selection-represenations
|
||||
vtkCubeAxesRepresentation* cubeAxes =
|
||||
vtkCubeAxesRepresentation::SafeDownCast(
|
||||
this->GetSubSIProxy("CubeAxesRepresentation")->GetVTKObject());
|
||||
vtkSelectionRepresentation* selection =
|
||||
vtkSelectionRepresentation::SafeDownCast(
|
||||
this->GetSubSIProxy("SelectionRepresentation")->GetVTKObject());
|
||||
pvrepresentation->SetCubeAxesRepresentation(cubeAxes);
|
||||
pvrepresentation->SetSelectionRepresentation(selection);
|
||||
|
||||
// Update internal data-structures for the types of representations provided
|
||||
// by this instance.
|
||||
|
||||
// <RepresentationType subproxy="OutlineRepresentation" text="Outline"
|
||||
// subtype="0"/>
|
||||
unsigned int numElements = element->GetNumberOfNestedElements();
|
||||
for (unsigned int cc=0; cc < numElements; cc++)
|
||||
{
|
||||
vtkPVXMLElement* child = element->GetNestedElement(cc);
|
||||
if (child && child->GetName() &&
|
||||
strcmp(child->GetName(), "RepresentationType") == 0)
|
||||
{
|
||||
const char* name = child->GetAttribute("subproxy");
|
||||
vtkSIProxy* subproxy = this->GetSubSIProxy(name);
|
||||
if (!subproxy)
|
||||
{
|
||||
vtkErrorMacro("Missing data representation subproxy '"
|
||||
<< (name? name : "<null>")
|
||||
<< "' when processing RepresentationType element.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* text = child->GetAttribute("text");
|
||||
if (!text)
|
||||
{
|
||||
vtkErrorMacro(
|
||||
"Missing required 'text' attribute on RepresentationType element");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add each of the sub-representations to the composite representation.
|
||||
pvrepresentation->AddRepresentation(text,
|
||||
vtkPVDataRepresentation::SafeDownCast(subproxy->GetVTKObject()));
|
||||
|
||||
//// read optional subtype.
|
||||
const char* sub_text = child->GetAttribute("subtype");
|
||||
this->Internals->RepresentationProxies[text].SubProxy = subproxy;
|
||||
if (sub_text)
|
||||
{
|
||||
this->Internals->RepresentationProxies[text].SubText = sub_text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We add observer to the vtkCompositeRepresentation so that every time it's
|
||||
// modified, we ensure that the representation type is up-to-date.
|
||||
vtkObject::SafeDownCast(this->GetVTKObject())->AddObserver(
|
||||
vtkCommand::ModifiedEvent,
|
||||
this, &vtkSIPVRepresentationProxy::OnVTKObjectModified);
|
||||
|
||||
return this->Superclass::ReadXMLAttributes(element);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIPVRepresentationProxy::OnVTKObjectModified()
|
||||
{
|
||||
vtkCompositeRepresentation* repr = vtkCompositeRepresentation::SafeDownCast(
|
||||
this->GetVTKObject());
|
||||
const char* key = repr->GetActiveRepresentationKey();
|
||||
vtkInternals::RepresentationProxiesType::iterator iter = key?
|
||||
this->Internals->RepresentationProxies.find(key) :
|
||||
this->Internals->RepresentationProxies.end();
|
||||
if (iter != this->Internals->RepresentationProxies.end() &&
|
||||
iter->second.SubText != "")
|
||||
{
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< iter->second.SubProxy->GetVTKObject()
|
||||
<< "SetRepresentation"
|
||||
<< iter->second.SubText.c_str()
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIPVRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIPVRepresentationProxy::AboutToDelete()
|
||||
{
|
||||
this->Internals->RepresentationProxies.clear();
|
||||
this->Superclass::AboutToDelete();
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIPVRepresentationProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIPVRepresentationProxy
|
||||
// .SECTION Description
|
||||
// vtkSIPVRepresentationProxy is the helper for vtkSMPVRepresentationProxy.
|
||||
|
||||
#ifndef vtkSIPVRepresentationProxy_h
|
||||
#define vtkSIPVRepresentationProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
|
||||
#include "vtkSIProxy.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSIPVRepresentationProxy : public vtkSIProxy
|
||||
{
|
||||
public:
|
||||
static vtkSIPVRepresentationProxy* New();
|
||||
vtkTypeMacro(vtkSIPVRepresentationProxy, vtkSIProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
virtual void AboutToDelete();
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIPVRepresentationProxy();
|
||||
~vtkSIPVRepresentationProxy();
|
||||
|
||||
// Description:
|
||||
// Parses the XML to create property/subproxy helpers.
|
||||
// Overridden to parse all the "RepresentationType" elements.
|
||||
virtual bool ReadXMLAttributes(vtkPVXMLElement* element);
|
||||
|
||||
private:
|
||||
vtkSIPVRepresentationProxy(const vtkSIPVRepresentationProxy&); // Not implemented
|
||||
void operator=(const vtkSIPVRepresentationProxy&); // Not implemented
|
||||
|
||||
void OnVTKObjectModified();
|
||||
|
||||
class vtkInternals;
|
||||
vtkInternals* Internals;
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,123 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIUnstructuredGridVolumeRepresentationProxy.cxx
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "vtkSIUnstructuredGridVolumeRepresentationProxy.h"
|
||||
|
||||
#include "vtkClientServerInterpreter.h"
|
||||
#include "vtkClientServerStream.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
|
||||
|
||||
vtkStandardNewMacro(vtkSIUnstructuredGridVolumeRepresentationProxy);
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIUnstructuredGridVolumeRepresentationProxy::vtkSIUnstructuredGridVolumeRepresentationProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
vtkSIUnstructuredGridVolumeRepresentationProxy::~vtkSIUnstructuredGridVolumeRepresentationProxy()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIUnstructuredGridVolumeRepresentationProxy::OnCreateVTKObjects()
|
||||
{
|
||||
this->Superclass::OnCreateVTKObjects();
|
||||
|
||||
vtkObjectBase* self = this->GetVTKObject();
|
||||
vtkClientServerStream stream;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< self
|
||||
<< "AddVolumeMapper"
|
||||
<< "Projected tetra"
|
||||
<< this->GetSubSIProxy("VolumePTMapper")->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
#ifndef VTKGL2
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< self
|
||||
<< "AddVolumeMapper"
|
||||
<< "HAVS"
|
||||
<< this->GetSubSIProxy("VolumeHAVSMapper")->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
#endif
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< self
|
||||
<< "AddVolumeMapper"
|
||||
<< "Z sweep"
|
||||
<< this->GetSubSIProxy("VolumeZSweepMapper")->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
stream << vtkClientServerStream::Invoke
|
||||
<< self
|
||||
<< "AddVolumeMapper"
|
||||
<< "Bunyk ray cast"
|
||||
<< this->GetSubSIProxy("VolumeBunykMapper")->GetVTKObject()
|
||||
<< vtkClientServerStream::End;
|
||||
this->Interpreter->ProcessStream(stream);
|
||||
}
|
||||
|
||||
#ifdef FIXME_COLLABORATION
|
||||
// This FIXME is from view-restructuring days.
|
||||
//-----------------------------------------------------------------------------
|
||||
void vtkSIUnstructuredGridVolumeRepresentationProxy::UpdateRenderViewExtensions(
|
||||
vtkSIViewProxy* view)
|
||||
{
|
||||
#ifndef VTKGL2
|
||||
vtkSIRenderViewProxy* rvp = vtkSIRenderViewProxy::SafeDownCast(view);
|
||||
if (!rvp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
vtkPVOpenGLExtensionsInformation* glinfo =
|
||||
rvp->GetOpenGLExtensionsInformation();
|
||||
if (glinfo)
|
||||
{
|
||||
// These are extensions needed for HAVS. It would be nice
|
||||
// if these was some way of asking the HAVS mapper the extensions
|
||||
// it needs rather than hardcoding it here.
|
||||
int supports_GL_EXT_texture3D =
|
||||
glinfo->ExtensionSupported( "GL_EXT_texture3D");
|
||||
int supports_GL_EXT_framebuffer_object =
|
||||
glinfo->ExtensionSupported( "GL_EXT_framebuffer_object");
|
||||
int supports_GL_ARB_fragment_program =
|
||||
glinfo->ExtensionSupported( "GL_ARB_fragment_program" );
|
||||
int supports_GL_ARB_vertex_program =
|
||||
glinfo->ExtensionSupported( "GL_ARB_vertex_program" );
|
||||
int supports_GL_ARB_texture_float =
|
||||
glinfo->ExtensionSupported( "GL_ARB_texture_float" );
|
||||
int supports_GL_ATI_texture_float =
|
||||
glinfo->ExtensionSupported( "GL_ATI_texture_float" );
|
||||
|
||||
if ( !supports_GL_EXT_texture3D ||
|
||||
!supports_GL_EXT_framebuffer_object ||
|
||||
!supports_GL_ARB_fragment_program ||
|
||||
!supports_GL_ARB_vertex_program ||
|
||||
!(supports_GL_ARB_texture_float || supports_GL_ATI_texture_float))
|
||||
{
|
||||
this->SupportsHAVSMapper = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SupportsHAVSMapper = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
this->RenderViewExtensionsTested = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void vtkSIUnstructuredGridVolumeRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: vtkSIUnstructuredGridVolumeRepresentationProxy.h
|
||||
|
||||
Copyright (c) Kitware, Inc.
|
||||
All rights reserved.
|
||||
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notice for more information.
|
||||
|
||||
=========================================================================*/
|
||||
// .NAME vtkSIUnstructuredGridVolumeRepresentationProxy - representation that can be used to
|
||||
// show a unstructured grid volume in a render view.
|
||||
// .SECTION Description
|
||||
// vtkSIUnstructuredGridVolumeRepresentationProxy is a concrete representation that can be used
|
||||
// to render the unstructured grid volume in a vtkSIRenderViewProxy.
|
||||
|
||||
#ifndef vtkSIUnstructuredGridVolumeRepresentationProxy_h
|
||||
#define vtkSIUnstructuredGridVolumeRepresentationProxy_h
|
||||
|
||||
#include "vtkPVServerImplementationRenderingModule.h" //needed for exports
|
||||
#include "vtkSIProxy.h"
|
||||
|
||||
class VTKPVSERVERIMPLEMENTATIONRENDERING_EXPORT vtkSIUnstructuredGridVolumeRepresentationProxy : public vtkSIProxy
|
||||
{
|
||||
public:
|
||||
static vtkSIUnstructuredGridVolumeRepresentationProxy* New();
|
||||
vtkTypeMacro(vtkSIUnstructuredGridVolumeRepresentationProxy, vtkSIProxy);
|
||||
void PrintSelf(ostream& os, vtkIndent indent);
|
||||
|
||||
//BTX
|
||||
protected:
|
||||
vtkSIUnstructuredGridVolumeRepresentationProxy();
|
||||
~vtkSIUnstructuredGridVolumeRepresentationProxy();
|
||||
|
||||
// Description:
|
||||
// Register the mappers.
|
||||
virtual void OnCreateVTKObjects();
|
||||
|
||||
|
||||
private:
|
||||
vtkSIUnstructuredGridVolumeRepresentationProxy(const vtkSIUnstructuredGridVolumeRepresentationProxy&); // Not implemented
|
||||
void operator=(const vtkSIUnstructuredGridVolumeRepresentationProxy&); // Not implemented
|
||||
//ETX
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
// Do not edit.
|
||||
// Generated by CMake in directory @CMAKE_CURRENT_BINARY_DIR@
|
||||
// From @CMAKE_CURRENT_SOURCE_DIR@
|
||||
|
||||
vtkPVXMLParser* parser = vtkPVXMLParser::New();
|
||||
char* init_string;
|
||||
int parser_ret;
|
||||
(void) parser_ret;
|
||||
|
||||
@PARAVIEW_INCLUDE_MODULES_TO_SMAPPLICATION@
|
||||
|
||||
parser->Delete();
|
||||
Reference in New Issue
Block a user