X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI.cxx;h=e7b1795a707ab9f99d91faa63b9d0416a57140bb;hb=7d36523b6a8b9078da03c638a29ca9bb8cb249e5;hp=4af6cf398b395e4c5fc811bf83d530f41fa85b84;hpb=0f1fe5b1e3653316af45620f14dc4783b223d5e5;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 4af6cf398..e7b1795a7 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -23,7 +23,7 @@ // File : SMESHGUI.cxx // Author : Nicolas REJNERI, Open CASCADE S.A.S. // SMESH includes -// + #include "SMESHGUI.h" #include "SMESHGUI_NodesDlg.h" #include "SMESHGUI_TransparencyDlg.h" @@ -96,6 +96,8 @@ #include #include +#include + #include #include #include @@ -508,6 +510,9 @@ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){ unsigned int aMode = anActor->GetEntityMode(); switch(theCommandID){ + case 216: + InverseEntityMode(aMode,SMESH_Actor::e0DElements); + break; case 217: InverseEntityMode(aMode,SMESH_Actor::eEdges); break; @@ -644,6 +649,14 @@ 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; case 1132:{ vtkFloatingPointType color[3]; anActor->GetSufaceColor(color[0], color[1], color[2]); @@ -719,11 +732,20 @@ SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface(IObject); if( !aGroupObject->_is_nil() ) { - SALOMEDS::Color aColor; - aColor.R = (float)color.red() / 255.0; - aColor.G = (float)color.green() / 255.0; - aColor.B = (float)color.blue() / 255.0; - aGroupObject->SetColor( aColor ); + SMESH::ElementType anElementType = aGroupObject->GetType(); + QColor aColor; + switch( anElementType ) + { + case SMESH::NODE: aColor = nodecolor; break; + case SMESH::EDGE: aColor = edgecolor; break; + default: aColor = color; break; + } + + SALOMEDS::Color aGroupColor; + aGroupColor.R = (float)aColor.red() / 255.0; + aGroupColor.G = (float)aColor.green() / 255.0; + aGroupColor.B = (float)aColor.blue() / 255.0; + aGroupObject->SetColor( aGroupColor ); } delete aDlg; @@ -1443,7 +1465,14 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) ::SetDisplayMode(theCommandID); break; - // Display Entity + //2D quadratic representation + case 231: + case 232: + ::SetDisplayMode(theCommandID); + break; + + // Display Entity + case 216: // 0D elements case 217: // Edges case 218: // Faces case 219: // Volumes @@ -1548,7 +1577,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) break; } - case 400: // NODES + case 4000: // NODES { if(checkLock(aStudy)) break; @@ -1591,6 +1620,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 701: // COMPUTE MESH case 711: // PRECOMPUTE MESH + case 712: // EVALUATE MESH { if (checkLock(aStudy)) break; startOperation( theCommandID ); @@ -2049,6 +2079,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 1100: // EDIT HYPOTHESIS { + cout<<"EDIT HYPOTHESIS"<_is_nil() ) { - SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName()); - if (aCreator) + // BUG 0020378 + //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName()); + SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName()); + if (aCreator) { aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() ); + } else { // report error @@ -2120,6 +2154,15 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) { SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data()); + // update name of group object and its actor + SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface(IObject); + if( !aGroupObject->_is_nil() ) + { + aGroupObject->SetName( newName.toLatin1().data() ); + if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( IObject->getEntry() ) ) + anActor->setName( newName.toLatin1().data() ); + } + updateObjBrowser(); } } @@ -2156,7 +2199,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) break; } - case 401: // GEOM::EDGE + case 4009: // ELEM0D + case 4010: // GEOM::EDGE case 4021: // TRIANGLE case 4022: // QUAD case 4023: // POLYGON @@ -2169,6 +2213,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SMDSAbs_ElementType type = SMDSAbs_Edge; int nbNodes = 2; switch (theCommandID) { + case 4009: // ELEM0D + type = SMDSAbs_0DElement; nbNodes = 1; break; case 4021: // TRIANGLE type = SMDSAbs_Face; nbNodes = 3; break; case 4022: // QUAD @@ -2660,6 +2706,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" ); createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" ); createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" ); + createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" ); createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" ); createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" ); createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" ); @@ -2691,8 +2738,9 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true ); createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true ); createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true ); - createSMESHAction( 400, "NODE", "ICON_DLG_NODE" ); - createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" ); + createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" ); + createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" ); + createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" ); createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" ); createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" ); createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" ); @@ -2729,11 +2777,16 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true ); createSMESHAction( 214, "UPDATE", "ICON_UPDATE" ); createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true ); + createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true ); createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true ); createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true ); createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true ); createSMESHAction( 220, "ALL" ); createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true ); + + createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true ); + createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true ); + createSMESHAction( 1100, "EDIT_HYPO" ); createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 ); createSMESHAction( 1102, "UNASSIGN" ); @@ -2800,6 +2853,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( separator(), meshId, -1 ); createMenu( 701, meshId, -1 ); createMenu( 711, meshId, -1 ); + createMenu( 712, meshId, -1 ); createMenu( separator(), meshId, -1 ); createMenu( 801, meshId, -1 ); createMenu( 806, meshId, -1 ); @@ -2840,8 +2894,9 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( 6021, ctrlId, -1 ); createMenu( separator(), ctrlId, -1 ); - createMenu( 400, addId, -1 ); - createMenu( 401, addId, -1 ); + createMenu( 4000, addId, -1 ); + createMenu( 4009, addId, -1 ); + createMenu( 4010, addId, -1 ); createMenu( 4021, addId, -1 ); createMenu( 4022, addId, -1 ); createMenu( 4023, addId, -1 ); @@ -2901,6 +2956,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( separator(), meshTb ); createTool( 701, meshTb ); createTool( 711, meshTb ); + createTool( 712, meshTb ); createTool( separator(), meshTb ); createTool( 801, meshTb ); createTool( 806, meshTb ); @@ -2933,8 +2989,9 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( 6021, ctrlTb ); createTool( separator(), ctrlTb ); - createTool( 400, addRemTb ); - createTool( 401, addRemTb ); + createTool( 4000, addRemTb ); + createTool( 4009, addRemTb ); + createTool( 4010, addRemTb ); createTool( 4021, addRemTb ); createTool( 4022, addRemTb ); createTool( 4023, addRemTb ); @@ -3015,7 +3072,8 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE - createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE + createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE + createPopupItem( 712, OB, mesh, "&& isComputable" ); // COMPUTE createPopupItem( 214, OB, mesh_group ); // UPDATE createPopupItem( 900, OB, mesh_group ); // ADV_INFO createPopupItem( 902, OB, mesh ); // STD_INFO @@ -3067,6 +3125,7 @@ void SMESHGUI::initialize( CAM_Application* app ) hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"), hasElems("(count( elemTypes ) > 0)"), hasDifferentElems("(count( elemTypes ) > 1)"), + hasElems0d("({'Elem0d'} in elemTypes)"), hasEdges("({'Edge'} in elemTypes)"), hasFaces("({'Face'} in elemTypes)"), hasVolumes("({'Volume'} in elemTypes)"); @@ -3125,6 +3184,10 @@ void SMESHGUI::initialize( CAM_Application* app ) anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 ); + popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D + popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule); + popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule); + popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule ); @@ -3142,6 +3205,19 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( action( 220 ), anId, -1 ); // ALL popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule ); + + //------------------------------------------------- + // Representation of the 2D Quadratic elements + //------------------------------------------------- + anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 ); + popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION + popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule ); + popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule ); + + popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION + popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule ); + popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule ); + //------------------------------------------------- // Orientation of faces //------------------------------------------------- @@ -3179,7 +3255,7 @@ void SMESHGUI::initialize( CAM_Application* app ) aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes; anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 ); - + popupMgr()->insert( action( 200 ), anId, -1 ); // RESET popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule ); @@ -3260,7 +3336,7 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule ); popupMgr()->insert( separator(), -1, -1 ); - + //------------------------------------------------- // Display / Erase //------------------------------------------------- @@ -3323,8 +3399,10 @@ bool SMESHGUI::activateModule( SUIT_Study* study ) // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil()); if ( SalomeApp_Study* s = dynamic_cast( study )) - if ( _PTR(Study) aStudy = s->studyDS()) + if ( _PTR(Study) aStudy = s->studyDS()) { GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() ); + updateObjBrowser(); // objects can be removed + } return res; } @@ -3458,6 +3536,25 @@ void SMESHGUI::createPreferences() setPreferenceProperty( dispmode, "strings", modes ); setPreferenceProperty( dispmode, "indexes", indices ); + int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab ); + setPreferenceProperty( arcgroup, "columns", 2 ); + int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" ); + QStringList quadraticModes; + quadraticModes.append("Lines"); + quadraticModes.append("Arcs"); + indices.clear(); + indices.append( 0 ); + indices.append( 1 ); + setPreferenceProperty( quadraticmode, "strings", quadraticModes ); + setPreferenceProperty( quadraticmode, "indexes", indices ); + + int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin, + "SMESH", "max_angle" ); + setPreferenceProperty( maxAngle, "min", 1 ); + setPreferenceProperty( maxAngle, "max", 90 ); + + + int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab ); setPreferenceProperty( exportgroup, "columns", 2 ); addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" ); @@ -3502,17 +3599,29 @@ void SMESHGUI::createPreferences() int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab ); setPreferenceProperty( elemGroup, "columns", 2 ); - addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" ); - addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" ); + addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" ); + addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" ); addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" ); + addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" ); + + //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space ); + //setPreferenceProperty( sp, "hstretch", 0 ); + //setPreferenceProperty( sp, "vstretch", 0 ); + + int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup, + LightApp_Preferences::IntSpin, "SMESH", "elem0d_size"); int sp = addPreference( "", elemGroup, LightApp_Preferences::Space ); + int elemW = addPreference(tr("PREF_WIDTH"), elemGroup, + LightApp_Preferences::IntSpin, "SMESH", "element_width"); + int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup, + LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff"); + + setPreferenceProperty( size0d, "min", 1 ); + setPreferenceProperty( size0d, "max", 10 ); setPreferenceProperty( sp, "hstretch", 0 ); setPreferenceProperty( sp, "vstretch", 0 ); - int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" ); - int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" ); - setPreferenceProperty( elemW, "min", 1 ); setPreferenceProperty( elemW, "max", 5 ); @@ -3784,6 +3893,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const case 711: // Precompute mesh op = new SMESHGUI_PrecomputeOp(); break; + case 712: // Evaluate mesh + op = new SMESHGUI_EvaluateOp(); + break; case 806: // Create group on geom op = new SMESHGUI_GroupOnShapeOp(); break; @@ -3928,7 +4040,8 @@ void SMESHGUI::storeVisualParameters (int savePoint) { if (SVTK_ViewWindow* vtkView = dynamic_cast(views[i])) { - vtkActorCollection* allActors = vtkView->getRenderer()->GetActors(); + VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors()); + vtkActorCollection* allActors = aCopy.GetActors(); allActors->InitTraversal(); while (vtkActor* actor = allActors->GetNextActor()) { @@ -4144,7 +4257,8 @@ void SMESHGUI::restoreVisualParameters (int savePoint) // access later when restoring other parameters SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView(); vtkRenderer* Renderer = vtkView->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); + VTK::ActorCollectionCopy aCopy(Renderer->GetActors()); + vtkActorCollection* theActors = aCopy.GetActors(); theActors->InitTraversal(); bool isFound = false; vtkActor *ac = theActors->GetNextActor();