<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".
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" )
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 )
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;
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;
bool GEOMGUI_Selection::isFolder( const int index ) const
{
+ bool res = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
if ( appStudy ) {
_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;
}
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;
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;
<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>
<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>
<< GEOMOp::OpUnpublishObject
<< GEOMOp::OpPublishObject
<< GEOMOp::OpPointMarker
- << GEOMOp::OpCreateFolder;
+ << GEOMOp::OpCreateFolder
+ << GEOMOp::OpSortChildren;
if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
return;
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
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" );
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 ) ) );
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
case GEOMOp::OpCreateFolder:
OnCreateFolder();
break;
+ case GEOMOp::OpSortChildren:
+ OnSortChildren();
+ break;
default:
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
break;
void OnBringToFront();
void OnClsBringToFront();
void OnCreateFolder();
+ void OnSortChildren();
// Shortcut commands
void OnChangeTransparency( bool );
_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 );
+}