]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix on - Bug PAL7334 DEVELOPMENT : Control Improvement - implementation of Display...
authorapo <apo@opencascade.com>
Fri, 24 Dec 2004 13:16:34 +0000 (13:16 +0000)
committerapo <apo@opencascade.com>
Fri, 24 Dec 2004 13:16:34 +0000 (13:16 +0000)
resources/SMESH_en.xml
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/SMESHGUI/SMESHGUI.cxx

index a2e0232287a57bc3584b9573d3ecb28d33df364c..0c5541472c81ed4e432e711b0038e48e1f576745 100644 (file)
        <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <endsubmenu />
+   <submenu label-id="Display Entity" item-id="1135" pos-id="">
+       <popup-item item-id="217" pos-id="" label-id="Edges" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="218" pos-id="" label-id="Faces" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="219" pos-id="" label-id="Volumes" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="220" pos-id="" label-id="All" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
    <popup-item item-id="1132" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
        <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <endsubmenu />
+   <submenu label-id="Display Entity" item-id="1135" pos-id="">
+       <popup-item item-id="217" pos-id="" label-id="Edges" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="218" pos-id="" label-id="Faces" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="219" pos-id="" label-id="Volumes" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="220" pos-id="" label-id="All" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
    <popup-item item-id="1132" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
        <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <endsubmenu />
+   <submenu label-id="Display Entity" item-id="1135" pos-id="">
+       <popup-item item-id="217" pos-id="" label-id="Edges" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="218" pos-id="" label-id="Faces" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="219" pos-id="" label-id="Volumes" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="220" pos-id="" label-id="All" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
    <popup-item item-id="1132" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
index c3a7abe32e474e4350dc61efa26d8350587b8e0a..0c57a09da43f4fc503ac10e6bfa01bfb4a4d7824 100644 (file)
@@ -439,6 +439,8 @@ SMESH_Actor::SMESH_Actor(){
   myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
   aPtsTextProp->Delete();
     
+  myEntityMode = eAllEntity;
+
   myIsPointsLabeled = false;
 
   myPointLabels = vtkActor2D::New();
@@ -1021,6 +1023,55 @@ void SMESH_Actor::SetVisibility(int theMode, bool theIsUpdateRepersentation){
 }
 
 
+namespace{
+
+  inline bool UpdateEntityMode(unsigned int& theOutputMode, 
+                              unsigned int theInputMode, 
+                              unsigned int theMode,
+                              int theCondition)
+  {
+    if(!theCondition)
+      theOutputMode &= ~theMode;
+
+    return theOutputMode & theMode && theCondition;
+  }
+
+}
+
+void SMESH_Actor::SetEntityMode(unsigned int theMode){
+  if(!myVisualObj->GetNbEntities(SMESH::EDGE))
+    theMode &= ~eEdges;
+
+  if(!myVisualObj->GetNbEntities(SMESH::FACE))
+    theMode &= ~eFaces;
+
+  if(!myVisualObj->GetNbEntities(SMESH::VOLUME))
+    theMode &= ~eVolumes;
+
+  if(!theMode)
+    return;
+
+  myScalarBarActor->VisibilityOff();
+
+  my1DExtActor->VisibilityOff();
+  my1DActor->VisibilityOff();
+  
+  my2DActor->VisibilityOff();
+  my3DActor->VisibilityOff();
+  
+  if(theMode & eEdges)
+    my1DActor->VisibilityOn();
+  
+  if(theMode & eFaces)
+    my2DActor->VisibilityOn();
+  
+  if(theMode & eVolumes)
+    my3DActor->VisibilityOn();
+  
+  myEntityMode = theMode;
+}
+
+
 void SMESH_Actor::SetRepresentation(int theMode){ 
   int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE);
   int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE);
index 2fad89f01d30509d926bf14ab3e29f62aaf5115e..469fc6c07f6ff74b352fe28e84e6c178bfdcd336 100644 (file)
@@ -121,6 +121,11 @@ class SMESH_Actor : public SALOME_Actor{
 
   enum EReperesent { ePoint, eEdge, eSurface};
   virtual void SetRepresentation(int theMode);
+
+  enum EEntityMode { eEdges = 0x01, eFaces = 0x02, eVolumes = 0x04, eAllEntity = 0x07};
+  unsigned int GetEntityMode() const { return myEntityMode;}
+  void SetEntityMode(unsigned int theMode);
+
   void SetPointRepresentation(bool theIsPointsVisible);
   bool GetPointRepresentation();
 
@@ -198,6 +203,7 @@ class SMESH_Actor : public SALOME_Actor{
   vtkProperty* my1DExtProp;
   SMESH_DeviceActor* my1DExtActor;
 
+  unsigned int myEntityMode;
   bool myIsPointsVisible;
 
   bool myIsShrinkable;
index ca55141a14792b5be49b0dd1593c29cc344a6c3d..53f39f51834c3551cdef9859cc82c56a7ebecfaa 100644 (file)
@@ -140,7 +140,9 @@ namespace{
 
   void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
 
-  void SetViewMode(int theCommandID);
+  void SetDisplayMode(int theCommandID);
+
+  void SetDisplayEntity(int theCommandID);
 
   void Control( int theCommandID );
 
@@ -286,7 +288,48 @@ namespace{
     }
   }  
   
-  void SetViewMode(int theCommandID){
+  inline void InverseEntityMode(unsigned int& theOutputMode,
+                               unsigned int theMode)
+  {
+    bool anIsNotPresent = ~theOutputMode & theMode;
+    if(anIsNotPresent)
+      theOutputMode |= theMode;
+    else
+      theOutputMode &= ~theMode;
+  }
+
+  void SetDisplayEntity(int theCommandID){
+    SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
+    if(Sel->IObjectCount() >= 1){
+      SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+      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 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 SetDisplayMode(int theCommandID){
     SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
     if(Sel->IObjectCount() >= 1){
       switch(theCommandID){
@@ -1031,14 +1074,22 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
   case 1134: // Clipping
   case 1133: // Tranparency
   case 1132: // Colors / Size
-  case 215:
-  case 213:
-  case 212:
-  case 211:
-    {
-      ::SetViewMode(theCommandID);
-      break;
-    }
+
+    // Display Mode
+  case 215: // Nodes
+  case 213: // Nodes
+  case 212: // Nodes
+  case 211: // Nodes
+    ::SetDisplayMode(theCommandID);
+  break;
+
+    // Display Entity
+  case 217: // Edges
+  case 218: // Faces
+  case 219: // Volumes
+  case 220: // All Entity
+    ::SetDisplayEntity(theCommandID);
+  break;
 
   case 214:                                    // UPDATE
     {
@@ -2316,21 +2367,22 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
         if ( !aGeomGroup->_is_nil()  ) // group linked on geometry
          popup->removeItem( 803 ); // EDIT GROUP
           
-       SMESH_Actor* ac = SMESH::FindActorByEntry(IObject->getEntry());
+       SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
        // if object has actor
-       if ( ac && studyFrame->getTypeView() == VIEW_VTK ) {
+       if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
          VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
          if ( myRenderInter->isVisible( IObject ) ) {
            popup->removeItem( QAD_Display_Popup_ID );
-           popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes #
-           popup->setItemChecked( 9011, ac->GetCellsLabeled() );  // Numbering / Display Elements #
-           TVisualObjPtr aVisualObj = ac->GetObject();
+           popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
+           popup->setItemChecked( 9011, anActor->GetCellsLabeled() );  // Numbering / Display Elements #
+           TVisualObjPtr aVisualObj = anActor->GetObject();
            int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
            int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
            int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
+
            QMenuItem* mi = popup->findItem( 1131 );
            if ( mi && mi->popup() ) {
-             int  prType = ac->GetRepresentation();
+             int  prType = anActor->GetRepresentation();
              // Display Mode / Wireframe
              if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
                mi->popup()->removeItem( 211 );
@@ -2346,15 +2398,47 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
              // Display Mode / Points
              mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );  
              // Display Mode / Shrink
-             bool isShrunk = ac->IsShrunk();
-             bool isShrunkable = ac->IsShrunkable();
+             bool isShrunk = anActor->IsShrunk();
+             bool isShrunkable = anActor->IsShrunkable();
              mi->popup()->setItemChecked( 213, isShrunk );   
              mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
            }
-           // Scalar Bar
+
+           // Display Entity
+           mi = popup->findItem( 1135 );
+           if ( mi && mi->popup() ) {
+             QPopupMenu* aPopup = mi->popup();
+             unsigned int aMode = anActor->GetEntityMode();
+
+             if(aNbVolumes == 0)
+               aPopup->removeItem( 219 );
+             else
+               aPopup->setItemChecked( 219, aMode & SMESH_Actor::eVolumes );
+
+             if(aNbFaces == 0)
+               aPopup->removeItem( 218 );
+             else
+               aPopup->setItemChecked( 218, aMode & SMESH_Actor::eFaces );
+
+
+             if(aNbEdges == 0)
+               aPopup->removeItem( 217 );
+             else
+               aPopup->setItemChecked( 217, aMode & SMESH_Actor::eEdges );
+
+
+             bool aIsRemove = (aNbVolumes == 0 || aMode & SMESH_Actor::eVolumes);
+             aIsRemove &= (aNbFaces == 0 || aMode & SMESH_Actor::eFaces);
+             aIsRemove &= (aNbEdges == 0 || aMode & SMESH_Actor::eEdges);
+
+             if(aIsRemove)
+               aPopup->removeItem( 220 );
+           }
+
+           // Controls
            mi = popup->findItem( 2000 );
            if ( mi && mi->popup() ) {
-             SMESH_Actor::eControl cMode = ac->GetControlMode();
+             SMESH_Actor::eControl cMode = anActor->GetControlMode();
              switch ( cMode ) {
              case SMESH_Actor::eLengthEdges:
                mi->popup()->setItemChecked( 6001, true ); break;
@@ -2388,7 +2472,7 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
                mi->popup()->removeItem( 201 );
                break;
              }
-             TVisualObjPtr aVisualObj = ac->GetObject();
+             TVisualObjPtr aVisualObj = anActor->GetObject();
              if(aNbEdges == 0){
                mi->popup()->removeItem( 6001 );
                mi->popup()->removeItem( 6003 );