mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-19 04:00:33 +05:00
Issue 20099: Hide children
Add Show/Hide chidren menu command for GEOM module objects
This commit is contained in:
parent
63b2d29eae
commit
3e98d95f41
BIN
doc/salome/gui/GEOM/images/ob_popup_menu.png
Normal file
BIN
doc/salome/gui/GEOM/images/ob_popup_menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -2,12 +2,13 @@
|
||||
|
||||
\page view_geom_obj_page Viewing geometrical objects
|
||||
|
||||
\n Newly created geometrical objects are automatically displayed in
|
||||
Newly created geometrical objects are automatically displayed in
|
||||
the <b>OCC 3D Viewer</b>.
|
||||
|
||||
\n <b>OCC 3D Viewer</b> is described in the documentation on <b>GUI
|
||||
<b>OCC 3D Viewer</b> is described in the documentation on <b>GUI
|
||||
module</b>.
|
||||
\n After the object has appeared in the Viewer, you can select it with
|
||||
|
||||
After the object has appeared in the Viewer, you can select it with
|
||||
left mouse click to change its presentation parameters and access to
|
||||
other useful options by right-clicking on the selected object.
|
||||
|
||||
@ -32,27 +33,47 @@ sub-shapes of the selected geometrical object are automatically
|
||||
coloured by the unique colors. TUI Commands :
|
||||
<em>go.SetAutoColor(enable)</em>, <em>enabled = go.GetAutoColor()</em></li>
|
||||
<li><b>Hide</b> - allows to hide the selected geometrical object from the
|
||||
viewer. TUI Command : <em>sg.EraseOnly(ID)</em>
|
||||
\n \image html image18.png
|
||||
</li>
|
||||
viewer. TUI Command : <em>sg.EraseOnly(ID)</em></li>
|
||||
|
||||
\image html image18.png
|
||||
|
||||
<li><b>Hide all</b> - allows to hide all objects from the viewer. TUI
|
||||
Command: <em>sg.EraseAll()</em>
|
||||
\n \image html image26.png
|
||||
</li>
|
||||
Command: <em>sg.EraseAll()</em></li>
|
||||
|
||||
\image html image26.png
|
||||
|
||||
<li><b>Show Only</b> - allows to display only the selected
|
||||
geometrical object. TUI Command: <em>sg.DisplayOnly(ID)</em>
|
||||
\n \image html image33.png
|
||||
</li>
|
||||
geometrical object. TUI Command: <em>sg.DisplayOnly(ID)</em></li>
|
||||
|
||||
\image html image33.png
|
||||
|
||||
<li><b>Dump view</b> - exports an object from the viewer in bmp, png,
|
||||
jpg or jpeg image format.</li>
|
||||
<li><b>Change background</b> - allows to redefine the background
|
||||
color. By default it is black.
|
||||
\n\n Some of these functionalities are available through right-clicking
|
||||
color. By default it is black.</li>
|
||||
</ul>
|
||||
|
||||
Some of these functionalities are available through right-clicking
|
||||
on the viewer background:
|
||||
|
||||
\image html image22.png <br></li>
|
||||
\image html image22.png <br>
|
||||
|
||||
<ul>
|
||||
<li><b>Select Only</b> provides a filter for exclusive selection of objects of a certain type.</li>
|
||||
</ul>
|
||||
|
||||
The Object browser's popup menu can include some other commands:
|
||||
|
||||
\image html ob_popup_menu.png <br>
|
||||
|
||||
<ul>
|
||||
<li>\subpage work_with_groups_page "Create Group" - invokes dialog box
|
||||
that allows creating groups of geometrical objects.</li>
|
||||
<li><b>Hide Children</b> / <b>Show Children</b> - hide / show child
|
||||
sub-objects in the Object Browser. These commands are available only
|
||||
if the selected geometry object has any children. Note: when some
|
||||
children are hidden, the object name is hilghlighted with the bold
|
||||
font.</li>
|
||||
</ul>
|
||||
|
||||
*/
|
||||
|
@ -89,6 +89,10 @@ QVariant GEOMGUI_Selection::parameter( const int ind, const QString& p ) const
|
||||
return QVariant( isAutoColor( ind ) );
|
||||
else if ( p == "isVectorsMode" )
|
||||
return QVariant( isVectorsMode( ind ) );
|
||||
else if ( p == "hasHiddenChildren" )
|
||||
return QVariant( hasHiddenChildren( ind ) );
|
||||
else if ( p == "hasShownChildren" )
|
||||
return QVariant( hasShownChildren( ind ) );
|
||||
else
|
||||
return LightApp_Selection::parameter( ind, p );
|
||||
}
|
||||
@ -219,6 +223,70 @@ bool GEOMGUI_Selection::isVectorsMode( const int index ) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
|
||||
{
|
||||
bool ok = false;
|
||||
if ( obj ) {
|
||||
_PTR(ChildIterator) it ( obj->GetStudy()->NewChildIterator( obj ) );
|
||||
for ( ; it->More() && !ok; it->Next() ) {
|
||||
_PTR(SObject) child = it->Value();
|
||||
if ( child ) {
|
||||
_PTR(SObject) refObj;
|
||||
if ( child->ReferencedObject( refObj ) ) continue; // omit references
|
||||
if ( child->GetName() != "" ) ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
|
||||
{
|
||||
bool exp = true;
|
||||
_PTR(GenericAttribute) anAttr;
|
||||
if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) {
|
||||
_PTR(AttributeExpandable) aAttrExp = anAttr;
|
||||
exp = aAttrExp->IsExpandable();
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasHiddenChildren( const int index ) const
|
||||
{
|
||||
bool OK = false;
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
|
||||
(SUIT_Session::session()->activeApplication()->activeStudy());
|
||||
|
||||
if ( appStudy && index >= 0 && index < count() ) {
|
||||
_PTR(Study) study = appStudy->studyDS();
|
||||
QString anEntry = entry( index );
|
||||
|
||||
if ( study && !anEntry.isEmpty() ) {
|
||||
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
|
||||
OK = !expandable( aSO ) && hasChildren( aSO );
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasShownChildren( const int index ) const
|
||||
{
|
||||
bool OK = false;
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
|
||||
(SUIT_Session::session()->activeApplication()->activeStudy());
|
||||
|
||||
if ( appStudy && index >= 0 && index < count() ) {
|
||||
_PTR(Study) study = appStudy->studyDS();
|
||||
QString anEntry = entry( index );
|
||||
|
||||
if ( study && !anEntry.isEmpty() ) {
|
||||
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
|
||||
OK = expandable( aSO ) && hasChildren( aSO );
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::isComponent( const int index ) const
|
||||
{
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
|
||||
#include <LightApp_Selection.h>
|
||||
#include <SALOMEDSClient.hxx>
|
||||
|
||||
#include <SALOMEconfig.h>
|
||||
#include CORBA_SERVER_HEADER(GEOM_Gen)
|
||||
@ -50,6 +51,11 @@ private:
|
||||
QString displayMode( const int ) const;
|
||||
QString selectionMode() const;
|
||||
bool isVectorsMode( const int ) const;
|
||||
bool hasHiddenChildren( const int ) const;
|
||||
bool hasShownChildren( const int ) const;
|
||||
|
||||
static bool hasChildren( const _PTR(SObject)& );
|
||||
static bool expandable( const _PTR(SObject)& );
|
||||
|
||||
bool isComponent( const int ) const;
|
||||
GEOM::GEOM_Object_ptr getObject( const int ) const;
|
||||
|
@ -2323,6 +2323,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>MEN_POP_CREATE_GROUP</source>
|
||||
<translation>Create Group</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_CHILDREN</source>
|
||||
<translation>Show Children</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_HIDE_CHILDREN</source>
|
||||
<translation>Hide Children</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_ISOS</source>
|
||||
<translation>Isos</translation>
|
||||
@ -2863,6 +2871,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_POP_CREATE_GROUP</source>
|
||||
<translation>Create Group</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_CHILDREN</source>
|
||||
<translation>Show child objects</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_HIDE_CHILDREN</source>
|
||||
<translation>Hide child objects</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_ISOS</source>
|
||||
<translation>Isolines</translation>
|
||||
@ -3335,6 +3351,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>TOP_POP_CREATE_GROUP</source>
|
||||
<translation>Create Group</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_SHOW_CHILDREN</source>
|
||||
<translation>Show Children</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_HIDE_CHILDREN</source>
|
||||
<translation>Hide Children</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_ISOS</source>
|
||||
<translation>Isolines</translation>
|
||||
|
@ -386,6 +386,8 @@ void GeometryGUI::OnGUIEvent( int id )
|
||||
id == 8034 || // POPUP VIEWER - ISOS
|
||||
id == 8035 || // POPUP VIEWER - AUTO COLOR
|
||||
id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
|
||||
id == 8037 || // POPUP VIEWER - SHOW CHILDREN
|
||||
id == 8038 || // POPUP VIEWER - HIDE CHILDREN
|
||||
id == 804 || // POPUP VIEWER - ADD IN STUDY
|
||||
id == 901 || // OBJECT BROWSER - RENAME
|
||||
id == 9024 ) { // OBJECT BROWSER - OPEN
|
||||
@ -904,6 +906,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( 8035, "POP_AUTO_COLOR" );
|
||||
createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
|
||||
createGeomAction( 8001, "POP_CREATE_GROUP" );
|
||||
createGeomAction( 8037, "POP_SHOW_CHILDREN" );
|
||||
createGeomAction( 8038, "POP_HIDE_CHILDREN" );
|
||||
|
||||
// make wireframe-shading items to be exclusive (only one at a time is selected)
|
||||
//QActionGroup* dispModeGr = new QActionGroup( this, "", true );
|
||||
@ -1145,6 +1149,10 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( 8001 ), -1, -1 ); // create group
|
||||
mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( 8037 ), -1, -1 ); // show children
|
||||
mgr->setRule( action( 8037 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( 8038 ), -1, -1 ); // hide children
|
||||
mgr->setRule( action( 8038 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( 801 ), -1, -1 ); // edit group
|
||||
mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( separator(), -1, -1 ); // -----------
|
||||
|
@ -401,6 +401,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
||||
OnDisableAutoColor();
|
||||
break;
|
||||
}
|
||||
case 8037: // SHOW CHILDREN - POPUP VIEWER
|
||||
case 8038: // HIDE CHILDREN - POPUP VIEWER
|
||||
{
|
||||
OnShowHideChildren( theCommandID == 8037 );
|
||||
break;
|
||||
}
|
||||
case 9024 : // OPEN - OBJBROSER POPUP
|
||||
{
|
||||
OnOpen();
|
||||
|
@ -71,7 +71,8 @@ private:
|
||||
void OnNbIsos();
|
||||
void OnOpen();
|
||||
void OnSelectOnly(int mode);
|
||||
|
||||
void OnShowHideChildren( bool );
|
||||
|
||||
// Recursive deletion of object with children
|
||||
void removeObjectWithChildren( _PTR(SObject),
|
||||
_PTR(Study),
|
||||
|
@ -606,3 +606,42 @@ void GEOMToolsGUI::OnSelectOnly(int mode)
|
||||
getGeometryGUI()->setLocalSelectionMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMToolsGUI::OnShowHideChildren( bool show )
|
||||
{
|
||||
SALOME_ListIO selected;
|
||||
SalomeApp_Application* app =
|
||||
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if ( app ) {
|
||||
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if ( aSelMgr && appStudy ) {
|
||||
aSelMgr->selectedObjects( selected );
|
||||
if ( !selected.IsEmpty() ) {
|
||||
_PTR(Study) aStudy = appStudy->studyDS();
|
||||
_PTR(StudyBuilder) B = aStudy->NewBuilder();
|
||||
|
||||
bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
|
||||
if ( aLocked ) {
|
||||
SUIT_MessageBox::warning( app->desktop(),
|
||||
QObject::tr( "WRN_WARNING" ),
|
||||
QObject::tr( "WRN_STUDY_LOCKED" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||
|
||||
_PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
|
||||
_PTR(GenericAttribute) anAttr;
|
||||
if ( obj ) {
|
||||
_PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
|
||||
aExp->SetExpandable( show );
|
||||
} // if ( obj )
|
||||
} // iterator
|
||||
}
|
||||
}
|
||||
app->updateObjectBrowser( false );
|
||||
app->updateActions();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user