X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ExtrusionAlongPathDlg.cxx;h=64788a36623260564c7baf906abb7b499a127133;hp=a9af10b7674608ee637c7b4cbff39e558fc08053;hb=2c607013a23bd4e7ba07e72e0c04dee2c1209cff;hpb=7ce6ef7ee96d7287440bfb25bfc82f24fdcb4c06 diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index a9af10b76..64788a366 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// 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. +// 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. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_ExtrusionAlongPathDlg.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. @@ -33,6 +34,7 @@ #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_IdValidator.h" #include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_MeshEditPreview.h" #include #include @@ -108,8 +110,7 @@ private: // purpose : constructor //================================================================================= SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule ) - : QDialog( SMESH::GetDesktop( theModule ) ), - mySMESHGUI( theModule ), + : SMESHGUI_PreviewDlg( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myFilterDlg( 0 ) { @@ -166,6 +167,7 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod ElementsLineEdit = new QLineEdit(GroupArguments); ElementsLineEdit->setValidator(myIdValidator); + ElementsLineEdit->setMaxLength(-1); myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); @@ -186,15 +188,6 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod PathMeshLineEdit = new QLineEdit(PathGrp); PathMeshLineEdit->setReadOnly(true); - // Controls for path shape selection - QLabel* PathShapeLab = new QLabel(tr("SMESH_PATH_SHAPE"), PathGrp); - - SelectPathShapeButton = new QToolButton(PathGrp); - SelectPathShapeButton->setIcon(selectImage); - - PathShapeLineEdit = new QLineEdit(PathGrp); - PathShapeLineEdit->setReadOnly(true); - // Controls for path starting point selection QLabel* StartPointLab = new QLabel(tr("SMESH_PATH_START"), PathGrp); @@ -208,12 +201,9 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod PathGrpLayout->addWidget(PathMeshLab, 0, 0); PathGrpLayout->addWidget(SelectPathMeshButton, 0, 1); PathGrpLayout->addWidget(PathMeshLineEdit, 0, 2); - PathGrpLayout->addWidget(PathShapeLab, 1, 0); - PathGrpLayout->addWidget(SelectPathShapeButton, 1, 1); - PathGrpLayout->addWidget(PathShapeLineEdit, 1, 2); - PathGrpLayout->addWidget(StartPointLab, 2, 0); - PathGrpLayout->addWidget(SelectStartPointButton, 2, 1); - PathGrpLayout->addWidget(StartPointLineEdit, 2, 2); + PathGrpLayout->addWidget(StartPointLab, 1, 0); + PathGrpLayout->addWidget(SelectStartPointButton, 1, 1); + PathGrpLayout->addWidget(StartPointLineEdit, 1, 2); BasePointGrp = new QGroupBox(tr("SMESH_BASE_POINT"), GroupArguments); BasePointGrp->setCheckable(true); @@ -272,6 +262,9 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); MakeGroupsCheck->setChecked(true); + //Preview check box + myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments); + // layouting GroupArgumentsLayout->addWidget(ElementsLab, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); @@ -281,7 +274,8 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 4); GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 4); GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 4); - GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 4); + GroupArgumentsLayout->addWidget(myPreviewCheckBox, 5, 0, 1, 4); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4); /***************************************************************/ // common buttons group box @@ -319,10 +313,10 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod /***************************************************************/ // Initialisations - XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3); - YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3); - ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3); - AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, 3); + XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, "angle_precision"); mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); @@ -337,7 +331,8 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter); myElementsFilter = new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR); - myPathMeshFilter = new SMESH_TypeFilter (MESH); + //myPathMeshFilter = new SMESH_TypeFilter (MESH); + myPathMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH); myHelpFileName = "extrusion_along_path_page.html"; @@ -357,7 +352,6 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectPathMeshButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(SelectPathShapeButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectBasePointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -366,12 +360,23 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject())); connect(ElementsLineEdit, SIGNAL(textChanged(const QString&)), - SLOT(onTextChange(const QString&))); + SLOT(onTextChange(const QString&))); connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)), - SLOT(onTextChange(const QString&))); + SLOT(onTextChange(const QString&))); connect(MeshCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh())); + connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(ZSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(LinearAnglesCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh())); + + + //To Connect preview check box + connectPreviewControl(); + AnglesList->installEventFilter(this); ElementsLineEdit->installEventFilter(this); StartPointLineEdit->installEventFilter(this); @@ -405,12 +410,10 @@ void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls) myMesh = SMESH::SMESH_Mesh::_nil(); myIDSource = SMESH::SMESH_IDSource::_nil(); myMeshActor = 0; - myPathMesh = SMESH::SMESH_Mesh::_nil(); - myPathShape = GEOM::GEOM_Object::_nil(); + myPath = SMESH::SMESH_IDSource::_nil(); ElementsLineEdit->clear(); PathMeshLineEdit->clear(); - PathShapeLineEdit->clear(); StartPointLineEdit->clear(); if (ResetControls) { @@ -422,6 +425,8 @@ void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls) MeshCheck->setChecked(false); ConstructorsClicked(0); onSelectMesh(); + myPreviewCheckBox->setChecked(false); + onDisplaySimulation(false); } SetEditCurrentArgument(0); } @@ -436,6 +441,8 @@ void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type) disconnect(mySelectionMgr, 0, this, 0); + hidePreview(); + if (type == 0) GroupArguments->setTitle(tr("EXTRUSION_1D")); else if (type == 1) @@ -454,19 +461,19 @@ void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type) SMESH::SetPointRepresentation(false); if (MeshCheck->isChecked()) { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(ActorSelection); + aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->installFilter(myElementsFilter); } else { if (type == 0) - { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(EdgeSelection); - } + { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(EdgeSelection); + } if (type == 1) - { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(FaceSelection); - } + { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); + } } } connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); @@ -483,50 +490,21 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() if (mySMESHGUI->isActiveStudyLocked()) return false; - if (myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || - !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil()) + //if (myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || + // !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil()) + if ( myMesh->_is_nil() || (MeshCheck->isChecked() && myIDSource->_is_nil()) || + /*!myMeshActor ||*/ myPath->_is_nil() ) return false; if (!isValid()) return false; - SMESH::long_array_var anElementsId = new SMESH::long_array; - - if (!MeshCheck->isChecked()) { - // If "Select whole mesh, submesh or group" check box is off -> - // use only elements of given type selected by user - - SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh(); - if (aMesh) { - QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts); - anElementsId = new SMESH::long_array; - anElementsId->length(aListElementsId.count()); - bool bOk; - int j = 0; - for (int i = 0; i < aListElementsId.count(); i++) { - long ind = aListElementsId[ i ].toLong(&bOk); - if (bOk) { - const SMDS_MeshElement* e = aMesh->FindElement(ind); - if (e) { - bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || - Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face; - if (typeMatch) - anElementsId[ j++ ] = ind; - } - } - } - anElementsId->length(j); - } - - if (anElementsId->length() <= 0) { - return false; - } - } + SMESH::long_array_var anElementsId = getSelectedElements(); if (StartPointLineEdit->text().trimmed().isEmpty()) { return false; } - + bool bOk; long aNodeStart = StartPointLineEdit->text().toLong(&bOk); if (!bOk) { @@ -534,19 +512,13 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() } QStringList aParameters; + + //get angles + SMESH::double_array_var anAngles = getAngles(); + + for (int i = 0; i < myAnglesList.count(); i++) + aParameters << AnglesList->item(i)->text(); - // get angles - SMESH::double_array_var anAngles = new SMESH::double_array; - if (AnglesGrp->isChecked()) { - anAngles->length(myAnglesList.count()); - int j = 0; - for (int i = 0; i < myAnglesList.count(); i++) { - double angle = myAnglesList[i]; - anAngles[ j++ ] = angle*PI/180; - aParameters << AnglesList->item(i)->text(); - } - anAngles->length(j); - } // get base point SMESH::PointStruct aBasePoint; @@ -563,87 +535,110 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() try { SUIT_OverrideCursor wc; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( LinearAnglesCheck->isChecked() ) - anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles ); + //if ( LinearAnglesCheck->isChecked() ) { + // anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles ); + //} SMESH::SMESH_MeshEditor::Extrusion_Error retVal; + /* if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { if( MeshCheck->isChecked() ) { - if( GetConstructorId() == 0 ) - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint, retVal); - else - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint, retVal); + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); } else - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint, retVal); + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); } else { if( MeshCheck->isChecked() ) { - if( GetConstructorId() == 0 ) - retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint); - else - retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint); + if( GetConstructorId() == 0 ) + retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + else + retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); } else - retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint); + retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); } + */ + + bool NeedGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); + SMESH::ElementType ElemType = SMESH::FACE; + if( GetConstructorId() == 0 ) + ElemType = SMESH::EDGE; + if( !MeshCheck->isChecked() ) { + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(), + anAngles, LinearAnglesCheck->isChecked(), + BasePointGrp->isChecked(), aBasePoint, + NeedGroups, ElemType, retVal); + } + else { + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(), + anAngles, LinearAnglesCheck->isChecked(), + BasePointGrp->isChecked(), aBasePoint, + NeedGroups, ElemType, retVal); + } + if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) - myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + myMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); //wc.stop(); wc.suspend(); switch (retVal) { case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS: SUIT_MessageBox::warning(this, - tr("SMESH_ERROR"), - tr("NO_ELEMENTS_SELECTED")); + tr("SMESH_ERROR"), + tr("NO_ELEMENTS_SELECTED")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE: SUIT_MessageBox::warning(this, - tr("SMESH_ERROR"), - tr("SELECTED_PATH_IS_NOT_EDGE")); + tr("SMESH_ERROR"), + tr("SELECTED_PATH_IS_NOT_EDGE")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE: SUIT_MessageBox::warning(this, - tr("SMESH_ERROR"), - tr("BAD_SHAPE_TYPE")); + tr("SMESH_ERROR"), + tr("BAD_SHAPE_TYPE")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE: SUIT_MessageBox::warning(this, - tr("SMESH_ERROR"), - tr("EXTR_BAD_STARTING_NODE")); + tr("SMESH_ERROR"), + tr("EXTR_BAD_STARTING_NODE")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER: SUIT_MessageBox::warning(this, - tr("SMESH_ERROR"), - tr("WRONG_ANGLES_NUMBER")); + tr("SMESH_ERROR"), + tr("WRONG_ANGLES_NUMBER")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT: SUIT_MessageBox::warning(this, - tr("SMESH_ERROR"), - tr("CANT_GET_TANGENT")); + tr("SMESH_ERROR"), + tr("CANT_GET_TANGENT")); return false; break; case SMESH::SMESH_MeshEditor::EXTR_OK: break; @@ -653,7 +648,11 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() } //mySelectionMgr->clearSelected(); - SMESH::Update( myMeshActor->getIO(), myMeshActor->GetVisibility() ); + if ( myMeshActor ) + SMESH::Update( myMeshActor->getIO(), myMeshActor->GetVisibility() ); + + SMESHGUI::Modified(); + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) mySMESHGUI->updateObjBrowser(true); // new groups may appear //SMESH::UpdateView(); @@ -689,10 +688,10 @@ void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp() platform = "application"; #endif SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", - platform)). - arg(myHelpFileName)); + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -751,49 +750,50 @@ void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText) const Handle(SALOME_InteractiveObject)& anIO = myMeshActor->getIO(); TColStd_MapOfInteger newIndices; for (int i = 0; i < aListId.count(); i++) { - long ind = aListId[ i ].toLong(&bOk); - if (bOk) { - const SMDS_MeshElement* e = aMesh->FindElement(ind); - if (e) { - // check also type of element - bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || - Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face; - if (typeMatch) - newIndices.Add(e->GetID()); - } - } + long ind = aListId[ i ].toLong(&bOk); + if (bOk) { + const SMDS_MeshElement* e = aMesh->FindElement(ind); + if (e) { + // check also type of element + bool typeMatch = (Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge) || + (Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face); + if (typeMatch) + newIndices.Add(e->GetID()); + } + } } mySelector->AddOrRemoveIndex(anIO, newIndices, false); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->highlight( anIO, true, true ); + aViewWindow->highlight( anIO, true, true ); } - } else if (send == StartPointLineEdit && + } + else if (send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit) { - if (!myPathMesh->_is_nil()) { - SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); + if (!myPath->_is_nil()) { + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath); SMDS_Mesh* aMesh = 0; if (aPathActor) - aMesh = aPathActor->GetObject()->GetMesh(); + aMesh = aPathActor->GetObject()->GetMesh(); if (aMesh) { - //mySelectionMgr->clearSelected(); - //mySelectionMgr->AddIObject(aPathActor->getIO()); + //mySelectionMgr->clearSelected(); + //mySelectionMgr->AddIObject(aPathActor->getIO()); SALOME_ListIO aList; aList.Append(aPathActor->getIO()); mySelectionMgr->setSelectedObjects(aList, false); - bool bOk; - long ind = theNewText.toLong(&bOk); - if (bOk) { - const SMDS_MeshNode* n = aMesh->FindNode(ind); - if (n) { - //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) { + bool bOk; + long ind = theNewText.toLong(&bOk); + if (bOk) { + const SMDS_MeshNode* n = aMesh->FindNode(ind); + if (n) { + //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) { TColStd_MapOfInteger newIndices; - newIndices.Add(n->GetID()); - mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false ); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->highlight( aPathActor->getIO(), true, true ); - } - } + newIndices.Add(n->GetID()); + mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( aPathActor->getIO(), true, true ); + } + } } } } @@ -843,7 +843,7 @@ void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() } // find actor myMeshActor = SMESH::FindActorByObject(myMesh); - if (!myMeshActor) + if (!myMeshActor && !MeshCheck->isChecked()) return; if (MeshCheck->isChecked()) { @@ -862,57 +862,37 @@ void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() SMESH::GetNameOfSelectedElements(mySelector, IO, aString); ElementsLineEdit->setText(aString); } - } else if (myEditCurrentArgument == PathMeshLineEdit) { + } + else if (myEditCurrentArgument == PathMeshLineEdit) { // we are now selecting path mesh // reset PathMeshLineEdit->clear(); - myPathMesh = SMESH::SMESH_Mesh::_nil(); - PathShapeLineEdit->clear(); - myPathShape = GEOM::GEOM_Object::_nil(); + myPath = SMESH::SMESH_IDSource::_nil(); StartPointLineEdit->clear(); - + // try to get mesh from selection Handle(SALOME_InteractiveObject) IO = aList.First(); - myPathMesh = SMESH::IObjectToInterface(IO); - if(myPathMesh->_is_nil()) + myPath = SMESH::IObjectToInterface(IO); + if( myPath->_is_nil() ) return; - + QString aString; SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); PathMeshLineEdit->setText(aString); - } else if (myEditCurrentArgument == PathShapeLineEdit) { - // we are now selecting path mesh - // reset - PathShapeLineEdit->clear(); - myPathShape = GEOM::GEOM_Object::_nil(); - StartPointLineEdit->clear(); - - // return if path mesh is not yet selected - if (myPathMesh->_is_nil()) - return; - - // try to get shape from selection - Handle(SALOME_InteractiveObject) IO = aList.First(); - myPathShape = SMESH::IObjectToInterface(IO); - if (myPathShape->_is_nil()) - return; - - QString aString; - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - PathShapeLineEdit->setText(aString); - } else if (myEditCurrentArgument == StartPointLineEdit) { + } + else if (myEditCurrentArgument == StartPointLineEdit) { // we are now selecting start point of path // reset StartPointLineEdit->clear(); // return if path mesh or path shape is not yet selected - if (myPathMesh->_is_nil() || myPathShape->_is_nil()) + if( myPath->_is_nil() ) return; // try to get shape from selection Handle(SALOME_InteractiveObject) IO = aList.First(); - SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath); if ( !aPathActor ) return; @@ -937,10 +917,10 @@ void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() TopoDS_Vertex aVertex; if (!aGeomObj->_is_nil()) { if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) { - gp_Pnt aPnt = BRep_Tool::Pnt(aVertex); - XSpin->SetValue(aPnt.X()); - YSpin->SetValue(aPnt.Y()); - ZSpin->SetValue(aPnt.Z()); + gp_Pnt aPnt = BRep_Tool::Pnt(aVertex); + XSpin->SetValue(aPnt.X()); + YSpin->SetValue(aPnt.Y()); + ZSpin->SetValue(aPnt.Z()); } return; } @@ -972,6 +952,7 @@ void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument() YSpin->SetValue(n->Y()); ZSpin->SetValue(n->Z()); } + onDisplaySimulation(true); } //================================================================================= @@ -983,7 +964,6 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() QToolButton* send = (QToolButton*)sender(); if (send != SelectElementsButton && send != SelectPathMeshButton && - send != SelectPathShapeButton && send != SelectStartPointButton && send != SelectBasePointButton) return; @@ -997,7 +977,7 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument() void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button) { disconnect(mySelectionMgr, 0, this, 0); - mySelectionMgr->clearSelected(); + // mySelectionMgr->clearSelected(); mySelectionMgr->clearFilters(); SMESH::SetPickable(); @@ -1006,19 +986,19 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button SMESH::SetPointRepresentation(false); if (MeshCheck->isChecked()) { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(ActorSelection); + aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->installFilter(myElementsFilter); } else { if (Elements1dRB->isChecked()) - { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(EdgeSelection); - } + { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(EdgeSelection); + } else if (Elements2dRB->isChecked()) - { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(FaceSelection); - } + { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); + } } } else if (button == SelectPathMeshButton) { myEditCurrentArgument = PathMeshLineEdit; @@ -1027,31 +1007,16 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->installFilter(myPathMeshFilter); } - else if (button == SelectPathShapeButton) { - myEditCurrentArgument = PathShapeLineEdit; - SMESH::SetPointRepresentation(false); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(ActorSelection); - - if (!myPathMesh->_is_nil()) { - GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh(); - SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); - - if (!aMainShape->_is_nil() && aPathActor) - mySelectionMgr->installFilter(new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, -1, - TopAbs_EDGE, aMainShape)); - //SMESH::SetPickable(aPathActor); - } - } else if (button == SelectStartPointButton) { myEditCurrentArgument = StartPointLineEdit; - if (!myPathMesh->_is_nil()) { - SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh); + //if (!myPathMesh->_is_nil()) { + if (!myPath->_is_nil()) { + SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath); if (aPathActor) { - SMESH::SetPointRepresentation(true); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(NodeSelection); - SMESH::SetPickable(aPathActor); + SMESH::SetPointRepresentation(true); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); + SMESH::SetPickable(aPathActor); } } } @@ -1196,21 +1161,21 @@ bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event QKeyEvent* ke = (QKeyEvent*)event; if (object == AnglesList) { if (ke->key() == Qt::Key_Delete) - OnAngleRemoved(); + OnAngleRemoved(); } } else if (event->type() == QEvent::FocusIn) { if (object == ElementsLineEdit) { if (myEditCurrentArgument != ElementsLineEdit) - SetEditCurrentArgument(SelectElementsButton); + SetEditCurrentArgument(SelectElementsButton); } else if (object == StartPointLineEdit) { if (myEditCurrentArgument != StartPointLineEdit) - SetEditCurrentArgument(SelectStartPointButton); + SetEditCurrentArgument(SelectStartPointButton); } else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) { if (myEditCurrentArgument != XSpin) - SetEditCurrentArgument(SelectBasePointButton); + SetEditCurrentArgument(SelectBasePointButton); } } return QDialog::eventFilter(object, event); @@ -1240,8 +1205,8 @@ void SMESHGUI_ExtrusionAlongPathDlg::setFilters() { if(myMesh->_is_nil()) { SUIT_MessageBox::critical(this, - tr("SMESH_ERROR"), - tr("NO_MESH_SELECTED")); + tr("SMESH_ERROR"), + tr("NO_MESH_SELECTED")); return; } if ( !myFilterDlg ) @@ -1294,10 +1259,162 @@ void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles() enableLinear = false; anItem->text().toDouble(&enableLinear); if( !enableLinear ) - break; + break; } } if( !enableLinear ) LinearAnglesCheck->setChecked( false ); LinearAnglesCheck->setEnabled( enableLinear ); } + +//================================================================================= +// function : isValuesValid() +// purpose : Return true in case if values entered into dialog are valid +//================================================================================= +bool SMESHGUI_ExtrusionAlongPathDlg::isValuesValid() { + + if ( (MeshCheck->isChecked() && myIDSource->_is_nil()) || + myMesh->_is_nil() || + myPath->_is_nil() ) + return false; + + if(!MeshCheck->isChecked()) { + QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts); + if(aListElementsId.count() <= 0) + return false; + } + + bool bOk; + StartPointLineEdit->text().toLong(&bOk); + if (!bOk) { + return false; + } + + return true; +} + + +//================================================================================= +// function : onDisplaySimulation +// purpose : Show/Hide preview +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::onDisplaySimulation( bool toDisplayPreview ) { + if (myPreviewCheckBox->isChecked() && toDisplayPreview) { + if(isValid() && isValuesValid()) { + + //Get selected elements: + SMESH::long_array_var anElementsId = getSelectedElements(); + + // get angles + SMESH::double_array_var anAngles = getAngles(); + + // get base point + SMESH::PointStruct aBasePoint; + if (BasePointGrp->isChecked()) { + aBasePoint.x = XSpin->GetValue(); + aBasePoint.y = YSpin->GetValue(); + aBasePoint.z = ZSpin->GetValue(); + } + bool bOk; + long aNodeStart = StartPointLineEdit->text().toLong(&bOk); + if (bOk) { + + try { + SUIT_OverrideCursor wc; + + SMESH::SMESH_MeshEditor::Extrusion_Error retVal; + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); + bool NeedGroups = false; + SMESH::ElementType ElemType = SMESH::FACE; + if( GetConstructorId() == 0 ) + ElemType = SMESH::EDGE; + if( !MeshCheck->isChecked() ) { + aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(), + anAngles, LinearAnglesCheck->isChecked(), + BasePointGrp->isChecked(), aBasePoint, + NeedGroups, ElemType, retVal); + } + else { + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(), + anAngles, LinearAnglesCheck->isChecked(), + BasePointGrp->isChecked(), aBasePoint, + NeedGroups, ElemType, retVal); + } + + wc.suspend(); + if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) { + SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); + mySimulation->SetData(aMeshPreviewStruct._retn()); + } else { + hidePreview(); + } + + } catch (...) { + hidePreview(); + } + } else { + hidePreview(); + } + + } else { + hidePreview(); + } + } else { + hidePreview(); + } +} + + +//================================================================================= +// function : getSelectedElements +// purpose : return list of the selected elements +//================================================================================= +SMESH::long_array_var SMESHGUI_ExtrusionAlongPathDlg::getSelectedElements() { + + // If "Select whole mesh, submesh or group" check box is off -> + // use only elements of given type selected by user + SMESH::long_array_var anElementsId = new SMESH::long_array; + if (!MeshCheck->isChecked()) { + + SMDS_Mesh* aMesh; + if ( myMeshActor ) + aMesh = myMeshActor->GetObject()->GetMesh(); + + if (aMesh) { + QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts); + anElementsId = new SMESH::long_array; + anElementsId->length(aListElementsId.count()); + bool bOk; + int j = 0; + for (int i = 0; i < aListElementsId.count(); i++) { + long ind = aListElementsId[ i ].toLong(&bOk); + if (bOk) { + const SMDS_MeshElement* e = aMesh->FindElement(ind); + if (e) { + bool typeMatch = (Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge) || + (Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face); + if (typeMatch) + anElementsId[ j++ ] = ind; + } + } + } + anElementsId->length(j); + } + } + return anElementsId; +} + +SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getAngles() { + SMESH::double_array_var anAngles = new SMESH::double_array; + if (AnglesGrp->isChecked()) { + anAngles->length(myAnglesList.count()); + int j = 0; + for (int i = 0; i < myAnglesList.count(); i++) { + double angle = myAnglesList[i]; + anAngles[ j++ ] = angle*PI/180; + } + anAngles->length(j); + } + return anAngles; +}