25    keep_attr = _keep_attr;
 
   36 int GLVisCommand::lock()
 
   39    unique_lock<mutex> scope_lock(glvis_mutex);
 
   44    my_id = num_waiting++;
 
   47       glvis_cond.wait(scope_lock);
 
   58 int GLVisCommand::signal()
 
   70 void GLVisCommand::unlock()
 
   72    command_ready = 
false;
 
   74    lock_guard<mutex> scope_lock(glvis_mutex);
 
   78       glvis_cond.notify_all();
 
   83                                      std::unique_ptr<GridFunction> _new_g)
 
   89    command = NEW_MESH_AND_SOLUTION;
 
   90    new_state.
mesh = std::move(_new_m);
 
   91    new_state.
grid_f = std::move(_new_g);
 
  105    command = SCREENSHOT;
 
  106    screenshot_filename = filename;
 
  120    command = KEY_COMMANDS;
 
  135    command = WINDOW_SIZE;
 
  151    command = WINDOW_GEOMETRY;
 
  169    command = WINDOW_TITLE;
 
  170    window_title = title;
 
  184    command = PLOT_CAPTION;
 
  185    plot_caption = caption;
 
  199    command = AXIS_LABELS;
 
  230    command = VIEW_ANGLES;
 
  231    view_ang_theta = theta;
 
  247    zoom_factor = factor;
 
  261    command = SUBDIVISIONS;
 
  277    command = VALUE_RANGE;
 
  308    command = VIEW_CENTER;
 
  325    autoscale_mode = mode;
 
  354    command = PALETTE_REPEAT;
 
  370    for (
int i = 0; i < 9; i++)
 
  388    autopause_mode = mode;
 
  408       case NEW_MESH_AND_SOLUTION:
 
  410          double mesh_range = -1.0;
 
  415             mesh_range = new_state.
grid_f->Max() + 1.0;
 
  419             if (mesh_range > 0.0)
 
  421                (*vs)->SetValueRange(-mesh_range, mesh_range);
 
  427             cout << 
"Stream: field type does not match!" << endl;
 
  431             cout << 
"Autopause ..." << endl;
 
  439          cout << 
"Command: screenshot -> " << screenshot_filename << endl;
 
  448          cout << 
"Command: keys: '" << key_commands << 
"'" << endl;
 
  457          cout << 
"Command: window_size: " << window_w << 
" x " << window_h << endl;
 
  462       case WINDOW_GEOMETRY:
 
  464          cout << 
"Command: window_geometry: " 
  465               << 
"@(" << window_x << 
"," << window_y << 
") " 
  466               << window_w << 
" x " << window_h << endl;
 
  473          cout << 
"Command: window_title: " << window_title << endl;
 
  480          cout << 
"Command: plot_caption: " << plot_caption << endl;
 
  481          ::plot_caption = plot_caption;
 
  482          (*vs)->PrepareCaption(); 
 
  489          cout << 
"Command: axis_labels: '" << axis_label_x << 
"' '" 
  490               << axis_label_y << 
"' '" << axis_label_z << 
"'" << endl;
 
  491          (*vs)->SetAxisLabels(axis_label_x.c_str(), axis_label_y.c_str(),
 
  492                               axis_label_z.c_str());
 
  499          cout << 
"Command: pause: ";
 
  506          cout << 
"Command: view: " << view_ang_theta << 
' ' << view_ang_phi
 
  508          (*vs)->SetView(view_ang_theta, view_ang_phi);
 
  515          cout << 
"Command: zoom: " << zoom_factor << endl;
 
  516          (*vs)->Zoom(zoom_factor);
 
  523          cout << 
"Command: subdivisions: " << flush;
 
  524          (*vs)->SetRefineFactors(subdiv_tot, subdiv_bdr);
 
  525          cout << subdiv_tot << 
' ' << subdiv_bdr << endl;
 
  532          cout << 
"Command: valuerange: " << flush;
 
  533          (*vs)->SetValueRange(val_min, val_max);
 
  534          cout << val_min << 
' ' << val_max << endl;
 
  541          cout << 
"Command: shading: " << flush;
 
  543          if (shading == 
"flat")
 
  547          else if (shading == 
"smooth")
 
  551          else if (shading == 
"cool")
 
  557             (*vs)->SetShading(s, 
false);
 
  558             cout << shading << endl;
 
  563             cout << shading << 
" ?" << endl;
 
  570          cout << 
"Command: viewcenter: " 
  571               << view_center_x << 
' ' << view_center_y << endl;
 
  572          (*vs)->ViewCenterX = view_center_x;
 
  573          (*vs)->ViewCenterY = view_center_y;
 
  580          cout << 
"Command: autoscale: " << autoscale_mode;
 
  581          if (autoscale_mode == 
"off")
 
  583             (*vs)->SetAutoscale(0);
 
  585          else if (autoscale_mode == 
"on")
 
  587             (*vs)->SetAutoscale(1);
 
  589          else if (autoscale_mode == 
"value")
 
  591             (*vs)->SetAutoscale(2);
 
  593          else if (autoscale_mode == 
"mesh")
 
  595             (*vs)->SetAutoscale(3);
 
  607          cout << 
"Command: palette: " << palette << endl;
 
  608          (*vs)->palette.SetIndex(palette-1);
 
  611             (*vs)->EventUpdateColors();
 
  619          cout << 
"Command: palette_repeat: " << palette_repeat << endl;
 
  620          (*vs)->palette.SetRepeatTimes(palette_repeat);
 
  621          (*vs)->palette.Init();
 
  625             (*vs)->EventUpdateColors();
 
  633          cout << 
"Command: camera: ";
 
  634          for (
int i = 0; i < 9; i++)
 
  636             cout << 
' ' << camera[i];
 
  639          (*vs)->cam.Set(camera);
 
  646          if (autopause_mode == 
"off" || autopause_mode == 
"0")
 
  654          cout << 
"Command: autopause: " << 
strings_off_on[autopause] << endl;
 
  668    command = NO_COMMAND;
 
  676       lock_guard<mutex> scope_lock(glvis_mutex);
 
  680       lock_guard<mutex> scope_lock(glvis_mutex);
 
  683          glvis_cond.notify_all();
 
  690    autopause = autopause ? 0 : 1;
 
  706       cout << 
"\nGLVisCommand::~GLVisCommand() : num_waiting = " 
  707            << num_waiting << 
'\n' << endl;
 
  720       tid = std::thread(&communication_thread::execute, 
this);
 
  728       terminate_thread = 
true;
 
  733 void communication_thread::execute()
 
  739       if (terminate_thread) { 
break; }
 
  747       if (ident == 
"mesh" || ident == 
"solution" ||
 
  754             tmp.
mesh.reset(
new Mesh(*is[0], 1, 0, fix_elem_orient));
 
  761          else if (ident == 
"solution")
 
  763             tmp.
mesh.reset(
new Mesh(*is[0], 1, 0, fix_elem_orient));
 
  768             tmp.
grid_f.reset(
new GridFunction(tmp.
mesh.get(), *is[0]));
 
  774          else if (ident == 
"parallel")
 
  776             Array<Mesh *> mesh_array;
 
  777             Array<GridFunction *> gf_array;
 
  778             int proc, nproc, np = 0;
 
  782                istream &isock = *is[np];
 
  783                isock >> nproc >> proc >> ws;
 
  785                cout << 
"connection[" << np << 
"]: parallel " << nproc << 
' ' 
  788                isock >> ident >> ws; 
 
  789                mesh_array.SetSize(nproc);
 
  790                gf_array.SetSize(nproc);
 
  791                mesh_array[proc] = 
new Mesh(isock, 1, 0, fix_elem_orient);
 
  795                   for (
int i = 0; i < mesh_array[proc]->GetNE(); i++)
 
  797                      mesh_array[proc]->GetElement(i)->SetAttribute(proc+1);
 
  799                   for (
int i = 0; i < mesh_array[proc]->GetNBE(); i++)
 
  801                      mesh_array[proc]->GetBdrElement(i)->SetAttribute(proc+1);
 
  804                gf_array[proc] = 
new GridFunction(mesh_array[proc], isock);
 
  810                *is[np] >> ident >> ws; 
 
  813             tmp.
mesh.reset(
new Mesh(mesh_array, nproc));
 
  814             tmp.
grid_f.reset(
new GridFunction(tmp.
mesh.get(), gf_array, nproc));
 
  816             for (
int p = 0; p < nproc; p++)
 
  818                delete gf_array[nproc-1-p];
 
  819                delete mesh_array[nproc-1-p];
 
  821             gf_array.DeleteAll();
 
  822             mesh_array.DeleteAll();
 
  835       else if (ident == 
"screenshot")
 
  839          *is[0] >> ws >> filename;
 
  842          for (
size_t i = 1; i < is.size(); i++)
 
  844             *is[i] >> ws >> ident; 
 
  845             *is[i] >> ws >> ident; 
 
  848          if (glvis_command->
Screenshot(filename.c_str()))
 
  853       else if (ident == 
"keys")
 
  857          *is[0] >> ws >> keys;
 
  860          for (
size_t i = 1; i < is.size(); i++)
 
  862             *is[i] >> ws >> ident; 
 
  863             *is[i] >> ws >> ident; 
 
  871       else if (ident == 
"window_size")
 
  878          for (
size_t i = 1; i < is.size(); i++)
 
  880             *is[i] >> ws >> ident; 
 
  889       else if (ident == 
"window_geometry")
 
  893          *is[0] >> x >> y >> w >> h;
 
  896          for (
size_t i = 1; i < is.size(); i++)
 
  898             *is[i] >> ws >> ident; 
 
  899             *is[i] >> t >> t >> t >> t;
 
  907       else if (ident == 
"window_title")
 
  914          getline(*is[0], title, c);
 
  917          for (
size_t i = 1; i < is.size(); i++)
 
  919             *is[i] >> ws >> ident; 
 
  921             getline(*is[i], ident, c);
 
  929       else if (ident == 
"plot_caption")
 
  936          getline(*is[0], caption, c);
 
  939          for (
size_t i = 1; i < is.size(); i++)
 
  941             *is[i] >> ws >> ident; 
 
  943             getline(*is[i], ident, c);
 
  951       else if (ident == 
"axis_labels")
 
  954          string label_x, label_y, label_z;
 
  958          getline(*is[0], label_x, c);
 
  960          getline(*is[0], label_y, c);
 
  962          getline(*is[0], label_z, c);
 
  965          for (
size_t i = 1; i < is.size(); i++)
 
  967             *is[i] >> ws >> ident; 
 
  969             getline(*is[i], ident, c);
 
  971             getline(*is[i], ident, c);
 
  973             getline(*is[i], ident, c);
 
  976          if (glvis_command->
AxisLabels(label_x.c_str(),
 
  983       else if (ident == 
"pause")
 
  986          for (
size_t i = 1; i < is.size(); i++)
 
  988             *is[i] >> ws >> ident; 
 
  991          if (glvis_command->
Pause())
 
  996       else if (ident == 
"view")
 
  998          double theta, phi, a;
 
 1000          *is[0] >> theta >> phi;
 
 1003          for (
size_t i = 1; i < is.size(); i++)
 
 1005             *is[i] >> ws >> ident; 
 
 1011             goto comm_terminate;
 
 1014       else if (ident == 
"zoom")
 
 1021          for (
size_t i = 1; i < is.size(); i++)
 
 1023             *is[i] >> ws >> ident; 
 
 1027          if (glvis_command->
Zoom(factor))
 
 1029             goto comm_terminate;
 
 1032       else if (ident == 
"subdivisions")
 
 1036          *is[0] >> tot >> bdr;
 
 1039          for (
size_t i = 1; i < is.size(); i++)
 
 1041             *is[i] >> ws >> ident; 
 
 1047             goto comm_terminate;
 
 1050       else if (ident == 
"valuerange")
 
 1052          double minv, maxv, a;
 
 1054          *is[0] >> minv >> maxv;
 
 1057          for (
size_t i = 1; i < is.size(); i++)
 
 1059             *is[i] >> ws >> ident; 
 
 1065             goto comm_terminate;
 
 1068       else if (ident == 
"shading")
 
 1072          *is[0] >> ws >> shd;
 
 1075          for (
size_t i = 1; i < is.size(); i++)
 
 1077             *is[i] >> ws >> ident; 
 
 1078             *is[i] >> ws >> ident;
 
 1083             goto comm_terminate;
 
 1086       else if (ident == 
"viewcenter")
 
 1093          for (
size_t i = 1; i < is.size(); i++)
 
 1095             *is[i] >> ws >> ident; 
 
 1101             goto comm_terminate;
 
 1104       else if (ident == 
"autoscale")
 
 1108          *is[0] >> ws >> mode;
 
 1111          for (
size_t i = 1; i < is.size(); i++)
 
 1113             *is[i] >> ws >> ident; 
 
 1114             *is[i] >> ws >> ident;
 
 1117          if (glvis_command->
Autoscale(mode.c_str()))
 
 1119             goto comm_terminate;
 
 1122       else if (ident == 
"palette")
 
 1129          for (
size_t i = 1; i < is.size(); i++)
 
 1131             *is[i] >> ws >> ident; 
 
 1135          if (glvis_command->
Palette(pal))
 
 1137             goto comm_terminate;
 
 1140       else if (ident == 
"palette_repeat")
 
 1147          for (
size_t i = 1; i < is.size(); i++)
 
 1149             *is[i] >> ws >> ident; 
 
 1155             goto comm_terminate;
 
 1158       else if (ident == 
"camera")
 
 1162          for (
int i = 0; i < 9; i++)
 
 1168          for (
size_t i = 1; i < is.size(); i++)
 
 1170             *is[i] >> ws >> ident; 
 
 1171             for (
int j = 0; j < 9; j++)
 
 1177          if (glvis_command->
Camera(cam))
 
 1179             goto comm_terminate;
 
 1182       else if (ident == 
"autopause")
 
 1186          *is[0] >> ws >> mode;
 
 1189          for (
size_t i = 1; i < is.size(); i++)
 
 1191             *is[i] >> ws >> ident; 
 
 1192             *is[i] >> ws >> ident;
 
 1195          if (glvis_command->
Autopause(mode.c_str()))
 
 1197             goto comm_terminate;
 
 1202          cout << 
"Stream: unknown command: " << ident << endl;
 
 1206    cout << 
"Stream: end of input." << endl;
 
 1209    for (
size_t i = 0; i < is.size(); i++)
 
 1211       socketstream *isock = 
dynamic_cast<socketstream *
>(is[i].get());
 
int ValueRange(double minv, double maxv)
 
bool FixElementOrientations()
 
void Extrude1DMeshAndSolution()
Helper function for visualizing 1D data. 
 
int WindowTitle(const char *title)
 
void MyExpose(GLsizei w, GLsizei h)
 
int WindowGeometry(int x, int y, int w, int h)
 
int SetShading(const char *shd)
 
std::unique_ptr< mfem::GridFunction > grid_f
 
int AxisLabels(const char *a_x, const char *a_y, const char *a_z)
 
std::vector< std::unique_ptr< std::istream >> StreamCollection
 
void screenshot(std::string filename, bool convert=false)
Queues a screenshot to be taken. 
 
communication_thread(StreamCollection _is, GLVisCommand *cmd)
 
int NewMeshAndSolution(std::unique_ptr< Mesh > _new_m, std::unique_ptr< GridFunction > _new_g)
 
void SetMeshSolution()
Set a (checkerboard) solution when only the mesh is given. 
 
bool SetNewMeshAndSolution(StreamState new_state, VisualizationScene *vs)
 
int PlotCaption(const char *caption)
 
std::unique_ptr< mfem::Mesh > mesh
 
void ResizeWindow(int w, int h)
 
SdlWindow * GetAppWindow()
 
void MoveResizeWindow(int x, int y, int w, int h)
 
thread_local GLVisCommand * glvis_command
 
int KeyCommands(const char *keys)
 
void SetWindowTitle(const char *title)
 
int WindowSize(int w, int h)
 
int Autoscale(const char *mode)
 
int Subdivisions(int tot, int bdr)
 
int Screenshot(const char *filename)
 
int Autopause(const char *mode)
 
const char * strings_off_on[]
 
GLVisCommand(VisualizationSceneScalarData **_vs, StreamState &thread_state, bool *_keep_attr)
 
void CallKeySequence(const char *seq)
 
int ViewCenter(double x, double y)
 
int ViewAngles(double theta, double phi)
 
int Camera(const double cam[])