--- /dev/null
+/*!
+
+\page arranging_study_objects_page Arranging objects in study
+
+If sub-meshes or groups container item 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 smesh_sort.png "Sorting of sub-objects"
+
+*/
\subpage using_notebook_mesh_page "Salome notebook".</li>
</ul>
+The possibility to sort the created sub-meshes or groups is detailed on
+\subpage arranging_study_objects_page section.
+
Mesh module preferences are described in the \subpage mesh_preferences_page section of SALOME Mesh Help.
Almost all mesh module functionalities are accessible via
module SMESH
{
+ typedef sequence<SALOMEDS::SObject> sobject_list;
typedef sequence<GEOM::GEOM_Object> object_array;
typedef sequence<SMESH_Mesh> mesh_array;
* \brief Get names of meshes defined in file with the specified name.
*/
string_array GetMeshNames(in string theFileName);
+
+ /*!
+ * \brief Moves objects to the specified position
+ *
+ * This function is used in the drag-n-drop functionality.
+ *
+ * \param what objects being moved
+ * \param where parent object where objects are moved to
+ * \param row position in the parent object's children list at which objects are moved
+ */
+ void Move( in sobject_list what,
+ in SALOMEDS::SObject where,
+ in long row );
};
};
#include <SALOMEDSClient_SComponent.hxx>
#include <SALOMEDSClient_StudyBuilder.hxx>
#include <SALOMEDS_Study.hxx>
+#include <SALOMEDS_SObject.hxx>
// OCCT includes
#include <Standard_ErrorHandler.hxx>
}
}
+ void sortChildren(){
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel ) {
+ aSel->selectedObjects( selected );
+
+ if(selected.Extent()){
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
+ if (aSObj) {
+ if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
+ SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+ }
+ }
+ }
+ }
+ }
+
void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
{
SALOME_ListIO selected;
dlg->show();
break;
}
+ case 41:
+ ::sortChildren();
+ break;
+
}
anApp->updateActions(); //SRN: To update a Save button in the toolbar
createSMESHAction( 301, "SHOW" );
createSMESHAction( 302, "DISPLAY_ONLY" );
+ createSMESHAction( 41, "SORT_CHILD_ITEMS" );
+
// ----- create menu --------------
int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
popupMgr()->insert( separator(), -1, -1 );
+ popupMgr()->insert( action( 41 ), -1, -1 );
+ popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
+ popupMgr()->insert( separator(), -1, -1 );
+
connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
else if ( p=="quadratic2DMode") val = QVariant(quadratic2DMode(ind));
else if ( p=="isDistributionVisible") val = QVariant(isDistributionVisible(ind));
+ else if ( p=="hasChildren") val = QVariant(hasChildren(ind));
+ else if ( p=="nbChildren") val = QVariant(nbChildren(ind));
+ else if ( p=="isContainer") val = QVariant(isContainer(ind));
if( val.isValid() )
return val;
return QVariant( false );
}
+//=======================================================================
+//function : hasChildren
+//purpose :
+//=======================================================================
+
+bool SMESHGUI_Selection::hasChildren( int ind ) const
+{
+ if ( ind >= 0 )
+ {
+ _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj );
+ }
+ return false;
+}
+
+//=======================================================================
+//function : hasChildren
+//purpose :
+//=======================================================================
+
+int SMESHGUI_Selection::nbChildren( int ind ) const
+{
+ int nb = 0;
+ if ( ind >= 0 )
+ {
+ _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ if ( sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
+ _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
+ for (it->Init(false); it->More(); it->Next()) nb++;
+ }
+ }
+ return nb;
+}
+
+//=======================================================================
+//function : isContainer
+//purpose :
+//=======================================================================
+
+bool SMESHGUI_Selection::isContainer( int ind ) const
+{
+ return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown";
+}
+
//=======================================================================
//function : type
//purpose :
virtual QString quadratic2DMode(int ) const;
virtual bool isDistributionVisible(int ) const;
+ virtual bool hasChildren( int ) const;
+ virtual int nbChildren( int ) const;
+ virtual bool isContainer( int ) const;
// parameters got from actor return nothing if an actor is not visible
virtual QList<QVariant> elemTypes( int ) const;
<source>SMESH_GIGABYTE</source>
<translation>%1 GB</translation>
</message>
+ <message>
+ <source>MEN_SORT_CHILD_ITEMS</source>
+ <translation>Sort children</translation>
+ </message>
+ <message>
+ <source>STB_SORT_CHILD_ITEMS</source>
+ <translation>Sort child items</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_Dialog</name>
<translation>L'objet sélectionné a été utilisé pour en créer un autre.
Il ne peut pas être supprimé.</translation>
</message>
+ <message>
+ <source>MEN_SORT_CHILD_ITEMS</source>
+ <translation type="unfinished">Sort children</translation>
+ </message>
+ <message>
+ <source>STB_SORT_CHILD_ITEMS</source>
+ <translation type="unfinished">Sort child items</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_Dialog</name>
}
pd << ""; // prevent optimizing pd out
+ // creation of tree nodes for all data objects in the study
+ // to support tree representation customization and drag-n-drop:
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = theComponent->GetStudy()->GetUseCaseBuilder();
+ if ( !useCaseBuilder->IsUseCaseNode( theComponent ) ) {
+ useCaseBuilder->SetRootCurrent();
+ useCaseBuilder->Append( theComponent ); // component object is added as the top level item
+ SALOMEDS::ChildIterator_var it = theComponent->GetStudy()->NewChildIterator( theComponent );
+ for (it->InitEx(true); it->More(); it->Next()) {
+ useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() );
+ }
+ }
+
INFOS( "SMESH_Gen_i::Load completed" );
return true;
}
#endif
}
+//=================================================================================
+// function : Move()
+// purpose : Moves objects to the specified position.
+// Is used in the drag-n-drop functionality.
+//=================================================================================
+void SMESH_Gen_i::Move( const SMESH::sobject_list& what,
+ SALOMEDS::SObject_ptr where,
+ CORBA::Long row )
+{
+ if ( CORBA::is_nil( where ) ) return;
+
+ SALOMEDS::Study_var study = where->GetStudy();
+ SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+ SALOMEDS::SComponent_var father = where->GetFatherComponent();
+ std::string dataType = father->ComponentDataType();
+ if ( dataType != "SMESH" ) return; // not a SMESH component
+
+ SALOMEDS::SObject_var objAfter;
+ if ( row >= 0 && useCaseBuilder->HasChildren( where ) ) {
+ // insert at given row -> find insertion position
+ SALOMEDS::UseCaseIterator_var useCaseIt = useCaseBuilder->GetUseCaseIterator( where );
+ int i;
+ for ( i = 0; i < row && useCaseIt->More(); i++, useCaseIt->Next() );
+ if ( i == row && useCaseIt->More() ) {
+ objAfter = useCaseIt->Value();
+ }
+ }
+
+ for ( int i = 0; i < what.length(); i++ ) {
+ SALOMEDS::SObject_var sobj = what[i];
+ if ( CORBA::is_nil( sobj ) ) continue; // skip bad object
+ // insert the object to the use case tree
+ if ( !CORBA::is_nil( objAfter ) )
+ useCaseBuilder->InsertBefore( sobj, objAfter ); // insert at given row
+ else
+ useCaseBuilder->AppendTo( where, sobj ); // append to the end of list
+ }
+}
+
//=============================================================================
/*!
* SMESHEngine_factory
const std::string & GetLastObjEntry() const { return myLastObj; }
std::vector< std::string > GetAllParameters(const std::string& theObjectEntry) const;
+ // Move objects to the specified position
+ void Move( const SMESH::sobject_list& what,
+ SALOMEDS::SObject_ptr where,
+ CORBA::Long row );
+
private:
// Create hypothesis of given type
SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
{
SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR );
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder();
if ( SO->_is_nil() ) {
if ( theTag == 0 )
SO = aStudyBuilder->NewObject( theFatherObject );
selAttr->SetSelectable( false );
}
+ // add object to the use case tree
+ // (to support tree representation customization and drag-n-drop)
+ useCaseBuilder->AppendTo( SO->GetFather(), SO );
+
return SO._retn();
}
if ( !theSObject->FindSubObject( theTag, aReferenceSO.inout() ))
aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag );
aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
+ // add reference to the use case tree
+ // (to support tree representation customization and drag-n-drop)
+ theStudy->GetUseCaseBuilder()->AppendTo( aReferenceSO->GetFather(), aReferenceSO );
}
}
return father._retn();
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder();
SALOMEDS::GenericAttribute_wrap anAttr;
SALOMEDS::AttributePixMap_wrap aPixmap;
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
CORBA::String_var userName = aComp->componentusername();
SetName( father, userName.in(), "MESH" );
+ // add component to the use case tree
+ // (to support tree representation customization and drag-n-drop)
+ useCaseBuilder->SetRootCurrent();
+ useCaseBuilder->Append( father ); // component object is added as the top level item
if(MYDEBUG) MESSAGE("PublishComponent--END");
return father._retn();