Commit ef676b3d by Christophe Geuzaine

first step at highlight of physical groups during interactive model creation

parent fe24f286
......@@ -1464,8 +1464,8 @@ void Msg::ImportPhysicalGroupsInOnelab()
std::string name = GModel::current()->getPhysicalName(dim, it->first);
char tmp[256];
if(name.empty()){
sprintf(tmp, "Physical %s %d", (dim == 3) ? "Volume " : (dim == 2) ? "Surface " :
(dim == 1) ? "Line " : "Point ", num);
sprintf(tmp, "Physical %s %d", (dim == 3) ? "Volume" : (dim == 2) ? "Surface" :
(dim == 1) ? "Curve" : "Point", num);
name = tmp;
}
sprintf(tmp, "Gmsh/Physical group %d/", index);
......
......@@ -1161,6 +1161,33 @@ static void view_group_cb(Fl_Widget *w, void *data)
drawContext::global()->draw();
}
static void highlight_physical_group_cb(Fl_Widget *w, void *data)
{
if(!data) return;
std::string group((char*)data);
if(group.empty()) return;
if(group.find("Physical Point") != std::string::npos){
int num = atoi(group.substr(15).c_str());
printf("will highlight physical point %d\n", num);
}
else if(group.find("Physical Curve") != std::string::npos){
int num = atoi(group.substr(15).c_str());
printf("will highlight physical curve %d\n", num);
}
else if(group.find("Physical Surface") != std::string::npos){
int num = atoi(group.substr(17).c_str());
printf("will highlight physical surface %d\n", num);
}
else if(group.find("Physical Volume") != std::string::npos){
int num = atoi(group.substr(16).c_str());
printf("will highlight physical volume %d\n", num);
}
else{
printf("will highlight physical group with name '%s'\n", group.c_str());
}
drawContext::global()->draw();
}
void onelabGroup::rebuildTree(bool deleteWidgets)
{
setButtonVisibility();
......@@ -1246,6 +1273,16 @@ void onelabGroup::rebuildTree(bool deleteWidgets)
_treeStrings.push_back(group);
but->callback(view_group_cb, (void*)group);
}
else if(getPath(n).find("Physical group: ") != std::string::npos){
but = new Fl_Button(1, 1, ww, hh);
but->box(FL_NO_BOX);
but->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
but->tooltip("Toggle highlight of physical group");
std::string::size_type pos = getPath(n).find("Physical group: ");
char *group = strdup(getPath(n).substr(pos + 16).c_str());
_treeStrings.push_back(group);
but->callback(highlight_physical_group_cb, (void*)group);
}
else{
but = new Fl_Box(1, 1, ww, hh);
but->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
......@@ -1500,4 +1537,3 @@ void onelabGroup::addSolver(const std::string &name, const std::string &executab
// initialize the client
onelab_cb(0, (void*)"initialize");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment