VTKFIG  0.20.20181114
Easy VTK based in situ visualization
void vtkfig::internals::MainThread::CommunicatorThreadCallback ( MainThread mainthread)
staticprivate

Callback function for communicator thread if multithreading is off.

Definition at line 964 of file vtkfigMainThread-2018-01-26-2205.cxx.

965  {
967  {
968 
969  // Lock mutex
971  std::unique_lock<std::mutex> lock(mainthread->mutex);
972 
973  if (mainthread->debug_level>0)
974  cout << "s cmd: " << static_cast<int>(mainthread->cmd) << " frame: " <<mainthread->iframe<< endl;
975 
976  mainthread->communicator->SendCommand(mainthread->cmd);
978 
979  // Command dispatch
980  switch(mainthread->cmd)
981  {
982 
984  {
985 
986  }
987  break;
988 
990  {
991  auto frame=mainthread->framemap[mainthread->iframe];
992  mainthread->communicator->SendInt(frame->parameter.nvpx);
993  mainthread->communicator->SendInt(frame->parameter.nvpy);
994  frame->nvpx=frame->parameter.nvpx;
995  frame->nvpy=frame->parameter.nvpy;
996  }
997  break;
998 
1000  {
1001  auto frame=mainthread->framemap[mainthread->iframe];
1002  mainthread->communicator->SendInt(frame->parameter.active_subframe);
1003  }
1004  break;
1005 
1007  {
1008 
1009  }
1010  break;
1011 
1013  {
1014  for (auto framepair: mainthread->framemap)
1015  for (auto & figure: framepair.second->figures)
1016  {
1017  figure->SetRange();
1018  figure->ServerRTSendData(mainthread->communicator);
1019  }
1020  }
1021  break;
1022 
1024  {
1025 
1026  auto frame=mainthread->framemap[mainthread->iframe];
1027  mainthread->communicator->SendString(frame->parameter.filename);
1028  }
1029  break;
1030 
1032  {
1033  auto frame=mainthread->framemap[mainthread->iframe];
1034  mainthread->communicator->SendInt(frame->parameter.winsize_x);
1035  mainthread->communicator->SendInt(frame->parameter.winsize_y);
1036  }
1037  break;
1038 
1040  {
1041  auto frame=mainthread->framemap[mainthread->iframe];
1042  mainthread->communicator->SendInt(frame->parameter.winposition_x);
1043  mainthread->communicator->SendInt(frame->parameter.winposition_y);
1044  }
1045  break;
1046 
1048  {
1049  auto frame=mainthread->framemap[mainthread->iframe];
1050  mainthread->communicator->SendString(frame->parameter.frametitle);
1051  }
1052  break;
1053 
1054 
1056  {
1057  auto frame=mainthread->framemap[mainthread->iframe];
1058  mainthread->communicator->SendString(frame->parameter.wintitle);
1059  }
1060  break;
1061 
1062 
1064  {
1065  auto frame=mainthread->framemap[mainthread->iframe];
1066  mainthread->communicator->SendString(frame->parameter.current_figure->SubClassName());
1067  mainthread->communicator->SendInt(frame->parameter.current_figure->framepos);
1068  }
1069  break;
1070 
1072  {
1073  auto frame=mainthread->framemap[mainthread->iframe];
1074  mainthread->communicator->SendString(frame->parameter.current_figure->SubClassName());
1075  mainthread->communicator->SendInt(frame->parameter.current_figure->framepos);
1076  }
1077  break;
1078 
1079 
1081  {
1082  auto frame=mainthread->framemap[mainthread->iframe];
1083  mainthread->communicator->SendInt(frame->parameter.camlinkthisframepos);
1084  mainthread->communicator->SendInt(frame->parameter.camlinkframenum);
1085  mainthread->communicator->SendInt(frame->parameter.camlinkframepos);
1086  }
1087  break;
1088 
1090  {
1091  // for (auto & figure: frame->figures)
1092  // {
1093 
1094  // //frame->communicator->SendCommand(vtkfig::Command::FrameShow);
1095  // }
1096 
1097  }
1098  break;
1099 
1101  // Close window and terminate
1102  {
1103 
1104  if (mainthread->debug_level>0)
1105  cout << "s term" << endl;
1106  mainthread->framemap.clear();
1107  // Notify that command was exeuted
1108  mainthread->condition_variable.notify_all();
1110  return;
1111  }
1112  break;
1113 
1114  default:
1115  {
1116  cout << "s cmd: " << static_cast<int>(mainthread->cmd) << endl;
1117  throw std::runtime_error("wrong command on server");
1118  }
1119 
1120  break;
1121  }
1122 
1123  // Clear command
1125 
1126  // Notify that command was exeuted
1128  mainthread->condition_variable.notify_all();
1129  }
1130 
1131  }
vtkSmartPointer< Communicator > communicator
Communicator object for communication with cliend.
static MainThread * mainthread
"This" thread
Communicator::Command cmd
Communication command.
std::condition_variable condition_variable
Condition variable signalizing finished command.
std::mutex mutex
Mutex to organize communication.
int debug_level
Debug level for client communication.
std::map< int, Frame * > framemap
Map of all frames handeled by thread.
bool running_multithreaded
Thread state.
int iframe
Frame number as parameter during communication.