+
+
+//=======================================================================
+//function : onActionClicked
+//purpose : slot called when an action type changed
+//=======================================================================
+
+void SMESHGUI_RotationDlg::onActionClicked(int button)
+{
+ int aNbGroups = 0;
+ for ( int i = 0; i < myMeshes.count(); i++ )
+ aNbGroups += myMeshes[i]->NbGroups();
+
+ switch ( button ) {
+ case MOVE_ELEMS_BUTTON:
+ MakeGroupsCheck->setEnabled(false);
+ LineEditNewMesh->setEnabled(false);
+ break;
+ case COPY_ELEMS_BUTTON:
+ LineEditNewMesh->setEnabled(false);
+ MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
+ MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 );
+ break;
+ case MAKE_MESH_BUTTON:
+ LineEditNewMesh->setEnabled(true);
+ MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
+ MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 );
+ break;
+ }
+ setNewMeshName();
+ toDisplaySimulation();
+}
+
+//=======================================================================
+//function : setNewMeshName
+//purpose : update contents of LineEditNewMesh
+//=======================================================================
+
+void SMESHGUI_RotationDlg::setNewMeshName()
+{
+ LineEditNewMesh->setText("");
+ if ( LineEditNewMesh->isEnabled() && !myMeshes.isEmpty() ) {
+ QString name;
+ if ( CheckBoxMesh->isChecked() ) {
+ name = myMeshes.count() > 1 ? "*" : LineEditElements->text();
+ }
+ else {
+ _PTR(SObject) meshSO = SMESH::FindSObject( myMeshes[0] );
+ name = meshSO->GetName().c_str();
+ }
+ if ( !name.isEmpty() )
+ LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "rotated"));
+ }
+}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 ) {
+ e->accept();
+ ClickOnHelp();
+ }
+}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_RotationDlg::setFilters()
+{
+ if ( myMeshes.isEmpty() ) {
+ SUIT_MessageBox::critical(this,
+ tr("SMESH_ERROR"),
+ tr("NO_MESH_SELECTED"));
+ return;
+ }
+ if ( !myFilterDlg ) {
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
+ connect(myFilterDlg, SIGNAL(Accepted()), SLOT(onFilterAccepted()));
+ }
+
+ QList<int> types;
+ if ( myMeshes[0]->NbEdges() ) types << SMESH::EDGE;
+ if ( myMeshes[0]->NbFaces() ) types << SMESH::FACE;
+ if ( myMeshes[0]->NbVolumes() ) types << SMESH::VOLUME;
+ if ( myMeshes[0]->NbBalls() ) types << SMESH::BALL;
+ if ( myMeshes[0]->Nb0DElements()) types << SMESH::ELEM0D;
+ if ( types.count() > 1 ) types << SMESH::ALL;
+
+ myFilterDlg->Init( types );
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMeshes[0] );
+ myFilterDlg->SetSourceWg( LineEditElements );
+
+ myFilterDlg->show();
+}
+
+//=======================================================================
+// name : onFilterAccepted()
+// Purpose : SLOT. Called when Filter dlg closed with OK button.
+// Activate [Apply] if no Actor is available
+//=======================================================================
+void SMESHGUI_RotationDlg::onFilterAccepted()
+{
+ if ( myMeshes.length() > 0 && !buttonOk->isEnabled() )
+ {
+ myElementsId = LineEditElements->text();
+ QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
+ myNbOkElements = aListElementsId.count();
+ buttonOk->setEnabled( myNbOkElements );
+ buttonApply->setEnabled( myNbOkElements );
+ }
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_RotationDlg::isValid()
+{
+ bool ok = true;
+ QString msg;
+
+ 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;
+
+ 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;
+}
+
+
+//=================================================================================
+// function : onDisplaySimulation
+// purpose : Show/Hide preview
+//=================================================================================
+void SMESHGUI_RotationDlg::onDisplaySimulation( bool toDisplayPreview ) {
+ if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
+ if(myNbOkElements && isValid() && IsAxisOk()) {
+ QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
+ SMESH::long_array_var anElementsId = new SMESH::long_array;
+
+ anElementsId->length(aListElementsId.count());
+ for (int i = 0; i < aListElementsId.count(); i++)
+ anElementsId[i] = aListElementsId[i].toInt();
+
+ SMESH::AxisStruct anAxis;
+
+ anAxis.x = SpinBox_X->GetValue();
+ anAxis.y = SpinBox_Y->GetValue();
+ anAxis.z = SpinBox_Z->GetValue();;
+ anAxis.vx = SpinBox_DX->GetValue();
+ anAxis.vy = SpinBox_DY->GetValue();
+ anAxis.vz = SpinBox_DZ->GetValue();
+ double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
+
+ try {
+ SUIT_OverrideCursor aWaitCursor;
+ bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON ||
+ ActionGroup->checkedId() == MAKE_MESH_BUTTON );
+ QList<SMESH::MeshPreviewStruct_var> aMeshPreviewStruct;
+ if(CheckBoxMesh->isChecked())
+ for ( int i = 0; i < myObjects.count(); i++ ) {
+ SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer();
+ aMeshEditor->RotateObject(myObjects[i], anAxis, anAngle, copy);
+ aMeshPreviewStruct << aMeshEditor->GetPreviewData();
+ }
+ else {
+ SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer();
+ aMeshEditor->Rotate(anElementsId, anAxis, anAngle, copy);
+ aMeshPreviewStruct << aMeshEditor->GetPreviewData();
+ }
+ setSimulationPreview( aMeshPreviewStruct );
+ } catch (...) {
+ hidePreview();
+ }
+ }
+ else {
+ hidePreview();
+ }
+ } else {
+ hidePreview();
+ }
+}