QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
// Table
mySizeMapTable = new QTreeWidget( mySmpGroup );
- mySizeMapTable ->setMinimumWidth(300);
+ mySizeMapTable ->setMinimumWidth(250);
// tab widget
smpTab = new QTabWidget( mySmpGroup );
smpTab->setTabShape( QTabWidget::Rounded );
removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
+ modifyMapButton->setEnabled(false);
// Attractor GroupBox
//myAttractorGroup = new QGroupBox(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup);
myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myParamsGroup);
myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myParamsGroup, /*multiSel=*/false,/*stretch=*/false);
myAttSelWdg->SetDefaultText("Select the attractor", "QLineEdit { color: grey }");
+
myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
+ myGeomSelWdg1->AvoidSimultaneousSelection(myGeomSelWdg2);
// Initialization of widgets
// myAttDistSpin->hide();
connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
- connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
+ 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( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
- connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this,SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
-// connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
+ 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( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
- connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
+ connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
+ connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onSmpTabChanged( int ) ) );
// Enforced vertices
connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
// *** BEGIN SIZE MAP ***
// **********************
-// void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
-// {
-// if ( myGeomSelWdg2->IsObjectSelected() ){
-// mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
-// TopAbs_ShapeEnum myShapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( mySMapObject ).ShapeType();
-// if ( myShapeType == TopAbs_FACE ){
-// smpTab->setTabEnabled(ATT_TAB,true);
-// // if (!myAttractorGroup->isChecked()){
-// myDistanceGroup->setEnabled(false);
-// // myDistanceGroup->setChecked(false);
-// // }
-// }
-// else
-// {
-// smpTab->setTabEnabled(ATT_TAB,false);
-// // myAttractorGroup->setEnabled(false);
-// // myAttractorGroup->setChecked(false);
-// myDistanceGroup->setEnabled(true);
-// }
-// }
-//
-// } NOTE inutile pour l'instant à supprimer si toujours pas utile
+void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
+{
+ BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+ 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);
+ }
+
+}
// void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){
// // QObjectList grpChildren = myAttractorGroup->children();
void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
{
-
MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
if (col == SMP_SIZEMAP_COLUMN){
QString 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);
- myGeomSelWdg2->SetObject(obj);
- if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){
- smpTab->setCurrentIndex(ATT_TAB);
- double phySize = that->mySMPMap[entry].toDouble();
+ 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);
+ myGeomSelWdg2->SetObject(obj);
myAttSelWdg->SetObject(attObj);
myAttSizeSpin->setValue(phySize);
if (sizeMap.startsWith("Attractor")){
myAttDistSpin->setValue(infDist);
myAttractorCheck->setChecked(true);
}
+ else {
+ myAttractorCheck->setChecked(false);
+ }
if (sizeMap.startsWith("Constant") || constDist > 1e-12 ){
myAttDistSpin2->setValue(constDist);
myConstSizeCheck->setChecked(true);
}
+ else{
+ myConstSizeCheck->setChecked(false);
+ }
}
- else {
- smpTab->setCurrentIndex(SMP_STD_TAB);
+ 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());
// myAttractorGroup->setChecked( false );
}
}
- }
+ }
+}
+
+void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
+{
+ myAttDistSpin->setValue(0.); // Reinitialize widgets
+ myAttSizeSpin->setValue(0.);
+ myAttDistSpin2->setValue(0.);
+ mySmpSizeSpin->setValue(0.);
+ myGeomSelWdg1->deactivateSelection();
+ myGeomSelWdg2->deactivateSelection();
+ myAttSelWdg->deactivateSelection();
+ myGeomSelWdg1->SetObject(CORBA::Object::_nil());
+ myGeomSelWdg2->SetObject(CORBA::Object::_nil());
+ myAttSelWdg->SetObject(CORBA::Object::_nil());
+ myAttractorCheck->setChecked(false);
+ myConstSizeCheck->setChecked(false);
}
void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
return;
if (that->mySMPMap.contains(entry))
if (that->mySMPMap[entry] == sizeMap
- || sizeMap.startsWith("Attractor :")
- || sizeMap.startsWith("Const.") ){
+ || sizeMap.startsWith("Attractor")
+ || sizeMap.startsWith("Constant") ){
return;
}
// QColor* bgColor = new QColor("white");
if (! sizeMap.isEmpty()) {
that->mySMPMap[entry] = sizeMap;
- // sizeMapValidationFromRow(row); // TODO utiliser sizempavalidationfromitem
+ sizeMapValidationFromEntry(entry);
// if (! sizeMapValidationFromRow(row)) {
// bgColor->setRgb(255,0,0);
// fgColor->setRgb(255,255,255);
}
else {
MESSAGE("Size map empty: reverse to precedent value" );
- }
- if (sizeMap.isEmpty()) {
item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
}
// that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor));
myAttDistSpin->setValue(0.);
myAttSizeSpin->setValue(0.);
myAttDistSpin2->setValue(0.);
+ mySmpSizeSpin->setValue(0.);
myGeomSelWdg1->deactivateSelection();
myGeomSelWdg2->deactivateSelection();
myAttSelWdg->deactivateSelection();
+ myGeomSelWdg1->SetObject(CORBA::Object::_nil());
+ myGeomSelWdg2->SetObject(CORBA::Object::_nil());
+ myAttSelWdg->SetObject(CORBA::Object::_nil());
// mySmpDistSpin->setValue(0.);
// mySmpSizeSpin->setValue(0.);
}
myAttDistSpin->setValue(0.);
myAttSizeSpin->setValue(0.);
myAttDistSpin2->setValue(0.);
+ mySmpSizeSpin->setValue(0.);
myGeomSelWdg1->deactivateSelection();
myGeomSelWdg2->deactivateSelection();
myAttSelWdg->deactivateSelection();
+ myGeomSelWdg1->SetObject(CORBA::Object::_nil());
+ myGeomSelWdg2->SetObject(CORBA::Object::_nil());
+ myAttSelWdg->SetObject(CORBA::Object::_nil());
}
void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
QTreeWidgetItem* item = new QTreeWidgetItem();
if (modify){
int rowToChange = findRowFromEntry(shapeEntry);
- item = mySizeMapTable->takeTopLevelItem( rowToChange );
+ item = mySizeMapTable->topLevelItem( rowToChange );
}
else{
if (that->mySMPMap.contains(shapeEntry)) {
item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
- mySizeMapTable->addTopLevelItem(item);
-
mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
+ mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
+ mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
mySizeMapTable->clearSelection();
// mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) ); //TODO voir si cette option est utile