0021708: [CEA 586] Object browser sort only children:

+ Add Use Case browser data tree management
+ Add "Sort children" contextual menu popup item
+ Update user documentation
This commit is contained in:
akl 2013-07-09 08:22:16 +00:00
parent a992b19d3a
commit 1dd8f0e9e6
11 changed files with 100 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 KiB

View File

@ -20,6 +20,10 @@ To create a folder select "Create folder" popup menu item for root "Geometry" ob
<li> folder(s)
</ul>
If geometrical object has more than one child sub-object, then there is a possibility to sort these children in ascending order. To use sort functionality select "Sort children" popup menu item for the parent object.
\image html geom_sort.png "Sorting of sub-objects"
Our <b>TUI Scripts</b> provide you with useful examples of
\ref tui_arranging_study_objects "Arranging objects in study".

View File

@ -161,6 +161,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
v = topLevel( idx );
else if ( p == "hasChildren" )
v = hasChildren( idx );
else if ( p == "nbChildren" )
v = nbChildren(idx);
else if ( p == "hasConcealedChildren" )
v = hasConcealedChildren( idx );
else if ( p == "hasDisclosedChildren" )
@ -399,19 +401,8 @@ bool GEOMGUI_Selection::isVectorsMode( const int index ) const
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;
// as soon as Use Case browser data tree was added
return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
}
bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
@ -436,6 +427,17 @@ bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj )
return ret;
}
bool GEOMGUI_Selection::isFolder( const _PTR(SObject)& obj )
{
bool ret = false;
_PTR(GenericAttribute) anAttr;
if ( obj->FindAttribute(anAttr, "AttributeLocalID") ) {
_PTR(AttributeLocalID) aLocalID( anAttr );
ret = aLocalID->Value() == 999;
}
return ret;
}
bool GEOMGUI_Selection::hasChildren( const int index ) const
{
bool ok = false;
@ -452,6 +454,25 @@ bool GEOMGUI_Selection::hasChildren( const int index ) const
return ok;
}
int GEOMGUI_Selection::nbChildren( const int index ) const
{
int nb = 0;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
if ( appStudy ) {
QString anEntry = entry( index );
_PTR(Study) study = appStudy->studyDS();
if ( study && !anEntry.isEmpty() ) {
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
if ( aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
_PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
for (it->Init(false); it->More(); it->Next()) nb++;
}
}
}
return nb;
}
bool GEOMGUI_Selection::hasConcealedChildren( const int index ) const
{
bool OK = false;
@ -625,6 +646,7 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const
bool GEOMGUI_Selection::isFolder( const int index ) const
{
bool res = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
if ( appStudy ) {
@ -632,15 +654,9 @@ bool GEOMGUI_Selection::isFolder( const int index ) const
_PTR(Study) study = appStudy->studyDS();
if ( study && !anEntry.isNull() ) {
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
if ( aSO ) {
_PTR(GenericAttribute) anAttr;
if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
_PTR(AttributeLocalID) aLocalID( anAttr );
return aLocalID->Value() == 999;
}
}
if ( aSO ) res = isFolder( aSO );
}
}
return false;
return res;
}

View File

@ -52,6 +52,7 @@ public:
static bool hasChildren( const _PTR(SObject)& );
static bool expandable( const _PTR(SObject)& );
static bool isCompoundOfVertices( GEOM::GEOM_Object_ptr );
static bool isFolder( const _PTR(SObject)& );
protected:
// virtual QVariant contextParameter( const QString& ) const;
@ -67,6 +68,7 @@ private:
QString selectionMode() const;
bool isVectorsMode( const int ) const;
bool hasChildren( const int ) const;
int nbChildren( const int ) const;
bool hasConcealedChildren( const int ) const;
bool hasDisclosedChildren( const int ) const;
bool compoundOfVertices( const int ) const;

View File

@ -4652,6 +4652,14 @@ Please, select face, shell or solid and try again</translation>
<source>NEW_FOLDER_NAME</source>
<translation>NewFolder</translation>
</message>
<message>
<source>MEN_POP_SORT_CHILD_ITEMS</source>
<translation>Sort children</translation>
</message>
<message>
<source>STB_POP_SORT_CHILD_ITEMS</source>
<translation>Sort child items</translation>
</message>
<message>
<source>GEOM_RESULT_NAME_GRP</source>
<translation>Result name</translation>

View File

@ -4658,6 +4658,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>NEW_FOLDER_NAME</source>
<translation type="unfinished">NewFolder</translation>
</message>
<message>
<source>MEN_POP_SORT_CHILD_ITEMS</source>
<translation type="unfinished">Sort children</translation>
</message>
<message>
<source>STB_POP_SORT_CHILD_ITEMS</source>
<translation type="unfinished">Sort child items</translation>
</message>
<message>
<source>GEOM_RESULT_NAME_GRP</source>
<translation>Nom du résultat</translation>

View File

@ -391,7 +391,8 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
<< GEOMOp::OpUnpublishObject
<< GEOMOp::OpPublishObject
<< GEOMOp::OpPointMarker
<< GEOMOp::OpCreateFolder;
<< GEOMOp::OpCreateFolder
<< GEOMOp::OpSortChildren;
if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
return;
@ -444,6 +445,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
case GEOMOp::OpClsBringToFront: //
case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
libName = "GEOMToolsGUI";
break;
case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
@ -905,6 +907,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
@ -1407,7 +1410,11 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
mgr->hide( mgr->actionId( action( myEraseAll ) ) );

View File

@ -60,6 +60,7 @@ namespace GEOMOp {
OpEdgeWidth = 1260, // POPUP MENU - LINE WIDTH - EDGE WIDTH
OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH
OpCreateFolder = 1262, // POPUP MENU - CREATE FOLDER
OpSortChildren = 1263, // POPUP MENU - SORT CHILD ITEMS
// DisplayGUI ------------------//--------------------------------
OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
OpShowAll = 2002, // MENU VIEW - SHOW ALL

View File

@ -389,6 +389,9 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
case GEOMOp::OpCreateFolder:
OnCreateFolder();
break;
case GEOMOp::OpSortChildren:
OnSortChildren();
break;
default:
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
break;

View File

@ -89,6 +89,7 @@ private:
void OnBringToFront();
void OnClsBringToFront();
void OnCreateFolder();
void OnSortChildren();
// Shortcut commands
void OnChangeTransparency( bool );

View File

@ -835,3 +835,30 @@ void GEOMToolsGUI::OnCreateFolder()
_CAST(SObject, aFatherSO)->GetSObject() );
app->updateObjectBrowser( false );
}
void GEOMToolsGUI::OnSortChildren()
{
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
if ( !appStudy ) return;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr ) return;
SALOME_ListIO selected;
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
Handle(SALOME_InteractiveObject) anIObject = selected.First();
_PTR(Study) aStudy = appStudy->studyDS();
if( !aStudy ) return;
_PTR(SObject) aFatherSO(aStudy->FindObjectID(anIObject->getEntry()));
if ( !aFatherSO ) return;
aStudy->GetUseCaseBuilder()->SortChildren( aFatherSO, true/*AscendingOrder*/ );
app->updateObjectBrowser( true );
}