myGeomGroupBtn->setEnabled(false);
myGeomGroupLine->setEnabled(false);
}
-
-
- /* Move widget on the botton right corner of main widget */
- int x, y ;
- mySMESHGUI->DefineDlgPosition(this, x, y);
- this->move(x, y);
}
//=================================================================================
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
- SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl)
+ SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySMESHGUI( theModule ),
myCurrentLineEdit = myMeshGroupLine;
setSelectionMode(5);
}
-
- /* Move widget on the botton right corner of main widget */
- int x, y ;
- mySMESHGUI->DefineDlgPosition(this, x, y);
- this->move(x, y);
}
//=================================================================================
myGroupLine = new QLineEdit(aSelectBox, "group line");
myGroupLine->setReadOnly(true);
onSelectGroup(false);
-
+
/***************************************************************/
QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
wg1Layout->addWidget(aContentBox, 0, 0);
myGeomGroupLine->setReadOnly(true); //VSR ???
onSelectGeomGroup(false);
+ if (!create)
+ {
+ myGeomGroupBtn->setEnabled(false);
+ myGeomGroupLine->setEnabled(false);
+ }
+
/***************************************************************/
QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
wg2Layout->addWidget(geomObject, 0, 0);
myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
/***************************************************************/
+ QGroupBox* aColorBox = new QGroupBox(this, "color box");
+ aColorBox->setTitle(tr("SMESH_SET_COLOR"));
+
+ mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
+ mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
+ mySelectColorGroup->setMinimumSize(50, 0);
+
+ myColorGroupLine = new QLineEdit(aColorBox, "color line");
+ myColorGroupLine->setReadOnly(false);
+ onSelectColorGroup(false);
+
+ /***************************************************************/
+ QHBoxLayout* aColorLayout = new QHBoxLayout(aColorBox, 15, 20);
+ aColorLayout->setAutoAdd(false);
+
+ aColorLayout->addWidget(mySelectColorGroup);
+ aColorLayout->addWidget(myColorGroupLine);
+
+ /***************************************************************/
+
QFrame* aButtons = new QFrame(this, "button box");
aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
aMainLayout->setRowStretch( 5, 5 );
- aMainLayout->addMultiCellWidget(aButtons, 6, 6, 0, 2);
+ aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
+ aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
/* signals and slots connections */
connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
-
+ connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
+ connect(myColorGroupLine, SIGNAL(textChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&)));
+
connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
/* init data from current selection */
myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
myGroup = SMESH::SMESH_Group::_nil();
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
myActor = SMESH::FindActorByObject(myMesh);
SMESH::SetPickable(myActor);
// function : Init()
// purpose :
//=================================================================================
-void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup)
+void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
{
myMesh = theGroup->GetMesh();
- myGroup = SMESH::SMESH_Group::_duplicate(theGroup);
- myActor = SMESH::FindActorByObject(myMesh);
- if ( !myActor )
- myActor = SMESH::FindActorByObject(myGroup);
- SMESH::SetPickable(myActor);
+ myName->setText(theGroup->GetName());
+ myName->home(false);
+
+ myColorGroupLine->setText(QString::number(theGroup->GetColorNumber()));
+ myColorGroupLine->home(false);
+
+ myMeshGroupLine->setText(theGroup->GetName());
int aType = 0;
switch(theGroup->GetType()) {
case SMESH::FACE: aType = 2; break;
case SMESH::VOLUME: aType = 3; break;
}
+ myTypeGroup->setButton(aType);
+
+ myGroup = SMESH::SMESH_Group::_narrow( theGroup );
- myName->setText(myGroup->GetName());
- myName->home(false);
- myMeshGroupLine->setText(myGroup->GetName());
+ if ( !myGroup->_is_nil() )
+ {
+ myGrpTypeGroup->setButton(0);
+ onGrpTypeChanged(0);
- myCurrentLineEdit = 0;
- myTypeGroup->setButton(aType);
- myElements->clear();
- setSelectionMode(aType);
- myTypeId = aType;
-
- myIdList.clear();
- if (!theGroup->IsEmpty()) {
- SMESH::long_array_var anElements = myGroup->GetListOfID();
- int k = anElements->length();
- for (int i = 0; i < k; i++) {
- myIdList.append(anElements[i]);
- myElements->insertItem(QString::number(anElements[i]));
+ myActor = SMESH::FindActorByObject(myMesh);
+ if ( !myActor )
+ myActor = SMESH::FindActorByObject(myGroup);
+ SMESH::SetPickable(myActor);
+
+ myCurrentLineEdit = 0;
+ myElements->clear();
+ setSelectionMode(aType);
+ myTypeId = aType;
+
+ myIdList.clear();
+ if (!myGroup->IsEmpty()) {
+ SMESH::long_array_var anElements = myGroup->GetListOfID();
+ int k = anElements->length();
+ for (int i = 0; i < k; i++) {
+ myIdList.append(anElements[i]);
+ myElements->insertItem(QString::number(anElements[i]));
+ }
+ myElements->selectAll(true);
+ }
+ }
+ else
+ {
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
+
+ if ( !myGroupOnGeom->_is_nil() )
+ {
+ myGrpTypeGroup->setButton(1);
+ onGrpTypeChanged(1);
+
+ myActor = SMESH::FindActorByObject(myMesh);
+ if ( !myActor )
+ myActor = SMESH::FindActorByObject(myGroup);
+ SMESH::SetPickable(myActor);
+
+ QString aShapeName("");
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
+ if (!aGroupShape->_is_nil())
+ {
+ _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
+ aShapeName = aGroupShapeSO->GetName().c_str();
+ }
+ myGeomGroupLine->setText( aShapeName );
+ }
}
- myElements->selectAll(true);
- }
}
//=================================================================================
if (myGrpTypeId == 0)
enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
else if (myGrpTypeId == 1)
- enable = !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup );
+ {
+ bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
+ enable = !myName->text().stripWhiteSpace().isEmpty() && (!CORBA::is_nil( myGeomGroup ) || isEditMode);
+ }
QPushButton* aBtn;
aBtn = (QPushButton*) child("ok", "QPushButton");
if (aBtn) aBtn->setEnabled(enable);
updateButtons();
}
+//=================================================================================
+// function : onNbColorsChanged()
+// purpose :
+//=================================================================================
+void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text)
+{
+ updateButtons();
+}
+
//=================================================================================
// function : onTypeChanged()
// purpose : Group elements type radio button management
myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
myGroup->Add(anIdList.inout());
-
+
+ int aColorNumber = myColorGroupLine->text().toInt();
+ myGroup->SetColorNumber(aColorNumber);
+
+ _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
+
+ SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
+
+ SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
+
/* init for next operation */
myName->setText("");
+ myColorGroupLine->setText("");
myElements->clear();
myGroup = SMESH::SMESH_Group::_nil();
} else {
myGroup->SetName(myName->text());
+
+ int aColorNumber = myColorGroupLine->text().toInt();
+ myGroup->SetColorNumber(aColorNumber);
QValueList<int> aAddList;
QValueList<int>::iterator anIt;
return true;
} else if (myGrpTypeId == 1 &&
!myName->text().stripWhiteSpace().isEmpty() &&
- !CORBA::is_nil(myGeomGroup))
+ (!CORBA::is_nil(myGeomGroup) || !CORBA::is_nil(myGroupOnGeom)))
{
- SMESH::ElementType aType = SMESH::ALL;
- switch (myTypeId) {
- case 0: aType = SMESH::NODE; break;
- case 1: aType = SMESH::EDGE; break;
- case 2: aType = SMESH::FACE; break;
- case 3: aType = SMESH::VOLUME; break;
+ if (myGroupOnGeom->_is_nil()) {
+ SMESH::ElementType aType = SMESH::ALL;
+ switch (myTypeId) {
+ case 0: aType = SMESH::NODE; break;
+ case 1: aType = SMESH::EDGE; break;
+ case 2: aType = SMESH::FACE; break;
+ case 3: aType = SMESH::VOLUME; break;
+ }
+
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ GEOM::GEOM_IGroupOperations_var aGroupOp =
+ SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
+
+ myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
+
+ int aColorNumber = myColorGroupLine->text().toInt();
+ myGroupOnGeom->SetColorNumber(aColorNumber);
+
+ _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
+
+ SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
+
+ SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
+
+ /* init for next operation */
+ myName->setText("");
+ myColorGroupLine->setText("");
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
}
-
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- GEOM::GEOM_IGroupOperations_var aGroupOp =
- SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
-
- SMESH::SMESH_GroupOnGeom_var aGroupOnGeom =
- myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
-
+ else
+ {
+ myGroupOnGeom->SetName(myName->text());
+
+ int aColorNumber = myColorGroupLine->text().toInt();
+ myGroupOnGeom->SetColorNumber(aColorNumber);
+ }
+
mySMESHGUI->updateObjBrowser(true);
mySelectionMgr->clearSelected();
- /* init for next operation */
- myName->setText("");
return true;
}
-
+
return false;
}
myGeomGroupLine->setEnabled(true);
updateButtons();
} else {
- SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO);
+ SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
if (aGroup->_is_nil())
{
myIsBusy = false;
if (!myActor) {
if (!myGroup->_is_nil())
myActor = SMESH::FindActorByObject(myGroup);
+ else if(!myGroupOnGeom->_is_nil())
+ myActor = SMESH::FindActorByObject(myGroupOnGeom);
else
myActor = SMESH::FindActorByObject(myMesh);
}
}
}
+//=================================================================================
+// function : (onSelectColorGroup)
+// purpose : Called when setting a color on group
+//=================================================================================
+void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
+{
+ if (on) {
+ setSelectionMode(7);
+ }
+ else {
+ myColorGroupLine->setText("");
+ myCurrentLineEdit = 0;
+ if (myTypeId != -1)
+ setSelectionMode(myTypeId);
+ }
+ myColorGroupLine->setEnabled(on);
+}
//=================================================================================
// function : setCurrentSelection()