mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 02:00:34 +05:00
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:
parent
e0f019ccf9
commit
7c7b4b0636
BIN
doc/salome/gui/SMESH/images/smesh_sort.png
Normal file
BIN
doc/salome/gui/SMESH/images/smesh_sort.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
11
doc/salome/gui/SMESH/input/arranging_study_objects_page.doc
Normal file
11
doc/salome/gui/SMESH/input/arranging_study_objects_page.doc
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
|
||||
\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"
|
||||
|
||||
*/
|
@ -23,6 +23,9 @@ array of dedicated operations;</li>
|
||||
\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
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
module SMESH
|
||||
{
|
||||
typedef sequence<SALOMEDS::SObject> sobject_list;
|
||||
typedef sequence<GEOM::GEOM_Object> object_array;
|
||||
typedef sequence<SMESH_Mesh> mesh_array;
|
||||
|
||||
@ -402,6 +403,19 @@ module SMESH
|
||||
* \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 );
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -162,6 +162,7 @@
|
||||
#include <SALOMEDSClient_SComponent.hxx>
|
||||
#include <SALOMEDSClient_StudyBuilder.hxx>
|
||||
#include <SALOMEDS_Study.hxx>
|
||||
#include <SALOMEDS_SObject.hxx>
|
||||
|
||||
// OCCT includes
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
@ -1221,6 +1222,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -3533,6 +3553,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
||||
dlg->show();
|
||||
break;
|
||||
}
|
||||
case 41:
|
||||
::sortChildren();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
anApp->updateActions(); //SRN: To update a Save button in the toolbar
|
||||
@ -3830,6 +3854,8 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
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 ),
|
||||
@ -4512,6 +4538,10 @@ void SMESHGUI::initialize( CAM_Application* app )
|
||||
|
||||
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* ) ) );
|
||||
|
||||
|
@ -127,6 +127,9 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
|
||||
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;
|
||||
@ -529,6 +532,50 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const
|
||||
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 :
|
||||
|
@ -63,6 +63,9 @@ public:
|
||||
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;
|
||||
|
@ -4114,6 +4114,14 @@ It can't be deleted </translation>
|
||||
<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>
|
||||
|
@ -4114,6 +4114,14 @@ avec le paramètre '%1' des préférences du module Mesh.</translation
|
||||
<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>
|
||||
|
@ -4790,6 +4790,18 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -4997,6 +5009,46 @@ char* SMESH_Gen_i::getVersion()
|
||||
#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
|
||||
|
@ -585,6 +585,11 @@ public:
|
||||
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,
|
||||
|
@ -261,6 +261,7 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy,
|
||||
{
|
||||
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 );
|
||||
@ -286,6 +287,10 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy,
|
||||
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();
|
||||
}
|
||||
|
||||
@ -377,6 +382,9 @@ static void addReference (SALOMEDS::Study_ptr theStudy,
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,6 +464,7 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theSt
|
||||
return father._retn();
|
||||
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
|
||||
SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder();
|
||||
SALOMEDS::GenericAttribute_wrap anAttr;
|
||||
SALOMEDS::AttributePixMap_wrap aPixmap;
|
||||
|
||||
@ -466,6 +475,10 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theSt
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user