#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
#include <SVTK_ViewWindow.h>
#include <SVTK_Selector.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
-#include <QSpinBox>
#include <QKeyEvent>
// IDL includes
SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
- SpinBox_NbSteps = new QSpinBox(GroupAngleBox);
+ SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
GroupAngleLayout->addWidget(RadioButton3, 0, 0);
GroupAngleLayout->addWidget(RadioButton4, 0, 1);
connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
+ connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
+
ConstructorsClicked(0);
SelectionIntoArgument();
}
// function : ClickOnApply()
// purpose :
//=================================================================================
-void SMESHGUI_RevolutionDlg::ClickOnApply()
+bool SMESHGUI_RevolutionDlg::ClickOnApply()
{
if (mySMESHGUI->isActiveStudyLocked())
- return;
+ return false;
+
+ if (!isValid())
+ return false;
if (myNbOkElements && IsAxisOk()) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
if ( GroupAngle->checkedId() == 1 )
anAngle = anAngle/aNbSteps;
+ QStringList aParameters;
+ aParameters << SpinBox_X->text();
+ aParameters << SpinBox_Y->text();
+ aParameters << SpinBox_Z->text();
+ aParameters << SpinBox_DX->text();
+ aParameters << SpinBox_DY->text();
+ aParameters << SpinBox_DZ->text();
+ aParameters << SpinBox_Angle->text();
+ aParameters << SpinBox_NbSteps->text();
+ aParameters << SpinBox_Tolerance->text();
+
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
- if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
- anAngle, aNbSteps, aTolerance);
- else
- aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
+ if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ }
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
+ anAngle, aNbSteps, aTolerance);
+ }
+ else {
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
+ else
+ aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
+ }
+ else
+ aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
+ }
+
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} catch (...) {
}
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
+
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_RevolutionDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
}
}
+//=======================================================================
+// function : onAngleTextChange()
+// purpose :
+//=======================================================================
+void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
+{
+ bool isNumber;
+ SpinBox_Angle->text().toDouble( &isNumber );
+ if( !isNumber )
+ RadioButton3->setChecked( true );
+ RadioButton4->setEnabled( isNumber );
+}
+
//=======================================================================
// function : onTextChange()
// purpose :
}
if (CheckBoxMesh->isChecked()) {
- int aConstructorId = GetConstructorId();
-
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
- // get IDs from mesh
- SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
- if (!aSMDSMesh)
- return;
-
- if (aConstructorId == 0) {
- SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
-
- while (anIter->more()) {
- const SMDS_MeshEdge * edge = anIter->next();
- if (edge) {
- myElementsId += QString(" %1").arg(edge->GetID());
- aNbUnits++;
- }
- }
- } else if (aConstructorId == 1) {
- SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
- while (anIter->more()) {
- const SMDS_MeshFace * face = anIter->next();
- if (face) {
- myElementsId += QString(" %1").arg(face->GetID());
- aNbUnits++;
- }
- }
- }
- } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
- // get submesh
- SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
-
- // get IDs from submesh
- SMESH::long_array_var anElementsIds = new SMESH::long_array;
- if (aConstructorId == 0)
- anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
- else if (aConstructorId == 1)
- anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
-
- for (int i = 0; i < anElementsIds->length(); i++)
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- aNbUnits = anElementsIds->length();
- } else { // GROUP
- // get smesh group
- SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
- if (aGroup->_is_nil())
- return;
-
- if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
- (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
- return;
-
- // get IDs from smesh group
- SMESH::long_array_var anElementsIds = new SMESH::long_array;
- anElementsIds = aGroup->GetListOfID();
- for (int i = 0; i < anElementsIds->length(); i++) {
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- }
- aNbUnits = anElementsIds->length();
- }
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ else
+ return;
} else {
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
myElementsId = aString;
+ if (aNbUnits < 1)
+ return;
}
-
- if (aNbUnits < 1)
- return;
-
myNbOkElements = true;
} else {
aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
- aMeshEditor->RotationSweep(anElementsId.inout(),
- anAxis,
- anAngle,
- aNbSteps,
- aTolerance);
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ else
+ aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ }
+ else
+ aMeshEditor->RotationSweep(anElementsId.inout(),
+ anAxis,
+ anAngle,
+ aNbSteps,
+ aTolerance);
SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
mySimulation->SetData(aMeshPreviewStruct._retn());
} catch (...) {}
mySimulation->SetVisibility(false);
}
}
+
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_RevolutionDlg::isValid()
+{
+ QString msg;
+ bool ok = true;
+ ok = SpinBox_X->isValid( msg, true ) && ok;
+ ok = SpinBox_Y->isValid( msg, true ) && ok;
+ ok = SpinBox_Z->isValid( msg, true ) && ok;
+ ok = SpinBox_DX->isValid( msg, true ) && ok;
+ ok = SpinBox_DY->isValid( msg, true ) && ok;
+ ok = SpinBox_DZ->isValid( msg, true ) && ok;
+ ok = SpinBox_Angle->isValid( msg, true ) && ok;
+ ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
+ ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
+
+ if( !ok ) {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+ return false;
+ }
+ return true;
+}