////////////////////////END PYTHON///////////////////////////
//////////////////MY MAPS////////////////////////////////////////
+namespace {
TopTools_IndexedMapOfShape FacesWithSizeMap;
std::map<int,string> FaceId2SizeMap;
TopTools_IndexedMapOfShape EdgesWithSizeMap;
std::map<int,PyObject*> EdgeId2PythonSmp;
std::map<int,PyObject*> VertexId2PythonSmp;
+typedef std::map<int, std::vector< BLSURFPlugin_Attractor* > > TId2ClsAttractorVec;
+TId2ClsAttractorVec FaceId2ClassAttractor;
+TId2ClsAttractorVec FaceIndex2ClassAttractor;
std::map<int,std::vector<double> > FaceId2AttractorCoords;
-std::map<int,BLSURFPlugin_Attractor*> FaceId2ClassAttractor;
-std::map<int,BLSURFPlugin_Attractor*> FaceIndex2ClassAttractor;
+int theNbAttractors;
TopTools_IndexedMapOfShape FacesWithEnforcedVertices;
std::map< int, BLSURFPlugin_Hypothesis::TEnfVertexCoordsList > FaceId2EnforcedVertexCoords;
bool HasSizeMapOnEdge=false;
bool HasSizeMapOnVertex=false;
//bool HasAttractorOnFace=false;
-
+}
//=============================================================================
/*!
*
// - build the map here for each face with an attractor set and only if the attractor shape as changed since the last call to _buildmap()
// -> define a bool _mapbuilt in the class that is set to false by default and set to true when calling _buildmap() OK
+ theNbAttractors = 0;
const BLSURFPlugin_Hypothesis::TAttractorMap class_attractors = BLSURFPlugin_Hypothesis::GetClassAttractorEntries(hyp);
int key=-1;
BLSURFPlugin_Hypothesis::TAttractorMap::const_iterator AtIt = class_attractors.begin();
if ( !AtIt->second->Empty() ) {
// MESSAGE("cadsurf_set_attractor(): " << AtIt->first << " = " << AtIt->second);
GeomShape = entryToShape(AtIt->first);
+ if ( !SMESH_MesherHelper::IsSubShape( GeomShape, theGeomShape ))
+ continue;
AttShape = AtIt->second->GetAttractorShape();
GeomType = GeomShape.ShapeType();
// Group Management
|| AttShape.ShapeType() == TopAbs_COMPOUND) ){
HasSizeMapOnFace = true;
- if (! FacesWithSizeMap.Contains(TopoDS::Face(GeomShape)) ) {
- key = FacesWithSizeMap.Add(TopoDS::Face(GeomShape) );
- }
- else {
- key = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape));
-// MESSAGE("Face with key " << key << " already in map");
- }
+ key = FacesWithSizeMap.Add(TopoDS::Face(GeomShape) );
- FaceId2ClassAttractor[key] = AtIt->second;
+ FaceId2ClassAttractor[key].push_back( AtIt->second );
+ ++theNbAttractors;
}
else{
MESSAGE("Wrong shape type !!")
// Fix problem with locales
Kernel_Utils::Localizer aLocalizer;
+ this->SMESH_Algo::_progress = 1e-3; // prevent progress advancment while computing attractors
+
if ( !compute( aMesh, aShape, /*allowSubMeshClearing=*/true ))
return false;
// -----------------
// Class Attractors
// -----------------
- std::map<int,BLSURFPlugin_Attractor* >::iterator clAttractor_iter = FaceId2ClassAttractor.find(faceKey);
+ TId2ClsAttractorVec::iterator clAttractor_iter = FaceId2ClassAttractor.find(faceKey);
if (clAttractor_iter != FaceId2ClassAttractor.end()){
MESSAGE("Face indice: " << iface);
MESSAGE("Adding attractor");
- FaceIndex2ClassAttractor[iface]=clAttractor_iter->second;
+ std::vector< BLSURFPlugin_Attractor* > & attVec = clAttractor_iter->second;
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ if ( !attVec[i]->IsMapBuilt() ) {
+ std::cout<<"Compute " << theNbAttractors-- << "-th attractor" <<std::endl;
+ attVec[i]->BuildMap();
+ }
+ FaceIndex2ClassAttractor[iface].swap( attVec );
FaceId2ClassAttractor.erase(clAttractor_iter);
}
} // if (HasSizeMapOnFace && !use_precad)
status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data)
{
//MESSAGE("size_on_surface")
+ TId2ClsAttractorVec::iterator f2attVec;
if (FaceId2PythonSmp.count(face_id) != 0){
//MESSAGE("A size map is used to calculate size on face : "<<face_id)
PyObject * pyresult = NULL;
*size = result;
PyGILState_Release(gstate);
}
- else if (FaceIndex2ClassAttractor.count(face_id) !=0 && !FaceIndex2ClassAttractor[face_id]->Empty()){
+ else if (( f2attVec = FaceIndex2ClassAttractor.find(face_id)) != FaceIndex2ClassAttractor.end() && !f2attVec->second.empty()){
// MESSAGE("attractor used on face :"<<face_id)
// MESSAGE("List of attractor is not empty")
// MESSAGE("Attractor empty : "<< FaceIndex2ClassAttractor[face_id]->Empty())
- real result = FaceIndex2ClassAttractor[face_id]->GetSize(uv[0],uv[1]);
- *size = result;
+ real result = 0;
+ //result = 1e100;
+ std::vector< BLSURFPlugin_Attractor* > & attVec = f2attVec->second;
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ {
+ result += attVec[i]->GetSize(uv[0],uv[1]);
+ //result = Min( result, attVec[i]->GetSize(uv[0],uv[1]));
+ }
+ *size = result / attVec.size(); // mean of sizes defined by all attractors
+ //*size = result;
}
else {
// MESSAGE("List of attractor is empty !!!")
const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
- bool attExists = (_classAttractors.find(entry) != _classAttractors.end());
- double u1,u2,v1,v2, diag;
-
- if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){
- ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2);
-// diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1));
- BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 ); // test 0.002 * diag);
- myAttractor->BuildMap();
- myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
- _classAttractors[entry] = myAttractor;
- NotifySubMeshesHypothesisModification();
+ TAttractorMap::iterator attIt = _classAttractors.find(entry);
+ for ( ; attIt != _classAttractors.end(); ++attIt )
+ if ( attIt->first == entry &&
+ attIt->second->GetAttractorEntry() == attEntry )
+ break;
+ bool attExists = (attIt != _classAttractors.end());
+
+ BLSURFPlugin_Attractor* myAttractor;
+ if ( !attExists ) {
+ myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
+ _classAttractors.insert( make_pair( entry, myAttractor ));
}
else {
- _classAttractors[entry]->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
- if (!_classAttractors[entry]->IsMapBuilt()){
- _classAttractors[entry]->BuildMap();
- }
- NotifySubMeshesHypothesisModification();
+ myAttractor = attIt->second;
}
-
+ // if (!myAttractor->IsMapBuilt())
+ // myAttractor->BuildMap();
+ myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
+
+ NotifySubMeshesHypothesisModification();
}
//=======================================================================
else {
TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
if ( it_clAt != _classAttractors.end() ) {
- _classAttractors.erase(it_clAt);
+ do {
+ _classAttractors.erase(it_clAt);
+ it_clAt = _classAttractors.find( entry );
+ }
+ while ( it_clAt != _classAttractors.end() );
MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
NotifySubMeshesHypothesisModification();
}
double attParams[4];
double step;
while (isOK && hasNewAttractor) {
- std::cout<<"Load new attractor"<<std::endl;
+ //std::cout<<"Load new attractor"<<std::endl;
isOK = (load >> newAtFaceEntry);
if (isOK) {
if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
- attractor->BuildMap();
- _classAttractors[newAtFaceEntry]=attractor;
+ //attractor->BuildMap();
+ _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
}
}
connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
+ connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
// connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
i.next();
const QString entry = i.key();
const QString sizeMap = i.value();
- string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
+ string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
int row = mySizeMapTable->topLevelItemCount();
QTreeWidgetItem* item = new QTreeWidgetItem();
- mySizeMapTable->addTopLevelItem( item );
+ mySizeMapTable->addTopLevelItem( item );
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
- if (that->myATTMap.contains(entry)){
- const QString attEntry = that->myATTMap[entry];
- std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
- QTreeWidgetItem* child = new QTreeWidgetItem();
- item->addChild( child );
- item->setExpanded(true);
- child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
- child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) );
- child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) );
-
- if (that->myAttDistMap[entry] > std::numeric_limits<double>::epsilon()){
- item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) );
- }
- else{
- item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) );
+ if (that->myATTMap.contains(entry)) {
+ TAttractorVec & attVec = that->myATTMap[entry];
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ {
+ std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
+ QTreeWidgetItem* child = new QTreeWidgetItem();
+ item->addChild( child );
+ item->setExpanded(true);
+ child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
+ child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
+ child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
+
+ if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
+ item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
+ }
+ else{
+ item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
+ }
}
}
else
that->mySMPMap.clear();
that->myATTMap.clear();
- that->myAttDistMap.clear();
- that->myDistMap.clear();
+ // that->myAttDistMap.clear();
+ // that->myDistMap.clear();
// classic size maps
BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
QString faceEntry = myAttractorParams.faceEntry.in();
QString attEntry = myAttractorParams.attEntry.in();
MESSAGE("attEntry = "<<attEntry.toStdString())
- double startSize = myAttractorParams.startSize;
- double endSize = myAttractorParams.endSize;
- double infDist = myAttractorParams.infDist;
- double constDist = myAttractorParams.constDist;
- that->mySMPMap[faceEntry] = QString::number( startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
+ that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
- that->myATTMap[faceEntry] = attEntry;
- that->myAttDistMap[faceEntry] = infDist;
- that->myDistMap[faceEntry] = constDist;
+ that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
+ myAttractorParams.startSize,
+ myAttractorParams.infDist,
+ myAttractorParams.constDist ));
}
// Enforced vertices
// h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
}
else {
- if (!myATTMap[entry].isEmpty()){
- QString att_entry = myATTMap[entry];
- double infDist = myAttDistMap[entry];
- double constDist = myDistMap[entry];
- double phySize = h->GetPhySize();
- QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
- QApplication::restoreOverrideCursor();
+ if (!myATTMap[entry].empty()){
+ const TAttractorVec& attVec = myATTMap[entry];
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ {
+ h->SetClassAttractorEntry( entry.toLatin1().constData(),
+ attVec[i].attEntry.c_str(),
+ attVec[i].startSize,
+ h->GetPhySize(),
+ attVec[i].infDist,
+ attVec[i].constDist );
+ }
}
else {
QString fullSizeMap;
void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
{
- BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
-
- if ( myGeomSelWdg2->IsObjectSelected() ){
+ if ( myGeomSelWdg2->IsObjectSelected() ){
mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
}
else if ( myGeomSelWdg1->IsObjectSelected() ){
mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
}
- std::string entry = (string) mySMapObject->GetStudyEntry();
- QString qEntry = QString::fromStdString(entry);
- if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {
- addMapButton->setEnabled(false);
- modifyMapButton->setEnabled(true);
- }
- else{
- addMapButton->setEnabled(true);
- modifyMapButton->setEnabled(false);
+ else {
+ mySMapObject = GEOM::GEOM_Object::_nil();
+ }
+ bool dataAvailable = !mySMapObject->_is_nil();
+ QString qEntry;
+ if ( dataAvailable )
+ qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
+
+ bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
+ if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
+ ( dataAvailable = myAttSelWdg->isEnabled() ) &&
+ ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
+ ( myATTMap.contains( qEntry )))
+ {
+ mapExists = false;
+ QString attEntry = myAttSelWdg->GetValue();
+ const TAttractorVec& attVec = myATTMap[ qEntry ];
+ for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
+ mapExists = ( attEntry == attVec[i].attEntry.c_str() );
}
-
-}
+
+ addMapButton->setEnabled( !mapExists && dataAvailable );
+ modifyMapButton->setEnabled( mapExists && dataAvailable );
+}
void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
- if (col == SMP_SIZEMAP_COLUMN){
+ if (col == SMP_SIZEMAP_COLUMN) {
QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
+ QString childEntry;
if (!mySMPMap.contains(entry))
- return;
+ {
+ if ( QTreeWidgetItem* parent = item->parent() )
+ {
+ childEntry = entry;
+ item = parent;
+ entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
+ }
+ if (!mySMPMap.contains(entry))
+ return;
+ }
QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
- CORBA::Object_var obj = entryToObject(entry);
- if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ // ADVANCED MAPS
+ CORBA::Object_var obj = entryToObject(entry);
+ if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
smpTab->setCurrentIndex(ATT_TAB); // Change Tab
- double phySize = that->mySMPMap[entry].toDouble(); // Retrieve values of the selected item in the current tab widgets
- double infDist = that->myAttDistMap[entry];
- double constDist = that->myDistMap[entry];
- QString attEntry = that->myATTMap[entry];
- CORBA::Object_var attObj = entryToObject(attEntry);
- myAttSizeSpin->setValue(phySize);
- if (sizeMap.startsWith("Attractor")){
- myAttDistSpin->setValue(infDist);
- myAttractorCheck->setChecked(true);
- }
- else {
- myAttractorCheck->setChecked(false);
- }
- if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits<double>::epsilon()){
- myAttDistSpin2->setValue(constDist);
- myConstSizeCheck->setChecked(true);
- }
- else{
- myConstSizeCheck->setChecked(false);
+ // Retrieve values of the selected item in the current tab widgets
+ const TAttractorVec& attVec = myATTMap[entry];
+ if ( !attVec.empty() )
+ {
+ int iAtt = 0;
+ if ( !childEntry.isEmpty() )
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ if ( childEntry == attVec[i].attEntry.c_str() )
+ {
+ iAtt = i;
+ break;
+ }
+ double phySize = attVec[iAtt].startSize;
+ double infDist = attVec[iAtt].infDist;
+ double constDist = attVec[iAtt].constDist;
+ QString attEntry = attVec[iAtt].attEntry.c_str();
+ CORBA::Object_var attObj = entryToObject(attEntry);
+ myAttSizeSpin->setValue(phySize);
+ if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
+ myAttDistSpin->setValue(infDist);
+ myAttractorCheck->setChecked(true);
+ }
+ else {
+ myAttractorCheck->setChecked(false);
+ }
+ if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
+ myAttDistSpin2->setValue(constDist);
+ myConstSizeCheck->setChecked(true);
+ }
+ else{
+ myConstSizeCheck->setChecked(false);
+ }
+ myGeomSelWdg2->SetObject(obj);
+ myAttSelWdg->SetObject(attObj);
}
- myGeomSelWdg2->SetObject(obj);
- myAttSelWdg->SetObject(attObj);
}
else { // CLASSIC MAPS
smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
if (!sizeMap.startsWith("def")){
- mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
+ mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
}
- }
- }
+ }
+ }
}
void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
{
- getGeomSelectionTool()->selectionMgr()->clearFilters();// rm other tab filters
+ getGeomSelectionTool()->selectionMgr()->clearFilters();
if ( sender() == myTabWidget )
{
myGeomSelWdg1 ->deactivateSelection();
else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
}
- }
+ }
+ onMapGeomContentModified();
}
void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
}
}
+ onMapGeomContentModified();
}
void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
that->mySMPShapeTypeMap.remove(entry);
if (that->myATTMap.contains(entry))
that->myATTMap.remove(entry);
- if (that->myDistMap.contains(entry))
- that->myDistMap.remove(entry);
- if (that->myAttDistMap.contains(entry))
- that->myAttDistMap.remove(entry);
+ // if (that->myDistMap.contains(entry))
+ // that->myDistMap.remove(entry);
+ // if (that->myAttDistMap.contains(entry))
+ // that->myAttDistMap.remove(entry);
delete item;
}
mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
void BLSURFPluginGUI_HypothesisCreator::onAddMap()
{
bool res = false;
- if ( smpTab->currentIndex() == ATT_TAB ){
- if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
+ if ( smpTab->currentIndex() == ATT_TAB ){
+ if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
res = insertAttractor(mySMapObject, myAttObject);
if (smpTab->currentIndex() == SMP_STD_TAB ){
if ( myGeomSelWdg1->IsObjectSelected() ){
mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
- res = insertElement(mySMapObject);
- }
+ res = insertElement(mySMapObject);
+ }
}
if ( !res ) {
// Local size should be more than 0
bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
- BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
- BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
+ // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
+ // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
mySizeMapTable->addTopLevelItem(item);
}
that->mySMPMap[shapeEntry] = sizeMap;
- that->myDistMap[shapeEntry] = 0. ;
+ //that->myDistMap[shapeEntry] = 0. ;
that->mySMPShapeTypeMap[shapeEntry] = shapeType;
item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
QString constDistString = QString::fromStdString(oss3.str());
QTreeWidgetItem* item;
- QTreeWidgetItem* child;
- if (modify){
+ QTreeWidgetItem* child;
+ TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
+ if (modify) {
int rowToChange = findRowFromEntry(shapeEntry);
item = mySizeMapTable->topLevelItem( rowToChange );
- child = item->child( 0 );
+
+ for ( int i = 0, nb = item->childCount(); i < nb; ++i )
+ if (( child = item->child( i )))
+ if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
+ break;
+ TAttractorVec & attVec = myATTMap[shapeEntry];
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ if ( attVec[i].attEntry == attEntry )
+ {
+ attVec[i] = attParams;
+ break;
+ }
}
else{
- if (that->mySMPMap.contains(shapeEntry)) {
- if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
- // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
- return false;
- }
- }
+ // if (that->mySMPMap.contains(shapeEntry)) {
+ // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
+ // // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
+ // return false;
+ // }
+ // }
item = new QTreeWidgetItem();
child = new QTreeWidgetItem();
mySizeMapTable->addTopLevelItem(item);
item->addChild(child);
+ myATTMap[shapeEntry].push_back( attParams );
}
- that->mySMPMap.insert(shapeEntry,sizeMap);
- that->myATTMap.insert(shapeEntry,qAttEntry);
- that->myAttDistMap.insert(shapeEntry,infDist);
- that->myDistMap.insert(shapeEntry,constDist);
- that->mySMPShapeTypeMap.insert(shapeEntry,shapeType);
+ mySMPMap.insert(shapeEntry,sizeMap);
+ mySMPShapeTypeMap.insert(shapeEntry,shapeType);
item->setExpanded(true);
item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );