SMP_ENTRY_COLUMN = 0,
SMP_NAME_COLUMN,
SMP_SIZEMAP_COLUMN,
+ SMP_DIST_COLUMN,
SMP_NB_COLUMNS,
// Enforced vertices array columns
ENF_VER_NAME_COLUMN = 0,
SMP_BTNS = 0,
// SMP_ATTRACTOR_BTN,
// SMP_SEPARATOR1,
- SMP_POINT_BTN,
- SMP_EDGE_BTN,
- SMP_SURFACE_BTN,
+// SMP_POINT_BTN,
+// SMP_EDGE_BTN,
+// SMP_SURFACE_BTN,
+ SMP_GEOM_BTN,
SMP_SEPARATOR2,
+ SMP_ATT_GROUP,
+ SMP_DIST_GROUP,
+ SMP_ADD_BTN,
SMP_REMOVE_BTN,
SMP_NB_LINES
};
+
+enum {
+ SMP_ATT_BTNS = 0,
+ SMP_ATT_SHAPE,
+ SMP_ATT_SIZE,
+ SMP_ATT_DIST
+};
+
+enum {
+ SMP_DIST_BTNS = 0,
+ SMP_DIST
+};
// Enforced vertices inputs
enum {
QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup );
+ //mySizeMapTable->setSortingEnabled(true);
QStringList sizeMapHeaders;
- sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" );
+ sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" ) << tr( "SMP_DIST_COLUMN" );
mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders);
mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN );
mySizeMapTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+ mySizeMapTable->horizontalHeader()->setStretchLastSection(true);
+ //mySizeMapTable->horizontalHeader()->setProperty("showSortIndicator", QVariant(true));
mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
+ mySizeMapTable->resizeColumnToContents(SMP_DIST_COLUMN);
mySizeMapTable->setAlternatingRowColors(true);
mySizeMapTable->verticalHeader()->hide();
+ mySizeMapTable->setShowGrid(true);
+
/*
addAttractorButton = new QPushButton(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup);
QFrame *line = new QFrame(mySmpGroup);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
*/
- addSurfaceButton = new QPushButton(tr("BLSURF_SM_SURFACE"),mySmpGroup);
- addEdgeButton = new QPushButton(tr("BLSURF_SM_EDGE"),mySmpGroup);
- addPointButton = new QPushButton(tr("BLSURF_SM_POINT"),mySmpGroup);
+ //addSurfaceButton = new QPushButton(tr("BLSURF_SM_SURFACE"),mySmpGroup);
+ //addEdgeButton = new QPushButton(tr("BLSURF_SM_EDGE"),mySmpGroup);
+ //addPointButton = new QPushButton(tr("BLSURF_SM_POINT"),mySmpGroup);
+
+ // Filters of selection
+ TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
+
+ SM_ShapeTypes.Add( TopAbs_VERTEX );
+ SM_ShapeTypes.Add( TopAbs_EDGE );
+ SM_ShapeTypes.Add( TopAbs_FACE );
+
+ ATT_ShapeTypes.Add( TopAbs_VERTEX );
+ ATT_ShapeTypes.Add( TopAbs_EDGE );
+
+ SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
+ SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
+
+ // Size Map GroupBox
+ myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
+ myGeomSelWdg->SetDefaultText("Select a Shape", "QLineEdit { color: grey }");
QFrame *line2 = new QFrame(mySmpGroup);
line2->setFrameShape(QFrame::HLine);
line2->setFrameShadow(QFrame::Sunken);
- removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
-
-
+ removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
+ addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
+
+ // Attractor GroupBox
+ myAttractorGroup = new QGroupBox(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup);
+ myAttractorGroup->setCheckable(true);
+ myAttractorGroup->setChecked(false);
+ myAttractorGroup->setEnabled(false);
+ QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
+ myAttDistSpin = new QDoubleSpinBox(myAttractorGroup);
+ myAttSizeSpin = new QDoubleSpinBox(myAttractorGroup);
+ QLabel* myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
+ QLabel* myAttSizeLabel = new QLabel(tr("BLSURF_ATT_SIZE"),myAttractorGroup);
+ myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
+ myAttSelWdg->SetDefaultText("Select a Shape", "QLineEdit { color: grey }");
+ myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg);
+
+ myAttDistSpin->setValue(0.);
+ myAttSizeSpin->setValue(0.);
+ // Constant Size GroupBox
+ myDistanceGroup = new QGroupBox(tr("BLSURF_SM_CONST"),mySmpGroup);
+ myDistanceGroup->setCheckable(true);
+ myDistanceGroup->setChecked(false);
+ myDistanceGroup->setEnabled(false);
+ QGridLayout* aDistLayout = new QGridLayout(myDistanceGroup);
+ mySmpDistSpin = new QDoubleSpinBox(myDistanceGroup);
+ QLabel* mySmpDistLabel = new QLabel(tr("BLSURF_SM_DIST"),myDistanceGroup);
+
+
+
// ADD WIDGETS (SIZEMAP TAB)
- anSmpLayout->addWidget(mySizeMapTable, SMP_POINT_BTN, 0, SMP_NB_LINES+1, 1);
+// anSmpLayout->addWidget(mySizeMapTable, SMP_POINT_BTN, 0, SMP_NB_LINES+1, 1);
+ anSmpLayout->addWidget(mySizeMapTable, 1, 0, SMP_NB_LINES+1, 1);
// anSmpLayout->addWidget(addAttractorButton, SMP_ATTRACTOR_BTN, 1, 1, 1);
// anSmpLayout->addWidget(line, SMP_SEPARATOR1, 1, 1, 1);
- anSmpLayout->addWidget(addPointButton, SMP_POINT_BTN, 1, 1, 1);
- anSmpLayout->addWidget(addEdgeButton, SMP_EDGE_BTN, 1, 1, 1);
- anSmpLayout->addWidget(addSurfaceButton, SMP_SURFACE_BTN, 1, 1, 1);
- anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 1, 1);
- anSmpLayout->addWidget(removeButton, SMP_REMOVE_BTN, 1, 1, 1);
+// anSmpLayout->addWidget(addPointButton, SMP_POINT_BTN, 1, 1, 1);
+// anSmpLayout->addWidget(addEdgeButton, SMP_EDGE_BTN, 1, 1, 1);
+// anSmpLayout->addWidget(addSurfaceButton, SMP_SURFACE_BTN, 1, 1, 1);
+ anSmpLayout->addWidget(myGeomSelWdg, SMP_GEOM_BTN, 1, 1, 2);
+ anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 1, 2);
+ anSmpLayout->addWidget(myAttractorGroup, SMP_ATT_GROUP, 1, 1, 2);
+ anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
+ anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
+ anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
+ anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
+ anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
+ anSmpLayout->addWidget(myDistanceGroup, SMP_DIST_GROUP, 1, 1, 2);
+ aDistLayout->addWidget(mySmpDistLabel, SMP_DIST, 1, 1, 1);
+ aDistLayout->addWidget(mySmpDistSpin, SMP_DIST, 2, 1, 1);
+ anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 2);
+ anSmpLayout->addWidget(removeMapButton, SMP_REMOVE_BTN, 1, 1, 2);
+
// Enforced vertices parameters
tab->setCurrentIndex( STD_TAB );
// ---
- connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
- connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
- connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
- connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
- connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
-
- connect( addSurfaceButton, SIGNAL( clicked()), this, SLOT( onAddMapOnSurface() ) );
- connect( addEdgeButton, SIGNAL( clicked()), this, SLOT( onAddMapOnEdge() ) );
- connect( addPointButton, SIGNAL( clicked()), this, SLOT( onAddMapOnPoint() ) );
- connect( removeButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
- connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
-
- connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
- connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
- connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
- connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
- connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
- connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
-// connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
-// connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
+ connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
+ connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
+ connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
+ connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
+ connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
+ // Size Maps
+ connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
+ connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
+ connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
+ connect( mySizeMapTable, SIGNAL( itemClicked (QTableWidgetItem *)),this, SLOT( onItemClicked(QTableWidgetItem *) ) );
+ connect( myGeomSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
+ connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
+
+ // Enforced vertices
+ connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
+ connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
+ connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
+ connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
+ connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
+ connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
return fr;
}
myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
// Sizemaps
-// MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
+ MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
QMapIterator<QString, QString> i(that->mySMPMap);
GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
while (i.hasNext()) {
i.next();
const QString entry = i.key();
- string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
+ string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
const QString sizeMap = i.value();
int row = mySizeMapTable->rowCount();
mySizeMapTable->setRowCount( row+1 );
mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 );
mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) );
mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 );
- mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) );
- mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |
+ if (that->myATTMap.contains(entry)){
+ const QString attEntry = that->myATTMap[entry];
+ MESSAGE("attEntry = "<<attEntry.toStdString())
+ std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
+ MESSAGE("attName = "<<attName)
+ mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( QString::fromStdString("Attractor :" + attName) ) );
+ mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |
+ Qt::ItemIsEnabled );
+ }
+ else
+ {
+ mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) );
+ mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |
Qt::ItemIsEditable |
Qt::ItemIsEnabled );
}
+ mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( QString::number( that->myDistMap[entry], 'g', 6) ) );
+ mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( 0 );
+ }
mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
that->myOptions = h->GetOptionValues();
that->mySMPMap.clear();
+ that->myATTMap.clear();
+ that->myAttDistMap.clear();
+ that->myDistMap.clear();
// classic size maps
BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
}
}
+ // attractor new version
+ MESSAGE("retriveParams, Attractors")
+ BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
+ for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
+ BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
+ 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->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
+ that->myATTMap[faceEntry] = attEntry;
+ that->myAttDistMap[faceEntry] = infDist;
+ that->myDistMap[faceEntry] = constDist;
+ }
+
// Enforced vertices
h_data.coordsList.clear();
h_data.entryCoordsListMap.clear();
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
QMapIterator<QString,QString> i(that->mySMPMap);
+ // QMapIterator<QString,QString> att_it(that->myATTMap);
+ // QMapIterator<QString,QString> inf_dist_it(that->myAttDistMap);
+ // QMapIterator<QString,QString> const_dist_it(that->myDistMap)
// Iterate over each size map
while (i.hasNext()) {
i.next();
const QString sizeMap = i.value();
if (sizeMap == "__TO_DELETE__") {
-// MESSAGE("Delete entry " << entry.toStdString() << " from engine");
+ MESSAGE("Delete entry " << entry.toStdString() << " from engine");
h->UnsetEntry(entry.toLatin1().constData());
}
else if (sizeMap.startsWith("ATTRACTOR")) {
// h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
}
else {
- QString fullSizeMap;
- fullSizeMap = QString("");
- if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
- fullSizeMap = QString("def f(u,v): return ") + sizeMap;
- else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
- fullSizeMap = QString("def f(t): return ") + sizeMap;
- else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
- fullSizeMap = QString("def f(): return ") + sizeMap;
-
-// MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
- h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
+ // TODO coder le stockage des parametres ici dans l'idee de ce qui est fait en dessous
+ if (!myATTMap[entry].isEmpty()){
+ QString att_entry = myATTMap[entry];
+ double infDist = myAttDistMap[entry];
+ double constDist = myDistMap[entry];
+ double phySize = h->GetPhySize();
+ //double const_dist = myDistMap[entry];
+ h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
+ }
+// else if( myAttDistMap[entry] > 1e-12) {
+// h->SetConstantSizeOnAdjacentFaces(att_entry.toLatin1().constData(), conversion en double (sizeMap), endSize = user_size, const_dist )
+// }
+ else {
+ QString fullSizeMap;
+ fullSizeMap = QString("");
+ if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
+ fullSizeMap = QString("def f(u,v): return ") + sizeMap;
+ else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
+ fullSizeMap = QString("def f(t): return ") + sizeMap;
+ else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
+ fullSizeMap = QString("def f(): return ") + sizeMap;
+
+ // MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
+ h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
+ }
}
}
// *** BEGIN SIZE MAP ***
// **********************
+void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
+{
+ if ( myGeomSelWdg->IsObjectSelected() ){
+ mySMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
+ TopAbs_ShapeEnum myShapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( mySMapObject ).ShapeType();
+ if ( myShapeType == TopAbs_FACE ){
+ myAttractorGroup->setEnabled(true);
+ if (!myAttractorGroup->isChecked()){
+ myDistanceGroup->setEnabled(false);
+ }
+ }
+ else
+ {
+ myAttractorGroup->setEnabled(false);
+ myAttractorGroup->setChecked(false);
+ myDistanceGroup->setEnabled(true);
+ }
+ }
+
+}
+
+void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){
+ if (checked){
+ myDistanceGroup->setEnabled(true);
+ }
+ else{
+ myDistanceGroup->setEnabled(false);
+ }
+}
+
void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
{
that->mySMPMap[entry] = "__TO_DELETE__";
if (that->mySMPShapeTypeMap.contains(entry))
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);
mySizeMapTable->removeRow(row );
}
mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
}
+CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
+{
+ SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
+ CORBA::Object_var obj;
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
+ if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ CORBA::String_var aVal = anIOR->Value();
+ obj = myStudy->ConvertIORToObject(aVal);
+ }
+ return obj;
+}
+
+void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item)
+{
+ int row = item->row();
+ int col = item->column();
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::onCellClicked("<<row<<", "<<col<<")")
+ BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+ if (col == SMP_SIZEMAP_COLUMN){
+ QString entry = that->mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text();
+ QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed();
+
+ if (sizeMap.startsWith("Attractor :")){
+ myAttractorGroup->setChecked( true );
+ myDistanceGroup->setChecked( true );
+ double phySize = that->mySMPMap[entry].toDouble();
+ double infDist = that->myAttDistMap[entry];
+ QString attEntry = that->myATTMap[entry];
+ CORBA::Object_var attObj = entryToObject(attEntry);
+
+ myAttSelWdg->SetObject(attObj);
+ myAttSizeSpin->setValue(phySize);
+ myAttDistSpin->setValue(infDist);
+ }
+ else {
+ myAttractorGroup->setChecked( false );
+ }
+ CORBA::Object_var obj = entryToObject(entry);
+ double constDist = that->myDistMap[entry];
+
+ myGeomSelWdg->SetObject(obj);
+ mySmpDistSpin->setValue(constDist);
+ }
+}
+
void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col)
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< row << "," << col << ")");
+ MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
if (col == SMP_SIZEMAP_COLUMN) {
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
QString entry = that->mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text();
if (! that->mySMPShapeTypeMap.contains(entry))
return;
if (that->mySMPMap.contains(entry))
- if (that->mySMPMap[entry] == sizeMap)
+ if (that->mySMPMap[entry] == sizeMap || sizeMap.startsWith("Attractor :")){
return;
- QColor* bgColor = new QColor("white");
- QColor* fgColor = new QColor("black");
+ }
+// QColor* bgColor = new QColor("white");
+// QColor* fgColor = new QColor("black");
+
if (! sizeMap.isEmpty()) {
that->mySMPMap[entry] = sizeMap;
- if (! sizeMapValidationFromRow(row)) {
- bgColor->setRgb(255,0,0);
- fgColor->setRgb(255,255,255);
- }
+ sizeMapValidationFromRow(row);
+// if (! sizeMapValidationFromRow(row)) {
+// bgColor->setRgb(255,0,0);
+// fgColor->setRgb(255,255,255);
+// }
}
else {
-// MESSAGE("Size map empty: reverse to precedent value" );
+ MESSAGE("Size map empty: reverse to precedent value" );
+ }
+ if (sizeMap.isEmpty()) {
that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setText(that->mySMPMap[entry]);
}
- that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor));
- that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setBackground(QBrush(*bgColor));
- that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setForeground(QBrush(*fgColor));
- that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setForeground(QBrush(*fgColor));
+// that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor));
+// that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setBackground(QBrush(*bgColor));
+// that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setForeground(QBrush(*fgColor));
+// that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setForeground(QBrush(*fgColor));
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
}
}
-void BLSURFPluginGUI_HypothesisCreator::onAddMapOnSurface()
+void BLSURFPluginGUI_HypothesisCreator::onAddMap()
{
- insertElementType(TopAbs_FACE);
+ if ( myGeomSelWdg->IsObjectSelected() ){
+ mySMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
+ if ( myAttractorGroup->isChecked() ){
+ if ( myAttSelWdg->IsObjectSelected() ){
+ myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
+ insertAttractor(mySMapObject, myAttObject);
+ }
+ }
+ else {
+ insertElement(mySMapObject);
+ }
+ BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+ that->getGeomSelectionTool()->selectionMgr()->clearFilters();
+ myGeomSelWdg->deactivateSelection();
+ myAttSizeSpin->clear();
+ myAttDistSpin->clear();
+ }
}
-void BLSURFPluginGUI_HypothesisCreator::onAddMapOnEdge()
+void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject)
{
- insertElementType(TopAbs_EDGE);
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
+ BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
+ BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
+
+ BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+ TopAbs_ShapeEnum shapeType;
+ string entry, shapeName;
+ entry = (string) anObject->GetStudyEntry();
+ MESSAGE("entry = "<<entry);
+ shapeName = anObject->GetName();
+ shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
+ mySizeMapTable->setFocus();
+ QString shapeEntry;
+ shapeEntry = QString::fromStdString(entry);
+ double phySize = h->GetPhySize();
+ std::ostringstream oss;
+ oss << phySize;
+ QString sizeMap;
+ sizeMap = QString::fromStdString(oss.str());
+ if (that->mySMPMap.contains(shapeEntry)) {
+ if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
+// MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
+ return;
+ }
+ }
+ that->mySMPMap[shapeEntry] = sizeMap;
+ that->myDistMap[shapeEntry] = 0. ;
+ that->mySMPShapeTypeMap[shapeEntry] = shapeType;
+ int row = mySizeMapTable->rowCount();
+ mySizeMapTable->setRowCount( row + 1 );
+ mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( shapeEntry ) );
+ mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 );
+ mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) );
+ mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 );
+ mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) );
+ mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
+ mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( ) );
+ mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( 0 );
+ mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
+ mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
+ mySizeMapTable->resizeColumnToContents( SMP_DIST_COLUMN );
+ mySizeMapTable->clearSelection();
+ mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) );
+
+ if ( myPhysicalMesh->currentIndex() != SizeMap ) {
+ myPhysicalMesh->setCurrentIndex( SizeMap );
+ onPhysicalMeshChanged();
+ }
}
-void BLSURFPluginGUI_HypothesisCreator::onAddMapOnPoint()
-{
- insertElementType(TopAbs_VERTEX);
+int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
+ QString entryForChecking;
+ int endRow = mySizeMapTable->rowCount()-1;
+ int row = 0;
+ entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text();
+ while (entry != entryForChecking && row <= endRow){
+ row++;
+ entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text();
+ }
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)
+ return row;
}
-void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeShapeAsked)
+void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor)
{
-// MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElementType()");
-
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
- GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
-
- LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr();
TopAbs_ShapeEnum shapeType;
- string entry, shapeName;
- SALOME_ListIO ListSelectedObjects;
- mySel->selectedObjects(ListSelectedObjects, NULL, false );
- if (!ListSelectedObjects.IsEmpty())
- {
- SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
- for (; Object_It.More(); Object_It.Next())
- {
- Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
- entry = myGeomToolSelected->getEntryOfObject(anObject);
- shapeName = anObject->getName();
- shapeType = myGeomToolSelected->entryToShapeType(entry);
-// MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType);
- if (shapeType == typeShapeAsked)
- {
- mySizeMapTable->setFocus();
- QString shapeEntry;
- shapeEntry = QString::fromStdString(entry);
- double phySize = h->GetPhySize();
- std::ostringstream oss;
- oss << phySize;
- QString sizeMap;
- sizeMap = QString::fromStdString(oss.str());
- if (that->mySMPMap.contains(shapeEntry)) {
- if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
-// MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
- break;
- }
- }
- that->mySMPMap[shapeEntry] = sizeMap;
- that->mySMPShapeTypeMap[shapeEntry] = typeShapeAsked;
- int row = mySizeMapTable->rowCount() ;
- mySizeMapTable->setRowCount( row+1 );
- mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( shapeEntry ) );
- mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 );
- mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) );
- mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 );
- mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) );
- mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
- mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
- mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
- mySizeMapTable->clearSelection();
- mySizeMapTable->scrollToItem( mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN ) );
-
- if ( myPhysicalMesh->currentIndex() != SizeMap ) {
- myPhysicalMesh->setCurrentIndex( SizeMap );
- onPhysicalMeshChanged();
- }
- }
- }
+ string entry, attEntry, faceName, attName;
+ entry = (string) aFace->GetStudyEntry();
+ attEntry = (string) anAttractor->GetStudyEntry();
+ faceName = aFace->GetName();
+ attName = anAttractor->GetName();
+ shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
+ mySizeMapTable->setFocus();
+ QString shapeEntry = QString::fromStdString(entry);
+ QString qAttEntry = QString::fromStdString(attEntry);
+
+ //double phySize = h->GetPhySize();
+ double phySize = myAttSizeSpin->value();
+ double infDist = myAttDistSpin->value();
+ double constDist = 0. ;
+ if (myDistanceGroup->isChecked()){
+ constDist = mySmpDistSpin->value();
+ }
+ std::ostringstream oss;
+ std::ostringstream oss2;
+ std::ostringstream oss3;
+ oss << phySize;
+ oss2 << infDist;
+ oss3 << constDist;
+ QString sizeMap = QString::fromStdString(oss.str());
+ QString infDistString = QString::fromStdString(oss2.str());
+ QString constDistString = QString::fromStdString(oss3.str());
+
+ int row = mySizeMapTable->rowCount();
+ int rowToChange;
+ if (!that->mySMPMap.contains(shapeEntry)) {
+ mySizeMapTable->setRowCount( row + 1 );
+ mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( ) );
+ mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 );
+ mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( ) );
+ mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 );
+ mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( ) );
+ mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
+ mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( ) );
+ mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled);
+ rowToChange = row;
+ }
+ // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
+// // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
+// return;
+// }
+ else {
+ rowToChange = findRowFromEntry(shapeEntry);
+ MESSAGE("rowToChange = "<<rowToChange)
+ }
+ 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);
+ mySizeMapTable->item( rowToChange, SMP_ENTRY_COLUMN )->setText(shapeEntry);
+ mySizeMapTable->item( rowToChange, SMP_NAME_COLUMN )->setText( QString::fromStdString(faceName));
+ mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setText(QString::fromStdString("Attractor : "+attName));
+ mySizeMapTable->item( rowToChange, SMP_DIST_COLUMN )->setText(constDistString );
+ mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
+ mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
+ mySizeMapTable->resizeColumnToContents( SMP_DIST_COLUMN );
+ mySizeMapTable->clearSelection();
+ mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) );
+
+ if ( myPhysicalMesh->currentIndex() != SizeMap ) {
+ myPhysicalMesh->setCurrentIndex( SizeMap );
+ onPhysicalMeshChanged();
}
+ MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
}
bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
{
-// MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
int row = 0, nbRows = mySizeMapTable->rowCount();
for ( ; row < nbRows; ++row )
if (! sizeMapValidationFromRow(row))
bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
{
-// MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow()");
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
QString myEntry = mySizeMapTable->item( myRow, SMP_ENTRY_COLUMN )->text();
bool res = sizeMapValidationFromEntry(myEntry,displayError);
mySizeMapTable->setFocus();