From 2d926edd925ca69575f1a0b230b975ed11d9bc3e Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 24 Dec 2004 13:16:34 +0000 Subject: [PATCH] Fix on - Bug PAL7334 DEVELOPMENT : Control Improvement - implementation of Display Entity functionality --- resources/SMESH_en.xml | 24 +++++++ src/OBJECT/SMESH_Actor.cxx | 51 +++++++++++++++ src/OBJECT/SMESH_Actor.h | 6 ++ src/SMESHGUI/SMESHGUI.cxx | 126 ++++++++++++++++++++++++++++++------- 4 files changed, 186 insertions(+), 21 deletions(-) diff --git a/resources/SMESH_en.xml b/resources/SMESH_en.xml index a2e023228..0c5541472 100644 --- a/resources/SMESH_en.xml +++ b/resources/SMESH_en.xml @@ -231,6 +231,14 @@ + + + + + + + + @@ -274,6 +282,14 @@ + + + + + + + + @@ -319,6 +335,14 @@ + + + + + + + + diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index c3a7abe32..0c57a09da 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -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); diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index 2fad89f01..469fc6c07 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -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; diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index ca55141a1..53f39f518 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -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 ); -- 2.39.2