Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI_StreamLinesDlg.cxx
index aba09d667d20c0cb77489cba94b000fbfb2171f3..e6fa3cc2990d31d80e38b22352cb6d40a2045515 100644 (file)
@@ -82,8 +82,7 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule)
 
   connect(myUseSrcCombo, SIGNAL(activated(int)), this, SLOT(onSourceTypeChange(int)));
 
-  // Find All prs obj
-  //SUIT_Study* aActiveStudy = VISU::(myVisuGUI);
+  // Find all fields and time stamps on it
   _PTR(Study) aActiveStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI));
   LightApp_SelectionMgr* aSel = VISU::GetSelectionMgr(myVisuGUI);
   SALOME_ListIO selected;
@@ -92,71 +91,114 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule)
     Handle(SALOME_InteractiveObject) aIO = selected.First();
     if (aIO->hasEntry()) {
       _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry());
+
+      _PTR(GenericAttribute) anTmpAttr;
+      if (aSObject->FindAttribute(anTmpAttr, "AttributeComment")) {
+        _PTR(AttributeComment) aTmpComment (anTmpAttr);
+        string aTmpComm = aTmpComment->Value();
+        QString aTmpstrIn (aTmpComm.c_str());
+        VISU::Storable::TRestoringMap aTmpaMap;
+        VISU::Storable::StrToMap(aTmpstrIn,aTmpaMap);
+        bool aTmpisExist;
+        VISU::VISUType aTmpType =
+          (VISU::VISUType)VISU::Storable::FindValue(aTmpaMap,"myType",&aTmpisExist).toInt();
+        switch (aTmpType) {
+        case VISU::TTIMESTAMP:
+          {
+            aSObject = aSObject->GetFather();
+            aSObject = aSObject->GetFather();
+            break;
+          }
+        case VISU::TFIELD:
+          {
+            _PTR(SObject) newSObject;
+            if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject;
+            aSObject = aSObject->GetFather();
+            break;
+          }
+        case VISU::TANIMATION:
+          {
+            _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject);
+            for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) {
+              _PTR(SObject) aTmpChildSObj = aTmpIter->Value();
+              _PTR(SObject) newSObject;
+              if(aTmpChildSObj->ReferencedObject(newSObject)){
+                aSObject = newSObject;
+                aSObject->GetFather();
+                break;
+              }
+            }
+            break;
+          }
+        }
+      }
+
       aSObject = aSObject->GetFather();
       aSObject = aSObject->GetFather();
-      aSObject = aSObject->GetFather();
-      aSObject = aSObject->GetFather();
+
       mySelectionObj = aSObject;
       CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj);
-      VISU::Result_var aResult;
       if (CORBA::is_nil(anObject)) {
        mySelectionObj = mySelectionObj->GetFather();
       }
-      _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj);
-
-      for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
-       _PTR(SObject) aChildSObj = aIter->Value();
-       CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj);
-
-       if (!CORBA::is_nil(aChildObject)) {
-         VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
-         if (!CORBA::is_nil(aPrsObj)) { // if this is a Prs object
-           if ((aPrsObj->GetType() != VISU::TSTREAMLINES) &&
-               (aPrsObj->GetType() != VISU::TMESH)) {
-             _PTR(GenericAttribute) anAttr;
-             if (aChildSObj->FindAttribute(anAttr, "AttributeName")) {
-               _PTR(AttributeName) aName (anAttr);
-               myPrsLst += QString(aName->Value().c_str());
-               myPrsList.append(aPrsObj);
-               continue;
-             }
-           }
-         }
-       }
-       // else { // This is not a Prs object
-       _PTR(GenericAttribute) anAttr;
-       if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) {
-         _PTR(AttributeComment) aComment (anAttr);
-         string aComm = aComment->Value();
-         QString strIn (aComm.c_str());
-         VISU::Storable::TRestoringMap aMap;
-         VISU::Storable::StrToMap(strIn,aMap);
-         bool isExist;
-         VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
-         if (isExist) {
-           if ((aType == VISU::TFAMILY) || (aType == VISU::TGROUP) || (aType == VISU::TENTITY)) {
-             _PTR(GenericAttribute) aNameAttr;
-             if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) {
-               _PTR(AttributeName) aName (aNameAttr);
-               VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
-               switch (aType) {
-               case VISU::TFAMILY:
-                 myFamilisLst += QString(aName->Value().c_str());
-                 myFamilyList.append(aPrsObj);
-                 break;
-               case VISU::TGROUP:
-                 myGroupsLst += QString(aName->Value().c_str());
-                 myGroupList.append(aPrsObj);
-                 break;
-               case VISU::TENTITY:
-                 myEntitiesLst += QString(aName->Value().c_str());
-                 myEntityList.append(aPrsObj);
-                 break;
-               }
-             }
-           }
-         }
-       }
+    }
+  }
+
+  if (mySelectionObj) {
+    _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj);
+
+    for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
+      _PTR(SObject) aChildSObj = aIter->Value();
+      CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj);
+
+      if (!CORBA::is_nil(aChildObject)) {
+        VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
+        if (!CORBA::is_nil(aPrsObj)) { // if this is a Prs object
+          if ((aPrsObj->GetType() != VISU::TSTREAMLINES) &&
+              (aPrsObj->GetType() != VISU::TMESH)) {
+            _PTR(GenericAttribute) anAttr;
+            if (aChildSObj->FindAttribute(anAttr, "AttributeName")) {
+              _PTR(AttributeName) aName (anAttr);
+              myPrsLst += QString(aName->Value().c_str());
+              myPrsList.append(aPrsObj);
+              continue;
+            }
+          }
+        }
+      }
+
+      _PTR(GenericAttribute) anAttr;
+      if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) {
+        _PTR(AttributeComment) aComment (anAttr);
+        string aComm = aComment->Value();
+        QString strIn (aComm.c_str());
+        VISU::Storable::TRestoringMap aMap;
+        VISU::Storable::StrToMap(strIn,aMap);
+        bool isExist;
+        VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+        if (isExist) {
+          if ((aType == VISU::TFAMILY) || (aType == VISU::TGROUP) || (aType == VISU::TENTITY)) {
+            _PTR(GenericAttribute) aNameAttr;
+            if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) {
+              _PTR(AttributeName) aName (aNameAttr);
+              VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
+              switch (aType) {
+              case VISU::TFAMILY:
+                myFamilisLst += QString(aName->Value().c_str());
+                myFamilyList.append(aPrsObj);
+                break;
+              case VISU::TGROUP:
+                myGroupsLst += QString(aName->Value().c_str());
+                myGroupList.append(aPrsObj);
+                break;
+              case VISU::TENTITY:
+                myEntitiesLst += QString(aName->Value().c_str());
+                myEntityList.append(aPrsObj);
+                break;
+              }
+            }
+          }
+        }
       }
     }
   }
@@ -244,7 +286,6 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule)
 }
 
 
-
 void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs)
 {
   myScalarPane->initFromPrsObject(thePrs);