X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_AddMeshElementDlg.cxx;h=b1082076dbbc2dc3ba473403ebe94cb879b53b21;hp=f198189ce2ef20d9b625ca9e6361e3435a1ea1c3;hb=a274ade365bd0f0e19d56c577acc4a13aa1972a7;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index f198189ce..b1082076d 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 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 @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -40,7 +40,7 @@ #include #include -// SALOME GUI inclues +// SALOME GUI includes #include #include #include @@ -51,8 +51,12 @@ #include #include #include +#include +#include +#include -// IDL incldues + +// IDL includes #include CORBA_SERVER_HEADER(SMESH_MeshEditor) // OCCT includes @@ -65,6 +69,7 @@ #include #include #include +#include // Qt includes #include @@ -95,6 +100,10 @@ namespace SMESH SALOME_Actor* myPreviewActor; vtkDataSetMapper* myMapper; vtkUnstructuredGrid* myGrid; + + SALOME_Actor* myBallActor; + VTKViewer_PolyDataMapper* myBallMapper; + vtkPolyData* myBallPolyData; SALOME_Actor* myFaceOrientation; vtkPolyDataMapper* myFaceOrientationDataMapper; @@ -120,16 +129,18 @@ namespace SMESH myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper(myMapper); - double anRGB[3]; + QColor ffc, bfc; + int delta; + vtkProperty* aProp = vtkProperty::New(); - GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); - aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + SMESH::GetColor( "SMESH", "preview_color", ffc, delta, "0, 255, 0|-100" ) ; + aProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. ); myPreviewActor->SetProperty( aProp ); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); - aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + bfc = Qtx::mainColorToSecondary(ffc, delta); + aBackProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. ); myPreviewActor->SetBackfaceProperty( aBackProp ); aBackProp->Delete(); @@ -148,12 +159,35 @@ namespace SMESH myFaceOrientation->SetMapper(myFaceOrientationDataMapper); vtkProperty* anOrientationProp = vtkProperty::New(); + double anRGB[3]; GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); anOrientationProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); myFaceOrientation->SetProperty( anOrientationProp ); anOrientationProp->Delete(); - myVTKViewWindow->AddActor(myFaceOrientation); + + // Preview for the balls + vtkProperty* aBallProp = vtkProperty::New(); + aBallProp->SetColor(ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255.); + //double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10); + double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_diameter",1); + aBallProp->SetPointSize(aBallElemSize); + + myBallPolyData = vtkPolyData::New(); + myBallPolyData->Allocate(); + + myBallMapper = VTKViewer_PolyDataMapper::New(); + myBallMapper->SetInputData(myBallPolyData); + myBallMapper->SetBallEnabled(true); + + myBallActor = SALOME_Actor::New(); + myBallActor->PickableOff(); + myBallActor->SetVisibility(false); + myBallActor->SetProperty(aBallProp); + myBallActor->SetMapper(myBallMapper); + aBallProp->Delete(); + + myVTKViewWindow->AddActor(myBallActor); } typedef std::vector TVTKIds; @@ -163,7 +197,7 @@ namespace SMESH { vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); myGrid->SetPoints(aGrid->GetPoints()); - myGrid->Reset(); + myGrid->Reset(); const std::vector& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( theType )); SMDS_MeshCell::applyInterlace( interlace, theIds ); @@ -177,36 +211,70 @@ namespace SMESH myGrid->Modified(); - SetVisibility(true, theActor->GetFacesOriented()); + SetVisibility(true, theActor->GetFacesOriented(), false); } + void SetBallPosition(SMESH_Actor* theActor,TVTKIds& theIds, double theDiameter) + { + vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); + myBallPolyData->SetPoints(NULL); + myBallPolyData->Reset(); + myBallPolyData->DeleteCells(); + myBallPolyData->SetPoints(aGrid->GetPoints()); - void SetVisibility (bool theVisibility, bool theShowOrientation = false) + vtkDataArray* aScalars = vtkDataArray::CreateDataArray(VTK_DOUBLE); + aScalars->SetNumberOfComponents(1); + aScalars->SetNumberOfTuples(theIds.size()); + myBallPolyData->GetCellData()->SetScalars(aScalars); + aScalars->Delete(); + + vtkIdList *anIds = vtkIdList::New(); + anIds->SetNumberOfIds(1); + for (int i = 0, iEnd = theIds.size(); i < iEnd; i++){ + anIds->InsertId(0,theIds[i]); + vtkIdType anId = myBallPolyData->InsertNextCell(VTK_POLY_VERTEX,anIds); + double d = theDiameter * theActor->GetBallScale(); + aScalars->SetTuple(anId,&d); + anIds->Reset(); + } + + anIds->Delete(); + myBallPolyData->Modified(); + SetVisibility (false, false, true); + } + + void SetVisibility (bool theVisibility, bool theShowOrientation = false, bool theShowBalls = false) { myPreviewActor->SetVisibility(theVisibility); myFaceOrientation->SetVisibility(theShowOrientation); + myBallActor->SetVisibility(theShowBalls); RepaintCurrentView(); } ~TElementSimulation() { + myMapper->RemoveAllInputs(); + myFaceOrientationDataMapper->RemoveAllInputs(); + myBallMapper->RemoveAllInputs(); + if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { - myVTKViewWindow->RemoveActor(myPreviewActor); - myVTKViewWindow->RemoveActor(myFaceOrientation); + myVTKViewWindow->RemoveActor(myPreviewActor,false,false); + myVTKViewWindow->RemoveActor(myFaceOrientation,false,false); + myVTKViewWindow->RemoveActor(myBallActor,false,false); } - myPreviewActor->Delete(); - myFaceOrientation->Delete(); - myMapper->RemoveAllInputs(); myMapper->Delete(); - - myFaceOrientationFilter->Delete(); - - myFaceOrientationDataMapper->RemoveAllInputs(); + myGrid->Delete(); + myPreviewActor->Delete(); + + myFaceOrientationFilter->Delete(); myFaceOrientationDataMapper->Delete(); + myFaceOrientation->Delete(); - myGrid->Delete(); + myBallMapper->Delete(); + myBallPolyData->Delete(); + myBallActor->Delete(); } }; } @@ -240,68 +308,68 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theMo myNbNodes = 1; myElementType = SMDSAbs_0DElement; elemName = "ELEM0D"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_0delems_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-0delems-anchor"; break; case SMDSEntity_Ball: myNbNodes = 1; myElementType = SMDSAbs_Ball; elemName = "BALL"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_ball_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-balls-anchor"; break; case SMDSEntity_Edge: myNbNodes = 2; myElementType = SMDSAbs_Edge; elemName = "EDGE"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_edges_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-edges-anchor"; break; case SMDSEntity_Triangle: myNbNodes = 3; elemName = "TRIANGLE"; myElementType = SMDSAbs_Face; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_triangles_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-triangles-anchor"; break; case SMDSEntity_Quadrangle: myNbNodes = 4; myElementType = SMDSAbs_Face; elemName = "QUADRANGLE"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_quadrangles_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-quadrangles-anchor"; break; case SMDSEntity_Polygon: myNbNodes = 0; myElementType = SMDSAbs_Face; elemName = "POLYGON"; myIsPoly = true; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_polygons_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-polygons-anchor"; break; case SMDSEntity_Tetra: myNbNodes = 4; elemName = "TETRAS"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_tetrahedrons_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-tetrahedrons-anchor"; break; case SMDSEntity_Pyramid: myNbNodes = 5; elemName = "PYRAMID"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_pyramids_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-pyramids-anchor"; break; case SMDSEntity_Hexa: myNbNodes = 8; elemName = "HEXAS"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_hexahedrons_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-hexahedrons-anchor"; break; case SMDSEntity_Penta: myNbNodes = 6; elemName = "PENTA"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_pentahedrons_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-pentahedrons-anchor"; break; case SMDSEntity_Hexagonal_Prism: myNbNodes = 12; elemName = "OCTA"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_octahedrons_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-octahedrons-anchor"; break; default: myNbNodes = 2; elemName = "EDGE"; - myHelpFileName = "adding_nodes_and_elements_page.html#adding_edges_anchor"; + myHelpFileName = "adding_nodes_and_elements.html#adding-edges-anchor"; } QString iconName = tr(QString("ICON_DLG_%1").arg(elemName).toLatin1().data()); @@ -346,7 +414,9 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theMo LineEditC1A1->setValidator (new SMESHGUI_IdValidator(this, ( myIsPoly || myNbNodes == 1 ) ? 1000 : myNbNodes)); - Reverse = (myElementType == SMDSAbs_Face || myElementType == SMDSAbs_Volume ) ? new QCheckBox(tr("SMESH_REVERSE"), GroupC1) : 0; + ReverseOrDulicate = (myElementType == SMDSAbs_Face || myElementType == SMDSAbs_Volume ) ? new QCheckBox(tr("SMESH_REVERSE"), GroupC1) : 0; + if ( myElementType == SMDSAbs_0DElement ) + ReverseOrDulicate = new QCheckBox(tr("SMESH_DUPLICATE_0D"), GroupC1); DiameterSpinBox = ( myGeomType == SMDSEntity_Ball ) ? new SMESHGUI_SpinBox(GroupC1) : 0; QLabel* diameterLabel = DiameterSpinBox ? new QLabel( tr("BALL_DIAMETER"),GroupC1) : 0; @@ -354,15 +424,16 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theMo GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); GroupC1Layout->addWidget(LineEditC1A1, 0, 2); - if ( Reverse ) { - GroupC1Layout->addWidget(Reverse, 1, 0, 1, 3); + if ( ReverseOrDulicate ) { + GroupC1Layout->addWidget(ReverseOrDulicate, 1, 0, 1, 3); } if ( DiameterSpinBox ) { GroupC1Layout->addWidget(diameterLabel, 1, 0); GroupC1Layout->addWidget(DiameterSpinBox, 1, 1, 1, 2); DiameterSpinBox->RangeStepAndValidator( 1e-7, 1e+9, 0.1 ); - DiameterSpinBox->SetValue( 1. ); + DiameterSpinBox->SetValue( SMESH::GetFloat("SMESH:ball_elem_diameter", 1) ); + connect( DiameterSpinBox, SIGNAL( valueChanged ( double ) ), this, SLOT( onDiameterChanged( ) ) ); } /* Add to group ************************************************/ GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this ); @@ -448,13 +519,16 @@ void SMESHGUI_AddMeshElementDlg::Init() connect(SelectButtonC1A1,SIGNAL(clicked()), SLOT(SetEditCurrentArgument())); connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()),SLOT(DeactivateActiveDialog())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument())); /* to close dialog if study frame change */ connect(mySMESHGUI, SIGNAL(SignalStudyFrameChanged()), SLOT(reject())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject())); + connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView())); - if (Reverse) - connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int))); + if (ReverseOrDulicate) + connect(ReverseOrDulicate, SIGNAL(stateChanged(int)), SLOT(CheckBox(int))); // set selection mode SMESH::SetPointRepresentation(true); @@ -476,16 +550,16 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() if( !isValid() ) return; - if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) { + if (myNbOkNodes && !SMESHGUI::isStudyLocked()) { myBusy = true; QStringList aListId = myEditCurrentArgument->text().split(" ", QString::SkipEmptyParts); SMESH::long_array_var anArrayOfIndices = new SMESH::long_array; anArrayOfIndices->length(aListId.count()); const std::vector& revIndex = SMDS_MeshCell::reverseSmdsOrder( myGeomType ); - if ( Reverse && Reverse->isChecked() && !revIndex.empty() ) + if ( ReverseOrDulicate && ReverseOrDulicate->isChecked() && (int)revIndex.size() == aListId.count() ) for (int i = 0; i < aListId.count(); i++) anArrayOfIndices[i] = aListId[ revIndex[i] ].toInt(); - else if ( Reverse && Reverse->isChecked() && revIndex.empty() ) // polygon + else if ( ReverseOrDulicate && ReverseOrDulicate->isChecked() && revIndex.empty() ) // polygon for (int i = 0; i < aListId.count(); i++) anArrayOfIndices[i] = aListId[ aListId.count()-1 - i ].toInt(); else @@ -512,6 +586,13 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ); if ( res == 1 ) return; } + 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; + } aGroup = myGroups[idx-1]; } } @@ -520,15 +601,26 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() SMESH::long_array_var anIdList = new SMESH::long_array; anIdList->length( 1 ); anIdList[0] = -1; + int nbElemsBefore = 0; switch (myElementType) { - case SMDSAbs_0DElement: + case SMDSAbs_0DElement: { + bool duplicateElements = ReverseOrDulicate->isChecked(); + nbElemsBefore = myMesh->Nb0DElements(); anIdList->length( anArrayOfIndices->length() ); for ( size_t i = 0; i < anArrayOfIndices->length(); ++i ) - anIdList[i] = aMeshEditor->Add0DElement(anArrayOfIndices[i]); + anIdList[i] = aMeshEditor->Add0DElement(anArrayOfIndices[i], duplicateElements); + + CORBA::ULong nbAdded = myMesh->Nb0DElements() - nbElemsBefore; + if ( !duplicateElements && nbAdded < anArrayOfIndices->length() ) + SUIT_MessageBox::information(SMESHGUI::desktop(), + tr("SMESH_INFORMATION"), + tr("NB_ADDED").arg( nbAdded )); break; + } case SMDSAbs_Ball: if ( myGeomType == SMDSEntity_Ball ) { + nbElemsBefore = myMesh->NbBalls(); anIdList->length( anArrayOfIndices->length() ); for ( size_t i = 0; i < anArrayOfIndices->length(); ++i ) anIdList[i] = aMeshEditor->AddBall(anArrayOfIndices[i], @@ -536,21 +628,24 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() } break; case SMDSAbs_Edge: + nbElemsBefore = myMesh->NbEdges(); anIdList[0] = aMeshEditor->AddEdge(anArrayOfIndices.inout()); break; case SMDSAbs_Face: + nbElemsBefore = myMesh->NbFaces(); if ( myIsPoly ) anIdList[0] = aMeshEditor->AddPolygonalFace(anArrayOfIndices.inout()); else anIdList[0] = aMeshEditor->AddFace(anArrayOfIndices.inout()); break; default: + nbElemsBefore = myMesh->NbVolumes(); anIdList[0] = aMeshEditor->AddVolume(anArrayOfIndices.inout()); break; } if ( anIdList[0] > 0 && addToGroup && !aGroupName.isEmpty() ) { SMESH::SMESH_Group_var aGroupUsed; if ( aGroup->_is_nil() ) { - // create new group + // create new group aGroupUsed = SMESH::AddGroup( myMesh, (SMESH::ElementType)myElementType, aGroupName ); if ( !aGroupUsed->_is_nil() ) { myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed)); @@ -558,7 +653,8 @@ void SMESHGUI_AddMeshElementDlg::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 ) { @@ -566,6 +662,13 @@ void SMESHGUI_AddMeshElementDlg::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 ); } @@ -578,9 +681,26 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() mySelector->ClearIndex(); mySelectionMgr->setSelectedObjects( aList, false ); - SMESH::UpdateView(); mySimulation->SetVisibility(false); + if ( nbElemsBefore == 0 ) + { + // 1st element of the type has been added, update actor to show this entity + unsigned int aMode = myActor->GetEntityMode(); + switch ( myElementType ) { + case SMDSAbs_Edge: + myActor->SetRepresentation(SMESH_Actor::eEdge); + myActor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break; + case SMDSAbs_Face: + myActor->SetRepresentation(SMESH_Actor::eSurface); + myActor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break; + case SMDSAbs_Volume: + myActor->SetRepresentation(SMESH_Actor::eSurface); + myActor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break; + } + } + SMESH::UpdateView(); + buttonOk->setEnabled(false); buttonApply->setEnabled(false); @@ -608,7 +728,6 @@ void SMESHGUI_AddMeshElementDlg::ClickOnOk() //================================================================================= void SMESHGUI_AddMeshElementDlg::reject() { - //mySelectionMgr->clearSelected(); mySimulation->SetVisibility(false); SMESH::SetPointRepresentation(false); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) @@ -659,7 +778,7 @@ void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText) mySimulation->SetVisibility(false); - // hilight entered nodes + // highlight entered nodes SMDS_Mesh* aMesh = 0; if (myActor) aMesh = myActor->GetObject()->GetMesh(); @@ -798,17 +917,21 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation() for (int i = 0; i < aListId.count(); i++) anIds.push_back(myActor->GetObject()->GetNodeVTKId(aListId[ i ].toInt())); - if (Reverse && Reverse->isChecked()) + if (ReverseOrDulicate && ReverseOrDulicate->isChecked()) { const std::vector& i = SMDS_MeshCell::reverseSmdsOrder( myGeomType ); - if ( i.empty() ) // polygon + if ( i.size() != anIds.size() ) // polygon std::reverse( anIds.begin(), anIds.end() ); else SMDS_MeshCell::applyInterlace( i, anIds ); } vtkIdType aType = SMDS_MeshCell::toVtkType( myGeomType ); - mySimulation->SetPosition(myActor,aType,anIds); + if(aType == VTK_POLY_VERTEX) { + mySimulation->SetBallPosition(myActor,anIds,DiameterSpinBox->GetValue()); + } else { + mySimulation->SetPosition(myActor,aType,anIds); + } SMESH::UpdateView(); } } @@ -869,9 +992,15 @@ void SMESHGUI_AddMeshElementDlg::ActivateThisDialog() //================================================================================= void SMESHGUI_AddMeshElementDlg::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::TElementSimulation( + dynamic_cast( mySMESHGUI->application() ) ); + } + ActivateThisDialog(); + } } //================================================================================= @@ -906,7 +1035,45 @@ void SMESHGUI_AddMeshElementDlg::keyPressEvent( QKeyEvent* e ) } //================================================================================= -// function : isValid +// function : onDiameterChanged() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::onDiameterChanged(){ + displaySimulation(); +} + +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::onOpenView() +{ + if ( mySelector && mySimulation ) { + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + mySimulation = new SMESH::TElementSimulation( + dynamic_cast( mySMESHGUI->application() ) ); + ActivateThisDialog(); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::onCloseView() +{ + DeactivateActiveDialog(); + mySelector = 0; + delete mySimulation; + mySimulation = 0; +} + +//================================================================================= +// function : isValid() // purpose : //================================================================================= bool SMESHGUI_AddMeshElementDlg::isValid()