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

fix old-style physical group labels in list browser

parent 6c8d9efd
No related branches found
No related tags found
No related merge requests found
...@@ -190,12 +190,12 @@ class VisibilityList { // singleton ...@@ -190,12 +190,12 @@ class VisibilityList { // singleton
_entities.push_back(new VisModel(GModel::list[i], i)); _entities.push_back(new VisModel(GModel::list[i], i));
std::string name = GModel::list[i]->getName(); std::string name = GModel::list[i]->getName();
if(GModel::list[i] == GModel::current()) name += " (Active)"; if(GModel::list[i] == GModel::current()) name += " (Active)";
setLabel(i, name); setLabel(i, name, 1);
} }
} }
if(type == ElementaryEntities){ else if(type == ElementaryEntities){
for(GModel::piter it = m->firstElementaryName(); it != m->lastElementaryName(); ++it) for(GModel::piter it = m->firstElementaryName(); it != m->lastElementaryName(); ++it)
setLabel(it->first, it->second); setLabel(it->first, it->second, 1);
for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++) for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++)
_entities.push_back(new VisElementary(*it)); _entities.push_back(new VisElementary(*it));
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++) for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++)
...@@ -207,7 +207,7 @@ class VisibilityList { // singleton ...@@ -207,7 +207,7 @@ class VisibilityList { // singleton
} }
else if(type == PhysicalEntities){ else if(type == PhysicalEntities){
for(GModel::piter it = m->firstPhysicalName(); it != m->lastPhysicalName(); ++it) for(GModel::piter it = m->firstPhysicalName(); it != m->lastPhysicalName(); ++it)
setLabel(it->first, it->second); setLabel(it->first, it->second, 1);
std::map<int, std::vector<GEntity*> > groups[4]; std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups); m->getPhysicalGroups(groups);
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
...@@ -262,21 +262,23 @@ class VisibilityList { // singleton ...@@ -262,21 +262,23 @@ class VisibilityList { // singleton
std::string getBrowserLine(int n) std::string getBrowserLine(int n)
{ {
int tag = _entities[n]->getTag(); int tag = _entities[n]->getTag();
char str[256]; std::ostringstream sstream;
bool label_exists = _labels.count(tag); sstream << "\t" << _entities[n]->getName() << "\t" << tag << "\t";
const char *label_color = (label_exists && _labels[tag].second) ? "@b" : ""; if(_labels.count(tag)){
sprintf(str, "\t%s\t%d\t%s%s", _entities[n]->getName().c_str(), tag, if(_labels[tag].second)
label_color, label_exists ? _labels[tag].first.c_str() : ""); sstream << "@b";
return std::string(str); sstream << _labels[tag].first;
}
return sstream.str();
} }
// set the sort mode // set the sort mode
void setSortMode(int mode){ _sortMode = (_sortMode != mode) ? mode : -mode; } void setSortMode(int mode){ _sortMode = (_sortMode != mode) ? mode : -mode; }
// get the sort mode // get the sort mode
int getSortMode(){ return _sortMode; } int getSortMode(){ return _sortMode; }
// associate a label with a tag (quality=0 for "old-style" unreliable labels) // associate a label with a tag (quality=0 for "old-style" unreliable labels)
void setLabel(int tag, std::string label, int quality=1) void setLabel(int tag, std::string label, int quality)
{ {
_labels[tag] = std::make_pair(label, quality); if(label.size()) _labels[tag] = std::pair<std::string, int>(label, quality);
} }
// get the label associated with a tag // get the label associated with a tag
std::string getLabel(int tag){ return _labels[tag].first; } std::string getLabel(int tag){ return _labels[tag].first; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment