X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MultiEditDlg.cxx;h=bf0074babdea4173a4ac79fc4e46d9ea922d0fdc;hb=521479f0efe4d0b2b964ecfecf0c257df6c6a7ff;hp=a12ca8fbe1fed72b8fa009a7d0efc5d2047877ce;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index a12ca8fbe..bf0074bab 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 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 @@ -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) @@ -225,7 +226,7 @@ QWidget* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool myComboBoxFunctor->addItem(tr("ASPECTRATIO_ELEMENTS")); myComboBoxFunctor->addItem(tr("MINIMUMANGLE_ELEMENTS")); myComboBoxFunctor->addItem(tr("SKEW_ELEMENTS")); - myComboBoxFunctor->addItem(tr("AREA_ELEMENTS")); + //myComboBoxFunctor->addItem(tr("AREA_ELEMENTS")); //myComboBoxFunctor->addItem(tr("LENGTH2D_EDGES")); // for existing elements only //myComboBoxFunctor->addItem(tr("MULTI2D_BORDERS")); // for existing elements only myComboBoxFunctor->setCurrentIndex(0); @@ -362,6 +363,8 @@ SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor() aNF = aFilterMgr->CreateLength2D(); else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS")) aNF = aFilterMgr->CreateMultiConnection2D(); + else if (myComboBoxFunctor->currentText() == tr("MIN_DIAG_ELEMENTS")) + aNF = aFilterMgr->CreateMaxElementLength2D(); else; return aNF._retn(); @@ -382,14 +385,14 @@ void SMESHGUI_MultiEditDlg::Init() // main buttons connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); - connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject())); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp())); // selection and SMESHGUI connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject())); // dialog controls connect(myFilterBtn, SIGNAL(clicked()), SLOT(onFilterBtn() )); @@ -421,7 +424,7 @@ void SMESHGUI_MultiEditDlg::Init() void SMESHGUI_MultiEditDlg::onOk() { if (onApply()) - onClose(); + reject(); } //======================================================================= @@ -437,65 +440,6 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds(SMESH::SMESH_IDSource_var& o { myIds.Clear(); obj = SMESH::SMESH_IDSource::_narrow( myMesh ); -// SMESH_Actor * anActor = SMESH::FindActorByObject(myMesh); -// if (!anActor) -// anActor = myActor; -// if (anActor != 0) -// { -// // skl 07.02.2006 -// SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); -// if( myFilterType == SMESH::TriaFilter || -// myFilterType == SMESH::QuadFilter || -// myFilterType == SMESH::FaceFilter ) { -// SMDS_FaceIteratorPtr it = aMesh->facesIterator(); -// while(it->more()) { -// const SMDS_MeshFace* f = it->next(); -// if(myFilterType == SMESH::FaceFilter) { -// myIds.Add(f->GetID()); -// } -// else if( myFilterType==SMESH::TriaFilter && -// ( f->NbNodes()==3 || f->NbNodes()==6 ) ) { -// myIds.Add(f->GetID()); -// } -// else if( myFilterType==SMESH::QuadFilter && -// ( f->NbNodes()==4 || f->NbNodes()==8 ) ) { -// myIds.Add(f->GetID()); -// } -// } -// } -// else if(myFilterType == SMESH::VolumeFilter) { -// SMDS_VolumeIteratorPtr it = aMesh->volumesIterator(); -// while(it->more()) { -// const SMDS_MeshVolume* f = it->next(); -// myIds.Add(f->GetID()); -// } -// } - /* commented by skl 07.02.2006 - to work with quadratic elements - TVisualObjPtr aVisualObj = anActor->GetObject(); - vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid(); - if (aGrid != 0) { - for (int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++) { - vtkCell* aCell = aGrid->GetCell(i); - if (aCell != 0) { - vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell); - vtkQuad* aQua = vtkQuad::SafeDownCast(aCell); - vtkPolygon* aPG = vtkPolygon::SafeDownCast(aCell); - - vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell); - vtkConvexPointSet* aPH = vtkConvexPointSet::SafeDownCast(aCell); - - if (aTri && myFilterType == SMESHGUI_TriaFilter || - aQua && myFilterType == SMESHGUI_QuadFilter || - (aTri || aQua || aPG) && myFilterType == SMESHGUI_FaceFilter || - (a3d || aPH) && myFilterType == SMESHGUI_VolumeFilter) { - int anObjId = aVisualObj->GetElemObjId(i); - myIds.Add(anObjId); - } - } - } - } - */ - //} } anIds->length(myIds.Extent()); @@ -508,10 +452,10 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds(SMESH::SMESH_IDSource_var& o } //======================================================================= -// name : SMESHGUI_MultiEditDlg::onClose +// name : SMESHGUI_MultiEditDlg::reject // Purpose : SLOT called when "Close" button pressed. Close dialog //======================================================================= -void SMESHGUI_MultiEditDlg::onClose() +void SMESHGUI_MultiEditDlg::reject() { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); @@ -525,7 +469,7 @@ void SMESHGUI_MultiEditDlg::onClose() //mySelectionMgr->clearSelected(); mySelectionMgr->clearFilters(); - reject(); + QDialog::reject(); } //================================================================================= @@ -605,7 +549,9 @@ void SMESHGUI_MultiEditDlg::onSelectionDone() anItem->setSelected(true); } } - myMesh = SMESH::GetMeshByIO(anIO); + SMESH::SMESH_Mesh_var aSelMesh = SMESH::GetMeshByIO(anIO); + if (!aSelMesh->_is_nil()) + myMesh = aSelMesh; } if (nbSel > 0) { @@ -644,24 +590,6 @@ void SMESHGUI_MultiEditDlg::enterEvent (QEvent*) } } -//======================================================================= -// name : SMESHGUI_MultiEditDlg::closeEvent -// Purpose : -//======================================================================= -void SMESHGUI_MultiEditDlg::closeEvent (QCloseEvent*) -{ - onClose(); -} -//======================================================================= -// name : SMESHGUI_MultiEditDlg::hideEvent -// Purpose : caused by ESC key -//======================================================================= -void SMESHGUI_MultiEditDlg::hideEvent (QHideEvent*) -{ - if (!isMinimized()) - onClose(); -} - //======================================================================= // name : SMESHGUI_MultiEditDlg::onFilterBtn // Purpose : SLOT. Called when "Filter" button pressed. @@ -678,7 +606,7 @@ void SMESHGUI_MultiEditDlg::onFilterBtn() myFilterDlg->SetSelection(); myFilterDlg->SetMesh(myMesh); - myFilterDlg->SetSourceWg(myListBox); + myFilterDlg->SetSourceWg(myListBox, false); myFilterDlg->show(); } @@ -992,18 +920,18 @@ void SMESHGUI_MultiEditDlg::setSelectionMode() { SMESH::RemoveFilters(); - mySelectionMgr->clearSelected(); + // mySelectionMgr->clearSelected(); mySelectionMgr->clearFilters(); if (mySubmeshChk->isChecked()) { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(new SMESH_TypeFilter(SUBMESH)); + mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::SUBMESH)); } else if (myGroupChk->isChecked()) { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP)); + mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::GROUP)); } if (entityType()) { @@ -1153,7 +1081,13 @@ SMESHGUI_UnionOfTrianglesDlg { setWindowTitle(tr("CAPTION")); - myComboBoxFunctor->setEnabled(true); + //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 myComboBoxFunctor->addItem(tr("TAPER_ELEMENTS")); // for quadrangles only @@ -1174,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"; } @@ -1220,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 @@ -1238,8 +1220,18 @@ SMESHGUI_CuttingOfQuadsDlg QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout()); aLay->addWidget(myPreviewChk, aLay->rowCount(), 0, 1, aLay->columnCount()); + // "split to 4 tria" option + + QRadioButton* to4TriaRB = new QRadioButton(tr("TO_4_TRIA"), myChoiceWidget); + ((QVBoxLayout*)(myCriterionGrp->layout()))->insertWidget(0, to4TriaRB); + myGroupChoice->addButton(to4TriaRB, 3); + to4TriaRB->setChecked(true); + onCriterionRB(); + myCriterionGrp->show(); myChoiceWidget->show(); + myComboBoxFunctor->insertItem(0, tr("MIN_DIAG_ELEMENTS")); + myComboBoxFunctor->setCurrentIndex(0); myComboBoxFunctor->setEnabled(false); connect(myPreviewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk())); @@ -1254,10 +1246,10 @@ SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg() { } -void SMESHGUI_CuttingOfQuadsDlg::onClose() +void SMESHGUI_CuttingOfQuadsDlg::reject() { erasePreview(); - SMESHGUI_MultiEditDlg::onClose(); + SMESHGUI_MultiEditDlg::reject(); } bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, @@ -1270,6 +1262,14 @@ bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, return hasObj ? theEditor->SplitQuadObject(obj, true) : theEditor->SplitQuad(theIds, true); case 1: // use diagonal 2-4 return hasObj ? theEditor->SplitQuadObject(obj, false) : theEditor->SplitQuad(theIds, false); + case 3: // split to 4 tria + { + if ( hasObj ) + return theEditor->QuadTo4Tri( obj ), true; + SMESH::SMESH_IDSource_wrap elems = theEditor->MakeIDSource( theIds, SMESH::FACE ); + theEditor->QuadTo4Tri( elems ); + return true; + } default: // use numeric functor break; } @@ -1285,6 +1285,16 @@ void SMESHGUI_CuttingOfQuadsDlg::onCriterionRB() else myComboBoxFunctor->setEnabled(false); + if (myGroupChoice->checkedId() == 3) // To 4 tria + { + if ( myPreviewChk->isChecked() ) + myPreviewChk->setChecked( false ); + myPreviewChk->setEnabled( false ); + } + else + { + myPreviewChk->setEnabled( true ); + } onPreviewChk(); } @@ -1314,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); @@ -1335,6 +1346,10 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview() return; } + if ( anElemIds->length() == 0 ) { + anElemIds = obj->GetIDs(); + } + //Create grid vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); @@ -1446,7 +1461,7 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview() // Create and display actor vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetInput(aGrid); + aMapper->SetInputData(aGrid); myPreviewActor = SALOME_Actor::New(); myPreviewActor->PickableOff(); @@ -1510,9 +1525,11 @@ bool SMESHGUI_CuttingIntoTetraDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito const SMESH::long_array& theIds, SMESH::SMESH_IDSource_ptr theObj) { - SMESH::SMESH_IDSource_var obj = theObj; + SMESH::SMESH_IDSource_wrap obj = theObj; if ( CORBA::is_nil( obj )) obj = theEditor->MakeIDSource( theIds, myEntityType ? SMESH::VOLUME : SMESH::FACE ); + else + obj->Register(); try { theEditor->SplitVolumesIntoTetra( obj, myGroupChoice->checkedId()+1 ); } @@ -1520,5 +1537,8 @@ bool SMESHGUI_CuttingIntoTetraDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito SalomeApp_Tools::QtCatchCorbaException( S_ex ); return false; } + catch(...) { + return false; + } return true; }