X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ExtrusionDlg.cxx;h=2fe9e92bcc5b7ec3b7e9138c963bf8cf47dcae42;hp=66b268813104936d9b37566b969bc311e1aedfa8;hb=2c751a0eddb8c36cbd7582543d6b18d6a3e827e1;hpb=3a821b48ba986795abde72f524fa1a62a5802df2 diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 66b268813..2fe9e92bc 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 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 @@ -709,6 +709,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) // Scales ScalesGrp = new QGroupBox(tr("SMESH_SCALES"), GroupArguments); + ScalesGrp->setCheckable(true); + ScalesGrp->setChecked(false); QGridLayout* ScalesGrpLayout = new QGridLayout( ScalesGrp ); ScalesGrpLayout->setSpacing(SPACING); ScalesGrpLayout->setMargin(MARGIN); @@ -730,10 +732,40 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) ScalesGrpLayout->addWidget(AddScaleButton, 0, 1); ScalesGrpLayout->addWidget(RemoveScaleButton, 2, 1); ScalesGrpLayout->addWidget(ScaleSpin, 0, 2); - ScalesGrpLayout->addWidget(LinearScalesCheck, 4, 0); + ScalesGrpLayout->addWidget(LinearScalesCheck, 4, 0, 1, 3); ScalesGrpLayout->setRowMinimumHeight(1, 10); ScalesGrpLayout->setRowStretch(3, 10); + // Angles + + AnglesGrp = new QGroupBox(tr("SMESH_ANGLES"), GroupArguments); + AnglesGrp->setCheckable(true); + AnglesGrp->setChecked(false); + QGridLayout* AnglesGrpLayout = new QGridLayout( AnglesGrp ); + AnglesGrpLayout->setSpacing(SPACING); AnglesGrpLayout->setMargin(MARGIN); + + AnglesList = new QListWidget( AnglesGrp ); + AnglesList->setSelectionMode(QListWidget::ExtendedSelection); + + AddAngleButton = new QToolButton( AnglesGrp ); + AddAngleButton->setIcon( addImage ); + + RemoveAngleButton = new QToolButton( AnglesGrp ); + RemoveAngleButton->setIcon( removeImage ); + + AngleSpin = new SMESHGUI_SpinBox( AnglesGrp ); + AngleSpin->SetValue(10); + + LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp ); + + AnglesGrpLayout->addWidget(AnglesList, 0, 0, 4, 1); + AnglesGrpLayout->addWidget(AddAngleButton, 0, 1); + AnglesGrpLayout->addWidget(RemoveAngleButton, 2, 1); + AnglesGrpLayout->addWidget(AngleSpin, 0, 2); + AnglesGrpLayout->addWidget(LinearAnglesCheck, 4, 0, 1, 3); + AnglesGrpLayout->setRowMinimumHeight(1, 10); + AnglesGrpLayout->setRowStretch(3, 10); + // layouting GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 1, 9); GroupArgumentsLayout->addWidget(ExtrMethod_RBut0, 1, 0, 1, 3); @@ -761,7 +793,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) GroupArgumentsLayout->addWidget(ByAverageNormalCheck, 6, 0, 1, 4); GroupArgumentsLayout->addWidget(UseInputElemsOnlyCheck, 6, 4, 1, 4); GroupArgumentsLayout->addWidget(BasePointGrp, 7, 0, 1, 9); - GroupArgumentsLayout->addWidget(ScalesGrp, 8, 0, 1, 9); + GroupArgumentsLayout->addWidget(ScalesGrp, 8, 0, 1, 4); + GroupArgumentsLayout->addWidget(AnglesGrp, 8, 5, 1, 4); GroupArgumentsLayout->addWidget(myPreviewCheckBox, 9, 0, 1, 8); GroupArgumentsLayout->addWidget(MakeGroupsCheck, 10,0, 1, 8); GroupArgumentsLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 10, 0); @@ -810,16 +843,17 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) BasePoint_YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); BasePoint_ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); ScaleSpin->RangeStepAndValidator (COORD_MIN, COORD_MAX, 1.0, "length_precision"); + AngleSpin->RangeStepAndValidator (-180.0, 180.0, 5.0, "angle_precision"); ExtrMethod_RBut0->setChecked(true); UseInputElemsOnlyCheck->setChecked(true); MakeGroupsCheck->setChecked(true); - mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); mySMESHGUI->SetActiveDialogBox(this); - myHelpFileName = "extrusion_page.html"; + myHelpFileName = "extrusion.html"; Init(); @@ -844,6 +878,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) connect(AddScaleButton, SIGNAL(clicked()), this, SLOT(OnScaleAdded())); connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(OnScaleRemoved())); + connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(OnScaleAdded())); + connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnScaleRemoved())); connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectBasePointButton,SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -871,10 +907,15 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) connect(AddScaleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); connect(LinearScalesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); + connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation())); + connect(LinearAnglesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); connect(BasePointGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); connect(BasePoint_XSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); connect(BasePoint_YSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); connect(BasePoint_ZSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); + connect(ScalesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); + connect(AnglesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation())); //To Connect preview check box connectPreviewControl(); @@ -964,14 +1005,26 @@ bool SMESHGUI_ExtrusionDlg::isValuesValid() //purpose : return 3 scaling parameters //======================================================================= -bool SMESHGUI_ExtrusionDlg::getScaleParams( SMESH::double_array*& scales, - SMESH::double_array*& basePoint ) +void SMESHGUI_ExtrusionDlg::getScaleParams( SMESH::double_array*& scales, + SMESH::double_array*& basePoint, + bool & scalesVariation, + SMESH::double_array*& angles, + bool & anglesVariation ) { scales = new SMESH::double_array; - scales->length( myScalesList.count() ); - for ( int i = 0; i < myScalesList.count(); ++i ) - (*scales)[i] = myScalesList[i]; - + if ( ScalesGrp->isChecked() ) + { + scales->length( myScalesList.count() ); + for ( int i = 0; i < myScalesList.count(); ++i ) + (*scales)[i] = myScalesList[i]; + } + angles = new SMESH::double_array; + if ( AnglesGrp->isChecked() ) + { + angles->length( myAnglesList.count() ); + for ( int i = 0; i < myAnglesList.count(); ++i ) + (*angles)[i] = myAnglesList[i]*M_PI/180.; + } basePoint = new SMESH::double_array; if ( BasePointGrp->isChecked() ) { @@ -981,7 +1034,8 @@ bool SMESHGUI_ExtrusionDlg::getScaleParams( SMESH::double_array*& scales, (*basePoint)[2] = BasePoint_ZSpin->GetValue(); } - return ( scales->length() > 0 && LinearScalesCheck->isChecked() ); + scalesVariation = ( scales->length() > 0 && LinearScalesCheck->isChecked() ); + anglesVariation = ( angles->length() > 0 && LinearAnglesCheck->isChecked() ); } //================================================================================= @@ -1074,6 +1128,7 @@ void SMESHGUI_ExtrusionDlg::ClickOnRadio() BasePointGrp->setEnabled( !ExtrMethod_RBut2->isChecked() ); ScalesGrp ->setEnabled( !ExtrMethod_RBut2->isChecked() ); + AnglesGrp ->setEnabled( !ExtrMethod_RBut2->isChecked() ); CheckIsEnable(); @@ -1092,7 +1147,7 @@ void SMESHGUI_ExtrusionDlg::ClickOnRadio() bool SMESHGUI_ExtrusionDlg::ClickOnApply() { - if (mySMESHGUI->isActiveStudyLocked()) + if (SMESHGUI::isStudyLocked()) return false; if (!isValid()) @@ -1126,13 +1181,11 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() long aNbSteps = (long)SpinBox_NbSteps->value(); aParameters << SpinBox_NbSteps->text(); - SMESH::double_array_var scales = new SMESH::double_array; - scales->length( myScalesList.count() ); for (int i = 0; i < myScalesList.count(); i++) - { - scales[i] = myScalesList[i]; aParameters << ScalesList->item(i)->text(); - } + + for (int i = 0; i < myAnglesList.count(); i++) + aParameters << AnglesList->item(i)->text(); bool meshHadNewTypeBefore = true; int maxSelType = 0; @@ -1159,7 +1212,7 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() SMESH::SMESH_MeshEditor_var meshEditor = mesh->GetMeshEditor(); SMESH::ListOfGroups_var groups; - mesh->SetParameters( aParameters.join(":").toLatin1().constData() ); + mesh->SetParameters( aParameters.join(":").toUtf8().constData() ); if ( ExtrMethod_RBut2->isVisible() && ExtrMethod_RBut2->isChecked() ) // Extrusion by normal @@ -1170,17 +1223,19 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() bool byAverageNormal = ByAverageNormalCheck->isChecked(); int dim = (maxSelType == SMESH::FACE) ? 2 : 1; - groups = meshEditor->ExtrusionByNormal( faces, stepSize, nbSteps, useInputElemsOnly, - byAverageNormal, makeGroups, dim ); + groups = meshEditor->ExtrusionByNormal( faces, stepSize, nbSteps, byAverageNormal, + useInputElemsOnly, makeGroups, dim ); } else { - SMESH::double_array_var scales, basePoint; - bool linVariation = getScaleParams( scales.out(), basePoint.out() ); + SMESH::double_array_var scales, basePoint, angles; + bool scalesVariation, anglesVariation; + getScaleParams( scales.out(), basePoint.out(), scalesVariation, + angles.out(), anglesVariation ); groups = meshEditor->ExtrusionSweepObjects( nodes, edges, faces, - aVector, aNbSteps, - scales, linVariation, basePoint, - makeGroups ); + aVector, aNbSteps, makeGroups, + scales, scalesVariation, basePoint, + angles, anglesVariation ); } } catch (...) { @@ -1206,9 +1261,9 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() SMESH::Update( actor->getIO(), actor->GetVisibility() ); if ( makeGroups ) mySMESHGUI->updateObjBrowser(true); // new groups may appear - Init(false); + mySelectionMgr->clearSelected(); - SelectorWdg->Clear(); + Init(false); SMESHGUI::Modified(); } @@ -1289,7 +1344,7 @@ void SMESHGUI_ExtrusionDlg::ClickOnHelp() #endif SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)). arg(myHelpFileName)); } @@ -1323,7 +1378,7 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() return; const SMDS_MeshFace* face = - dynamic_cast(aMesh->FindElement(aMapIndex(1))); + aMesh->DownCast< SMDS_MeshFace >(aMesh->FindElement(aMapIndex(1))); if (!face) return; @@ -1560,20 +1615,22 @@ void SMESHGUI_ExtrusionDlg::onDisplaySimulation( bool toDisplayPreview ) bool byAverageNormal = ByAverageNormalCheck->isChecked(); int dim = (maxSelType == SMESH::FACE) ? 2 : 1; - groups = meshEditor->ExtrusionByNormal( faces, stepSize, nbSteps, useInputElemsOnly, - byAverageNormal, makeGroups, dim ); + groups = meshEditor->ExtrusionByNormal( faces, stepSize, nbSteps, byAverageNormal, + useInputElemsOnly, makeGroups, dim ); } else { - SMESH::double_array_var scales, basePoint; - bool linVariation = getScaleParams( scales.out(), basePoint.out() ); + SMESH::double_array_var scales, basePoint, angles; + bool scalesVariation, anglesVariation; + getScaleParams( scales.out(), basePoint.out(), scalesVariation, + angles.out(), anglesVariation ); groups = meshEditor->ExtrusionSweepObjects( nodes, edges, faces, - aVector, aNbSteps, - scales, linVariation, basePoint, - makeGroups ); + aVector, aNbSteps, makeGroups, + scales, scalesVariation, basePoint, + angles, anglesVariation ); } SMESH::MeshPreviewStruct_var aMeshPreviewStruct = meshEditor->GetPreviewData(); - mySimulation->SetData(aMeshPreviewStruct._retn()); + mySimulation->SetData(aMeshPreviewStruct); } catch (...) { hidePreview(); @@ -1614,35 +1671,65 @@ void SMESHGUI_ExtrusionDlg::getExtrusionVector(SMESH::DirStruct& aVector) //======================================================================= // function : OnScaleAdded() -// purpose : Called when user adds Scale to the list +// purpose : Called when user adds Scale or Angle to the list //======================================================================= void SMESHGUI_ExtrusionDlg::OnScaleAdded() { - QString msg; - if( !ScaleSpin->isValid( msg, true ) ) { - QString str( tr( "SMESH_INCORRECT_INPUT" ) ); - if ( !msg.isEmpty() ) - str += "\n" + msg; - SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); - return; + if ( sender() == AddScaleButton ) + { + QString msg; + if( !ScaleSpin->isValid( msg, true ) ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return; + } + ScalesList->addItem(ScaleSpin->text()); + myScalesList.append(ScaleSpin->GetValue()); + } + + if ( sender() == AddAngleButton ) + { + QString msg; + if( !AngleSpin->isValid( msg, true ) ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return; + } + AnglesList->addItem(AngleSpin->text()); + myAnglesList.append(AngleSpin->GetValue()); } - ScalesList->addItem(ScaleSpin->text()); - myScalesList.append(ScaleSpin->GetValue()); } //======================================================================= // function : OnScaleRemoved() -// purpose : Called when user removes Scale(s) from the list +// purpose : Called when user removes Scales or Angles from the list //======================================================================= void SMESHGUI_ExtrusionDlg::OnScaleRemoved() { - QList aList = ScalesList->selectedItems(); + QListWidget* widget; + QList* list; + if ( sender() == RemoveScaleButton ) + { + widget = ScalesList; + list = & myScalesList; + } + else + { + widget = AnglesList; + list = & myAnglesList; + } + + QList aList = widget->selectedItems(); QListWidgetItem* anItem; int row = 0; foreach(anItem, aList) { - row = ScalesList->row(anItem); - myScalesList.removeAt(row); + row = widget->row(anItem); + list->removeAt(row); delete anItem; } - ScalesList->setCurrentRow( row, QItemSelectionModel::Select ); + widget->setCurrentRow( row, QItemSelectionModel::Select ); }