+ Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter(HYPOTHESIS);
+ Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter(ALGORITHM);
+ Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter(MESH);
+ Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter(SUBMESH);
+ Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter =
+ new SMESH_TypeFilter(MESHorSUBMESH);
+ Handle(SMESH_TypeFilter) aSubMeshVextexFilter =
+ new SMESH_TypeFilter(SUBMESH_VERTEX);
+ Handle(SMESH_TypeFilter) aSubMeshEdgeFilter =
+ new SMESH_TypeFilter(SUBMESH_EDGE);
+ Handle(SMESH_TypeFilter) aSubMeshFaceFilter =
+ new SMESH_TypeFilter(SUBMESH_FACE);
+ Handle(SMESH_TypeFilter) aSubMeshSolidFilter =
+ new SMESH_TypeFilter(SUBMESH_SOLID);
+ Handle(SMESH_TypeFilter) aSubMeshCompoundFilter =
+ new SMESH_TypeFilter(SUBMESH_COMPOUND);
+
+ Sel->AddFilter(aHypFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "Hypothesis";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(anAlgoFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "Algorithm";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aMeshFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "Mesh";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aSubMeshFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "SubMesh";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aSubMeshVextexFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "SubMeshVertex";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aSubMeshEdgeFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "SubMeshEdge";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aSubMeshFaceFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "SubMeshFace";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aSubMeshSolidFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "SubMeshSolid";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddFilter(aSubMeshCompoundFilter);
+ if (Sel->AddIObject(IO) != -1)
+ {
+ Sel->ClearFilters();
+ return "SubMeshCompound";
+ }
+
+ Sel->ClearFilters();
+ Sel->AddIObject(IO);
+ return "NoType";
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
+{
+ /* Create or retrieve an object SMESHGUI */
+ SMESHGUI::GetOrCreateSMESHGUI(parent);
+
+ // NRI : Temporary added
+ if (smeshGUI->myStudy->GetProperties()->IsLocked())
+ {
+ return false;
+ }
+ //NRI
+
+ // QAD_Viewer3d* v3d;
+ OCCViewer_Viewer3d *v3d;
+
+ Handle(AIS_InteractiveContext) ic;
+ vtkRenderer *Renderer;
+ vtkRenderWindow *RenWin;
+
+ if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
+ VIEW_OCC)
+ {
+ v3d =
+ ((OCCViewer_ViewFrame *) smeshGUI->myActiveStudy->
+ getActiveStudyFrame()->getRightFrame()->getViewFrame())->
+ getViewer();
+ ic = v3d->getAISContext();
+ }
+ else if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
+ VIEW_VTK)
+ {
+ Renderer =
+ ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
+ getActiveStudyFrame()->getRightFrame()->getViewFrame())->
+ getRenderer();
+ RenWin = Renderer->GetRenderWindow();
+ }
+
+ switch (theCommandID)
+ {
+ case 33: // DELETE
+ smeshGUI->OnEditDelete();
+ break;
+
+ case 113: // IMPORT
+ case 112:
+ case 111:
+ {
+ smeshGUI->Import_Document(parent, theCommandID);
+ break;
+ }
+
+ case 122: // EXPORT MED
+ case 121:
+ case 123:
+ {
+ Export_Mesh(parent, theCommandID);
+ break;
+ }
+
+ case 200: // SCALAR BAR
+ {
+ smeshGUI->DisplayScalarBar(false);
+ break;
+ }
+ case 201:
+ {
+ SMESHGUI_EditScalarBarDlg *aDlg =
+ new SMESHGUI_EditScalarBarDlg(parent, "", false);
+ aDlg->show();
+ break;
+ }
+ case 202:
+ {
+ smeshGUI->DisplayScalarBar(true);
+ break;
+ }
+
+ case 1133: // DISPLAY MODE : WireFrame, Surface, Shrink
+ case 1132:
+ case 213:
+ case 212:
+ case 211:
+ {
+ smeshGUI->SetViewMode(theCommandID);
+ break;
+ }
+
+ case 214: // UPDATE
+ {
+ smeshGUI->Update();
+ break;
+ }
+
+ case 300: // ERASE
+ {
+ SALOME_Selection *Sel =
+ SALOME_Selection::Selection(smeshGUI->myActiveStudy->
+ getSelection());
+ if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
+ VIEW_VTK)
+ {
+ // VTK
+ SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+ for (; It.More(); It.Next())
+ {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ if (IOS->hasEntry())
+ {
+ Standard_Boolean res;
+ SMESH_Actor *ac =
+ smeshGUI->FindActorByEntry(IOS->getEntry(), res, true);
+ if (res)
+ smeshGUI->EraseActor(ac);
+ }
+ }
+ }
+ Sel->ClearIObjects();
+ smeshGUI->myActiveStudy->updateObjBrowser(true);
+ }
+
+ case 301: // DISPLAY
+ {
+ if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
+ VIEW_VTK)
+ {
+ // VTK
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ SALOMEDS::SObject_var fatherSF =
+ smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
+ getActiveStudyFrame()->entry());
+
+ 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();
+ if (IObject->hasEntry())
+ {
+ Standard_Boolean res;
+ SMESH_Actor *ac =
+ smeshGUI->FindActorByEntry(IObject->getEntry(), res,
+ false);
+ if (res)
+ {
+ smeshGUI->DisplayActor(ac, true);
+ smeshGUI->DisplayEdges(ac);
+ smeshGUI->ChangeRepresentation(ac,
+ ac->getDisplayMode());
+ }
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ }
+ break;
+ }
+
+ case 302: // DISPLAY ONLY
+ {
+ if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
+ VIEW_VTK)
+ {
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ vtkActorCollection *theActors = Renderer->GetActors();
+ theActors->InitTraversal();
+ vtkActor *ac = theActors->GetNextActor();
+ while (!(ac == NULL))
+ {
+ if (ac->IsA("SMESH_Actor"))
+ {
+ SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
+ if (!anActor->isHighlighted())
+ {
+ //anActor->VisibilityOff();
+ //NRI- : 02/12/2002 : Fixed bugId 882
+ // anActor->EdgeDevice->VisibilityOff();
+ // anActor->EdgeShrinkDevice->VisibilityOff();
+ anActor->SetVisibility(false);
+ }
+ }
+ ac = theActors->GetNextActor();
+ }
+
+ // Display selection
+ SALOMEDS::SObject_var fatherSF =
+ smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
+ getActiveStudyFrame()->entry());
+
+ 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());
+
+ VTKViewer_RenderWindowInteractor *myRenderInter =
+ ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
+ getActiveStudyFrame()->getRightFrame()->getViewFrame())->
+ getRWInteractor();
+ // vtkQGLRenderWindowInteractor* myRenderInter= smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
+
+ if (myRenderInter->isInViewer(IObject))
+ {
+ if (IObject->hasEntry())
+ {
+ Standard_Boolean res;
+ SMESH_Actor *ac =
+ smeshGUI->FindActorByEntry(IObject->getEntry(), res,
+ true);
+ if (res)
+ {
+ smeshGUI->DisplayActor(ac, true);
+ smeshGUI->DisplayEdges(ac);
+ smeshGUI->ChangeRepresentation(ac,
+ ac->getDisplayMode());
+ }
+ }
+ }
+ }
+ smeshGUI->myActiveStudy->updateObjBrowser(true);
+ QApplication::restoreOverrideCursor();
+ }
+ break;
+ }
+
+ case 400: // 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_NodesDlg *aDlg = new SMESHGUI_NodesDlg(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 405: // MOVE NODE
+ {
+ smeshGUI->myDesktop->SetSelectionMode(1, true);
+ SALOME_Selection *Sel =
+ SALOME_Selection::Selection(smeshGUI->myActiveStudy->
+ getSelection());
+ SMESHGUI_MoveNodesDlg *aDlg =
+ new SMESHGUI_MoveNodesDlg(parent, "", Sel);
+ break;
+ }
+
+ case 701: // COMPUTE MESH
+ {
+ if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
+ VIEW_VTK)
+ { //VTK
+ SALOME_Selection *Sel =
+ SALOME_Selection::Selection(smeshGUI->myActiveStudy->
+ getSelection());
+ int nbSel = Sel->IObjectCount();
+ if (nbSel != 1)
+ {
+ QApplication::restoreOverrideCursor();
+ break;
+ }
+
+ SMESH::SMESH_Mesh_var aM;
+ SMESH::SMESH_subMesh_var aSubM;
+ Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+ if (IObject->hasEntry())
+ {
+ SALOMEDS::SObject_var aMorSM =
+ smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if (!aMorSM->_is_nil())
+ {
+ if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : IOR = "
+ << anIOR->Value())CORBA::Object_var cobj;
+ try
+ {
+ cobj = _orb->string_to_object(anIOR->Value());
+ if (CORBA::is_nil(cobj))
+ {
+ MESSAGE
+ ("SMESHGUI::OnGUIEvent - Compute mesh : nil object")}
+ }
+ catch(CORBA::COMM_FAILURE & ex)
+ {
+ MESSAGE
+ ("SMESHGUI::OnGUIEvent - Compute mesh : exception (1)")}
+ aM = SMESH::SMESH_Mesh::_narrow(cobj);
+ //aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
+ aSubM =
+ SMESH::SMESH_subMesh::_narrow(_orb->
+ string_to_object(anIOR->Value()));
+ if (!aM->_is_nil())
+ {
+ GEOM::GEOM_Shape_var refShape =
+ smeshGUI->myStudyAPI.
+ GetShapeOnMeshOrSubMesh(aMorSM);
+ if (!refShape->_is_nil())
+ {
+ bool compute =
+ smeshGUI->myComponentMesh->
+ IsReadyToCompute(aM, refShape);
+ if (!compute)
+ {
+ QApplication::restoreOverrideCursor();
+ QAD_MessageBox::warn1(QAD_Application::
+ getDesktop(), tr("SMESH_WRN_WARNING"),
+ tr("SMESH_WRN_MISSING_PARAMETERS"),
+ tr("SMESH_BUT_YES"));
+ break;
+ }
+ try
+ {
+ smeshGUI->myComponentMesh->Compute(aM,
+ refShape);
+ smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
+ true);
+ // TO Do : change icon of all submeshes
+ }
+ catch(const SALOME::SALOME_Exception & S_ex)
+ {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ }
+ else if (!aSubM->_is_nil())
+ {
+ aM = aSubM->GetFather();
+ GEOM::GEOM_Shape_var refShape =
+ smeshGUI->myStudyAPI.
+ GetShapeOnMeshOrSubMesh(aMorSM);
+ if (!refShape->_is_nil())
+ {
+ bool compute =
+ smeshGUI->myComponentMesh->
+ IsReadyToCompute(aM, refShape);
+ if (!compute)
+ {
+ QApplication::restoreOverrideCursor();
+ QAD_MessageBox::warn1(QAD_Application::
+ getDesktop(), tr("SMESH_WRN_WARNING"),
+ tr("SMESH_WRN_MISSING_PARAMETERS"),
+ tr("SMESH_BUT_YES"));
+ break;
+ }
+ try
+ {
+ smeshGUI->myComponentMesh->Compute(aM,
+ refShape);
+ smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
+ true);
+ // TO Do : change icon of all submeshes
+ }
+ catch(const SALOME::SALOME_Exception & S_ex)
+ {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Check whether the actor for the mesh exists at least in one view
+ Standard_Boolean res;
+ SMESH_Actor *ac =
+ smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
+ if (!res)
+ smeshGUI->InitActor(aM);
+ else
+ {
+ // Check whether the actor belongs to the active view
+ VTKViewer_RenderWindowInteractor *rwInter =
+ ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
+ getActiveStudyFrame()->getRightFrame()->getViewFrame())->
+ getRWInteractor();
+
+ // The actor belongs to inactive view -> create a copy and add it in the active view
+ if (!rwInter->isInViewer(IObject))
+ {
+ SMESH_Actor *acCopy = SMESH_Actor::New();
+ acCopy->ShallowCopy(ac);
+
+ smeshGUI->DisplayActor(acCopy, false);
+ }
+ }
+
+ if (smeshGUI->myAutomaticUpdate)
+ {
+ SMESH_Actor *Mesh = smeshGUI->ReadScript(aM);
+ if (Mesh != NULL)
+ {