Skip to content
Snippets Groups Projects
Commit 9b55dd18 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

little hack to finish remote demonstrator (until we have proper

serialization of options)
parent 33f6455c
No related branches found
No related tags found
No related merge requests found
......@@ -129,3 +129,14 @@ std::string ReplacePercentS(std::string in, std::string val)
}
return out;
}
std::string ConvertFileToString(std::string fileName)
{
FILE *fp = fopen(fileName.c_str(), "r");
if(!fp) return "";
std::string out;
char str[256];
while(!feof(fp) && fgets(str, sizeof(str), fp)) out += str;
fclose(fp);
return out;
}
......@@ -18,5 +18,6 @@ std::string FixRelativePath(std::string reference, std::string in);
std::vector<std::string> SplitFileName(std::string fileName);
std::vector<std::string> SplitWhiteSpace(std::string in, unsigned int len);
std::string ReplacePercentS(std::string in, std::string val);
std::string ConvertFileToString(std::string fileName);
#endif
......@@ -7,6 +7,7 @@
// Stephen Guzik
//
#include <stdio.h>
#include <FL/Fl_Value_Slider.H>
#include <FL/Fl_Menu_Window.H>
#include <FL/Fl_Select_Browser.H>
......@@ -211,10 +212,8 @@ class ConnectionBrowser : public Fl_Hold_Browser {
int i = value();
if(i){
remove(i);
if(i <= size())
select(i);
else if(i > 1)
select(i - 1);
if(i <= size()) select(i);
else if(i > 1) select(i - 1);
}
return 1;
}
......@@ -227,17 +226,12 @@ class ConnectionBrowser : public Fl_Hold_Browser {
: Fl_Hold_Browser(x, y, w, h, l) {}
void save(Fl_Preferences &prefs)
{
std::set<std::string> uniq;
for(int i = 0; i < size(); i++) uniq.insert(text(i + 1));
for(int i = 0; i < 100; i++){
char name[256];
int j = 0;
for(std::set<std::string>::iterator it = uniq.begin(); it != uniq.end(); it++){
sprintf(name, "connection%02d", j++);
prefs.set(name, it->c_str());
}
for(int i = j; i < 100; i++){
sprintf(name, "connection%02d", i);
if(prefs.entryExists(name))
if(i < size())
prefs.set(name, text(i + 1));
else if(prefs.entryExists(name))
prefs.deleteEntry(name);
}
}
......@@ -301,7 +295,7 @@ std::string connectionChooser()
if(old > 0 && old <= n)
chooser->input->value(chooser->browser->text(old));
else
chooser->input->value(chooser->browser->text(n));
chooser->input->value(chooser->browser->text(1));
}
else
chooser->input->value("./gmsh ../tutorial/view3.pos");
......@@ -314,7 +308,19 @@ std::string connectionChooser()
Fl_Widget* o = Fl::readqueue();
if (!o) break;
if (o == chooser->ok) {
chooser->browser->add(chooser->input->value());
if(strlen(chooser->input->value())){
// insert choosen value at the top of the history if it's not
// already present
bool found = false;
for(int i = 0; i < chooser->browser->size(); i++){
if(!strcmp(chooser->input->value(), chooser->browser->text(i + 1))){
found = true;
break;
}
}
if(!found)
chooser->browser->insert(1, chooser->input->value());
}
chooser->browser->save(prefs);
chooser->window->hide();
return chooser->input->value();
......
......@@ -13,6 +13,9 @@
#include "GmshSocket.h"
#include "PViewData.h"
#include "SBoundingBox3d.h"
#include "Options.h"
#include "StringUtils.h"
#include "Context.h"
// The container for a remote dataset (does not contain any actual
// data!)
......@@ -64,7 +67,11 @@ class PViewDataRemote : public PViewData {
return 1;
}
setDirty(true);
// server->SendString(GmshSocket::GMSH_PARSER_STRING, options);
std::string fileName = CTX::instance()->homeDir + CTX::instance()->tmpFileName;
// FIXME: until we rewrite the option code and allow nice serialization ;-)
PrintOptions(0, GMSH_FULLRC, 1, 0, fileName.c_str());
std::string options = ConvertFileToString(fileName);
server->SendString(GmshSocket::GMSH_PARSE_STRING, options.c_str());
server->SendString(GmshSocket::GMSH_VERTEX_ARRAY, "Send the vertex arrays!");
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment