X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_AddQuadraticElementDlg.cxx;h=5cfddb9ce8850d6010519951a9d9cb24e90ef2fb;hp=f469941ca3df56dc793f50e3117847a06d798b2b;hb=b22e182dd1a2c30be324b21074158390d00714b3;hpb=2b96c0d91199618fec51a5771e7713cabb1a19ff diff --git a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx index f469941ca..5cfddb9ce 100644 --- a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -36,7 +36,6 @@ #include #include -#include #include #include @@ -53,8 +52,6 @@ #include #include -#include -#include #include @@ -68,14 +65,12 @@ #include // VTK includes -#include #include #include #include #include #include #include -#include // Qt includes #include @@ -100,13 +95,39 @@ namespace { + + // Define the sequences of ids + static int FirstEdgeIds[] = {0}; + static int LastEdgeIds[] = {1}; + + static int FirstTriangleIds[] = {0,1,2}; + static int LastTriangleIds[] = {1,2,0}; + + static int FirstQuadrangleIds[] = {0,1,2,3}; + static int LastQuadrangleIds[] = {1,2,3,0}; + + static int FirstTetrahedronIds[] = {0,1,2,3,3,3}; + static int LastTetrahedronIds[] = {1,2,0,0,1,2}; + + static int FirstPyramidIds[] = {0,1,2,3,4,4,4,4}; + static int LastPyramidIds[] = {1,2,3,0,0,1,2,3}; + + static int FirstPentahedronIds[] = {0,1,2,3,4,5,0,1,2}; + static int LastPentahedronIds[] = {1,2,0,4,5,3,3,4,5}; + + static int FirstHexahedronIds[] = {0,1,2,3,4,5,6,7,0,1,2,3}; + static int LastHexahedronIds[] = {1,2,3,0,5,6,7,4,4,5,6,7}; + + static vector FirstPolygonIds; + static vector LastPolygonIds; + void ReverseConnectivity( std::vector & ids, SMDSAbs_EntityType type, bool toReverse, // inverse element bool toVtkOrder ) // smds connectivity to vtk one { if ( toReverse ) // first reverse smds order { - const std::vector& index = SMDS_MeshCell::reverseSmdsOrder(type); + const std::vector& index = SMDS_MeshCell::reverseSmdsOrder(type, ids.size()); SMDS_MeshCell::applyInterlace( index, ids ); } if ( toVtkOrder ) // from smds to vtk connectivity @@ -118,7 +139,8 @@ namespace } namespace SMESH { - class TElementSimulationQuad { + class TElementSimulationQuad + { SalomeApp_Application* myApplication; SUIT_ViewWindow* myViewWindow; SVTK_ViewWindow* myVTKViewWindow; @@ -126,14 +148,7 @@ namespace SMESH SALOME_Actor* myPreviewActor; vtkDataSetMapper* myMapper; vtkUnstructuredGrid* myGrid; - - SALOME_Actor* myCornerActor; - VTKViewer_PolyDataMapper* myCornerMapper; - vtkPolyData* myCornerPolyData; - - SALOME_Actor* mySelectCornerActor; - VTKViewer_PolyDataMapper* mySelectCornerMapper; - vtkPolyData* mySelectCornerPolyData; + //vtkProperty* myBackProp, *myProp; //double myRGB[3], myBackRGB[3]; @@ -160,7 +175,7 @@ namespace SMESH myPreviewActor->PickableOff(); myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper(myMapper); - + QColor ffc, bfc; int delta; vtkProperty* myProp = vtkProperty::New(); @@ -198,45 +213,6 @@ namespace SMESH anOrientationProp->Delete(); myVTKViewWindow->AddActor(myFaceOrientation); - - // Create and display actor with corner nodes - myCornerPolyData = vtkPolyData::New(); - myCornerPolyData->Allocate(); - myCornerMapper = VTKViewer_PolyDataMapper::New(); - myCornerMapper->SetInputData(myCornerPolyData); - myCornerMapper->SetMarkerEnabled(true); - - myCornerActor = SALOME_Actor::New(); - myCornerActor->PickableOff(); - myCornerActor->VisibilityOff(); - myCornerActor->SetMapper(myCornerMapper); - - vtkProperty* myCornerProp = vtkProperty::New(); - myCornerProp->SetColor( 50 / 255. , 100 / 255. , 0 / 255. ); - myCornerActor->SetProperty( myCornerProp ); - myCornerProp->Delete(); - - myVTKViewWindow->AddActor(myCornerActor); - - // Create and display actor with selected corner nodes - mySelectCornerPolyData = vtkPolyData::New(); - mySelectCornerPolyData->Allocate(); - mySelectCornerMapper = VTKViewer_PolyDataMapper::New(); - mySelectCornerMapper->SetInputData(mySelectCornerPolyData); - mySelectCornerMapper->SetMarkerEnabled(true); - - mySelectCornerActor = SALOME_Actor::New(); - mySelectCornerActor->PickableOff(); - mySelectCornerActor->VisibilityOff(); - mySelectCornerActor->SetMapper(mySelectCornerMapper); - - vtkProperty* mySelectCornerProp = vtkProperty::New(); - mySelectCornerProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. ); - mySelectCornerActor->SetProperty( mySelectCornerProp ); - mySelectCornerProp->Delete(); - - myVTKViewWindow->AddActor(mySelectCornerActor); - } typedef std::vector TVTKIds; @@ -269,76 +245,26 @@ namespace SMESH myPreviewActor->GetMapper()->Update(); myPreviewActor->SetRepresentation( theMode ); + SetVisibility(true, theActor->GetFacesOriented()); } - void SetCornerNodes (SMESH_Actor* theActor, - TVTKIds& theIds) - { - vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); - - myCornerMapper->SetMarkerStd(theActor->GetMarkerType(), theActor->GetMarkerScale()); - myCornerPolyData->Reset(); - myCornerPolyData->DeleteCells(); - myCornerPolyData->SetPoints(aGrid->GetPoints()); - vtkIdList *anIds = vtkIdList::New(); - for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) { - anIds->InsertId(i,theIds[i]); - myCornerPolyData->InsertNextCell(VTK_VERTEX, anIds); - anIds->Reset(); - } - anIds->Delete(); - myCornerPolyData->Modified(); - myCornerActor->GetMapper()->Update(); - myCornerActor->SetRepresentation(SMESH_Actor::ePoint); - } - void SetSelectedNodes (SMESH_Actor* theActor, - TVTKIds& theIds) - { - vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); - - mySelectCornerMapper->SetMarkerStd(theActor->GetMarkerType(), theActor->GetMarkerScale()); - - mySelectCornerPolyData->Reset(); - mySelectCornerPolyData->DeleteCells(); - mySelectCornerPolyData->SetPoints(aGrid->GetPoints()); - - vtkIdList *anIds = vtkIdList::New(); - for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) { - anIds->InsertId(i,theIds[i]); - mySelectCornerPolyData->InsertNextCell(VTK_VERTEX, anIds); - anIds->Reset(); - } - anIds->Delete(); - mySelectCornerPolyData->Modified(); - mySelectCornerActor->GetMapper()->Update(); - mySelectCornerActor->SetRepresentation(SMESH_Actor::ePoint); - } - - void SetVisibility ( bool theVisibility, - bool theCornerVisibility = false, - bool theSelectCornerVisibility = false, - bool theShowOrientation = false ) + void SetVisibility (bool theVisibility, bool theShowOrientation = false) { myPreviewActor->SetVisibility(theVisibility); myFaceOrientation->SetVisibility(theShowOrientation); - myCornerActor->SetVisibility(theCornerVisibility); - mySelectCornerActor->SetVisibility(theSelectCornerVisibility); RepaintCurrentView(); } + ~TElementSimulationQuad() { if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { myVTKViewWindow->RemoveActor(myPreviewActor); myVTKViewWindow->RemoveActor(myFaceOrientation); - myVTKViewWindow->RemoveActor(myCornerActor); - myVTKViewWindow->RemoveActor(mySelectCornerActor); } myPreviewActor->Delete(); myFaceOrientation->Delete(); - myCornerActor->Delete(); - mySelectCornerActor->Delete(); myMapper->RemoveAllInputs(); myMapper->Delete(); @@ -350,43 +276,12 @@ namespace SMESH myGrid->Delete(); - myCornerMapper->RemoveAllInputs(); - myCornerMapper->Delete(); - myCornerPolyData->Delete(); - - mySelectCornerMapper->RemoveAllInputs(); - mySelectCornerMapper->Delete(); - mySelectCornerPolyData->Delete(); - -// myProp->Delete(); -// myBackProp->Delete(); + // myProp->Delete(); + // myBackProp->Delete(); } }; } - -// Define the sequences of ids -static int FirstEdgeIds[] = {0}; -static int LastEdgeIds[] = {1}; - -static int FirstTriangleIds[] = {0,1,2}; -static int LastTriangleIds[] = {1,2,0}; - -static int FirstQuadrangleIds[] = {0,1,2,3}; -static int LastQuadrangleIds[] = {1,2,3,0}; - -static int FirstTetrahedronIds[] = {0,1,2,3,3,3}; -static int LastTetrahedronIds[] = {1,2,0,0,1,2}; - -static int FirstPyramidIds[] = {0,1,2,3,4,4,4,4}; -static int LastPyramidIds[] = {1,2,3,0,0,1,2,3}; - -static int FirstPentahedronIds[] = {0,1,2,3,4,5,0,1,2}; -static int LastPentahedronIds[] = {1,2,0,4,5,3,3,4,5}; - -static int FirstHexahedronIds[] = {0,1,2,3,4,5,6,7,0,1,2,3}; -static int LastHexahedronIds[] = {1,2,3,0,5,6,7,4,4,5,6,7}; - /*! \class BusyLocker \brief Simple 'busy state' flag locker. @@ -444,7 +339,6 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myGeomType( theType ), - //myType( theType ), myBusy( false ) { setModal( false ); @@ -468,6 +362,9 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM case SMDSEntity_Quad_Quadrangle: anElementName = QString("QUADRATIC_QUADRANGLE"); break; + case SMDSEntity_Quad_Polygon: + anElementName = QString("QUADRATIC_POLYGON"); + break; case SMDSEntity_BiQuad_Quadrangle: anElementName = QString("BIQUADRATIC_QUADRANGLE"); break; @@ -670,6 +567,11 @@ void SMESHGUI_AddQuadraticElementDlg::Init() myNbCenterNodes = 1; myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_quadrangles break; + case SMDSEntity_Quad_Polygon: + aNumRows = 5; + myNbCorners = 0; // no limit + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_polygons + break; case SMDSEntity_Quad_Tetra: aNumRows = 6; myNbCorners = 4; @@ -759,6 +661,8 @@ void SMESHGUI_AddQuadraticElementDlg::Init() connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(reject())); connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(reject())); + connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL (SignalCloseView()), SLOT(onCloseView())); myCurrentLineEdit = myCornerNodes; @@ -796,6 +700,7 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() break; case SMDSEntity_Quad_Triangle: case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_Quad_Polygon: case SMDSEntity_BiQuad_Triangle: case SMDSEntity_BiQuad_Quadrangle: case SMDSEntity_Quad_Tetra: @@ -823,7 +728,7 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() if ( myReverseCB->isChecked()) ReverseConnectivity( anIds, myGeomType, /*toReverse=*/true, /*toVtkOrder=*/false ); - int aNumberOfIds = anIds.size(); + int aNumberOfIds = anIds.size(); SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; anArrayOfIdeces->length( aNumberOfIds ); @@ -846,7 +751,14 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] ); if ( !aGeomGroup->_is_nil() ) { int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ), - tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ), + tr( "MESH_GEOM_GRP_CHOSEN" ).arg( aGroupName ), + tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ); + if ( res == 1 ) return false; + } + SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( myGroups[idx-1] ); + if ( !aFilterGroup->_is_nil() ) { + int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ), + tr( "MESH_FILTER_GRP_CHOSEN" ).arg( aGroupName ), tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ); if ( res == 1 ) return false; } @@ -855,24 +767,31 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() } SMESH::ElementType anElementType; - long anElemId = -1; + long anElemId = -1, nbElemsBefore = 0; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); switch (myGeomType) { case SMDSEntity_Quad_Edge: anElementType = SMESH::EDGE; + nbElemsBefore = myMesh->NbEdges(); anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; case SMDSEntity_Quad_Triangle: case SMDSEntity_Quad_Quadrangle: case SMDSEntity_BiQuad_Triangle: case SMDSEntity_BiQuad_Quadrangle: anElementType = SMESH::FACE; + nbElemsBefore = myMesh->NbFaces(); anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break; + case SMDSEntity_Quad_Polygon: + anElementType = SMESH::FACE; + nbElemsBefore = myMesh->NbFaces(); + anElemId = aMeshEditor->AddQuadPolygonalFace(anArrayOfIdeces.inout()); break; case SMDSEntity_Quad_Tetra: case SMDSEntity_Quad_Pyramid: case SMDSEntity_Quad_Penta: case SMDSEntity_Quad_Hexa: case SMDSEntity_TriQuad_Hexa: anElementType = SMESH::VOLUME; + nbElemsBefore = myMesh->NbVolumes(); anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; default: break; } @@ -888,7 +807,8 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() } } else { - SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup ); + SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup ); + SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGroup ); if ( !aGeomGroup->_is_nil() ) { aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup ); if ( !aGroupUsed->_is_nil() && idx > 0 ) { @@ -896,6 +816,13 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); } } + else if ( !aFilterGroup->_is_nil() ) { + aGroupUsed = myMesh->ConvertToStandalone( aFilterGroup ); + if ( !aGroupUsed->_is_nil() && idx > 0 ) { + myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed); + SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); + } + } else aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup ); } @@ -908,6 +835,23 @@ bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply() } } + if ( nbElemsBefore == 0 ) + { + // 1st element of the type has been added, update actor to show this entity + unsigned int aMode = myActor->GetEntityMode(); + switch ( anElementType ) { + case SMESH::EDGE: + myActor->SetRepresentation(SMESH_Actor::eEdge); + myActor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break; + case SMESH::FACE: + myActor->SetRepresentation(SMESH_Actor::eSurface); + myActor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break; + case SMESH::VOLUME: + myActor->SetRepresentation(SMESH_Actor::eSurface); + myActor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break; + } + } + SALOME_ListIO aList; aList.Append( myActor->getIO() ); mySelector->ClearIndex(); mySelectionMgr->setSelectedObjects( aList, false ); @@ -953,6 +897,35 @@ void SMESHGUI_AddQuadraticElementDlg::reject() QDialog::reject(); } +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_AddQuadraticElementDlg::onOpenView() +{ + if ( mySelector && mySimulation ) { + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + mySimulation = new SMESH::TElementSimulationQuad( + dynamic_cast( mySMESHGUI->application() ) ); + ActivateThisDialog(); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_AddQuadraticElementDlg::onCloseView() +{ + DeactivateActiveDialog(); + mySelector = 0; + delete mySimulation; + mySimulation = 0; +} //================================================================================= // function : ClickOnHelp() // purpose : @@ -1042,36 +1015,40 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() QString aCurrentEntry = myEntry; - // clear - myActor = 0; if ( myCurrentLineEdit ) + { + // clear + myActor = 0; + myCurrentLineEdit->setText(""); - if (!GroupButtons->isEnabled()) // inactive - return; + if (!GroupButtons->isEnabled()) // inactive + return; - mySimulation->SetVisibility(false); + mySimulation->SetVisibility(false); - // get selected mesh - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList); + // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); - if (aList.Extent() != 1) - { - UpdateTable(); - updateButtons(); - return; - } + if (aList.Extent() != 1) + { + UpdateTable(); + updateButtons(); + return; + } - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myEntry = anIO->getEntry(); - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) { - updateButtons(); - return; - } + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myEntry = anIO->getEntry(); + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) { + updateButtons(); + return; + } - myActor = SMESH::FindActorByEntry(anIO->getEntry()); + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + + } // process groups if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) { @@ -1081,6 +1058,7 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() anElementType = SMESH::EDGE; break; case SMDSEntity_Quad_Triangle: case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_Quad_Polygon: case SMDSEntity_BiQuad_Triangle: case SMDSEntity_BiQuad_Quadrangle: anElementType = SMESH::FACE; break; @@ -1140,10 +1118,9 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() // purpose : //================================================================================= -void SMESHGUI_AddQuadraticElementDlg::displaySimulation(int theRow, int theCol) +void SMESHGUI_AddQuadraticElementDlg::displaySimulation() { - bool isValid = IsValid(); - if ( ( isValid || myTable->isEnabled() ) && myActor ) + if ( IsValid() ) { SMESH::TElementSimulationQuad::TVTKIds anIds; @@ -1151,6 +1128,7 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation(int theRow, int theCol) int anID; bool ok; int aDisplayMode = VTK_SURFACE; + if ( myGeomType == SMDSEntity_Quad_Edge ) { anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) ); @@ -1174,33 +1152,20 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation(int theRow, int theCol) } anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); } - if ( myNbMidFaceNodes && isValid) + if ( myNbMidFaceNodes ) { QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts); for (int i = 0; i < aListId.count(); i++) anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() )); } - if ( myNbCenterNodes && isValid) + if ( myNbCenterNodes ) { QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts); anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() )); } } - if ( isValid ) - mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked()); - mySimulation->SetCornerNodes(myActor, anIds); - if ( theCol == 1 ) { - anIds.clear(); - anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(theRow, 0)->text().toInt() ) ); - anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(theRow, 2)->text().toInt() ) ); - bool ok; - int anID; - anID = myTable->item(theRow, 1)->text().toInt(&ok); - if (ok) - anIds.push_back(myActor->GetObject()->GetNodeVTKId(anID)); - mySimulation->SetSelectedNodes(myActor, anIds); - } - mySimulation->SetVisibility(isValid, true, true, myActor->GetFacesOriented()); + + mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked()); } else { @@ -1275,12 +1240,17 @@ void SMESHGUI_AddQuadraticElementDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= - void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*) { - if (GroupConstructors->isEnabled()) - return; - ActivateThisDialog(); + if ( !GroupConstructors->isEnabled() ) { + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if ( aViewWindow && !mySelector && !mySimulation) { + mySelector = aViewWindow->GetSelector(); + mySimulation = new SMESH::TElementSimulationQuad( + dynamic_cast( mySMESHGUI->application() ) ); + } + ActivateThisDialog(); + } } //================================================================================= @@ -1351,6 +1321,44 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) { QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts); + if ( myGeomType == SMDSEntity_Quad_Polygon ) // POLYGON + { + if ( aListCorners.count() < 3 ) + theConersValidity = false; + + if ( aListCorners.count() != myTable->rowCount() && theConersValidity ) + { + // adjust nb of rows for the polygon + int oldNbRows = myTable->rowCount(); + myTable->setRowCount( aListCorners.count() ); + for ( int row = oldNbRows; row < myTable->rowCount(); row++ ) + { + myTable->setItem( row, 0, new QTableWidgetItem( "" ) ); + myTable->item( row, 0 )->setFlags(0); + + IdEditItem* anEditItem = new IdEditItem( "" ); + anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + myTable->setItem(row, 1, anEditItem); + + myTable->setItem( row, 2, new QTableWidgetItem( "" ) ); + myTable->item( row, 2 )->setFlags(0); + } + myNbCorners = aListCorners.count(); + + // fill FirstPolygonIds and LastPolygonIds + FirstPolygonIds.resize( aListCorners.count() ); + LastPolygonIds .resize( aListCorners.count() ); + for ( int i = 0; i < aListCorners.count(); ++i ) + { + FirstPolygonIds[i] = i; + LastPolygonIds [i] = i+1; + } + LastPolygonIds.back() = 0; + + myNbCorners = aListCorners.count(); + } + } + if ( aListCorners.count() == myNbCorners && theConersValidity ) { myTable->setEnabled( true ); @@ -1377,6 +1385,10 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) aFirstColIds = FirstQuadrangleIds; aLastColIds = LastQuadrangleIds; break; + case SMDSEntity_Quad_Polygon: + aFirstColIds = & FirstPolygonIds[0]; + aLastColIds = & LastPolygonIds[0]; + break; case SMDSEntity_Quad_Tetra: aFirstColIds = FirstTetrahedronIds; aLastColIds = LastTetrahedronIds; @@ -1422,7 +1434,7 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol ) { myCurrentLineEdit = 0; - displaySimulation(theRow, theCol); + displaySimulation(); updateButtons(); } @@ -1434,7 +1446,7 @@ void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCo void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol) { myCurrentLineEdit = 0; - displaySimulation(theRow, theCol); + displaySimulation(); updateButtons(); }