Fix on - Bug PAL7334 DEVELOPMENT : Control Improvement - implementation of Display Entity functionality

This commit is contained in:
apo 2004-12-24 13:16:34 +00:00
parent 2adad59bbb
commit 2d926edd92
4 changed files with 186 additions and 21 deletions

View File

@ -231,6 +231,14 @@
<popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" 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> </submenu>
<endsubmenu /> <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="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="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="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
@ -274,6 +282,14 @@
<popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" 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> </submenu>
<endsubmenu /> <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="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="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="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
@ -319,6 +335,14 @@
<popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" 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> </submenu>
<endsubmenu /> <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="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="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="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>

View File

@ -439,6 +439,8 @@ SMESH_Actor::SMESH_Actor(){
myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp); myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
aPtsTextProp->Delete(); aPtsTextProp->Delete();
myEntityMode = eAllEntity;
myIsPointsLabeled = false; myIsPointsLabeled = false;
myPointLabels = vtkActor2D::New(); 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){ void SMESH_Actor::SetRepresentation(int theMode){
int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE); int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE);
int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE); int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE);

View File

@ -121,6 +121,11 @@ class SMESH_Actor : public SALOME_Actor{
enum EReperesent { ePoint, eEdge, eSurface}; enum EReperesent { ePoint, eEdge, eSurface};
virtual void SetRepresentation(int theMode); 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); void SetPointRepresentation(bool theIsPointsVisible);
bool GetPointRepresentation(); bool GetPointRepresentation();
@ -198,6 +203,7 @@ class SMESH_Actor : public SALOME_Actor{
vtkProperty* my1DExtProp; vtkProperty* my1DExtProp;
SMESH_DeviceActor* my1DExtActor; SMESH_DeviceActor* my1DExtActor;
unsigned int myEntityMode;
bool myIsPointsVisible; bool myIsPointsVisible;
bool myIsShrinkable; bool myIsShrinkable;

View File

@ -140,7 +140,9 @@ namespace{
void ExportMeshToFile(QAD_Desktop * parent, int theCommandID); void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
void SetViewMode(int theCommandID); void SetDisplayMode(int theCommandID);
void SetDisplayEntity(int theCommandID);
void Control( 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()); SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
if(Sel->IObjectCount() >= 1){ if(Sel->IObjectCount() >= 1){
switch(theCommandID){ switch(theCommandID){
@ -1031,14 +1074,22 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
case 1134: // Clipping case 1134: // Clipping
case 1133: // Tranparency case 1133: // Tranparency
case 1132: // Colors / Size case 1132: // Colors / Size
case 215:
case 213: // Display Mode
case 212: case 215: // Nodes
case 211: case 213: // Nodes
{ case 212: // Nodes
::SetViewMode(theCommandID); case 211: // Nodes
break; ::SetDisplayMode(theCommandID);
} break;
// Display Entity
case 217: // Edges
case 218: // Faces
case 219: // Volumes
case 220: // All Entity
::SetDisplayEntity(theCommandID);
break;
case 214: // UPDATE 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 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
popup->removeItem( 803 ); // EDIT GROUP popup->removeItem( 803 ); // EDIT GROUP
SMESH_Actor* ac = SMESH::FindActorByEntry(IObject->getEntry()); SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
// if object has actor // if object has actor
if ( ac && studyFrame->getTypeView() == VIEW_VTK ) { if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor(); VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
if ( myRenderInter->isVisible( IObject ) ) { if ( myRenderInter->isVisible( IObject ) ) {
popup->removeItem( QAD_Display_Popup_ID ); popup->removeItem( QAD_Display_Popup_ID );
popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes # popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements # popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
TVisualObjPtr aVisualObj = ac->GetObject(); TVisualObjPtr aVisualObj = anActor->GetObject();
int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE); int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE); int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME); int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
QMenuItem* mi = popup->findItem( 1131 ); QMenuItem* mi = popup->findItem( 1131 );
if ( mi && mi->popup() ) { if ( mi && mi->popup() ) {
int prType = ac->GetRepresentation(); int prType = anActor->GetRepresentation();
// Display Mode / Wireframe // Display Mode / Wireframe
if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){ if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
mi->popup()->removeItem( 211 ); mi->popup()->removeItem( 211 );
@ -2346,15 +2398,47 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
// Display Mode / Points // Display Mode / Points
mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint ); mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
// Display Mode / Shrink // Display Mode / Shrink
bool isShrunk = ac->IsShrunk(); bool isShrunk = anActor->IsShrunk();
bool isShrunkable = ac->IsShrunkable(); bool isShrunkable = anActor->IsShrunkable();
mi->popup()->setItemChecked( 213, isShrunk ); mi->popup()->setItemChecked( 213, isShrunk );
mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable); 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 ); mi = popup->findItem( 2000 );
if ( mi && mi->popup() ) { if ( mi && mi->popup() ) {
SMESH_Actor::eControl cMode = ac->GetControlMode(); SMESH_Actor::eControl cMode = anActor->GetControlMode();
switch ( cMode ) { switch ( cMode ) {
case SMESH_Actor::eLengthEdges: case SMESH_Actor::eLengthEdges:
mi->popup()->setItemChecked( 6001, true ); break; mi->popup()->setItemChecked( 6001, true ); break;
@ -2388,7 +2472,7 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
mi->popup()->removeItem( 201 ); mi->popup()->removeItem( 201 );
break; break;
} }
TVisualObjPtr aVisualObj = ac->GetObject(); TVisualObjPtr aVisualObj = anActor->GetObject();
if(aNbEdges == 0){ if(aNbEdges == 0){
mi->popup()->removeItem( 6001 ); mi->popup()->removeItem( 6001 );
mi->popup()->removeItem( 6003 ); mi->popup()->removeItem( 6003 );