Select Git revision
LuaBindings.h
Forked from
gmsh / gmsh
Source project has a limited visibility.
onelabWindow.cpp 48.13 KiB
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include <FL/Fl.H>
#include "GmshConfig.h"
#include "GmshMessage.h"
#if defined(HAVE_ONELAB)
#include "onelab.h"
#endif
#if defined(HAVE_ONELAB) && (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3)
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Input_Choice.H>
#include <FL/Fl_Output.H>
#include <FL/fl_ask.H>
#include "inputRange.h"
#include "Context.h"
#include "GModel.h"
#include "GmshDefines.h"
#include "Options.h"
#include "OS.h"
#include "StringUtils.h"
#include "OpenFile.h"
#include "CreateFile.h"
#include "drawContext.h"
#include "PView.h"
#include "PViewData.h"
#include "PViewOptions.h"
#include "FlGui.h"
#include "paletteWindow.h"
#include "menuWindow.h"
#include "fileDialogs.h"
#include "onelabWindow.h"
// This file contains the Gmsh/FLTK specific parts of the OneLab
// interface. You'll need to reimplement this if you plan to build
// a different OneLab server.
class onelabGmshServer : public GmshServer{
private:
onelab::localNetworkClient *_client;
public:
onelabGmshServer(onelab::localNetworkClient *client)
: GmshServer(), _client(client) {}
~onelabGmshServer(){}
int NonBlockingSystemCall(const char *str){ return SystemCall(str); }
int NonBlockingWait(int socket, double waitint, double timeout)
{
double start = GetTimeInSeconds();
while(1){
if(timeout > 0 && GetTimeInSeconds() - start > timeout)
return 2; // timout
if(_client->getPid() < 0 || (_client->getExecutable().empty() &&
!CTX::instance()->solver.listen))
return 1; // process has been killed or we stopped listening
// check if there is data (call select with a zero timeout to
// return immediately, i.e., do polling)
int ret = Select(0, 0, socket);
if(ret == 0){ // nothing available
// if asked, refresh the onelab GUI
std::vector<onelab::string> ps;
onelab::server::instance()->get(ps, "Gmsh/Action");
if(ps.size() && ps[0].getValue() == "refresh"){
ps[0].setVisible(false);
ps[0].setValue("");