X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_CreatePolyhedralVolumeDlg.cxx;h=7b0da5d8320d741de92edb224dbaae4684c1c1d9;hp=3a572c897d9f2eca6766a8fde1fab83816b57e94;hb=c63ee099ad2b149bd70136839c973e8910137bc5;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx index 3a572c897..7b0da5d83 100644 --- a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -39,15 +39,16 @@ #include "SMESH_TypeFilter.hxx" #include "SMDS_Mesh.hxx" -#include "VTKViewer_ViewWindow.h" - #include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" #include "SalomeApp_Application.h" #include "SalomeApp_Study.h" #include "SUIT_Desktop.h" #include "SUIT_MessageBox.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_Application.h" +#include "LightApp_SelectionMgr.h" #include "utilities.h" #include "SVTK_ViewWindow.h" @@ -64,6 +65,7 @@ #include #include #include +#include // QT Includes #include @@ -111,26 +113,21 @@ class TPolySimulation{ myPreviewActor->PickableOff(); myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper( myMapper ); + myPreviewActor->SetRepresentation( 3 ); + vtkFloatingPointType anRGB[3]; vtkProperty* aProp = vtkProperty::New(); - float anRGB[3]; - anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + GetColor( "SMESH", "selection_element_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreviewActor->SetProperty( aProp ); + vtkFloatingPointType aFactor,aUnits; + myPreviewActor->SetResolveCoincidentTopology(true); + myPreviewActor->GetPolygonOffsetParameters(aFactor,aUnits); + myPreviewActor->SetPolygonOffsetParameters(aFactor,0.2*aUnits); aProp->Delete(); - vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; - aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetBackfaceProperty( aBackProp ); - aBackProp->Delete(); - myViewWindow->AddActor( myPreviewActor ); - + } @@ -143,7 +140,7 @@ class TPolySimulation{ vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); myGrid->SetPoints(aGrid->GetPoints()); - if (theReset) ResetGrid(theReset); + ResetGrid(theReset); vtkIdList *anIds = vtkIdList::New(); @@ -151,11 +148,15 @@ class TPolySimulation{ anIds->InsertId(i,theIds[i]); myGrid->InsertNextCell(theType,anIds); + if(theIds.size()!=0){ + myGrid->InsertNextCell(theType,anIds); + myGrid->Modified(); + } + anIds->Delete(); - myGrid->Modified(); - SetVisibility(true); + } void ResetGrid(bool theReset=true){ @@ -191,11 +192,9 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI bool modal, WFlags fl ) : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0( SMESHGUI::resourceMgr()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH",tr("ICON_SELECT"))); if ( !name ) setName( "SMESHGUI_CreatePolyhedralVolumeDlg" ); @@ -253,6 +252,11 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI buttonOk->setAutoDefault( TRUE ); buttonOk->setDefault( TRUE ); GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonHelp = new QPushButton(GroupButtons, "buttonHelp"); + buttonHelp->setText(tr("SMESH_BUT_HELP" )); + buttonHelp->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonHelp, 0, 4); + SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupButtons, 2, 0 ); /***************************************************************/ @@ -310,6 +314,8 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI Preview = new QCheckBox( GroupContent, "Preview" ); Preview->setText( tr( "SMESH_POLYEDRE_PREVIEW" ) ); GroupContentLayout->addWidget( Preview , 5, 0 ); + + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupContent, 1, 0 ); @@ -317,6 +323,8 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI RadioButton1->setChecked( TRUE ); mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_polyhedrons?"; Init(); } @@ -350,6 +358,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::Init() connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) ); connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ; connect(buttonApply, SIGNAL( clicked() ), SLOT(ClickOnApply() ) ); + connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp() ) ); connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); connect(SelectElementsButton, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ; @@ -365,10 +374,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::Init() /* to close dialog if study change */ connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; this->show() ; /* displays Dialog */ ConstructorsClicked(0); @@ -382,8 +387,10 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::Init() //================================================================================= void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) { - disconnect(mySelectionMgr, 0, this, 0); + //disconnect(mySelectionMgr, 0, this, 0); + SALOME_ListIO io; + mySelectionMgr->selectedObjects( io ); SALOME_ListIO aList; mySelectionMgr->setSelectedObjects( aList ); myEditCurrentArgument->clear(); @@ -401,7 +408,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) } else SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); AddButton->setEnabled(false); RemoveButton->setEnabled(false); @@ -416,8 +424,13 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) } case 1 : { - SMESH::SetPointRepresentation(false); - myViewWindow->SetSelectionMode(FaceSelection); + if( myActor ){ + myActor->SetPointRepresentation(false); + } else { + SMESH::SetPointRepresentation(false); + } + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); TextLabelIds->setText( tr( "SMESH_ID_FACES" ) ); myFacesByNodesLabel->hide(); @@ -429,7 +442,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) } } - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + mySelectionMgr->setSelectedObjects( io ); } //================================================================================= @@ -449,6 +463,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() { if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked()) { + if(checkEditLine(false) == -1) {return;} busy = true; if (GetConstructorId() == 0) { @@ -514,11 +529,14 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() } } - SALOME_ListIO aList; - mySelectionMgr->setSelectedObjects( aList ); - mySimulation->SetVisibility(false); + //SALOME_ListIO aList; + //mySelectionMgr->setSelectedObjects( aList ); SMESH::UpdateView(); - ConstructorsClicked( GetConstructorId() ); + if( myActor ){ + unsigned int anEntityMode = myActor->GetEntityMode(); + myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode); + } + //ConstructorsClicked( GetConstructorId() ); busy = false; } } @@ -529,6 +547,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() //================================================================================= void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnOk() { + if(checkEditLine(false) == -1) {return;} ClickOnApply() ; ClickOnCancel() ; } @@ -541,16 +560,34 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnOk() void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel() { mySelectionMgr->clearFilters(); - SALOME_ListIO aList; - mySelectionMgr->setSelectedObjects( aList ); + //SALOME_ListIO aList; + //mySelectionMgr->setSelectedObjects( aList ); SMESH::SetPointRepresentation(false); mySimulation->SetVisibility(false); - myViewWindow->SetSelectionMode( ActorSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( ActorSelection ); disconnect( mySelectionMgr, 0, this, 0 ); mySMESHGUI->ResetState() ; reject() ; } +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName), + QObject::tr("BUT_OK")); + } +} + //======================================================================= //function : onTextChange //purpose : @@ -559,6 +596,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel() void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) { if ( busy ) return; + if (checkEditLine() == -1) return; busy = true; mySimulation->SetVisibility(false); @@ -570,48 +608,30 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) if (GetConstructorId() == 0) { if ( aMesh ) { - SALOME_ListIO aList; aList.Append( myActor->getIO() ); - mySelectionMgr->setSelectedObjects( aList ); - - TColStd_IndexedMapOfInteger selectedIndices; TColStd_MapOfInteger newIndices; - mySelector->GetIndex( myActor->getIO(), selectedIndices); - + QStringList aListId = QStringList::split( " ", theNewText, false); for ( int i = 0; i < aListId.count(); i++ ) { const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); if ( n ) { - /*if ( mySelectionMgr->IsIndexSelected( myActor->getIO(), n->GetID() )) - allOk = false; - else - mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true);*/ - if (selectedIndices.Add(n->GetID())) - newIndices.Add(n->GetID()); + newIndices.Add(n->GetID()); myNbOkElements++; } } - - if (newIndices.Extent() > 0){ - mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); - } - -/* bool aNodesOK = false; - if (aListId.count() >= 3) - aNodesOK = true; - - allOk = (allOk && aNodesOK);*/ - + + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false ); + + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); + if ( myNbOkElements>0 && aListId.count()>=3) AddButton->setEnabled(true); - else - AddButton->setEnabled(false); - -// if (allOk && !myOkElements) - displaySimulation(); - } + else + AddButton->setEnabled(false); + + displaySimulation(); } - else if (GetConstructorId() == 1) + } else if (GetConstructorId() == 1) { myNbOkElements = 0; buttonOk->setEnabled( false ); @@ -620,33 +640,22 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) // check entered ids of faces and hilight them QStringList aListId; if ( aMesh ) { - SALOME_ListIO aList; aList.Append( myActor->getIO() ); - mySelectionMgr->setSelectedObjects( aList ); - - TColStd_IndexedMapOfInteger selectedIndices; TColStd_MapOfInteger newIndices; - mySelector->GetIndex( myActor->getIO(), selectedIndices); - + aListId = QStringList::split( " ", theNewText, false); for ( int i = 0; i < aListId.count(); i++ ) { const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); if ( e ) { - /*if ( mySelectionMgr->IsIndexSelected( myActor->getIO(), e->GetID() )) - myOkElements = false; - else - mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);*/ - if (selectedIndices.Add(e->GetID())) - newIndices.Add(e->GetID()); + newIndices.Add(e->GetID()); myNbOkElements++; } } - if (newIndices.Extent() > 0){ - mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); - } - + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); + if ( myNbOkElements ) { if (aListId.count()>1){ buttonOk->setEnabled( true ); @@ -656,7 +665,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) buttonOk->setEnabled( false ); buttonApply->setEnabled( false ); } - displaySimulation(); + if(aListId.count()>1) + displaySimulation(); } } } @@ -710,37 +720,120 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument() // get selected nodes/faces QString aString = ""; + int anbNodes=0,aNbFaces=0; switch(GetConstructorId()){ case 0:{ - int anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); if (anbNodes >= 3) AddButton->setEnabled(true); - else - break; + else if (anbNodes < 3){ + AddButton->setEnabled(false); + } busy = true; myEditCurrentArgument->setText( aString ); + if (checkEditLine() == -1) {busy = false;return;} busy = false; break; } case 1:{ // get selected faces - int aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); - if (aNbFaces<=1) - return; + aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + if (aNbFaces<=1){ + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } else { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } busy = true; myEditCurrentArgument->setText( aString ); + if (checkEditLine() == -1) {busy = false;return;} busy = false; // OK myNbOkElements = 1; - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); break; } default: return; } + if(anbNodes>2 || aNbFaces>1) + displaySimulation(); +} + +/*\brief int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine() + * Checking of indices in edit line. + * If incorecct indices in edit line warning message appear and myEditCurrentArgument remove last index. + * \retval 1 - if all ok(or no indices in edit line), -1 - if there are incorrect indices. + */ +int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine(bool checkLast) +{ + QString aString = ""; + SMDS_Mesh* aMesh = 0; - displaySimulation(); + if(myMesh->_is_nil()) return 1; + if(!myActor){ + myActor = SMESH::FindActorByObject(myMesh); + if(!myActor) + return 1; + } + + aMesh = myActor->GetObject()->GetMesh(); + + // checking for nodes + if (checkLast && myEditCurrentArgument->text().right(1) != QString(" ") ) return 1; + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text() ); + for ( int i = 0; i < aListId.count(); i++ ){ + switch (GetConstructorId()){ + case 0:{ // nodes + const SMDS_MeshNode * aNode = aMesh->FindNode( aListId[ i ].toInt() ); + if( !aNode ){ + std::string aWarning; + aWarning = "The incorrect indices of nodes!"; + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + QObject::tr("SMESH_POLYEDRE_CREATE_ERROR"), + QObject::tr(aWarning.c_str()), + QObject::tr("SMESH_BUT_OK")); + + myEditCurrentArgument->clear(); + myEditCurrentArgument->setText( aString ); + return -1; + } + + break; + } + case 1:{ // faces + bool aElemIsOK = true; + const SMDS_MeshElement * aElem = aMesh->FindElement( aListId[ i ].toInt() ); + if (!aElem) + { + aElemIsOK = false; + } + else + { + SMDSAbs_ElementType aType = aMesh->GetElementType( aElem->GetID(),true ); + if (aType != SMDSAbs_Face){ + aElemIsOK = false; + } + } + if (!aElemIsOK){ + std::string aWarning; + aWarning = "The incorrect indices of faces!"; + SUIT_MessageBox::warn1(SMESHGUI::desktop(), + QObject::tr("SMESH_POLYEDRE_CREATE_ERROR"), + QObject::tr(aWarning.c_str()), + QObject::tr("SMESH_BUT_OK")); + + myEditCurrentArgument->clear(); + myEditCurrentArgument->setText( aString ); + return -1; + } + break; + } + } + aString += aListId[ i ] + " "; + } + + return 1; } //======================================================================= @@ -753,9 +846,11 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation() { SMESH::TPolySimulation::TVTKIds aVTKIds; vtkIdType aType = VTK_CONVEX_POINT_SET ; - if (GetConstructorId() == 0){ - if(!Preview->isChecked()) myActor->SetEntityMode(SMESH_Actor::eFaces); - else myActor->SetEntityMode(SMESH_Actor::eVolumes); + SMDS_Mesh* aMesh = 0; + if ( myActor ){ + aMesh = myActor->GetObject()->GetMesh(); + } + if (GetConstructorId() == 0 && aMesh){ if (!AddButton->isEnabled()){ QListBoxItem* anItem; mySimulation->ResetGrid(true); @@ -763,6 +858,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation() QStringList anIds = QStringList::split(" ", anItem->text()); SMESH::TPolySimulation::TVTKIds aVTKIds_faces; for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){ + const SMDS_MeshNode * aNode = aMesh->FindNode( (*it).toInt() ); + if (!aNode) continue; vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ) ; aVTKIds.push_back(aId); aVTKIds_faces.push_back(aId); @@ -772,53 +869,49 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation() mySimulation->SetPosition(myActor, aType, aVTKIds_faces,false); } } + if(myFacesByNodes->count() == 0){ + mySimulation->SetVisibility(false); + } else { + mySimulation->SetVisibility(true); + } if(Preview->isChecked()){ mySimulation->SetPosition(myActor, aType, aVTKIds); } } else { // add ids from edit line QStringList anEditIds = QStringList::split( " ", myEditCurrentArgument->text(), false); - myActor->SetEntityMode(SMESH_Actor::eFaces); for ( int i = 0; i < anEditIds.count(); i++ ) aVTKIds.push_back( myActor->GetObject()->GetNodeVTKId( anEditIds[ i ].toInt() )); aType = VTK_POLYGON; mySimulation->SetPosition(myActor, aType, aVTKIds); } - }else if(GetConstructorId() == 1){ - SMDS_Mesh* aMesh = 0; - if ( myActor ){ - aMesh = myActor->GetObject()->GetMesh(); - if (Preview->isChecked()) - myActor->SetEntityMode(SMESH_Actor::eVolumes); - else - myActor->SetEntityMode(SMESH_Actor::eFaces); - } - if ( aMesh ) { - QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); - for ( int i = 0; i < aListId.count(); i++ ) - { - const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() ); - if ( !anElem ) - return; + }else if(GetConstructorId() == 1 && aMesh){ + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + for ( int i = 0; i < aListId.count(); i++ ) + { + const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() ); + if ( !anElem ) continue; + SMDSAbs_ElementType aFaceType = aMesh->GetElementType( anElem->GetID(),true ); + if (aFaceType != SMDSAbs_Face) continue; - SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); - SMESH::TPolySimulation::TVTKIds aVTKIds_faces; - while( anIter->more() ) + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + SMESH::TPolySimulation::TVTKIds aVTKIds_faces; + while( anIter->more() ) if ( const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next() ){ vtkIdType aId = myActor->GetObject()->GetNodeVTKId( aNode->GetID() ) ; aVTKIds.push_back(aId); aVTKIds_faces.push_back(aId); } - if(!Preview->isChecked()){ - aType = VTK_POLYGON; - mySimulation->SetPosition(myActor, aType, aVTKIds_faces); - } + if(!Preview->isChecked()){ + aType = VTK_POLYGON; + mySimulation->SetPosition(myActor, aType, aVTKIds_faces); } - if(Preview->isChecked()) - mySimulation->SetPosition(myActor, aType, aVTKIds); - } + } + if(Preview->isChecked()) + mySimulation->SetPosition(myActor, aType, aVTKIds); } - } + SMESH::UpdateView(); + } } //================================================================================= @@ -866,7 +959,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog() mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - myViewWindow->SetSelectionMode( FaceSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( FaceSelection ); SelectionIntoArgument(); } @@ -927,9 +1021,10 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd() mySelectionMgr->selectedObjects( selected ); int aNbSel = selected.Extent(); if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; + + if (this->checkEditLine(false) == -1) return; busy = true; - if ( !(myEditCurrentArgument->text().isEmpty()) ) { myFacesByNodes->insertItem(myEditCurrentArgument->text()); @@ -937,7 +1032,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd() myNbOkElements = 1; myEditCurrentArgument->clear(); AddButton->setEnabled(false); - RemoveButton->setEnabled(true); buttonOk->setEnabled( true ); if(myFacesByNodes->count()>1) buttonApply->setEnabled( true ); } @@ -956,22 +1050,20 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onRemove() for (int i = myFacesByNodes->count(); i > 0; i--) { if (myFacesByNodes->isSelected(i-1)) { myFacesByNodes->removeItem(i-1); + myNbOkElements = 1; } } if (myFacesByNodes->count() < 1){ - myNbOkElements = 0; RemoveButton->setEnabled(false); buttonOk->setEnabled( false ); buttonApply->setEnabled( false ); } else if (myFacesByNodes->count() == 1){ - myNbOkElements = 0; buttonOk->setEnabled( false ); buttonApply->setEnabled( false ); } - displaySimulation(); busy = false; - onListSelectionChanged(); + displaySimulation(); } //================================================================================= @@ -982,22 +1074,27 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onListSelectionChanged() { if (busy || !myActor) return; busy = true; - - SALOME_ListIO list; - mySelectionMgr->setSelectedObjects( list ); + bool isSelected=false; + SALOME_ListIO aList; + mySelectionMgr->setSelectedObjects( aList ); TColStd_MapOfInteger aIndexes; QListBoxItem* anItem; for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) { if (anItem->isSelected()) { + isSelected = true; QStringList anIds = QStringList::split(" ", anItem->text()); for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it) aIndexes.Add((*it).toInt()); } } + if(isSelected) RemoveButton->setEnabled(true); + else RemoveButton->setEnabled(false); mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); - list.Append( myActor->getIO() ); - mySelectionMgr->setSelectedObjects( list ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); + mySelectionMgr->clearFilters(); + aList.Append( myActor->getIO() ); + mySelectionMgr->setSelectedObjects( aList ); busy = false; }