VTKFIG  0.21.20191019
Easy VTK based in situ visualization
vtkfigCommunicator.h
Go to the documentation of this file.
1 
10 #ifndef VTKFIG_COMMUNICATOR_H
11 #define VTKFIG_COMMUNICATOR_H
12 
13 #include <vtkSmartPointer.h>
14 #include <vtkSocketController.h>
15 #include <vtkServerSocket.h>
16 #include <vtkSocketCommunicator.h>
17 
18 #include "vtkfigTools.h"
19 
20 
21 namespace vtkfig
22 {
23 
24  namespace internals
25  {
26 
27 
31  class Communicator: public vtkSocketCommunicator
32  {
33 
34  public:
35  enum class Command: int
36  {
37  Dummy=-1,
38  Empty=0,
39  MainThreadShow=100,
40  MainThreadShowAndBlock,
41  MainThreadAddFrame,
42  MainThreadRemoveFrame,
43  FrameAddFigure,
44  FrameRemoveFigure,
45  FrameClear,
46  FrameSize,
47  FramePosition,
48  FrameSingleView,
49  FrameActiveSubFrame,
50  FrameActiveSubFrameCameraViewAngle,
51  FrameActiveSubFrameCameraPosition,
52  FrameActiveSubFrameCameraFocalPoint,
53  FrameDump,
54  FrameTitle,
55  StartVideo,
56  StopVideo,
57  WindowTitle,
58  FrameLinkCamera,
59  FrameLayout,
60  MainThreadTerminate,
61  String,
62  Clear,
63  Exit
64  };
65 
66 
67  static Communicator *New();
68 
69  Communicator();
70 
71  ~Communicator();
72 
73  int ServerMPConnect(const int port);
74 
75  int ClientMPConnect(const char * server, const int port);
76 
77  int SendCommand(Command cmd, int tag=static_cast<int>(Tag::Command));
78 
79  int ReceiveCommand(Command & cmd, int tag= static_cast<int>(Tag::Command));
80 
81  int SendInt(int i, int tag=static_cast<int>(Tag::Int) );
82 
83  int ReceiveInt(int &i, int tag= static_cast<int>(Tag::Int));
84 
85  int SendFloat(float d, int tag= static_cast<int>(Tag::Float));
86 
87  int ReceiveFloat(float &d, int tag= static_cast<int>(Tag::Float));
88 
89  int SendDouble(double d, int tag= static_cast<int>(Tag::Double));
90 
91  int ReceiveDouble(double &d, int tag= static_cast<int>(Tag::Double));
92 
93  int SendString(const std::string s, int tag=static_cast<int>(Tag::String) );
94 
95  int ReceiveString(std::string &s, int tag= static_cast<int>(Tag::String));
96 
97  int SendCharBuffer(char *buf, int ndata, int tag=static_cast<int>(Tag::CharBuffer) );
98 
99  int ReceiveCharBuffer(char *buf, int ndata, int tag= static_cast<int>(Tag::CharBuffer));
100 
101  int SendFloatBuffer(float *buf, int ndata, int tag=static_cast<int>(Tag::FloatBuffer) );
102 
103  int ReceiveFloatBuffer(float *buf, int ndata, int tag= static_cast<int>(Tag::FloatBuffer));
104 
105  int SendDoubleBuffer(double *buf, int ndata, int tag=static_cast<int>(Tag::DoubleBuffer) );
106 
107  int ReceiveDoubleBuffer(double *buf, int ndata, int tag= static_cast<int>(Tag::DoubleBuffer));
108 
110  void SendRGBTable(RGBTable & rgbtab);
111 
113  void ReceiveRGBTable(RGBTable & rgbtab);
114 
115 
116 
117  enum class Tag : int
118  {
119  Command=100,
120  Int,
121  Float,
122  Double,
123  String,
124  CharBuffer,
125  FloatBuffer,
126  DoubleBuffer,
127  DataSet
128  };
129 
130  static const int remoteHandle=1;
131 
132  private:
133  friend class MainThread;
134  friend class Frame;
135  friend class Client;
136 
137 
138  int server_listen_num_retry=10;
139  int server_listen_retry_timeout=100;
140  int server_listen_waiting_time=200;
141 
142  int client_connect_num_retry=10;
143  int client_connect_retry_timeout=100;
144 
145  vtkSmartPointer<vtkSocketController> controller;
146  vtkSmartPointer<vtkServerSocket> ssocket;
147 
148  };
149  }
150 }
151 
152 #endif
Derived class from vtkSocketCommunicator providing framework for server-client communication.
Definition: vtkfigCommunicator.h:31
Class to collect all data given on one grid.
Definition: vtkfigDataSet.h:37
void ReceiveRGBTable(RGBTable &rgbtab)
Receive RGB table.
Main communication thread.
Definition: vtkfigMainThread.h:31
Provide a framework wrapping window+interactor+renderers from vtk.
Definition: vtkfigFrame.h:38
Client side visualization setup.
Definition: vtkfigClient.h:29
Various helper tools and API functions not bound to classes.
void SendRGBTable(RGBTable &rgbtab)
Send RGB table to client.
std::vector< RGBPoint > RGBTable
Color table.
Definition: vtkfigTools.h:43