#include <LightApp_SelectionMgr.h>
#include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
// SALOME KERNEL incldues
#include <SALOMEDSClient_SObject.hxx>
+#include <SALOMEDSClient_Study.hxx>
// Qt includes
#include <QPushButton>
//================================================================================
StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg
-( SUIT_SelectionFilter* f, QWidget* parent)
- : QWidget( parent )
+( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
+ : QWidget( parent ), myMultiSelection( multiSelection )
{
myFilter = f;
init();
//================================================================================
StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg
-( MeshObjectType objType, QWidget* parent )
- : QWidget( parent )
+( MeshObjectType objType, QWidget* parent, bool multiSelection )
+ : QWidget( parent ), myMultiSelection( multiSelection )
{
myFilter = new SMESH_TypeFilter( objType );
init();
StdMeshersGUI_ObjectReferenceParamWdg::~StdMeshersGUI_ObjectReferenceParamWdg()
{
if ( myFilter )
+ {
+ mySelectionMgr->removeFilter( myFilter );
delete myFilter;
+ }
}
void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj)
{
- myObject = CORBA::Object::_nil();
+ myObjects.clear();
myObjNameLineEdit->setText( "" );
myParamValue = "";
if ( sobj ) {
std::string name = sobj->GetName();
myObjNameLineEdit->setText( name.c_str() );
- myObject = CORBA::Object::_duplicate( obj );
+ myObjects.push_back( CORBA::Object::_duplicate( obj ));
myParamValue = sobj->GetID().c_str();
}
}
+//================================================================================
+/*!
+ * \brief Initialize selected objects
+ * \param objects - entries of objects
+ */
+//================================================================================
+
+void StdMeshersGUI_ObjectReferenceParamWdg::SetObjects(SMESH::string_array_var& objects)
+{
+ myObjects.clear();
+ myObjNameLineEdit->setText( "" );
+ myParamValue = "";
+
+ for ( unsigned i = 0; i < objects->length(); ++i )
+ {
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(SObject) aSObj = aStudy->FindObjectID(objects[i].in());
+ CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+ if ( !CORBA::is_nil( anObj )) {
+ std::string name = aSObj->GetName();
+ QString text = myObjNameLineEdit->text();
+ if ( !text.isEmpty() )
+ text += " ";
+ text += name.c_str();
+ myObjNameLineEdit->setText( text );
+ myObjects.push_back( anObj );
+ myParamValue += " ";
+ myParamValue += objects[i];
+ }
+ }
+}
+
//================================================================================
/*!
* \brief Takes selected object
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList);
if (aList.Extent() == 1)
+ {
obj = SMESH::IObjectToObject( aList.First() );
- SetObject( obj.in() );
+ SetObject( obj.in() );
+ }
+ else if (myMultiSelection)
+ {
+ SMESH::string_array_var objIds = new SMESH::string_array;
+ objIds->length( aList.Extent());
+ SALOME_ListIteratorOfListIO io( aList );
+ int i = 0;
+ for ( ; io.More(); io.Next(), ++i )
+ {
+ Handle(SALOME_InteractiveObject) anIO = io.Value();
+ if ( anIO->hasEntry() )
+ objIds[i] = anIO->getEntry();
+ else
+ i--;
+ }
+ objIds->length(i);
+ SetObjects( objIds );
+ }
}
}
// CORBA includes
#include <CORBA.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
class SUIT_SelectionFilter;
class SMESHGUI;
class LightApp_SelectionMgr;
public:
StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter,
- QWidget* parent);
+ QWidget* parent,
+ bool multiSelection=false);
StdMeshersGUI_ObjectReferenceParamWdg( MeshObjectType objType,
- QWidget* parent);
+ QWidget* parent,
+ bool multiSelection=false);
~StdMeshersGUI_ObjectReferenceParamWdg();
void SetObject(CORBA::Object_ptr obj);
+ void SetObjects(SMESH::string_array_var& objEntries);
+
template<class TInterface>
- typename TInterface::_var_type GetObject() const {
- if ( IsObjectSelected() ) return TInterface::_narrow(myObject);
+ typename TInterface::_var_type GetObject(unsigned i=0) const {
+ if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]);
return TInterface::_nil();
}
+ int NbObjects() const { return myObjects.size(); }
+
QString GetValue() const { return myParamValue; }
- bool IsObjectSelected() const { return !CORBA::is_nil(myObject); }
+ bool IsObjectSelected(unsigned i=0) const
+ { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); }
void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
void init();
private:
- CORBA::Object_var myObject;
+
+ bool myMultiSelection;
+ std::vector<CORBA::Object_var> myObjects;
+
SUIT_SelectionFilter* myFilter;
bool mySelectionActivated;