mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 09:20:35 +05:00
0022777: [CEA 1291] Display the name of an object in the 3D View
This commit is contained in:
parent
74c5b4f281
commit
334ef9aff1
@ -17,3 +17,4 @@ gg.createAndDisplayGO(fuse_id)
|
||||
gg.setDisplayMode(fuse_id,1)
|
||||
gg.setVectorsMode(fuse_id, 1)
|
||||
gg.setVerticesMode(fuse_id, 1)
|
||||
gg.setNameMode(fuse_id, 1)
|
||||
|
@ -40,6 +40,17 @@ functionality for all objects in the current view via the main menu
|
||||
|
||||
\n <b>TUI Command:</b> <em>gg.setVerticesMode(ID, Bool)</em>
|
||||
|
||||
\n Moreover user can show the name of the selected
|
||||
shape. For this, choose in the context menu of the shape
|
||||
<b>Display mode -> Show Name</b>, or apply this
|
||||
functionality for all objects in the current view via the main menu
|
||||
<b> View -> Display Mode -> Show/Hide Name.</b>
|
||||
|
||||
\image html name_mode.png
|
||||
<center><em>Name Mode (Show Name)</em></center>
|
||||
|
||||
\n <b>TUI Command:</b> <em>gg.setNameMode(ID, Bool)</em>
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of
|
||||
\ref tui_change_disp_mode "Changing Display Parameters".
|
||||
|
||||
|
@ -141,6 +141,12 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
||||
( GetVerticesMode() ? tr("MEN_VERTICES_MODE_ON") : tr( "MEN_VERTICES_MODE_OFF" ) );
|
||||
getGeometryGUI()->menuMgr()->update();
|
||||
break;
|
||||
case GEOMOp::OpSwitchName: // MENU VIEW - DISPLAY MODE - SHOW/HIDE NAME
|
||||
SetNameMode(!GetNameMode());
|
||||
getGeometryGUI()->action( GEOMOp::OpSwitchName )->setText
|
||||
( GetNameMode() ? tr("MEN_NAME_MODE_ON") : tr( "MEN_NAME_MODE_OFF" ) );
|
||||
getGeometryGUI()->menuMgr()->update();
|
||||
break;
|
||||
case GEOMOp::OpWireframe: // POPUP MENU - DISPLAY MODE - WIREFRAME
|
||||
ChangeDisplayMode( 0 );
|
||||
break;
|
||||
@ -158,6 +164,8 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
||||
break;
|
||||
case GEOMOp::OpVertices: // POPUP MENU - DISPLAY MODE - SHOW VERTICES
|
||||
ChangeDisplayMode( 5 );
|
||||
case GEOMOp::OpShowName: // POPUP MENU - DISPLAY MODE - SHOW NAME
|
||||
ChangeDisplayMode( 6 );
|
||||
break;
|
||||
default:
|
||||
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
||||
@ -539,6 +547,52 @@ int DisplayGUI::GetVerticesMode( SUIT_ViewWindow* viewWindow )
|
||||
return viewWindow->property( "VerticesMode" ).toBool();
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// function : DisplayGUI::SetNameMode()
|
||||
// purpose : Set name mode for the viewer
|
||||
//=====================================================================================
|
||||
void DisplayGUI::SetNameMode( const bool mode, SUIT_ViewWindow* viewWindow )
|
||||
{
|
||||
SUIT_OverrideCursor();
|
||||
|
||||
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
||||
if ( !app ) return;
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
||||
if ( !aStudy ) return;
|
||||
|
||||
if ( !viewWindow )
|
||||
viewWindow = app->desktop()->activeWindow();
|
||||
|
||||
viewWindow->setProperty( "NameMode", mode );
|
||||
|
||||
GEOM_Displayer displayer( aStudy );
|
||||
|
||||
int aMgrId = viewWindow->getViewManager()->getGlobalId();
|
||||
|
||||
SALOME_ListIO anIOlst;
|
||||
displayer.GetActiveView()->GetVisible( anIOlst );
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
|
||||
Handle( SALOME_InteractiveObject ) io = It.Value();
|
||||
aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), mode );
|
||||
displayer.Redisplay( io, false );
|
||||
}
|
||||
displayer.UpdateViewer();
|
||||
GeometryGUI::Modified();
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// function : DisplayGUI::GetNameMode()
|
||||
// purpose : Get the "show name" mode of the viewer
|
||||
//=====================================================================================
|
||||
int DisplayGUI::GetNameMode( SUIT_ViewWindow* viewWindow )
|
||||
{
|
||||
if ( !viewWindow )
|
||||
viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
|
||||
return viewWindow->property( "NameMode" ).toBool();
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// function : DisplayGUI::ChangeDisplayMode()
|
||||
// purpose : Set display mode for selected objects in the viewer given
|
||||
@ -572,6 +626,8 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
|
||||
bool vectorMode = v.isValid() ? !v.toBool() : false;
|
||||
v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Vertices ), QVariant() );
|
||||
bool verticesMode = v.isValid() ? !v.toBool() : false;
|
||||
v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
|
||||
bool nameMode = v.isValid() ? !v.toBool() : false;
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
Handle( SALOME_InteractiveObject ) io = It.Value();
|
||||
@ -584,6 +640,9 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
|
||||
else if ( mode == 5 ) {
|
||||
aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), verticesMode );
|
||||
}
|
||||
else if ( mode == 6 ) {
|
||||
aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), nameMode );
|
||||
}
|
||||
displayer.Redisplay( io, false );
|
||||
}
|
||||
displayer.UpdateViewer();
|
||||
|
@ -75,6 +75,12 @@ public:
|
||||
// Get vertices mode of the viewer
|
||||
int GetVerticesMode( SUIT_ViewWindow* = 0 );
|
||||
|
||||
// NAME MODE methods
|
||||
// Set name mode for the viewer
|
||||
void SetNameMode( const bool, SUIT_ViewWindow* = 0 );
|
||||
// Get name mode of the viewer
|
||||
int GetNameMode( SUIT_ViewWindow* = 0 );
|
||||
|
||||
// Set display mode for selected objects in the viewer given
|
||||
// (current viewer if <viewWindow> = 0 )
|
||||
void ChangeDisplayMode( const int, SUIT_ViewWindow* = 0 );
|
||||
|
@ -916,6 +916,7 @@ void EntityGUI_SubShapeDlg::ClickOnOkFilter()
|
||||
( myGreaterFilterCheck->isChecked() && !myLessFilterCheck->isChecked() && isGreater ) ) {
|
||||
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject();
|
||||
io->setEntry( anEntry.toLatin1().constData() );
|
||||
io->setName( myObject->GetName() );
|
||||
toSelect.Append(io);
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +172,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
|
||||
v = isVectorsMode( idx );
|
||||
else if ( p == "isVerticesMode" )
|
||||
v = isVerticesMode( idx );
|
||||
else if ( p == "isNameMode" )
|
||||
v = isNameMode( idx );
|
||||
else if ( p == "topLevel" )
|
||||
v = topLevel( idx );
|
||||
else if ( p == "autoBringToFront" )
|
||||
@ -476,6 +478,53 @@ bool GEOMGUI_Selection::isVerticesMode( const int index ) const
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::isNameMode( const int index ) const
|
||||
{
|
||||
#ifdef USE_VISUAL_PROP_MAP
|
||||
QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::ShowName ) );
|
||||
if ( v.canConvert( QVariant::Bool ) )
|
||||
return v.toBool();
|
||||
#endif
|
||||
|
||||
bool res = false;
|
||||
|
||||
SALOME_View* view = GEOM_Displayer::GetActiveView();
|
||||
QString viewType = activeViewType();
|
||||
if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
|
||||
SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
|
||||
if ( prs ) {
|
||||
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
|
||||
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
|
||||
AIS_ListOfInteractive lst;
|
||||
occPrs->GetObjects( lst );
|
||||
if ( lst.Extent() ) {
|
||||
Handle(AIS_InteractiveObject) io = lst.First();
|
||||
if ( !io.IsNull() ) {
|
||||
Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
|
||||
if ( !aSh.IsNull() )
|
||||
res = aSh->isShowName();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
|
||||
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
|
||||
vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
|
||||
if ( lst ) {
|
||||
lst->InitTraversal();
|
||||
vtkActor* actor = lst->GetNextActor();
|
||||
if ( actor ) {
|
||||
GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
|
||||
if ( aGeomActor )
|
||||
res = aGeomActor->GetNameMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
|
||||
{
|
||||
if ( obj ) {
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
QString selectionMode() const;
|
||||
bool isVectorsMode( const int ) const;
|
||||
bool isVerticesMode( const int ) const;
|
||||
bool isNameMode( const int ) const;
|
||||
bool hasChildren( const int ) const;
|
||||
int nbChildren( const int ) const;
|
||||
bool hasConcealedChildren( const int ) const;
|
||||
|
@ -853,6 +853,10 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
|
||||
bool isVerticesMode = propMap.value( GEOM::propertyName( GEOM::Vertices ) ).toBool();
|
||||
AISShape->SetDisplayVertices( isVerticesMode );
|
||||
|
||||
// set display name flag
|
||||
bool isNameMode = propMap.value( GEOM::propertyName( GEOM::ShowName ) ).toBool();
|
||||
AISShape->SetDisplayName( isNameMode );
|
||||
|
||||
// set transparency
|
||||
if( HasTransparency() ) {
|
||||
AISShape->SetTransparency( GetTransparency() );
|
||||
@ -1141,6 +1145,9 @@ void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create )
|
||||
// set display vertices flag
|
||||
actor->SetVerticesMode( propMap.value( GEOM::propertyName( GEOM::Vertices ) ).toBool() );
|
||||
|
||||
// set display name flag
|
||||
actor->SetNameMode( propMap.value( GEOM::propertyName( GEOM::ShowName ) ).toBool() );
|
||||
|
||||
// set display mode
|
||||
int displayMode = HasDisplayMode() ?
|
||||
// predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
|
||||
@ -1755,6 +1762,7 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
|
||||
|
||||
if ( !GeomObject->_is_nil() )
|
||||
{
|
||||
theIO->setName( GeomObject->GetName() );
|
||||
// finally set shape
|
||||
setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
|
||||
}
|
||||
@ -2550,6 +2558,9 @@ PropMap GEOM_Displayer::getDefaultPropertyMap()
|
||||
// - show vertices flag (false by default)
|
||||
propMap.insert( GEOM::propertyName( GEOM::Vertices ), false );
|
||||
|
||||
// - show name flag (false by default)
|
||||
propMap.insert( GEOM::propertyName( GEOM::ShowName ), false );
|
||||
|
||||
// - shading color (take default value from preferences)
|
||||
propMap.insert( GEOM::propertyName( GEOM::ShadingColor ),
|
||||
colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) );
|
||||
|
@ -2968,6 +2968,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>MEN_POP_VERTICES</source>
|
||||
<translation>Show Vertices</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_NAME</source>
|
||||
<translation>Show Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_PREFERENCES</source>
|
||||
<translation>Preferences</translation>
|
||||
@ -3156,6 +3160,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>MEN_VERTICES_MODE_OFF</source>
|
||||
<translation>Hide Vertices</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_NAME_MODE_ON</source>
|
||||
<translation>Show Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_NAME_MODE_OFF</source>
|
||||
<translation>Hide Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_WIREFRAME</source>
|
||||
<translation>Wireframe</translation>
|
||||
@ -3864,6 +3876,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_POP_VERTICES</source>
|
||||
<translation>Show Vertices</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_NAME</source>
|
||||
<translation>Show Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SETTEXTURE</source>
|
||||
<translation>Add a texture</translation>
|
||||
@ -3928,6 +3944,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_VECTOR_MODE</source>
|
||||
<translation>Change Edge Presentation Mode</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_NAME_MODE</source>
|
||||
<translation>Show/Hide names of visible shapes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_SHADING_COLOR</source>
|
||||
<translation>Set shading color</translation>
|
||||
|
@ -2968,6 +2968,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<source>MEN_POP_VERTICES</source>
|
||||
<translation>Montrer les sommets</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_NAME</source>
|
||||
<translation>Montrer le nom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_PREFERENCES</source>
|
||||
<translation>Préférences</translation>
|
||||
@ -3156,6 +3160,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<source>MEN_VERTICES_MODE_OFF</source>
|
||||
<translation>Cacher les sommets</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_NAME_MODE_ON</source>
|
||||
<translation>Montrer le nom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_NAME_MODE_OFF</source>
|
||||
<translation>Cacher le nom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_WIREFRAME</source>
|
||||
<translation>Filaire</translation>
|
||||
@ -3864,6 +3876,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<source>STB_POP_VERTICES</source>
|
||||
<translation>Montrer les sommets</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_NAME</source>
|
||||
<translation>Montrer le nom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SETTEXTURE</source>
|
||||
<translation>Ajoute une texture</translation>
|
||||
@ -3928,6 +3944,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<source>STB_VECTOR_MODE</source>
|
||||
<translation>Changer le mode de représentation des arêtes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_NAME_MODE</source>
|
||||
<translation type="unfinished">Show/Hide names of visible shapes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_SHADING_COLOR</source>
|
||||
<translation>Définir la couleur d'ombrage</translation>
|
||||
|
@ -2923,6 +2923,10 @@
|
||||
<source>MEN_POP_VERTICES</source>
|
||||
<translation type="unfinished">Show Vertices</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_NAME</source>
|
||||
<translation type="unfinished">Show Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_PREFERENCES</source>
|
||||
<translation>設定</translation>
|
||||
@ -3107,6 +3111,14 @@
|
||||
<source>MEN_VERTICES_MODE_OFF</source>
|
||||
<translation type="unfinished">Hide Vertices</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_NAME_MODE_ON</source>
|
||||
<translation type="unfinished">Show Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_NAME_MODE_OFF</source>
|
||||
<translation type="unfinished">Hide Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_WIREFRAME</source>
|
||||
<translation>ワイヤ フレーム</translation>
|
||||
@ -3807,6 +3819,10 @@
|
||||
<source>STB_POP_VERTICES</source>
|
||||
<translation type="unfinished">Show Vertices</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_NAME</source>
|
||||
<translation type="unfinished">Show Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SETTEXTURE</source>
|
||||
<translation>テクスチャを追加します。</translation>
|
||||
@ -3871,6 +3887,10 @@
|
||||
<source>STB_VECTOR_MODE</source>
|
||||
<translation>エッジの表示モードを変更</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_NAME_MODE</source>
|
||||
<translation type="unfinished">Show/Hide names of visible shapes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_SHADING_COLOR</source>
|
||||
<translation>網かけの色を設定</translation>
|
||||
|
@ -513,12 +513,14 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
||||
case GEOMOp::OpShow: // MENU VIEW - DISPLAY
|
||||
case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
|
||||
case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE
|
||||
case GEOMOp::OpSwitchName: // MENU VIEW - VERTICES MODE
|
||||
case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
|
||||
case GEOMOp::OpShading: // POPUP MENU - SHADING
|
||||
case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
|
||||
case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
|
||||
case GEOMOp::OpVectors: // POPUP MENU - VECTORS
|
||||
case GEOMOp::OpVertices: // POPUP MENU - VERTICES
|
||||
case GEOMOp::OpShowName: // POPUP MENU - SHOW NAME
|
||||
libName = "DisplayGUI";
|
||||
break;
|
||||
case GEOMOp::OpPoint: // MENU BASIC - POINT
|
||||
@ -1034,6 +1036,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpShow, "DISPLAY" );
|
||||
createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
|
||||
createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE");
|
||||
createGeomAction( GEOMOp::OpSwitchName, "NAME_MODE");
|
||||
createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
|
||||
createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
|
||||
createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
|
||||
@ -1056,6 +1059,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
|
||||
createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
|
||||
createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true );
|
||||
createGeomAction( GEOMOp::OpShowName, "POP_SHOW_NAME", "", 0, true );
|
||||
createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
|
||||
createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
|
||||
createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
|
||||
@ -1300,6 +1304,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( separator(), dispmodeId, -1 );
|
||||
createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
|
||||
createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 );
|
||||
createMenu( GEOMOp::OpSwitchName, dispmodeId, -1 );
|
||||
|
||||
createMenu( separator(), viewId, -1 );
|
||||
createMenu( GEOMOp::OpShowAll, viewId, -1 );
|
||||
@ -1497,6 +1502,9 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
|
||||
mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
|
||||
mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
|
||||
mgr->insert( action( GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
|
||||
mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
|
||||
mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
|
||||
mgr->insert( separator(), -1, -1 ); // -----------
|
||||
|
||||
mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
|
||||
@ -2809,6 +2817,11 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
|
||||
}
|
||||
|
||||
if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
|
||||
param = occParam + GEOM::propertyName( GEOM::ShowName );
|
||||
ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
|
||||
}
|
||||
|
||||
if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
|
||||
param = occParam + GEOM::propertyName( GEOM::Deflection );
|
||||
ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
|
||||
@ -2981,6 +2994,8 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
|
||||
} else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
|
||||
aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
|
||||
} else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
|
||||
aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
|
||||
} else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
|
||||
aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
|
||||
} else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
|
||||
@ -3029,11 +3044,34 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
}
|
||||
}
|
||||
|
||||
// Compute current name mode of the viewer
|
||||
void UpdateNameMode( SalomeApp_Application* app )
|
||||
{
|
||||
bool isMode = false;
|
||||
SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
||||
SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
|
||||
GEOM_Displayer displayer( aStudy );
|
||||
int aMgrId = viewWindow->getViewManager()->getGlobalId();
|
||||
|
||||
SALOME_ListIO anIOlst;
|
||||
displayer.GetActiveView()->GetVisible( anIOlst );
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
|
||||
Handle( SALOME_InteractiveObject ) io = It.Value();
|
||||
QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
|
||||
bool isIONameMode = v.isValid() ? v.toBool() : false;
|
||||
if( isIONameMode )
|
||||
isMode = true;
|
||||
}
|
||||
viewWindow->setProperty( "NameMode", isMode );
|
||||
}
|
||||
|
||||
void GeometryGUI::onViewAboutToShow()
|
||||
{
|
||||
SUIT_ViewWindow* window = application()->desktop()->activeWindow();
|
||||
QAction* a = action( GEOMOp::OpSwitchVectors );
|
||||
QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
|
||||
QAction* aNameAction = action( GEOMOp::OpSwitchName );
|
||||
if ( window ) {
|
||||
a->setEnabled(true);
|
||||
bool vmode = window->property("VectorsMode").toBool();
|
||||
@ -3041,11 +3079,17 @@ void GeometryGUI::onViewAboutToShow()
|
||||
aVerticesAction->setEnabled(true);
|
||||
vmode = window->property("VerticesMode").toBool();
|
||||
aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
|
||||
UpdateNameMode( getApp() );
|
||||
aNameAction->setEnabled(true);
|
||||
vmode = window->property("NameMode").toBool();
|
||||
aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
|
||||
} else {
|
||||
a->setText ( tr("MEN_VECTOR_MODE_ON") );
|
||||
a->setEnabled(false);
|
||||
aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
|
||||
aVerticesAction->setEnabled(false);
|
||||
aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
|
||||
aNameAction->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ namespace GEOMOp {
|
||||
OpDMShadingWithEdges = 2012, // MENU VIEW - DISPLAY MODE - SHADING WITH EDGES
|
||||
OpDMTexture = 2013, // MENU VIEW - DISPLAY MODE - TEXTURE
|
||||
OpSwitchVertices = 2014, // MENU VIEW - DISPLAY MODE - SHOW/HIDE VERTICES
|
||||
OpSwitchName = 2015, // MENU VIEW - DISPLAY MODE - SHOW/HIDE NAME
|
||||
OpShow = 2100, // POPUP MENU - SHOW
|
||||
OpShowOnly = 2101, // POPUP MENU - SHOW ONLY
|
||||
OpHide = 2102, // POPUP MENU - HIDE
|
||||
@ -82,6 +83,7 @@ namespace GEOMOp {
|
||||
OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT
|
||||
OpClsBringToFront = 2206,
|
||||
OpVertices = 2208, // POPUP MENU - DISPLAY MODE - SHOW VERTICES
|
||||
OpShowName = 2209, // POPUP MENU - DISPLAY MODE - SHOW NAME
|
||||
// BasicGUI --------------------//--------------------------------
|
||||
OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT
|
||||
OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE
|
||||
|
@ -403,6 +403,18 @@ void GEOM_Swig::setVerticesMode( const char* theEntry, bool theOn, bool theUpdat
|
||||
theOn, theUpdateViewer ) );
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Show / hide name of shape for the presentation
|
||||
\param theEntry geometry object's entry
|
||||
\param theOn \c true to show name or \c false otherwise
|
||||
\param theUpdateViewer \c true to update active view's contents
|
||||
*/
|
||||
void GEOM_Swig::setNameMode( const char* theEntry, bool theOn, bool theUpdateViewer )
|
||||
{
|
||||
ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::ShowName ),
|
||||
theOn, theUpdateViewer ) );
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Change color of the presentation
|
||||
\param theEntry geometry object's entry
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
void setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer = true );
|
||||
void setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer = true );
|
||||
void setVerticesMode( const char* theEntry, bool theOn, bool theUpdateViewer = true );
|
||||
void setNameMode( const char* theEntry, bool theOn, bool theUpdateViewer = true );
|
||||
void setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer = true );
|
||||
void setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer = true );
|
||||
void setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer = true );
|
||||
|
@ -64,6 +64,7 @@ class GEOM_Swig
|
||||
void setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer = true );
|
||||
void setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer = true );
|
||||
void setVerticesMode( const char* theEntry, bool theOn, bool theUpdateViewer = true );
|
||||
void setNameMode( const char* theEntry, bool theOn, bool theUpdateViewer = true );
|
||||
void setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer = true );
|
||||
void setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer = true );
|
||||
void setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer = true );
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "GEOM_AISShape.hxx"
|
||||
#include "GEOM_AISVector.hxx"
|
||||
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <Basics_OCCTVersion.hxx>
|
||||
|
||||
// Open CASCADE Includes
|
||||
@ -330,6 +332,9 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
|
||||
if( anIsTextField )
|
||||
drawField( aPrs, true );
|
||||
|
||||
if( isShowName() )
|
||||
drawName( aPrs );
|
||||
|
||||
// aPrs->ReCompute(); // for hidden line recomputation if necessary...
|
||||
}
|
||||
|
||||
@ -384,6 +389,11 @@ void GEOM_AISShape::SetDisplayVertices(bool isDisplayed)
|
||||
myDisplayVertices = isDisplayed;
|
||||
}
|
||||
|
||||
void GEOM_AISShape::SetDisplayName(bool isDisplayed)
|
||||
{
|
||||
myDisplayName = isDisplayed;
|
||||
}
|
||||
|
||||
void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
|
||||
const Handle(Prs3d_Presentation)& aPrs,
|
||||
const Standard_Integer aMode)
|
||||
@ -611,6 +621,23 @@ void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
|
||||
}
|
||||
}
|
||||
|
||||
void GEOM_AISShape::drawName( const Handle(Prs3d_Presentation)& thePrs )
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup( thePrs );
|
||||
|
||||
gp_Ax3 anAx3 = GEOMUtils::GetPosition(myshape);
|
||||
gp_Pnt aCenter = anAx3.Location();
|
||||
|
||||
Graphic3d_Vertex aVertex( aCenter.X(), aCenter.Y(), aCenter.Z() );
|
||||
|
||||
Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
|
||||
anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
|
||||
aGroup->SetPrimitivesAspect( anAspectText3d );
|
||||
|
||||
const char* aName = getIO()->getName();
|
||||
aGroup->Text( TCollection_ExtendedString( aName ), aVertex, 16 );
|
||||
}
|
||||
|
||||
Standard_Boolean GEOM_AISShape::computeMassCenter( const TopoDS_Shape& theShape,
|
||||
gp_Pnt& theCenter )
|
||||
{
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
Standard_EXPORT void SetEdgesInShadingColor(const Quantity_Color &aCol);
|
||||
Standard_EXPORT void SetDisplayVectors(bool isShow);
|
||||
Standard_EXPORT void SetDisplayVertices(bool isShow);
|
||||
Standard_EXPORT void SetDisplayName(bool isShow);
|
||||
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
@ -88,6 +89,7 @@ public:
|
||||
|
||||
Standard_EXPORT virtual bool isShowVectors() { return myDisplayVectors; }
|
||||
Standard_EXPORT virtual bool isShowVertices() { return myDisplayVertices; }
|
||||
Standard_EXPORT virtual bool isShowName() { return myDisplayName; }
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean switchTopLevel();
|
||||
Standard_EXPORT virtual Standard_Boolean toActivate();
|
||||
@ -125,6 +127,9 @@ protected:
|
||||
const bool theIsText = false,
|
||||
const bool theIsHighlight = false );
|
||||
|
||||
// Displaying the name of shape
|
||||
Standard_EXPORT void drawName( const Handle(Prs3d_Presentation)& thePrs );
|
||||
|
||||
// Auxiliary method to compute a center of mass for the specified shape
|
||||
Standard_EXPORT static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape,
|
||||
gp_Pnt& theCenter );
|
||||
@ -136,6 +141,7 @@ private:
|
||||
TCollection_AsciiString myName;
|
||||
bool myDisplayVectors;
|
||||
bool myDisplayVertices;
|
||||
bool myDisplayName;
|
||||
Standard_Boolean myTopLevel;
|
||||
Standard_Integer myPrevDisplayMode;
|
||||
|
||||
|
@ -41,9 +41,12 @@
|
||||
#include "SVTK_Actor.h"
|
||||
|
||||
#include <OCC2VTK_Tools.h>
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <vtkObjectFactory.h>
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkTextActor.h>
|
||||
#include <vtkTextProperty.h>
|
||||
#include <vtkProperty.h>
|
||||
#include <vtkPointPicker.h>
|
||||
#include <vtkCellPicker.h>
|
||||
@ -84,6 +87,7 @@ GEOM_Actor::GEOM_Actor():
|
||||
myIsSelected(false),
|
||||
myVectorMode(false),
|
||||
myVerticesMode(false),
|
||||
myNameMode(false),
|
||||
|
||||
myVertexActor(GEOM_DeviceActor::New(),true),
|
||||
myVertexSource(GEOM_VertexSource::New(),true),
|
||||
@ -115,6 +119,8 @@ GEOM_Actor::GEOM_Actor():
|
||||
// defined in this class !!!
|
||||
myPolyDataMapper(GEOM_PainterPolyDataMapper::New(),true),
|
||||
|
||||
myTextActor( vtkTextActor::New() ),
|
||||
|
||||
myHighlightProp(vtkProperty::New()),
|
||||
myPreHighlightProp(vtkProperty::New()),
|
||||
myShadingFaceProp(vtkProperty::New()),
|
||||
@ -202,6 +208,7 @@ GEOM_Actor::GEOM_Actor():
|
||||
setDisplayMode(0); // WIRE FRAME
|
||||
SetVectorMode(0); //
|
||||
SetVerticesMode(0); //
|
||||
SetNameMode(0);
|
||||
}
|
||||
|
||||
|
||||
@ -246,6 +253,7 @@ SetModified()
|
||||
this->mySharedEdgeSource->Modified();
|
||||
this->myWireframeFaceSource->Modified();
|
||||
this->myShadingFaceSource->Modified();
|
||||
this->myTextActor->Modified();
|
||||
}
|
||||
|
||||
void
|
||||
@ -275,6 +283,8 @@ AddToRender(vtkRenderer* theRenderer)
|
||||
|
||||
myVertexActor->AddToRender(theRenderer);
|
||||
myStandaloneVertexActor->AddToRender(theRenderer);
|
||||
|
||||
theRenderer->AddActor( myTextActor );
|
||||
}
|
||||
|
||||
void
|
||||
@ -297,6 +307,7 @@ RemoveFromRender(vtkRenderer* theRenderer)
|
||||
myVertexActor->RemoveFromRender(theRenderer);
|
||||
myStandaloneVertexActor->RemoveFromRender(theRenderer);
|
||||
|
||||
theRenderer->RemoveActor( myTextActor );
|
||||
|
||||
SetSelected(false);
|
||||
SetVisibility(false);
|
||||
@ -374,6 +385,8 @@ SetVisibility(int theVisibility)
|
||||
myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points
|
||||
|
||||
myStandaloneVertexActor->SetVisibility(theVisibility);
|
||||
|
||||
myTextActor->SetVisibility( theVisibility && myNameMode );
|
||||
}
|
||||
|
||||
|
||||
@ -429,6 +442,38 @@ GEOM_Actor
|
||||
return myVerticesMode;
|
||||
}
|
||||
|
||||
void
|
||||
GEOM_Actor
|
||||
::SetShapeName(const TopoDS_Shape& theShape)
|
||||
{
|
||||
gp_Ax3 anAx3 = GEOMUtils::GetPosition(theShape);
|
||||
double center[3] = { anAx3.Location().X(),
|
||||
anAx3.Location().Y(),
|
||||
anAx3.Location().Z() };
|
||||
double* pos = center;
|
||||
myTextActor->GetTextProperty()->SetFontSize( 16 );
|
||||
myTextActor->GetTextProperty()->ShadowOn();
|
||||
myTextActor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
myTextActor->GetPositionCoordinate()->SetValue(pos);
|
||||
myTextActor->SetInput( getIO()->getName() );
|
||||
}
|
||||
|
||||
void
|
||||
GEOM_Actor
|
||||
::SetNameMode(bool theMode)
|
||||
{
|
||||
myNameMode = theMode;
|
||||
myTextActor->SetVisibility(theMode);
|
||||
SetModified();
|
||||
}
|
||||
|
||||
bool
|
||||
GEOM_Actor
|
||||
::GetNameMode()
|
||||
{
|
||||
return myNameMode;
|
||||
}
|
||||
|
||||
void
|
||||
GEOM_Actor::
|
||||
SetDeflection(double theDeflection)
|
||||
@ -490,6 +535,8 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
||||
myHighlightActor->GetDeviceActor()->SetInfinitive(true);
|
||||
}
|
||||
|
||||
SetShapeName( theShape );
|
||||
|
||||
// 0051777: TC7.2.0: Element could not be selected in Hypothesis Construction
|
||||
myAppendFilter->Update();
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ class GEOM_ShadingFace;
|
||||
typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
|
||||
|
||||
class vtkRenderer;
|
||||
class vtkTextActor;
|
||||
|
||||
class vtkAppendPolyData;
|
||||
typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
|
||||
@ -210,10 +211,20 @@ public:
|
||||
bool
|
||||
GetVerticesMode();
|
||||
|
||||
//! Name mode management
|
||||
virtual
|
||||
void
|
||||
SetNameMode(const bool theMode);
|
||||
|
||||
virtual
|
||||
bool
|
||||
GetNameMode();
|
||||
|
||||
protected:
|
||||
void SetModified();
|
||||
|
||||
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
|
||||
void SetShapeName(const TopoDS_Shape& theShape);
|
||||
|
||||
GEOM_Actor();
|
||||
~GEOM_Actor();
|
||||
@ -229,6 +240,7 @@ private:
|
||||
bool myIsSelected;
|
||||
bool myVectorMode;
|
||||
bool myVerticesMode;
|
||||
bool myNameMode;
|
||||
|
||||
PDeviceActor myVertexActor;
|
||||
PVertexSource myVertexSource;
|
||||
@ -252,6 +264,9 @@ private:
|
||||
PSFaceSource myShadingFaceSource;
|
||||
|
||||
PDeviceActor myHighlightActor;
|
||||
|
||||
vtkTextActor* myTextActor;
|
||||
|
||||
vtkSmartPointer<vtkProperty> myHighlightProp;
|
||||
vtkSmartPointer<vtkProperty> myPreHighlightProp;
|
||||
vtkSmartPointer<vtkProperty> myShadingFaceProp;
|
||||
|
@ -71,6 +71,8 @@ namespace GEOM
|
||||
"VectorMode", // VECTOR_MODE_PROP
|
||||
// "show vertices" flag
|
||||
"VerticesMode", // VERTICES_MODE_PROP
|
||||
// "show name" flag
|
||||
"NameMode", // NAME_MODE_PROP
|
||||
// deflection coefficient
|
||||
"DeflectionCoeff", // DEFLECTION_COEFF_PROP
|
||||
// point marker data
|
||||
|
@ -40,6 +40,7 @@ namespace GEOM
|
||||
Color,
|
||||
EdgesDirection,
|
||||
Vertices,
|
||||
ShowName,
|
||||
Deflection,
|
||||
PointMarker,
|
||||
Material,
|
||||
|
Loading…
Reference in New Issue
Block a user