static void select_elements_cb(Fl_Widget *w, void *data) { classificationEditor *e = (classificationEditor*)data; bool all = (w == e->buttons[CLASS_BUTTON_SELECT_ALL_ELEMENTS]); // allocate discrete edge to hold the selected mesh segments if(!e->selected){ e->selected = new discreteEdge (GModel::current(), GModel::current()->getMaxElementaryNumber(1) + 1, 0, 0); GModel::current()->add(e->selected); } if(all){ for(GModel::fiter it = GModel::current()->firstFace(); it != GModel::current()->lastFace(); ++it){ e->elements.insert(e->elements.end(), (*it)->triangles.begin(), (*it)->triangles.end()); e->elements.insert(e->elements.end(), (*it)->quadrangles.begin(), (*it)->quadrangles.end()); } } else{ CTX::instance()->pickElements = 1; while(1) { CTX::instance()->mesh.changed = ENT_ALL; drawContext::global()->draw(); Msg::StatusGl("Select elements\n" "[Press 'e' to end selection or 'q' to abort]"); char ib = FlGui::instance()->selectEntity(ENT_ALL); if(ib == 'l') { for(unsigned int i = 0; i < FlGui::instance()->selectedElements.size(); i++){ MElement *me = FlGui::instance()->selectedElements[i]; if(me->getDim() == 2 && me->getVisibility() != 2){ me->setVisibility(2); e->elements.push_back(me); } } } if(ib == 'r') { for(unsigned int i = 0; i < FlGui::instance()->selectedElements.size(); i++){ MElement *me = FlGui::instance()->selectedElements[i]; if(me->getVisibility() == 2) e->elements.erase(std::find(e->elements.begin(), e->elements.end(), me)); me->setVisibility(1); } } if(ib == 'e') { // ok, compute the edges GModel::current()->setSelection(0); break; } if(ib == 'q') { // do nothing GModel::current()->setSelection(0); e->elements.clear(); break; } } CTX::instance()->pickElements = 0; } e2t_cont adj; buildEdgeToElements(e->elements, adj); buildListOfEdgeAngle(adj, e->edges_detected, e->edges_lonly); ElementsSelectedMode(e); update_edges_cb(0, data); Msg::StatusGl(""); }
static void delete_edge_cb(Fl_Widget *w, void *data) { classificationEditor *e = (classificationEditor*)data; if(!e->selected) return; CTX::instance()->pickElements = 1; std::vector<MLine*> ele; while(1) { CTX::instance()->mesh.changed = ENT_ALL; drawContext::global()->draw(); Msg::StatusGl("Select elements\n" "[Press 'e' to end selection or 'q' to abort]"); char ib = FlGui::instance()->selectEntity(ENT_ALL); if(ib == 'l') { for(unsigned int i = 0; i < FlGui::instance()->selectedElements.size(); i++){ MElement *me = FlGui::instance()->selectedElements[i]; if(me->getType() == TYPE_LIN && me->getVisibility() != 2){ me->setVisibility(2); ele.push_back((MLine*)me); } } } if(ib == 'r') { for(unsigned int i = 0; i < FlGui::instance()->selectedElements.size(); i++){ MElement *me = FlGui::instance()->selectedElements[i]; if(me->getVisibility() == 2) ele.erase(std::find(ele.begin(), ele.end(), me)); me->setVisibility(1); } } if(ib == 'e') { GModel::current()->setSelection(0); break; } if(ib == 'q') { GModel::current()->setSelection(0); ele.clear(); break; } } std::sort(ele.begin(), ele.end()); // look in all selected edges if a deleted one is present and delete it std::vector<MLine*> temp = e->selected->lines; e->selected->lines.clear(); for(unsigned int i = 0; i < temp.size(); i++){ std::vector<MLine*>::iterator it = std::find(ele.begin(), ele.end(), temp[i]); if(it != ele.end()) delete temp[i]; else e->selected->lines.push_back(temp[i]); } CTX::instance()->mesh.changed = ENT_ALL; CTX::instance()->pickElements = 0; drawContext::global()->draw(); Msg::StatusGl(""); e->elements.clear(); e->edges_detected.clear(); }