- smeshGUI->DisplayActor(Mesh, true);
- smeshGUI->DisplayEdges(Mesh, true);
- smeshGUI->ChangeRepresentation(Mesh,
- Mesh->getDisplayMode());
- }
- }
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- QApplication::restoreOverrideCursor();
- break;
- }
-
- case 702: // ADD SUB MESH
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_AddSubMeshDlg *aDlg =
- new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
-
- case 703: // INIT MESH
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
- break;
- }
-
- case 704: // EDIT Hypothesis
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_EditHypothesesDlg *aDlg =
- new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
- break;
- }
-
- case 705: // EDIT Global Hypothesis
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_EditHypothesesDlg *aDlg =
- new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
- break;
- }
-
- case 706: // EDIT Local Hypothesis
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_EditHypothesesDlg *aDlg =
- new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
- break;
- }
-
- case 806: // ORIENTATION ELEMENTS
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- smeshGUI->myDesktop->SetSelectionMode(3, true);
- SMESHGUI_OrientationElementsDlg *aDlg =
- new SMESHGUI_OrientationElementsDlg(parent, "", Sel);
- break;
- }
-
- case 807: // DIAGONAL INVERSION
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(2, true);
- SMESHGUI_DiagonalInversionDlg *aDlg =
- new SMESHGUI_DiagonalInversionDlg(parent, "", Sel);
- break;
- }
-
- case 900: // MESH INFOS
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_MeshInfosDlg *aDlg =
- new SMESHGUI_MeshInfosDlg(parent, "", Sel);
- break;
- }
-
- case 1001: // AUTOMATIC UPDATE PREFERENCES
- {
- parent->menuBar()->setItemChecked(1001,
- !parent->menuBar()->isItemChecked(1001));
- if (parent->menuBar()->isItemChecked(1001))
- {
- QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
- smeshGUI->myAutomaticUpdate = true;
- }
- else
- {
- QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
- smeshGUI->myAutomaticUpdate = false;
- }
- break;
- }
-
- case 1003: // MESH PREFERENCES
- {
- smeshGUI->SetDisplaySettings();
- break;
- }
-
- case 1005:
- {
- QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold");
- QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic");
- QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow");
- QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily");
- QString Orientation = QAD_CONFIG->getSetting("ScalarBar:Orientation");
- float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat();
- float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat();
- int NumberOfLabels =
- QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt();
- int NumberOfColors =
- QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt();
-
- if (Width == 0)
- Width = 0.17;
- if (Height == 0)
- Height = 0.8;
- if (NumberOfLabels == 0)
- NumberOfLabels = 5;
- if (NumberOfColors == 0)
- NumberOfColors = 64;
-
- SMESHGUI_Preferences_ScalarBarDlg *aDlg =
- new SMESHGUI_Preferences_ScalarBarDlg(parent, "", true);
-
- if (Bold.compare("true") == 0)
- aDlg->Bold->setChecked(true);
- else
- aDlg->Bold->setChecked(false);
- if (Italic.compare("true") == 0)
- aDlg->Italic->setChecked(true);
- else
- aDlg->Italic->setChecked(false);
- if (Shadow.compare("true") == 0)
- aDlg->Shadow->setChecked(true);
- else
- aDlg->Shadow->setChecked(false);
-
- if (Orientation.compare("Horizontal") == 0)
- aDlg->RadioHoriz->setChecked(true);
- else
- aDlg->RadioVert->setChecked(true);
-
- int NbItems = aDlg->ComboBox1->count();
- int i = 0;
- aDlg->ComboBox1->setCurrentItem(i);
- while (i < NbItems)
- {
- if (FontFamily.compare(aDlg->ComboBox1->text(i)) == 0)
- aDlg->ComboBox1->setCurrentItem(i);
- i++;
- }
-
- aDlg->LineEditWidth->setText(QString("%1").arg(Width));
- aDlg->LineEditHeight->setText(QString("%1").arg(Height));
-
- aDlg->SpinBoxLabels->setValue(NumberOfLabels);
- aDlg->SpinBoxColors->setValue(NumberOfColors);
-
- aDlg->show();
- if (aDlg->result())
- {
- if (aDlg->RadioHoriz->isChecked())
- Orientation = "Horizontal";
- else
- Orientation = "Vertical";
- if (aDlg->Bold->isChecked())
- Bold = "true";
- else
- Bold = "false";
- if (aDlg->Italic->isChecked())
- Italic = "true";
- else
- Italic = "false";
- if (aDlg->Shadow->isChecked())
- Shadow = "true";
- else
- Shadow = "false";
-
- FontFamily = aDlg->ComboBox1->currentText();
- Width = aDlg->LineEditWidth->text().toFloat();
- Height = aDlg->LineEditHeight->text().toFloat();
- NumberOfColors = aDlg->SpinBoxColors->text().toInt();
- NumberOfLabels = aDlg->SpinBoxLabels->text().toInt();
-
- vtkScalarBarActor *aScalarBar = smeshGUI->GetScalarBar();
- if (aScalarBar != NULL)
- {
- smeshGUI->SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow,
- FontFamily, Orientation,
- Width, Height, NumberOfColors, NumberOfLabels);
- }
-
- QAD_CONFIG->addSetting("ScalarBar:Bold", Bold);
- QAD_CONFIG->addSetting("ScalarBar:Italic", Italic);
- QAD_CONFIG->addSetting("ScalarBar:Shadow", Shadow);
- QAD_CONFIG->addSetting("ScalarBar:FontFamily", FontFamily);
- QAD_CONFIG->addSetting("ScalarBar:Orientation", Orientation);
- QAD_CONFIG->addSetting("ScalarBar:Width", Width);
- QAD_CONFIG->addSetting("ScalarBar:Height", Height);
- QAD_CONFIG->addSetting("ScalarBar:NumberOfLabels", NumberOfLabels);
- QAD_CONFIG->addSetting("ScalarBar:NumberOfColors", NumberOfColors);
- }
- break;
- }
-
- case 1100: // EDIT HYPOTHESIS
- {
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- int nbSel = Sel->IObjectCount();
-
- if (nbSel == 1)
- {
- Standard_Boolean res;
- SMESH::SMESH_Hypothesis_var Hyp =
- smeshGUI->ConvertIOinSMESHHypothesis(Sel->firstIObject(), res);
-
- /* Look for all mesh objects that have this hupothesis affected in order to flag as ModifiedMesh */
- /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
- /* Warning : however by internal mechanism all subMeshes icons are changed ! */
- SALOMEDS::Study::ListOfSObject_var listSOmesh =
- smeshGUI->GetMeshesUsingAlgoOrHypothesis(Hyp);
-
- if (res)
- {
- QString Name = Hyp->GetName();
-
- if (Name.compare("LocalLength") == 0)
- {
- SMESH::SMESH_LocalLength_var LL =
- SMESH::SMESH_LocalLength::_narrow(Hyp);
- double beforeLength = LL->GetLength();
- double Length = smeshGUI->Parameter(res,
- beforeLength,
- tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"),
- tr("SMESH_VALUE"),
- 1.0E-5, 1E6, 6);
- if (res && Length != beforeLength)
- {
- LL->SetLength(Length);
- for (int i = 0; i < listSOmesh->length(); i++)
- {
- smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
- false);
- }
- break;
- }
-
- }
- else if (Name.compare("NumberOfSegments") == 0)
- {
- SMESH::SMESH_NumberOfSegments_var NOS =
- SMESH::SMESH_NumberOfSegments::_narrow(Hyp);
- int beforeNbSeg = NOS->GetNumberOfSegments();
- int NbSeg = smeshGUI->Parameter(res,
- beforeNbSeg,
- tr("SMESH_NB_SEGMENTS_HYPOTHESIS"),
- tr("SMESH_VALUE"),
- 1, 1000000);
-
- if (res && NbSeg != beforeNbSeg)
- {
- NOS->SetNumberOfSegments(NbSeg);
- for (int i = 0; i < listSOmesh->length(); i++)
- {
- SALOMEDS::SObject_var SO = listSOmesh[i];
- smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
- false);
- }
- break;
- }
-
- }
- else if (Name.compare("MaxElementArea") == 0)
- {
- SMESH::SMESH_MaxElementArea_var MEA =
- SMESH::SMESH_MaxElementArea::_narrow(Hyp);
- double beforeMaxArea = MEA->GetMaxElementArea();
- double MaxArea = smeshGUI->Parameter(res,
- beforeMaxArea,
- tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"),
- tr("SMESH_VALUE"),
- 1.0E-5, 1E6, 6);
- if (res && MaxArea != beforeMaxArea)
- {
- MEA->SetMaxElementArea(MaxArea);
- for (int i = 0; i < listSOmesh->length(); i++)
- {
- smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
- false);
- }
- break;
- }
-
- }
- else if (Name.compare("MaxElementVolume") == 0)
- {
- SMESH::SMESH_MaxElementVolume_var MEV =
- SMESH::SMESH_MaxElementVolume::_narrow(Hyp);
- double beforeMaxVolume = MEV->GetMaxElementVolume();
- double MaxVolume = smeshGUI->Parameter(res,
- beforeMaxVolume,
- tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"),
- tr("SMESH_VALUE"),
- 1.0E-5, 1E6, 6);
- if (res && MaxVolume != beforeMaxVolume)
- {
- MEV->SetMaxElementVolume(MaxVolume);
- for (int i = 0; i < listSOmesh->length(); i++)
- {
- smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
- false);
- }
- break;
- }
-
- }
- else if (Name.compare("Regular_1D") == 0)
- {
- }
- else if (Name.compare("MEFISTO_2D") == 0)
- {
- }
- else
- {
- }
-
- }
- }
- break;
- }
-
- case 1101: // RENAME
- {
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- for (; It.More(); It.Next())
- {
- Handle(SALOME_InteractiveObject) IObject = It.Value();
-
- SALOMEDS::SObject_var obj =
- smeshGUI->myStudy->FindObjectID(IObject->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- if (!obj->_is_nil())
- {
- if (obj->FindAttribute(anAttr, "AttributeName"))
- {
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- QString newName = QString(aName->Value());
- newName =
- SALOMEGUI_NameDlg::getName(QAD_Application::
- getDesktop(), newName);
- if (!newName.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- smeshGUI->myActiveStudy->renameIObject(IObject,
- newName);
- }
- QApplication::restoreOverrideCursor();
- }
- }
- }
- break;
- }
-
- case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- for (int i = 0; It.More(); It.Next(), i++)
- {
- Handle(SALOME_InteractiveObject) IObject = It.Value();
- smeshGUI->RemoveHypothesisOrAlgorithmOnMesh(IObject);
- }
- Sel->ClearIObjects();
- smeshGUI->myActiveStudy->updateObjBrowser(true);
- QApplication::restoreOverrideCursor();
- break;
- }
-
- case 401: // GEOM::EDGE
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(1, true);
- parent->menuBar()->setItemChecked(9010, false);
- parent->menuBar()->setItemChecked(9011, false);
- smeshGUI->ViewNodes();
- SMESHGUI_AddEdgeDlg *aDlg =
- new SMESHGUI_AddEdgeDlg(parent, "", Sel);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
- case 4021: // TRIANGLE
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(1, true);
- parent->menuBar()->setItemChecked(9010, false);
- parent->menuBar()->setItemChecked(9011, false);
- smeshGUI->ViewNodes();
- SMESHGUI_AddFaceDlg *aDlg =
- new SMESHGUI_AddFaceDlg(parent, "", Sel, 3);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
- case 4022: // QUAD
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(1, true);
- parent->menuBar()->setItemChecked(9010, false);
- parent->menuBar()->setItemChecked(9011, false);
- smeshGUI->ViewNodes();
- SMESHGUI_AddFaceDlg *aDlg =
- new SMESHGUI_AddFaceDlg(parent, "", Sel, 4);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
- case 4031: // TETRA
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(1, true);
- parent->menuBar()->setItemChecked(9010, false);
- parent->menuBar()->setItemChecked(9011, false);
- smeshGUI->ViewNodes();
- SMESHGUI_AddVolumeDlg *aDlg =
- new SMESHGUI_AddVolumeDlg(parent, "", Sel, 4);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
- case 4032: // HEXA
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(1, true);
- parent->menuBar()->setItemChecked(9010, false);
- parent->menuBar()->setItemChecked(9011, false);
- smeshGUI->ViewNodes();
- SMESHGUI_AddVolumeDlg *aDlg =
- new SMESHGUI_AddVolumeDlg(parent, "", Sel, 8);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
-
- case 4041: // REMOVES NODES
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(1, true);
- parent->menuBar()->setItemChecked(9010, false);
- parent->menuBar()->setItemChecked(9011, false);
- smeshGUI->ViewNodes();
- SMESHGUI_RemoveNodesDlg *aDlg =
- new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
- case 4042: // REMOVES ELEMENTS
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- Sel->ClearIObjects();
- smeshGUI->myDesktop->SetSelectionMode(3, true);
- SMESHGUI_RemoveElementsDlg *aDlg =
- new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
-
- case 5000: // HYPOTHESIS - ALGO
- {
- smeshGUI->CreateAlgorithm("Regular_1D", "Wire Discretisation");
- break;
- }
- case 5010:
- {
- smeshGUI->CreateAlgorithm("MEFISTO_2D", "Triangle (Mefisto)");
- break;
- }
- case 5011:
- {
- smeshGUI->CreateAlgorithm("Quadrangle_2D", "Quadrangle (Mapping)");
- break;
- }
- case 5020:
- {
- smeshGUI->CreateAlgorithm("Hexa_3D", "Hexahedron (i,j,k)");
- break;
- }
- case 5021:
- {
- smeshGUI->CreateAlgorithm("NETGEN_3D", "Tetrahedron (Netgen)");
- break;
- }
-
- case 5030: // HYPOTHESIS - LOCAL LENGTH
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_LocalLengthDlg *aDlg = new SMESHGUI_LocalLengthDlg(parent, "");
- break;
- }
- case 5031: // HYPOTHESIS - NB SEGMENTS
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_NbSegmentsDlg *aDlg = new SMESHGUI_NbSegmentsDlg(parent, "");
- break;
- }
-
- case 5032: // HYPOTHESIS - MAX ELEMENT AREA
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_MaxElementAreaDlg *aDlg =
- new SMESHGUI_MaxElementAreaDlg(parent, "");
- break;
- }
-
- case 5033: // HYPOTHESIS - MAX ELEMENT VOLUME
- {
- smeshGUI->EmitSignalDeactivateDialog();
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_MaxElementVolumeDlg *aDlg =
- new SMESHGUI_MaxElementVolumeDlg(parent, "");
- break;
- }
-
- case 5034: // HYPOTHESIS - LENGTH FROM EDGES
- {
- SMESH::SMESH_Hypothesis_var Hyp;
- try
- {
- Hyp = smeshGUI->myComponentMesh->CreateHypothesis("LengthFromEdges", smeshGUI->myStudyId);
-
- if (!Hyp->_is_nil())
- {
- SALOMEDS::SObject_var SHyp = smeshGUI->myStudyAPI.AddNewHypothesis(Hyp);
- smeshGUI->myStudyAPI.SetName(SHyp, "LengthFromEdges");
- }
- }
- catch(const SALOME::SALOME_Exception & S_ex)
- {
- QtCatchCorbaException(S_ex);
- }
- smeshGUI->myActiveStudy->updateObjBrowser(true);
-
- break;
- }
-
- case 6016: // CONTROLS
- case 6015:
- case 6014:
- case 6013:
- case 6012:
- case 6011:
- case 6001:
- {
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- int nbSel = Sel->IObjectCount();
- if (nbSel != 1)
- break;
- smeshGUI->Control(theCommandID);
- break;
- }
-
- case 6002:
- {
- if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
- VIEW_VTK)
- { //VTK
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- SMESHGUI_EdgesConnectivityDlg *Dlg =
- new SMESHGUI_EdgesConnectivityDlg(parent, "", Sel);
- }
- else
- {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1(QAD_Application::getDesktop(),
- tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
- tr("SMESH_BUT_YES"));
- }
- break;
- }
-
- case 9010:
- {
- if (!parent->menuBar()->isItemChecked(9010))
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- parent->menuBar()->setItemChecked(9011, false);
-
- smeshGUI->EraseSimulationActors();
- smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
-
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- int nbSel = Sel->IObjectCount();
- if (nbSel == 1)
- {
- Standard_Boolean res;
- SMESH_Actor *MeshActor =
- smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(),
- res, true);
- if (res)
- {
- parent->menuBar()->setItemChecked(9010,
- !parent->menuBar()->isItemChecked(9010));
-
- // It's necessary to display SMDS IDs instead of VTK ones, so
- // vtkIdFilter is unacceptable here. We have to do it manually :(
- vtkUnstructuredGrid *ptGrid = vtkUnstructuredGrid::New();
- ptGrid->CopyStructure(MeshActor->DataSource);
-
- int numPts = MeshActor->DataSource->GetNumberOfPoints();
-
- // Loop over points and generate ids
- vtkIntArray *ptIds = vtkIntArray::New();
- ptIds->SetNumberOfValues(numPts);
-
- for (int id = 0; id < numPts; id++)
- {
- int idSMDS = MeshActor->GetIdSMESHDSNode(id);
- ptIds->SetValue(id, idSMDS);
- }
-
-// mpv porting vtk4.2.2
- // vtkScalars* newScalars = vtkScalars::New();
- // newScalars->SetData(ptIds);
- // ptGrid->GetPointData()->SetScalars(newScalars);
- ptGrid->GetPointData()->SetScalars(ptIds);
- // newScalars->Delete();
-// mpv
- ptIds->Delete();
-
- vtkMaskPoints *mask = vtkMaskPoints::New();
- mask->SetInput(ptGrid);
- mask->SetOnRatio(1);
- // mask->SetMaximumNumberOfPoints( 50 );
- // mask->RandomModeOn();
-
- vtkSelectVisiblePoints *visPts =
- vtkSelectVisiblePoints::New();
- visPts->SetInput(mask->GetOutput());
- visPts->SetRenderer(((VTKViewer_ViewFrame *) smeshGUI->
- myActiveStudy->getActiveStudyFrame()->
- getRightFrame()->getViewFrame())->getRenderer());
- //visPts->SetSelectInvisible(1);
- visPts->SelectInvisibleOff();
- visPts->SetTolerance(0.1);
-
- vtkLabeledDataMapper *ldm = vtkLabeledDataMapper::New();
- ldm->SetInput(visPts->GetOutput());
- ldm->SetLabelFormat("%g");
- ldm->SetLabelModeToLabelScalars();
- //ldm->SetLabelModeToLabelFieldData();
-
- ldm->SetFontFamilyToTimes();
- ldm->SetFontSize(6 * parent->font().pointSize() / 5);
- ldm->SetBold(1);
- ldm->SetItalic(0);
- ldm->SetShadow(0);
-
- vtkActor2D *pointLabels = vtkActor2D::New();
- pointLabels->SetMapper(ldm);
- pointLabels->GetProperty()->SetColor(0, 1, 0);
-
- visPts->Delete();
- ldm->Delete();
- smeshGUI->mySimulationActors2D->AddItem(pointLabels);
- ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
- getActiveStudyFrame()->getRightFrame()->
- getViewFrame())->getRenderer()->AddActor2D(pointLabels);
- }
- }
- }
- else
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- parent->menuBar()->setItemChecked(9010,
- !parent->menuBar()->isItemChecked(9010));
- smeshGUI->EraseSimulationActors();
- smeshGUI->ScalarVisibilityOff();
- }
- QApplication::restoreOverrideCursor();
- break;
- }
- case 9011:
- {
- if (!parent->menuBar()->isItemChecked(9011))
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- parent->menuBar()->setItemChecked(9010, false);
-
- smeshGUI->EraseSimulationActors();
- smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
-
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->
- getSelection());
- int nbSel = Sel->IObjectCount();
- if (nbSel == 1)
- {
- Standard_Boolean res;
- SMESH_Actor *MeshActor =
- smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(),
- res, true);
- if (res)
- {
- parent->menuBar()->setItemChecked(9011,
- !parent->menuBar()->isItemChecked(9011));
-
- // It's necessary to display SMDS IDs instead of VTK ones, so
- // vtkIdFilter is unacceptable here. We have to do it manually :(
- vtkUnstructuredGrid *elGrid = vtkUnstructuredGrid::New();
- elGrid->CopyStructure(MeshActor->DataSource);
-
- int numCells = MeshActor->DataSource->GetNumberOfCells();
-
- // Loop over points and generate ids
- vtkIntArray *cellIds = vtkIntArray::New();
- cellIds->SetNumberOfValues(numCells);
-
- for (int id = 0; id < numCells; id++)
- {
- int idSMDS = MeshActor->GetIdSMESHDSElement(id);
- cellIds->SetValue(id, idSMDS);
- }
-
-// mpv porting vk4.2.2
- // vtkScalars* newScalars = vtkScalars::New();
- // newScalars->SetData(cellIds);
- elGrid->GetCellData()->SetScalars(cellIds);
- // elGrid->GetCellData()->SetScalars(newScalars);
- // newScalars->Delete();
-//mpv
-
- cellIds->Delete();
-
- vtkCellCenters *cc = vtkCellCenters::New();
- cc->SetInput(elGrid);
-
- vtkSelectVisiblePoints *visCells =
- vtkSelectVisiblePoints::New();
- visCells->SetInput(cc->GetOutput());
- visCells->SetRenderer(((VTKViewer_ViewFrame *) smeshGUI->
- myActiveStudy->getActiveStudyFrame()->
- getRightFrame()->getViewFrame())->getRenderer());
- visCells->SelectInvisibleOff();
- visCells->SetTolerance(0.1);
- // visCells->SetSelectInvisible(1);
-
- vtkLabeledDataMapper *ldm = vtkLabeledDataMapper::New();
- ldm->SetInput(visCells->GetOutput());
- ldm->SetLabelFormat("%g");
- ldm->SetLabelModeToLabelScalars();
-
- ldm->SetFontFamilyToTimes();
- ldm->SetFontSize(6 * parent->font().pointSize() / 5);
- ldm->SetBold(1);
- ldm->SetItalic(0);
- ldm->SetShadow(0);
-
- vtkActor2D *cellLabels = vtkActor2D::New();
- cellLabels->SetMapper(ldm);
- cellLabels->GetProperty()->SetColor(1, 0, 0);
-
- cc->Delete();
- visCells->Delete();
- ldm->Delete();
- smeshGUI->mySimulationActors2D->AddItem(cellLabels);
- ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
- getActiveStudyFrame()->getRightFrame()->
- getViewFrame())->getRenderer()->AddActor2D(cellLabels);
- }
- }
- }
- else
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- parent->menuBar()->setItemChecked(9011,
- !parent->menuBar()->isItemChecked(9011));
- smeshGUI->EraseSimulationActors();
- smeshGUI->ScalarVisibilityOff();
- }
- QApplication::restoreOverrideCursor();
- break;
- }
-
- case 10001: // DISPLAY MODE PREFERENCE
- {
- parent->menuBar()->setItemChecked(10001,
- !parent->menuBar()->isItemChecked(10001));
- parent->menuBar()->setItemChecked(10002, false);
- parent->menuBar()->setItemChecked(10003, false);
- QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
- break;
- }
- case 10002:
- {
- parent->menuBar()->setItemChecked(10002,
- !parent->menuBar()->isItemChecked(10002));
- parent->menuBar()->setItemChecked(10001, false);
- parent->menuBar()->setItemChecked(10003, false);
- QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
- break;
- }
- case 10003:
- {
- parent->menuBar()->setItemChecked(10003,
- !parent->menuBar()->isItemChecked(10003));
- parent->menuBar()->setItemChecked(10002, false);
- parent->menuBar()->setItemChecked(10001, false);
- QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shrink");
- break;
- }
-
- }
-
- smeshGUI->myActiveStudy->updateObjBrowser(true);
- return true;
-}
-
-//=============================================================================
-/*! function : GetMeshesUsingAlgoOrHypothesis()
- * purpose : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected.
- * : However is supposed here that father of father of an hypothesis is a Mesh Object.
- */
-//=============================================================================
-SALOMEDS::Study::ListOfSObject *
- SMESHGUI::GetMeshesUsingAlgoOrHypothesis(SMESH::
- SMESH_Hypothesis_ptr AlgoOrHyp)
-{
- SALOMEDS::Study::ListOfSObject_var listSOmesh =
- new SALOMEDS::Study::ListOfSObject;
- listSOmesh->length(0);
- unsigned int index = 0;
- if (!AlgoOrHyp->_is_nil())
- {
- SALOMEDS::SObject_var SO_Hypothesis =
- smeshGUI->GetStudyAPI().FindHypothesisOrAlgorithms(AlgoOrHyp);
- if (!SO_Hypothesis->_is_nil())
- {
- SALOMEDS::Study::ListOfSObject_var listSO =
- smeshGUI->myStudy->FindDependances(SO_Hypothesis);
- for (unsigned int i = 0; i < listSO->length(); i++)
- {
- SALOMEDS::SObject_var SO = listSO[i];
- if (!SO->_is_nil())
- {
- SALOMEDS::SObject_var SOfatherFather =
- SO->GetFather()->GetFather();
- if (!SOfatherFather->_is_nil())
- {
- index++;
- listSOmesh->length(index);
- listSOmesh[index - 1] = SOfatherFather;
- }
- }
- }
- }
- }
- return listSOmesh._retn();
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Export_Mesh(QAD_Desktop * parent, int theCommandID)
-{
- SALOME_Selection *Sel =
- SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
- int nbSel = Sel->IObjectCount();
- if (nbSel == 1)
- {
- Standard_Boolean res;
- Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
- SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(IObject, res);
- if (res)
- {
- if (theCommandID == 122)
- { // EXPORT MED
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- tr("MED files (*.med)"),
- tr("Export mesh"),
- false);
- if (!filename.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- aMesh->Export(filename.latin1(), "MED");
- QApplication::restoreOverrideCursor();
- }
- }
- else if (theCommandID == 121)
- { // EXPORT DAT
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- tr("DAT files (*.dat)"),
- tr("Export mesh"),
- false);
- if (!filename.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- aMesh->Export(filename.latin1(), "DAT");
- QApplication::restoreOverrideCursor();
- }
- }
- else if (theCommandID == 123)
- { // EXPORT UNV
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- tr("IDEAS files (*.unv)"),
- tr("Export mesh"),
- false);
- if (!filename.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- aMesh->Export(filename.latin1(), "UNV");
- QApplication::restoreOverrideCursor();
- }
- else
- aMesh->Export(filename.latin1(), "DAT");
-
- QApplication::restoreOverrideCursor();
-
- if (IObject->hasEntry())
- {
- MESSAGE("---");
- SALOMEDS::SObject_var SO =
- smeshGUI->myStudy->FindObjectID(IObject->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeComment_var aFileName;
- SALOMEDS::StudyBuilder_var aStudyBuilder =
- smeshGUI->myStudy->NewBuilder();
- anAttr =
- aStudyBuilder->FindOrCreateAttribute(SO,
- "AttributeComment");
- aFileName = SALOMEDS::AttributeComment::_narrow(anAttr);
- aFileName->SetValue(filename.latin1());
- }
- }
- }
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Import_Document(QAD_Desktop * parent, int theCommandID)
-{
- QString filter;
- string myExtension;
-
- if (theCommandID == 113)
- {
- filter = tr("MED files (*.med)");
- myExtension = string("MED");
- }
- else if (theCommandID == 112)
- {
- filter = tr("IDEAS files (*.unv)");
- myExtension = string("UNV");
- }
- else if (theCommandID == 111)
- {
- filter = tr("DAT files (*.dat)");
- myExtension = string("DAT");
- }
-
- QString filename = QAD_FileDlg::getFileName(parent, "", filter,
- tr("Import document"), true);
-
- if (!filename.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- try
- {
- if (!myComponentMesh->_is_nil())
- {
- SMESH::SMESH_Mesh_var aMesh =
- myComponentMesh->Import(myStudyId, filename.latin1(),
- myExtension.c_str());
-
- if (!aMesh->_is_nil())
- {
- SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh(aMesh);
- myStudyAPI.SetName(SM, filename);
- }
- }
- }
- catch(const SALOME::SALOME_Exception & S_ex)
- {
- QtCatchCorbaException(S_ex);
- }
- myActiveStudy->updateObjBrowser(true);
- QApplication::restoreOverrideCursor();
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
- QAD_StudyFrame * studyFrame)
-{
- SMESHGUI::GetOrCreateSMESHGUI(parent);
- return false;
+ }
+ else {
+ isEmpty = true;
+ }
+ }
+ }
+
+ // update Object browser
+ SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+
+ // browse to the published meshes
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList );
+
+ // show Error message box if there were errors
+ if ( errors.count() > 0 ) {
+ SUIT_MessageBox::critical( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_ERROR" ),
+ QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+ }
+
+ // show warning message box, if some imported mesh is empty
+ if ( isEmpty ) {
+ SUIT_MessageBox::warning( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_WRN_WARNING" ),
+ QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
+ }
+ }
+ }
+
+ //================================================================================
+ /*!
+ * \brief Export selected meshes or groups into a file
+ */
+ //================================================================================
+
+ void ExportMeshToFile( int theCommandID )
+ {
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
+ const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
+ const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
+ const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
+ const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
+ const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
+ const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
+
+ // actually, the following condition can't be met (added for insurance)
+ if( selected.Extent() == 0 ||
+ ( selected.Extent() > 1 && !isMED && !isSTL ))
+ return;
+
+ // get mesh object from selection and check duplication of their names
+ bool hasDuplicatedMeshNames = false;
+ QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
+ QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
+ SALOME_ListIteratorOfListIO It( selected );
+ for( ; It.More(); It.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anIObject = It.Value();
+ SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
+ if ( aMeshItem->_is_nil() ) {
+ SUIT_MessageBox::warning( SMESHGUI::desktop(),
+ QObject::tr( "SMESH_WRN_WARNING" ),
+ QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
+ return;
+ }
+
+ QString aMeshName = anIObject->getName();
+
+ // check for name duplications
+ if ( !hasDuplicatedMeshNames )
+ for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
+ if( aMeshName == (*aMeshIter).second ) {
+ hasDuplicatedMeshNames = true;
+ break;
+ }
+ }
+
+ aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
+ }
+
+ if( hasDuplicatedMeshNames && isMED ) {
+ int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
+ QObject::tr("SMESH_BUT_YES"),
+ QObject::tr("SMESH_BUT_NO"), 0, 1);
+ if (aRet != 0)
+ return;
+ }
+
+ aMeshIter = aMeshList.begin();
+ SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
+ SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
+ QString aMeshName = (*aMeshIter).second;
+
+ if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
+ {
+ // check for equal group names within each mesh
+ for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
+ SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
+ if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
+ int aRet = SUIT_MessageBox::warning
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
+ QObject::tr("SMESH_BUT_YES"),
+ QObject::tr("SMESH_BUT_NO"), 0, 1);
+ if (aRet != 0)
+ return;
+ }
+ }
+ }
+
+ // Warn the user about presence of not supported elements
+ QString format;
+ std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
+ if ( isDAT )
+ {
+ format = "DAT";
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
+ notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Tetra );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Tetra );
+ notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
+ notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
+ notSupportedElemTypes.push_back( SMESH::Entity_Penta );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
+ notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
+ notSupportedElemTypes.push_back( SMESH::Entity_0D );
+ notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ }
+ else if ( isUNV )
+ {
+ format = "UNV";
+ notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
+ notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
+ notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
+ notSupportedElemTypes.push_back( SMESH::Entity_0D );
+ notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ }
+ else if ( isSTL )
+ {
+ format = "STL";
+ notSupportedElemTypes.push_back( SMESH::Entity_Edge );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
+ notSupportedElemTypes.push_back( SMESH::Entity_0D );
+ notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ }
+ else if ( isCGNS )
+ {
+ format = "CGNS";
+ notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ }
+ else if ( isSAUV )
+ {
+ format = "SAUV";
+ notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
+ notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
+ notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
+ }
+ else if ( isGMF )
+ {
+ format = "GMF";
+ notSupportedElemTypes.push_back( SMESH::Entity_0D );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
+ notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
+ notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
+ notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
+ notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ }
+ if ( ! notSupportedElemTypes.empty() )
+ {
+ SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
+ for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
+ if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
+ presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
+ }
+ if ( !presentNotSupported.empty() )
+ {
+ QString typeNames;
+ const char* typeMsg[SMESH::Entity_Last] = { "SMESH_NODES",
+ "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES","SMESH_TRIANGLES",
+ "SMESH_QUADRATIC_TRIANGLES","SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES",
+ "SMESH_BIQUADRATIC_QUADRANGLES","SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
+ "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
+ "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
+ "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
+ "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
+ };
+ QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
+ for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
+ typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
+ if ( iType != presentNotSupported.size() - 1 )
+ typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
+ }
+ int aRet = SUIT_MessageBox::warning
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
+ QObject::tr("SMESH_BUT_YES"),
+ QObject::tr("SMESH_BUT_NO"), 0, 1);
+ if (aRet != 0)
+ return;
+ }
+
+ // Get parameters of export operation
+
+ QString aFilename;
+ SMESH::MED_VERSION aFormat;
+ // Init the parameters with the default values
+ bool aIsASCII_STL = true;
+ bool toCreateGroups = false;
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if ( resMgr )
+ toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
+ bool toOverwrite = true;
+
+ QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
+ QString anInitialPath = "";
+ if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ anInitialPath = QDir::currentPath();
+
+ // Get a file name to write in and additional otions
+ if ( isUNV || isDAT || isGMF ) // Export w/o options
+ {
+ if ( isUNV )
+ aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
+ else if ( isDAT )
+ aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
+ else if ( isGMF )
+ aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
+ ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
+ if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
+ aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
+ anInitialPath + QString("/") + aMeshName,
+ aFilter, aTitle, false);
+ }
+ // else if ( isGMF )// Export to GMF
+ // {
+ // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
+ // ( SMESHGUI::desktop(), false, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
+ // QStringList filters;
+ // filters << QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)"
+ // << QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
+ // fd->setWindowTitle( aTitle );
+ // fd->setNameFilters( filters );
+
+ // if ( !aMeshOrGroup->_is_equivalent( aMesh ))
+ // toCreateGroups = false;
+ // else
+ // toCreateGroups = ( aMesh->NbGroups() > 0 );
+
+ // fd->SetChecked( true );
+ // if ( !anInitialPath.isEmpty() )
+ // fd->setDirectory( anInitialPath );
+ // fd->selectFile(aMeshName);
+
+ // if ( fd->exec() )
+ // aFilename = fd->selectedFile();
+ // toCreateGroups = fd->IsChecked();
+
+ // delete fd;
+ // }
+ else if ( isCGNS )// Export to CGNS
+ {
+ SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
+ fd->setWindowTitle( aTitle );
+ fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
+ if ( !anInitialPath.isEmpty() )
+ fd->setDirectory( anInitialPath );
+ fd->selectFile(aMeshName);
+ SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
+ fd->setValidator( fv );
+
+ if ( fd->exec() )
+ aFilename = fd->selectedFile();
+ toOverwrite = fv->isOverwrite();
+
+ delete fd;
+ }
+ else if ( isSTL ) // Export to STL
+ {
+ QMap<QString, int> aFilterMap;
+ aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
+ aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
+
+ QStringList filters;
+ QMap<QString, int>::const_iterator it = aFilterMap.begin();
+ for ( ; it != aFilterMap.end(); ++it )
+ filters.push_back( it.key() );
+
+ SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
+ fd->setWindowTitle( aTitle );
+ fd->setNameFilters( filters );
+ fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
+ if ( !anInitialPath.isEmpty() )
+ fd->setDirectory( anInitialPath );
+ fd->selectFile(aMeshName);
+ bool is_ok = false;
+ while (!is_ok) {
+ if ( fd->exec() )
+ aFilename = fd->selectedFile();
+ aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
+ is_ok = true;
+ }
+ delete fd;
+ }
+ else if ( isMED || isSAUV ) // Export to MED or SAUV
+ {
+ QMap<QString, SMESH::MED_VERSION> aFilterMap;
+ //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
+ if ( isMED ) {
+ QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
+ //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
+ aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
+ }
+ else { // isSAUV
+ aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
+ aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
+ aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
+ }
+
+ QStringList filters;
+ QString aDefaultFilter;
+ QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
+ for ( ; it != aFilterMap.end(); ++it ) {
+ filters.push_back( it.key() );
+ if (it.value() == SMESH::MED_V2_2)
+ aDefaultFilter = it.key();
+ }
+
+ SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
+ ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
+ fd->setWindowTitle( aTitle );
+ fd->setNameFilters( filters );
+ fd->selectNameFilter(aDefaultFilter);
+ fd->SetChecked(toCreateGroups);
+ if ( !anInitialPath.isEmpty() )
+ fd->setDirectory( anInitialPath );
+ fd->selectFile(aMeshName);
+
+ SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
+ fd->setValidator( fv );
+
+ bool is_ok = false;
+ while (!is_ok) {
+ if ( fd->exec() )
+ aFilename = fd->selectedFile();
+ else {
+ aFilename = QString::null;
+ break;
+ }
+ aFormat = aFilterMap[fd->selectedNameFilter()];
+ toOverwrite = fv->isOverwrite();
+ is_ok = true;
+ if ( !aFilename.isEmpty() ) {
+ // med-2.1 does not support poly elements
+ if ( aFormat==SMESH::MED_V2_1 )
+ for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
+ SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
+ SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
+ if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
+ nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
+ {
+ int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
+ QObject::tr("SMESH_BUT_YES"),
+ QObject::tr("SMESH_BUT_NO"), 0, 1);
+ if (aRet != 0) {
+ is_ok = false;
+ break;
+ }
+ }
+ }
+ if( !toOverwrite ) {
+ // can't append to an existing using other format
+ SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
+ bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
+ if( !isVersionOk || aVersion != aFormat ) {
+ int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
+ QObject::tr("SMESH_BUT_YES"),
+ QObject::tr("SMESH_BUT_NO"), 0, 1);
+ if (aRet == 0)
+ toOverwrite = true;
+ else
+ is_ok = false;
+ }
+
+ QStringList aMeshNamesCollisionList;
+ SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
+ for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
+ QString anExistingMeshName( aMeshNames[ i ] );
+ for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
+ QString anExportMeshName = (*aMeshIter).second;
+ if( anExportMeshName == anExistingMeshName ) {
+ aMeshNamesCollisionList.append( anExportMeshName );
+ break;
+ }
+ }
+ }
+ if( !aMeshNamesCollisionList.isEmpty() ) {
+ QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
+ int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
+ QObject::tr("SMESH_BUT_YES"),
+ QObject::tr("SMESH_BUT_NO"),
+ QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
+ if (aRet == 0)
+ toOverwrite = true;
+ else if (aRet == 2)
+ is_ok = false;
+ }
+ }
+ }
+ }
+ toCreateGroups = fd->IsChecked();
+ delete fd;
+ }
+ else
+ {
+ return;
+ }
+
+ // Perform export
+
+ if ( !aFilename.isEmpty() ) {
+ // Check whether the file already exists and delete it if yes
+ QFile aFile( aFilename );
+ if ( aFile.exists() && toOverwrite )
+ aFile.remove();
+ SUIT_OverrideCursor wc;
+
+ try {
+ // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
+// bool Renumber = false;
+// // PAL 14172 : Check of we have to renumber or not from the preferences before export
+// if (resMgr)
+// Renumber= resMgr->booleanValue("renumbering");
+// if (Renumber){
+// SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
+// aMeshEditor->RenumberNodes();
+// aMeshEditor->RenumberElements();
+// if ( SMESHGUI::automaticUpdate() )
+// SMESH::UpdateView();
+// }
+ if ( isMED )
+ {
+ aMeshIter = aMeshList.begin();
+ for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
+ {
+ SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
+ SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
+ if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
+ aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
+ aFormat, toOverwrite && aMeshIndex == 0 );
+ else
+ aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
+ aFormat, toOverwrite && aMeshIndex == 0 );
+ }
+ }
+ else if ( isSAUV )
+ {
+ for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
+ {
+ SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
+ if( !aMeshItem->_is_nil() )
+ aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
+ }
+ }
+ else if ( isDAT )
+ {
+ if ( aMeshOrGroup->_is_equivalent( aMesh ))
+ aMesh->ExportDAT( aFilename.toLatin1().data() );
+ else
+ aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
+ }
+ else if ( isUNV )
+ {
+ if ( aMeshOrGroup->_is_equivalent( aMesh ))
+ aMesh->ExportUNV( aFilename.toLatin1().data() );
+ else
+ aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
+ }
+ else if ( isSTL )
+ {
+ if ( aMeshOrGroup->_is_equivalent( aMesh ))
+ aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
+ else
+ aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
+ }
+ else if ( isCGNS )
+ {
+ aMeshIter = aMeshList.begin();
+ for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
+ {
+ SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
+ SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
+ aMeshItem->ExportCGNS( aMeshOrGroup,
+ aFilename.toLatin1().data(),
+ toOverwrite && aMeshIndex == 0 );
+ }
+ }
+ else if ( isGMF )
+ {
+ toCreateGroups = true;
+ aMesh->ExportGMF( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups );
+ }
+ }
+ catch (const SALOME::SALOME_Exception& S_ex){
+ wc.suspend();
+ SUIT_MessageBox::warning(SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_FAILED"));
+ wc.resume();
+ }
+ }
+ }
+
+ inline void InverseEntityMode(unsigned int& theOutputMode,
+ unsigned int theMode)
+ {
+ bool anIsNotPresent = ~theOutputMode & theMode;
+ if(anIsNotPresent)
+ theOutputMode |= theMode;
+ else
+ theOutputMode &= ~theMode;
+ }
+
+ void SetDisplayEntity(int theCommandID){
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ if(selected.Extent() >= 1){
+ SALOME_ListIteratorOfListIO It( selected );
+ for( ; It.More(); It.Next()){
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if(IObject->hasEntry()){
+ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
+ unsigned int aMode = anActor->GetEntityMode();
+ switch(theCommandID){
+ case 222:
+ InverseEntityMode(aMode,SMESH_Actor::eBallElem);
+ break;
+ case 216:
+ InverseEntityMode(aMode,SMESH_Actor::e0DElements);
+ break;
+ case 217:
+ InverseEntityMode(aMode,SMESH_Actor::eEdges);
+ break;
+ case 218:
+ InverseEntityMode(aMode,SMESH_Actor::eFaces);
+ break;
+ case 219:
+ InverseEntityMode(aMode,SMESH_Actor::eVolumes);
+ break;
+ case 220:
+ aMode = SMESH_Actor::eAllEntity;
+ break;
+ }
+ if(aMode)
+ anActor->SetEntityMode(aMode);
+ }
+ }
+ }
+ }
+ }
+
+ void AutoColor(){
+ SALOME_ListIO selected;
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return;
+
+ LightApp_SelectionMgr* aSel = app->selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if( !aSel || !appStudy )
+ return;
+
+ aSel->selectedObjects( selected );
+ if( selected.IsEmpty() )
+ return;
+
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
+ SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
+ if( aMainObject->_is_nil() )
+ return;
+
+ aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
+
+ SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
+ for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
+ {
+ SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
+ SALOMEDS::Color aColor = aGroupObject->GetColor();
+ _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
+ if (aGroupSObject) {
+ QColor c;
+ int delta;
+ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
+ switch ( aGroupObject->GetType ()) {
+ case SMESH::NODE:
+ anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
+ case SMESH::EDGE:
+ anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
+ case SMESH::ELEM0D:
+ anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
+ case SMESH::BALL:
+ anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
+ case SMESH::VOLUME:
+ SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
+ anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
+ case SMESH::FACE:
+ default:
+ SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
+ anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
+ }
+ }
+ }
+ }
+
+ SMESH::RepaintCurrentView();
+ }
+
+ QString functorToString( SMESH::Controls::FunctorPtr f )
+ {
+ QString type = QObject::tr( "UNKNOWN_CONTROL" );
+ if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
+ type = QObject::tr( "VOLUME_3D_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
+ type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
+ else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
+ type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
+ else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
+ type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
+ type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
+ type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
+ type = QObject::tr( "WARP_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
+ type = QObject::tr( "TAPER_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
+ type = QObject::tr( "SKEW_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
+ type = QObject::tr( "AREA_ELEMENTS" );
+ else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
+ type = QObject::tr( "LENGTH_EDGES" );
+ else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
+ type = QObject::tr( "LENGTH2D_EDGES" );
+ else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
+ type = QObject::tr( "MULTI_BORDERS" );
+ else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
+ type = QObject::tr( "MULTI2D_BORDERS" );
+ else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
+ type = QObject::tr( "FREE_NODES" );
+ else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
+ type = QObject::tr( "FREE_EDGES" );
+ else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
+ type = QObject::tr( "FREE_BORDERS" );
+ else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
+ type = QObject::tr( "FREE_FACES" );
+ else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
+ type = QObject::tr( "BARE_BORDER_VOLUME" );
+ else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
+ type = QObject::tr( "BARE_BORDER_FACE" );
+ else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
+ type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
+ else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
+ type = QObject::tr( "OVER_CONSTRAINED_FACE" );
+ else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
+ type = QObject::tr( "EQUAL_NODE" );
+ else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
+ type = QObject::tr( "EQUAL_EDGE" );
+ else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
+ type = QObject::tr( "EQUAL_FACE" );
+ else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
+ type = QObject::tr( "EQUAL_VOLUME" );
+ return type;
+ }
+
+ void SaveDistribution()
+ {
+ LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if ( aSel )
+ aSel->selectedObjects( selected );
+
+ if ( selected.Extent() == 1 ) {
+ Handle(SALOME_InteractiveObject) anIO = selected.First();
+ if ( anIO->hasEntry() ) {
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
+ if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
+ SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
+ SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
+ if ( aScalarBarActor && aFunctor ) {
+ SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
+ if ( aNumFun ) {
+ std::vector<int> elements;
+ SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
+ if ( mesh->_is_nil() ) {
+ SMESH::SMESH_IDSource_var idSource =
+ SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
+ if ( !idSource->_is_nil() )
+ {
+ SMESH::long_array_var ids = idSource->GetIDs();
+ elements.resize( ids->length() );
+ for ( unsigned i = 0; i < elements.size(); ++i )
+ elements[i] = ids[i];
+ }
+ }
+ int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
+ vtkLookupTable* lookupTable =
+ static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
+ double * minmax = lookupTable->GetRange();
+ std::vector<int> nbEvents;
+ std::vector<double> funValues;
+ aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
+ QString anInitialPath = "";
+ if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+ anInitialPath = QDir::currentPath();
+ QString aMeshName = anIO->getName();
+ QStringList filter;
+ filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
+ filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
+ QString aFilename = anInitialPath + "/" + aMeshName + "_" +
+ functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
+ aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
+ aFilename,
+ filter,
+ QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
+ false );
+ if ( !aFilename.isEmpty() ) {
+ QFile f( aFilename );
+ if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
+ QTextStream out( &f );
+ out << "# Mesh: " << aMeshName << endl;
+ out << "# Control: " << functorToString( aFunctor ) << endl;
+ out << "#" << endl;
+ out.setFieldWidth( 10 );
+ for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
+ out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
+ f.close();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void ShowDistribution() {
+ LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if ( aSel )
+ aSel->selectedObjects( selected );
+
+ if ( selected.Extent() == 1 ) {
+ Handle(SALOME_InteractiveObject) anIO = selected.First();
+ if ( anIO->hasEntry() ) {
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
+ if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
+ SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
+ aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
+ }
+ }
+ }
+ }
+
+#ifndef DISABLE_PLOT2DVIEWER
+ void PlotDistribution() {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return;
+
+ LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if ( aSel )
+ aSel->selectedObjects( selected );
+
+ if ( selected.Extent() == 1 ) {
+ Handle(SALOME_InteractiveObject) anIO = selected.First();
+ if ( anIO->hasEntry() ) {
+ //Find Actor by entry before getting Plot2d viewer,
+ //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
+
+ SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
+
+ if( !aViewManager )
+ return;
+
+ SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
+ if ( !aView )
+ return;
+
+ Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
+ if ( !aPlot )
+ return;
+
+ if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
+ SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
+ QString functorName = functorToString( anActor->GetFunctor());
+ QString aHistogramName("%1 : %2");
+ aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
+ aHistogram->setName(aHistogramName);
+ aHistogram->setHorTitle(functorName);
+ aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
+ aPlot->displayObject(aHistogram, true);
+ }
+ }
+ }
+ }
+#endif //DISABLE_PLOT2DVIEWER
+
+ void DisableAutoColor(){
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ if(selected.Extent()){
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+ SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
+ if ( !aMesh->_is_nil() ) {
+ aMesh->SetAutoColor( false );
+ }
+ }
+ }
+
+ void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
+ {
+ SALOME_ListIO selected;
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return;
+
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if( !aSel || !appStudy )
+ return;
+
+ if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
+ if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
+ aModule->EmitSignalDeactivateDialog();
+ if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
+ (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
+ }
+ return;
+ }
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ aSel->selectedObjects( selected );
+
+ if(selected.Extent() >= 1){
+ switch(theCommandID){
+ case 1133:{
+ SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
+ (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
+ return;
+ }
+ case 1132: {
+ vtkFloatingPointType color[3];
+ QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
+ QColor orientationColor, outlineColor, volumeColor;
+ int deltaF = 0, deltaV = 0;
+ int elem0dSize = 1;
+ int ballSize = 1;
+ int edgeWidth = 1;
+ int outlineWidth = 1;
+ vtkFloatingPointType shrinkCoef = 0.0;
+ vtkFloatingPointType orientationScale = 0.0;
+ bool orientation3d = false;
+ VTK::MarkerType markerType = VTK::MT_NONE;
+ VTK::MarkerScale markerScale = VTK::MS_NONE;
+ int markerId = 0;
+ bool hasNodes = false;
+ int presentEntities = 0;
+ bool firstTime = true;
+
+ SALOME_ListIteratorOfListIO It( selected );
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if ( !IObject->hasEntry() ) continue;
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
+ if ( !anActor || !anActor->GetObject() ) continue;
+
+ if ( firstTime ) {
+ // nodes: color, marker
+ anActor->GetNodeColor( color[0], color[1], color[2] );
+ nodeColor.setRgbF( color[0], color[1], color[2] );
+ markerType = anActor->GetMarkerType();
+ markerScale = anActor->GetMarkerScale();
+ markerId = anActor->GetMarkerTexture();
+ // edges: color, width
+ anActor->GetEdgeColor( color[0], color[1], color[2] );
+ edgeColor.setRgbF( color[0], color[1], color[2] );
+ edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
+ // faces: front color, back color (delta)
+ anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
+ faceColor.setRgbF( color[0], color[1], color[2] );
+ // faces: front color, back color (delta)
+ anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
+ volumeColor.setRgbF( color[0], color[1], color[2] );
+ // 0d elements: color, size
+ anActor->Get0DColor( color[0], color[1], color[2] );
+ elem0dColor.setRgbF( color[0], color[1], color[2] );
+ elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
+ // balls: color, size
+ anActor->GetBallColor( color[0], color[1], color[2] );
+ ballColor.setRgbF( color[0], color[1], color[2] );
+ ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
+ // outlines: color
+ anActor->GetOutlineColor( color[0], color[1], color[2] );
+ outlineColor.setRgbF( color[0], color[1], color[2] );
+ outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
+ // orientation vectors: color, scale, 3d flag
+ anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
+ orientationColor.setRgbF( color[0], color[1], color[2] );
+ orientationScale = anActor->GetFacesOrientationScale();
+ orientation3d = anActor->GetFacesOrientation3DVectors();
+ // shrink factor
+ shrinkCoef = anActor->GetShrinkFactor();
+ }
+
+ firstTime = false; // we only take properties from first object (for performance reasons)
+
+ if ( !hasNodes )
+ hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
+ if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
+ presentEntities = presentEntities | SMESH_Actor::eEdges;
+ if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
+ presentEntities = presentEntities | SMESH_Actor::eFaces;
+ if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
+ presentEntities = presentEntities | SMESH_Actor::eVolumes;
+ if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
+ presentEntities = presentEntities | SMESH_Actor::e0DElements;
+ if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
+ presentEntities = presentEntities | SMESH_Actor::eBallElem;
+
+ // as we know that all types of elements are present, we can exit the loop
+ if ( presentEntities == SMESH_Actor::eAllEntity )
+ break;
+ }
+
+ SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
+ // nodes: color, marker
+ dlg.setNodeColor( nodeColor );
+ if( markerType != VTK::MT_USER )
+ dlg.setNodeMarker( markerType, markerScale );
+ else
+ dlg.setNodeCustomMarker( markerId );
+ // edges: color, line width
+ dlg.setEdgeColor( edgeColor );
+ dlg.setEdgeWidth( edgeWidth );
+ // faces: front color, back color
+ dlg.setFaceColor( faceColor, deltaF );
+ // volumes: normal color, reversed color
+ dlg.setVolumeColor( volumeColor, deltaV );
+ // outlines: color, line width
+ dlg.setOutlineColor( outlineColor );
+ dlg.setOutlineWidth( outlineWidth );
+ // 0d elements: color, size
+ dlg.setElem0dColor( elem0dColor );
+ dlg.setElem0dSize( elem0dSize );
+ // balls: color, size
+ dlg.setBallColor( ballColor );
+ dlg.setBallSize( ballSize );
+ // orientation: color, scale, 3d flag
+ dlg.setOrientationColor( orientationColor );
+ dlg.setOrientationSize( int( orientationScale * 100. ) );
+ dlg.setOrientation3d( orientation3d );
+ // shrink: scale factor
+ dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
+ // hide unused controls
+ dlg.showControls( presentEntities, hasNodes );
+
+ if ( dlg.exec() ) {
+ nodeColor = dlg.nodeColor();
+ markerType = dlg.nodeMarkerType();
+ markerScale = dlg.nodeMarkerScale();
+ markerId = dlg.nodeMarkerId();
+ edgeColor = dlg.edgeColor();
+ edgeWidth = dlg.edgeWidth();
+ faceColor = dlg.faceColor();
+ deltaF = dlg.faceColorDelta();
+ volumeColor = dlg.volumeColor();
+ deltaV = dlg.volumeColorDelta();
+ outlineColor = dlg.outlineColor();
+ outlineWidth = dlg.outlineWidth();
+ elem0dColor = dlg.elem0dColor();
+ elem0dSize = dlg.elem0dSize();
+ ballColor = dlg.ballColor();
+ ballSize = dlg.ballSize();
+ orientationColor = dlg.orientationColor();
+ orientationScale = dlg.orientationSize() / 100.;
+ orientation3d = dlg.orientation3d();
+ shrinkCoef = dlg.shrinkCoef() / 100.;
+
+ // store point markers map that might be changed by the user
+ theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
+
+ // set properties from dialog box to the presentations
+ SALOME_ListIteratorOfListIO It( selected );
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if ( !IObject->hasEntry() ) continue;
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
+ if ( !anActor ) continue;
+
+ // nodes: color, marker
+ anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
+ if ( markerType != VTK::MT_USER ) {
+ anActor->SetMarkerStd( markerType, markerScale );
+ }
+ else {
+ const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
+ VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
+ if ( iter != markerMap.end() )
+ anActor->SetMarkerTexture( markerId, iter->second.second );
+ }
+ // volumes: normal color, reversed color (delta)
+ anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
+ // faces: front color, back color (delta)
+ anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
+ // edges: color, width
+ anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
+ anActor->SetLineWidth( edgeWidth );
+ // outlines: color
+ anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
+ anActor->SetOutlineWidth( outlineWidth );
+ // 0D elements: color, size
+ anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
+ anActor->Set0DSize( elem0dSize );
+ // balls: color, size
+ anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
+ anActor->SetBallSize( ballSize );
+ // orientation: color, scale, 3d flag
+ anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
+ anActor->SetFacesOrientationScale( orientationScale );
+ anActor->SetFacesOrientation3DVectors( orientation3d );
+ // shrink factor
+ anActor->SetShrinkFactor( shrinkCoef );
+
+ // for groups, set also proper color
+ SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
+ if ( !aGroupObject->_is_nil() ) {
+ SMESH::ElementType anElementType = aGroupObject->GetType();
+ QColor aColor;
+ switch( anElementType ) {
+ case SMESH::NODE:
+ aColor = nodeColor; break;
+ case SMESH::EDGE:
+ aColor = edgeColor; break;
+ case SMESH::FACE:
+ aColor = faceColor; break;
+ case SMESH::VOLUME:
+ aColor = volumeColor; break;
+ case SMESH::ELEM0D:
+ aColor = elem0dColor; break;
+ case SMESH::BALL:
+ aColor = ballColor; break;
+ default: break;
+ }
+
+ if ( aColor.isValid() ) {
+ SALOMEDS::Color aGroupColor;
+ aGroupColor.R = aColor.redF();
+ aGroupColor.G = aColor.greenF();
+ aGroupColor.B = aColor.blueF();
+ aGroupObject->SetColor( aGroupColor );
+ }
+ } // if ( !aGroupObject->_is_nil() )
+ } // for ( ; It.More(); It.Next() )
+ SMESH::RepaintCurrentView();
+ } // if ( dlg.exec() )
+ return;
+ } // case 1132:
+ } // switch(theCommandID)
+ SALOME_ListIteratorOfListIO It( selected );
+ for( ; It.More(); It.Next()){
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if(IObject->hasEntry()){
+ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
+ switch(theCommandID){
+ case 211:
+ anActor->SetRepresentation(SMESH_Actor::eEdge);
+ break;
+ case 212:
+ anActor->SetRepresentation(SMESH_Actor::eSurface);
+ break;
+ case 213:
+ if(anActor->IsShrunk())
+ anActor->UnShrink();
+ else
+ anActor->SetShrink();
+ break;
+ case 215:
+ anActor->SetRepresentation(SMESH_Actor::ePoint);
+ break;
+ case 231:
+ if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
+ anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
+ break;
+ case 232:
+ if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
+ anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
+ break;
+ }
+ }
+ }
+ }
+ SMESH::RepaintCurrentView();
+ }
+ }
+
+ void Control( int theCommandID )
+ {
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ if( !selected.IsEmpty() ){
+ Handle(SALOME_InteractiveObject) anIO = selected.First();
+ if(!anIO.IsNull()){
+ SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
+ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
+ switch ( theCommandID ){
+ case 6001:
+ aControl = SMESH_Actor::eLength;
+ break;
+ case 6018:
+ aControl = SMESH_Actor::eLength2D;
+ break;
+ case 6002:
+ aControl = SMESH_Actor::eFreeEdges;
+ break;
+ case 6003:
+ aControl = SMESH_Actor::eFreeBorders;
+ break;
+ case 6004:
+ aControl = SMESH_Actor::eMultiConnection;
+ break;
+ case 6005:
+ aControl = SMESH_Actor::eFreeNodes;
+ break;
+ case 6019:
+ aControl = SMESH_Actor::eMultiConnection2D;
+ break;
+ case 6011:
+ aControl = SMESH_Actor::eArea;
+ break;
+ case 6012:
+ aControl = SMESH_Actor::eTaper;
+ break;
+ case 6013:
+ aControl = SMESH_Actor::eAspectRatio;
+ break;
+ case 6017:
+ aControl = SMESH_Actor::eAspectRatio3D;
+ break;
+ case 6014:
+ aControl = SMESH_Actor::eMinimumAngle;
+ break;
+ case 6015:
+ aControl = SMESH_Actor::eWarping;
+ break;
+ case 6016:
+ aControl = SMESH_Actor::eSkew;
+ break;
+ case 6009:
+ aControl = SMESH_Actor::eVolume3D;
+ break;
+ case 6021:
+ aControl = SMESH_Actor::eFreeFaces;
+ break;
+ case 6022:
+ aControl = SMESH_Actor::eMaxElementLength2D;
+ break;
+ case 6023:
+ aControl = SMESH_Actor::eMaxElementLength3D;
+ break;
+ case 6024:
+ aControl = SMESH_Actor::eBareBorderVolume;
+ break;
+ case 6025:
+ aControl = SMESH_Actor::eBareBorderFace;
+ break;
+ case 6026:
+ aControl = SMESH_Actor::eOverConstrainedVolume;
+ break;
+ case 6027:
+ aControl = SMESH_Actor::eOverConstrainedFace;
+ break;
+ case 6028:
+ aControl = SMESH_Actor::eCoincidentNodes;
+ break;
+ case 6029:
+ aControl = SMESH_Actor::eCoincidentElems1D;
+ break;
+ case 6030:
+ aControl = SMESH_Actor:: eCoincidentElems2D;
+ break;
+ case 6031:
+ aControl = SMESH_Actor::eCoincidentElems3D;
+ break;
+ }
+
+ anActor->SetControlMode(aControl);
+ anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
+ SMESH::RepaintCurrentView();
+#ifndef DISABLE_PLOT2DVIEWER
+ if(anActor->GetPlot2Histogram()) {
+ SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
+ QString functorName = functorToString( anActor->GetFunctor());
+ QString aHistogramName("%1 : %2");
+ aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
+ aHistogram->setName(aHistogramName);
+ aHistogram->setHorTitle(functorName);
+ SMESH::ProcessIn2DViewers(anActor);
+ }
+#endif
+ }
+ }
+ }
+ }
+
+
+ bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
+ SMESH::MeshObjectType theType,
+ const QString theInTypeName,
+ QString & theOutTypeName)
+ {
+ SMESH_TypeFilter aTypeFilter( theType );
+ QString entry;
+ if( !theIO.IsNull() )
+ {
+ entry = theIO->getEntry();
+ LightApp_DataOwner owner( entry );
+ if ( aTypeFilter.isOk( &owner )) {
+ theOutTypeName = theInTypeName;
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
+ {
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
+ if (aSObj) {
+ _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
+ CORBA::String_var anID = aSComp->GetID().c_str();
+ if (!strcmp(anID.in(),theIO->getEntry()))
+ return "Component";
+ }
+
+ QString aTypeName;
+ if (
+ CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
+ CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
+ CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
+ CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
+ CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
+ )
+ return aTypeName;
+
+ return "NoType";
+ }
+
+
+ QString CheckHomogeneousSelection()
+ {
+ //SUIT_Study* aStudy = SMESH::GetActiveStudy();
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ QString RefType = CheckTypeObject(selected.First());
+ SALOME_ListIteratorOfListIO It(selected);
+ for ( ; It.More(); It.Next())
+ {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ QString Type = CheckTypeObject(IObject);
+ if (Type.compare(RefType) != 0)
+ return "Heterogeneous Selection";
+ }
+
+ return RefType;
+ }
+
+
+ void SMESHGUI::OnEditDelete()
+ {
+ // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
+ LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
+
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeIOR) anIOR;
+
+ int objectCount = 0;
+ QString aNameList;
+ QString aParentComponent = QString::null;
+ Handle(SALOME_InteractiveObject) anIO;
+ for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
+ {
+ anIO = anIt.Value();
+ QString cur = anIO->getComponentDataType();
+ _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
+ if (aSO) {
+ // check if object is reference
+ _PTR(SObject) aRefSObj;
+ aNameList.append("\n - ");
+ if ( aSO->ReferencedObject( aRefSObj ) ) {
+ QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
+ aNameList.append( aRefName );
+ cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
+ }
+ else
+ aNameList.append(anIO->getName());
+ objectCount++;
+ }
+
+ if( aParentComponent.isNull() )
+ aParentComponent = cur;
+ else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
+ aParentComponent = "";
+ }
+
+ if ( objectCount == 0 )
+ return; // No Valid Objects Selected
+
+ if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
+ SUIT_MessageBox::warning( SMESHGUI::desktop(),
+ QObject::tr("ERR_ERROR"),
+ QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
+ return;
+ }
+ // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
+ if (SUIT_MessageBox::warning
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
+ return;
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+
+ // Put the whole hierarchy of sub-objects of the selected SO's into a list and
+ // then treat them all starting from the deepest objects (at list back)
+ std::list< _PTR(SObject) > listSO;
+ SALOME_ListIteratorOfListIO It(selected);
+ for( ; It.More(); It.Next()) // loop on selected IO's
+ {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if(IObject->hasEntry()) {
+ _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
+
+ // disable removal of "SMESH" component object
+ if(aSO->FindAttribute(anAttr, "AttributeIOR")){
+ anIOR = anAttr;
+ if ( engineIOR() == anIOR->Value().c_str() )
+ continue;
+ }
+ //Check the referenced object
+ _PTR(SObject) aRefSObject;
+ if ( aSO && aSO->ReferencedObject( aRefSObject ) )
+ aSO = aRefSObject; // Delete main Object instead of reference
+
+ listSO.push_back( aSO );
+ std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
+ for ( ; itSO != listSO.end(); ++itSO ) {
+ _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
+ for (it->InitEx(false); it->More(); it->Next())
+ listSO.push_back( it->Value() );
+ }
+ }
+ }
+ // Check if none of objects to delete is referred from outside
+ std::list< _PTR(SObject) >::reverse_iterator ritSO;
+ for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
+ {
+ _PTR(SObject) SO = *ritSO;
+ if ( !SO ) continue;
+ std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
+ for (size_t i = 0; i < aReferences.size(); i++) {
+ _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
+ std::string type = aComponent->ComponentDataType();
+ if ( type != "SMESH" )
+ {
+ SUIT_MessageBox::warning( anApp->desktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("DEP_OBJECT") );
+ return; // outside SMESH, there is an object depending on a SMESH object
+ }
+ }
+ }
+
+ // Treat SO's in the list starting from the back
+ aStudyBuilder->NewCommand(); // There is a transaction
+ for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
+ {
+ _PTR(SObject) SO = *ritSO;
+ if ( !SO ) continue;
+ std::string anEntry = SO->GetID();
+
+ /** Erase graphical object **/
+ if(SO->FindAttribute(anAttr, "AttributeIOR")){
+ ViewManagerList aViewMenegers = anApp->viewManagers();
+ ViewManagerList::const_iterator it = aViewMenegers.begin();
+ for( ; it != aViewMenegers.end(); it++) {
+ SUIT_ViewManager* vm = *it;
+ int nbSf = vm ? vm->getViewsCount() : 0;
+ if(vm) {
+ QVector<SUIT_ViewWindow*> aViews = vm->getViews();
+ for(int i = 0; i < nbSf; i++){
+ SUIT_ViewWindow *sf = aViews[i];
+ if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
+ SMESH::RemoveActor(sf,anActor);
+ }
+ }
+ }
+ }
+ }
+ /** Remove an object from data structures **/
+ SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
+ SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
+ if ( !aGroup->_is_nil() ) { // DELETE GROUP
+ SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
+ aMesh->RemoveGroup( aGroup );
+ }
+ else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
+ SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+ aMesh->RemoveSubMesh( aSubMesh );
+
+ _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
+ if (aMeshSO)
+ SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
+ }
+ else {
+ Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
+ ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
+ QString objType = CheckTypeObject(IObject);
+ if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
+ SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
+ aStudyBuilder->RemoveObjectWithChildren( SO );
+ }
+ else {// default action: remove SObject from the study
+ // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
+ //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
+ //op->start();
+ aStudyBuilder->RemoveObjectWithChildren( SO );
+ //op->finish();
+ }
+ }
+ } /* listSO back loop */
+
+ aStudyBuilder->CommitCommand();
+
+ /* Clear any previous selection */
+ SALOME_ListIO l1;
+ aSel->setSelectedObjects( l1 );
+
+ SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+ }
+//} namespace
+
+extern "C" {
+ SMESHGUI_EXPORT CAM_Module* createModule()
+ {
+ return new SMESHGUI();
+ }
+
+ SMESHGUI_EXPORT char* getModuleVersion() {
+ return (char*)SMESH_VERSION_STR;
+ }