]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PyQt Selection in and out OK
authorPaul RASCLE <paul.rascle@edf.fr>
Sun, 26 Feb 2017 10:36:59 +0000 (11:36 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Sun, 26 Feb 2017 10:36:59 +0000 (11:36 +0100)
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_Selector.cxx
src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_Selector.h

index 4cebc3a46578eb620dbbb3dba1ba055758c0912c..6b17d8d0941d806d97dde44c3d35790ec99bc504 100644 (file)
@@ -630,12 +630,6 @@ void SALOME_PYQT_ModuleLight::setSelected( const QStringList& entries, const boo
   return myHelper->selectionUpdated(entries);
 }
 
-
-//void SALOME_PYQT_ModuleLight::selectionChanged()
-//{
-//  MESSAGE("signal selectionChanged");
-//}
-
 void SALOME_PYQT_ModuleLight::setLocalSelected(const QStringList & entries)
 {
   MESSAGE("setLocalSelected");
index a344757d4766bf2ce8871127fa4c2aee11d3b98f..e6ba25f848efaf7d2e2f1520930c245d093a3f20 100644 (file)
@@ -1170,6 +1170,7 @@ void PyModuleHelper::actionActivated()
 void PyModuleHelper::selectionUpdated(const QStringList& entries)
 {
   FuncMsg fmsg( "PyModuleHelper::selectionUpdated()" );
+  MESSAGE("selectionUpdated");
 
   // perform synchronous request to Python event dispatcher
   class SelectionReq : public PyInterp_LockRequest
@@ -1181,10 +1182,13 @@ void PyModuleHelper::selectionUpdated(const QStringList& entries)
       : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
         myHelper( _helper ),
         myEntries( _entries  )
-    {}
+    {
+      MESSAGE("SelectionReq");
+    }
   protected:
     virtual void execute()
     {
+      MESSAGE("execute");
       myHelper->internalSelectionUpdated( myEntries );
     }
   private:
@@ -1192,11 +1196,6 @@ void PyModuleHelper::selectionUpdated(const QStringList& entries)
     const QStringList& myEntries;
   };
 
-  // get sender action
-  QAction* action = qobject_cast<QAction*>( sender() );
-  if ( !action )
-    return;
-
   // post request
   PyInterp_Dispatcher::Get()->Exec( new SelectionReq( myInterp, this, entries ) );
 }
@@ -2271,6 +2270,7 @@ void PyModuleHelper::internalActionActivated( int id )
 void PyModuleHelper::internalSelectionUpdated(const QStringList& entries)
 {
   FuncMsg fmsg("--- PyModuleHelper::internalSelectionUpdated()");
+  MESSAGE("internalSelectionUpdated");
 
   // Python interpreter should be initialized and Python module should be imported first
   if (!myInterp || !myPyModule)
@@ -2285,6 +2285,7 @@ void PyModuleHelper::internalSelectionUpdated(const QStringList& entries)
 #endif
   if (PyObject_HasAttrString(myPyModule, (char*) "onSelectionUpdated"))
     {
+      MESSAGE("call onSelectionUpdated");
       PyObjWrapper res(PyObject_CallMethod(myPyModule, (char*) "onSelectionUpdated", (char*) "O", sipList.get()));
 
       if (!res)
index 6d115dc73b4a718e839102cc11ba372bb246be23..0a2d61f8f3475abbf8e644dbe1e8ba34c066c990 100644 (file)
@@ -127,6 +127,7 @@ void SALOME_PYQT_Selector::getSelection(SUIT_DataOwnerPtrList& theList) const
   MESSAGE("getSelection");
   if (mySelectedList.count() == 0)
     {
+      MESSAGE("mySelectedList.count(): " << mySelectedList.count() << " myLocalEntries.size(): "<< myLocalEntries.size());
       SALOME_PYQT_Selector* that = (SALOME_PYQT_Selector*) this; // because of const...
       for (int i = 0; i < myLocalEntries.size(); i++)
         {
@@ -156,18 +157,18 @@ void SALOME_PYQT_Selector::setSelection(const SUIT_DataOwnerPtrList& theList)
   if (!myPyModule)
     return;
 
-  if (myEntries.count() == 0 || myModifiedTime < myPyModule->getModifiedTime())
-    fillEntries(myEntries);
-
-//  DataObjectList objList;
-//  for (SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it)
-//    {
-//      const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>((*it).operator->());
-//      if (owner && myEntries.contains(owner->entry()))
-//        objList.append(myEntries[owner->entry()]);
-//    }
-//
-//  myPyModule->setSelected(objList);
+  myEntries.clear();
+  for (SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it)
+    {
+      const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>((*it).operator->());
+      if (owner)
+        {
+          QString entry = owner->entry();
+          myEntries.append(entry);
+          MESSAGE("Selected: "<< entry.toStdString());
+        }
+    }
+  fillEntries(myEntries);
   mySelectedList.clear();
 }
 
@@ -175,21 +176,12 @@ void SALOME_PYQT_Selector::setSelection(const SUIT_DataOwnerPtrList& theList)
  \brief Fill map of the data objects currently shown in the Object Browser.
  \param entries map to be filled
  */
-void SALOME_PYQT_Selector::fillEntries(QMap<QString, LightApp_DataObject*>& entries)
+void SALOME_PYQT_Selector::fillEntries(QStringList& entries)
 {
   MESSAGE("fillEntries");
-  entries.clear();
-
   if (!myPyModule)
     return;
-
-//  for (SUIT_DataObjectIterator it(myPyModule->root(), SUIT_DataObjectIterator::DepthLeft); it.current(); ++it)
-//    {
-//      LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(it.current());
-//      if (obj)
-//        entries.insert(obj->entry(), obj);
-//    }
-
+  myPyModule->setSelected(entries);
   setModified();
 }
 
index a6ffc6aa1f7342f5894a42631826aad8616bd395..36ef872b526562281c6807925d188e51815eb513 100644 (file)
@@ -63,13 +63,13 @@ protected:
   virtual void       setSelection( const SUIT_DataOwnerPtrList& );
 
 private:
-  void               fillEntries( QMap<QString, LightApp_DataObject*>& );
+  void               fillEntries( QStringList& );
 
 private:
   QStringList                         myLocalEntries;
   SALOME_PYQT_ModuleLight*            myPyModule;
   SUIT_DataOwnerPtrList               mySelectedList;
-  QMap<QString, LightApp_DataObject*> myEntries;
+  QStringList                         myEntries;
   unsigned long                       myModifiedTime;
 };