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

more IO work
parent 4f4783f5
No related branches found
No related tags found
No related merge requests found
...@@ -319,10 +319,10 @@ projectionEditor::projectionEditor() ...@@ -319,10 +319,10 @@ projectionEditor::projectionEditor()
_window->size_range(width, (int)(0.85 * height)); _window->size_range(width, (int)(0.85 * height));
} }
void projectionEditor::load(FProjectionFace *face) void projectionEditor::load(FProjectionFace *face, std::string tag)
{ {
ProjectionSurface *ps = face->GetProjectionSurface(); ProjectionSurface *ps = face->GetProjectionSurface();
_browser->add(ps->GetName().c_str()); _browser->add(tag.size() ? tag.c_str() : ps->GetName().c_str());
projection *p = new projection(face, _paramWin[0], _paramWin[1], _paramWin[2], projection *p = new projection(face, _paramWin[0], _paramWin[1], _paramWin[2],
_paramWin[3], _paramWin[4], _paramWin[5], this); _paramWin[3], _paramWin[4], _paramWin[5], this);
_projections.push_back(p); _projections.push_back(p);
...@@ -417,7 +417,7 @@ void update_cb(Fl_Widget *w, void *data) ...@@ -417,7 +417,7 @@ void update_cb(Fl_Widget *w, void *data)
} }
} }
} }
// loop over elements and do the same thing // deal with elements here
e->uv()->set(u, v, dist, f); e->uv()->set(u, v, dist, f);
} }
...@@ -551,6 +551,7 @@ void filter_cb(Fl_Widget *w, void *data) ...@@ -551,6 +551,7 @@ void filter_cb(Fl_Widget *w, void *data)
ve->setSelection(false); ve->setSelection(false);
} }
} }
// deal with elements here
} }
update_cb(0, data); update_cb(0, data);
} }
...@@ -577,14 +578,14 @@ void save_selection_cb(Fl_Widget *w, void *data) ...@@ -577,14 +578,14 @@ void save_selection_cb(Fl_Widget *w, void *data)
Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1)); Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1));
return; return;
} }
// FIXME: maybe we should save as mesh file // maybe we should save as mesh file
for(unsigned int i = 0; i < ent.size(); i++){ for(unsigned int i = 0; i < ent.size(); i++){
GVertex *v = dynamic_cast<GVertex*>(ent[i]); GVertex *v = dynamic_cast<GVertex*>(ent[i]);
if(v && v->getSelection()) if(v && v->getSelection())
fprintf(fp, "Point(%d) = {%.16g,%.16g,%.16g,1};\n", v->tag(), fprintf(fp, "Point(%d) = {%.16g,%.16g,%.16g,1};\n", v->tag(),
v->x(), v->y(), v->z()); v->x(), v->y(), v->z());
} }
// FIXME: deal with std::vector<MElement*> &ele(e->getElements()); // deal with elements here
fclose(fp); fclose(fp);
} }
} }
...@@ -598,28 +599,35 @@ void load_projection_cb(Fl_Widget *w, void *data) ...@@ -598,28 +599,35 @@ void load_projection_cb(Fl_Widget *w, void *data)
Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1)); Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1));
return; return;
} }
char name[256]; int num;
if(!fscanf(fp, "%s", name)){ if(!fscanf(fp, "%d", &num)){
Msg(GERROR, "Bad projection file format"); Msg(GERROR, "Bad projection file format");
return; return;
} }
FProjectionFace *face = createProjectionFaceFromName(name); for(int proj = 0; proj < num; proj++){
if(face){ char name[256], tag[256];
e->load(face); if(!fscanf(fp, "%s", tag) || !fscanf(fp, "%s", name)){
projection *p = e->getLastProjection(); Msg(GERROR, "Bad projection file format");
if(p){ return;
for(unsigned int i = 0; i < p->parameters.size(); i++){ }
double val; FProjectionFace *face = createProjectionFaceFromName(name);
if(!fscanf(fp, "%lf", &val)){ if(face){
Msg(GERROR, "Missing paramater for projection `%s'", name); e->load(face, tag);
break; projection *p = e->getLastProjection();
if(p){
for(unsigned int i = 0; i < p->parameters.size(); i++){
double val;
if(!fscanf(fp, "%lf", &val)){
Msg(GERROR, "Missing paramater for projection `%s'", name);
break;
}
p->parameters[i]->value(val);
} }
p->parameters[i]->value(val);
} }
fclose(fp);
update_cb(0, data);
} }
} }
fclose(fp);
update_cb(0, data);
} }
} }
...@@ -635,7 +643,7 @@ void save_projection_cb(Fl_Widget *w, void *data) ...@@ -635,7 +643,7 @@ void save_projection_cb(Fl_Widget *w, void *data)
Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1)); Msg(GERROR, "Unable to open file `%s'", file_chooser_get_name(1));
return; return;
} }
fprintf(fp, "%s\n", ps->GetName().c_str()); fprintf(fp, "1\n%s\n%s\n", ps->GetName().c_str(), ps->GetName().c_str());
for(unsigned int i = 0; i < p->parameters.size(); i++) for(unsigned int i = 0; i < p->parameters.size(); i++)
fprintf(fp, "%.16g\n", p->parameters[i]->value()); fprintf(fp, "%.16g\n", p->parameters[i]->value());
fclose(fp); fclose(fp);
......
...@@ -67,7 +67,7 @@ class projectionEditor { ...@@ -67,7 +67,7 @@ class projectionEditor {
uvPlot *_uvPlot; uvPlot *_uvPlot;
public: public:
projectionEditor(); projectionEditor();
void load(FProjectionFace *face); void load(FProjectionFace *face, std::string tag="");
void show(){ _window->show(); select_cb(0, this); } void show(){ _window->show(); select_cb(0, this); }
uvPlot *uv() { return _uvPlot; } uvPlot *uv() { return _uvPlot; }
Fl_Value_Input* modes[4]; Fl_Value_Input* modes[4];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment