From: kga Date: Wed, 20 Nov 2013 09:12:48 +0000 (+0000) Subject: 22314: EDF 2594 SMESH: Preview "Union of triangles" result X-Git-Tag: V7_3_0a1~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7e624b26fa62734849b6106aadfa9f8e8ea3de14;p=modules%2Fsmesh.git 22314: EDF 2594 SMESH: Preview "Union of triangles" result --- diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index 1384b9376..bf0074bab 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -34,6 +34,7 @@ #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_MeshEditPreview.h" #include #include @@ -105,7 +106,7 @@ SMESHGUI_MultiEditDlg ::SMESHGUI_MultiEditDlg(SMESHGUI* theModule, const int theMode, const bool the3d2d): - QDialog(SMESH::GetDesktop(theModule)), + SMESHGUI_PreviewDlg(theModule), mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), mySMESHGUI(theModule) @@ -1080,6 +1081,11 @@ SMESHGUI_UnionOfTrianglesDlg { setWindowTitle(tr("CAPTION")); + //Preview check box + myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), mySelGrp); + QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout()); + aLay->addWidget(myPreviewCheckBox, aLay->rowCount(), 0, 1, aLay->columnCount()); + myComboBoxFunctor->setEnabled(true); myComboBoxFunctor->addItem(tr("AREA_ELEMENTS")); myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only @@ -1102,6 +1108,14 @@ SMESHGUI_UnionOfTrianglesDlg ((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp); myCriterionGrp->show(); + connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(toDisplaySimulation())); + connect(myMaxAngleSpin, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation())); + connect(this, SIGNAL(ListContensChanged()), this, SLOT(toDisplaySimulation())); + connectPreviewControl(); //To Connect preview check box + + myPreviewCheckBox->setChecked(false); + onDisplaySimulation(false); + myHelpFileName = "uniting_set_of_triangles_page.html"; } @@ -1148,7 +1162,47 @@ bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito ok = theEditor->TriToQuadObject(obj, aCriterion, aMaxAngle); return ok; } - + +void SMESHGUI_UnionOfTrianglesDlg::onDisplaySimulation( bool toDisplayPreview ) +{ + if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) { + if ( isValid( true ) ) { + try{ + SUIT_OverrideCursor aWaitCursor; + // get Ids of elements + SMESH::SMESH_IDSource_var obj; + SMESH::long_array_var anElemIds = getIds( obj ); + + SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor(); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); + + double aMaxAngle = myMaxAngleSpin->GetValue() * M_PI / 180.0; + + if ( CORBA::is_nil( obj ) ) + aMeshEditor->TriToQuad( anElemIds.inout(), aCriterion, aMaxAngle ); + else + aMeshEditor->TriToQuadObject( obj, aCriterion, aMaxAngle ); + + SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToWireframe(); + aProp->SetColor( 250, 0, 250 ); + aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 3 ); + mySimulation->GetActor()->SetProperty( aProp ); + aProp->Delete(); + + mySimulation->SetData( aMeshPreviewStruct._retn() ); + } catch ( ... ) { + hidePreview(); + } + } else { + hidePreview(); + } + } else { + hidePreview(); + } +} /*! * Class : SMESHGUI_CuttingOfQuadsDlg @@ -1270,6 +1324,7 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview() if (myPreviewActor != 0) erasePreview(); + SUIT_OverrideCursor aWaitCursor; // get Ids of elements SMESH::SMESH_IDSource_var obj; SMESH::long_array_var anElemIds = getIds(obj); @@ -1291,6 +1346,10 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview() return; } + if ( anElemIds->length() == 0 ) { + anElemIds = obj->GetIDs(); + } + //Create grid vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h index 4f6af1af1..68847772b 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -28,6 +28,7 @@ // SMESH includes #include "SMESH_SMESHGUI.hxx" +#include "SMESHGUI_PreviewDlg.h" // Qt includes #include @@ -64,7 +65,7 @@ class QButtonGroup; * union of two neighboring triangles */ -class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public QDialog +class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public SMESHGUI_PreviewDlg { Q_OBJECT @@ -197,6 +198,9 @@ protected: const SMESH::long_array&, SMESH::SMESH_IDSource_ptr obj ); +protected slots: + virtual void onDisplaySimulation( bool ); + private: SMESHGUI_SpinBox* myMaxAngleSpin; }; diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index c1034c7e6..359b865e1 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -277,12 +277,16 @@ namespace MeshEditor_I { void arrayToSet(const SMESH::long_array & IDs, const SMESHDS_Mesh* aMesh, TIDSortedElemSet& aMap, - const SMDSAbs_ElementType aType = SMDSAbs_All ) + const SMDSAbs_ElementType aType = SMDSAbs_All, + SMDS_MeshElement::Filter* aFilter = NULL) { SMDS_MeshElement::NonNullFilter filter1; SMDS_MeshElement::TypeFilter filter2( aType ); - SMDS_MeshElement::Filter & filter = - ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter&) filter1 : filter2; + + if ( aFilter == NULL ) + aFilter = ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter*) &filter1 : (SMDS_MeshElement::Filter*) &filter2; + + SMDS_MeshElement::Filter & filter = *aFilter; if ( aType == SMDSAbs_Node ) for (int i=0; iCopy( faces, copyFaces, select ); + workElements = & copyFaces; + } SMESH::NumericalFunctor_i* aNumericalFunctor = dynamic_cast( SMESH_Gen_i::GetServant( Criterion ).in() ); @@ -1732,12 +1744,13 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE else aCrit = aNumericalFunctor->GetNumericalFunctor(); - // Update Python script - TPythonDump() << "isDone = " << this << ".TriToQuad( " - << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )"; - + if ( !myIsPreviewMode ) { + // Update Python script + TPythonDump() << "isDone = " << this << ".TriToQuad( " + << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )"; + } - bool stat = getEditor().TriToQuad( faces, aCrit, MaxAngle ); + bool stat = getEditor().TriToQuad( *workElements, aCrit, MaxAngle ); declareMeshModified( /*isReComputeSafe=*/!stat ); return stat; @@ -1766,12 +1779,14 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle); - SMESH::NumericalFunctor_i* aNumericalFunctor = - SMESH::DownCast( Criterion ); + if ( !myIsPreviewMode ) { + SMESH::NumericalFunctor_i* aNumericalFunctor = + SMESH::DownCast( Criterion ); - // Update Python script - aTPythonDump << "isDone = " << this << ".TriToQuadObject(" - << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )"; + // Update Python script + aTPythonDump << "isDone = " << this << ".TriToQuadObject(" + << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )"; + } return isDone; @@ -1965,6 +1980,7 @@ CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad, int id = getEditor().BestSplit(quad, aCrit); declareMeshModified( /*isReComputeSafe=*/ id < 1 ); + return id; } SMESH_CATCH( SMESH::throwCorbaException );