Salome HOME
All modules must use SVTK package instead VTK
[modules/visu.git] / src / VISUGUI / VisuGUI_StreamLinesDlg.cxx
index 175920ebebe17a6a8c1d37235606968cddbb4294..904f438dcc34caa4fb152907c73685f6191b9b2c 100644 (file)
@@ -11,7 +11,7 @@
 #include "VisuGUI_StreamLinesDlg.h"
 
 #include "VisuGUI.h"
-//#include "VisuGUI_Selection.h"
+#include "VisuGUI_Tools.h"
 
 #include "VISU_Mesh_i.hh"
 #include "VISU_Gen_i.hh"
 #include "SalomeApp_Application.h"
 #include "SalomeApp_SelectionMgr.h"
 
+#include "SVTK_ViewWindow.h"
+
 #include "SUIT_Desktop.h"
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_MessageBox.h"
 
 #include "SALOME_ListIO.hxx"
 
-#include "SVTK_ViewWindow.h"
+#include <SALOMEDSClient_SObject.hxx>
 
 #include <limits.h>
 #include <qlayout.h>
 #include <qcolordialog.h>
 #include <qtabwidget.h>
 
-#include <SALOMEDSClient_SObject.hxx>
-#include <SALOMEDS_SObject.hxx>
-
 using namespace std;
 
-VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (QWidget* parent)
-     : QDialog(parent, "VisuGUI_StreamLinesDlg", false,
-               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule)
+     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_StreamLinesDlg", false,
+               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+       myVisuGUI(theModule)
 {
   myPrs = NULL;
   setCaption(tr("DLG_TITLE"));
@@ -83,39 +83,40 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (QWidget* parent)
   connect(myUseSrcCombo, SIGNAL(activated(int)), this, SLOT(onSourceTypeChange(int)));
 
   // Find All prs obj
-/*
-  SUIT_Study* aActiveStudy =  VisuGUI::GetActiveStudy();
-  SalomeApp_SelectionMgr* aSel = VisuGUI::application()->selectionMgr();
-  SALOME_ListIO selected; aSel->selectedObjects( selected );
-  if( selected.Extent() > 0 ) {
+  //SUIT_Study* aActiveStudy = VISU::(myVisuGUI);
+  _PTR(Study) aActiveStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI));
+  SalomeApp_SelectionMgr* aSel = VISU::GetSelectionMgr(myVisuGUI);
+  SALOME_ListIO selected;
+  aSel->selectedObjects(selected);
+  if (selected.Extent() > 0) {
     Handle(SALOME_InteractiveObject) aIO = selected.First();
-    if (aIO->hasEntry()){
-      SALOMEDSClient_SObject* aSObject = VisuGUI::GetStudyDocument()->FindObjectID(aIO->getEntry());
+    if (aIO->hasEntry()) {
+      _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry());
       aSObject = aSObject->GetFather();
       aSObject = aSObject->GetFather();
       aSObject = aSObject->GetFather();
       aSObject = aSObject->GetFather();
       mySelectionObj = aSObject;
-      CORBA::Object_var anObject = VISU::ClientSObjectToObject( mySelectionObj );
+      CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj);
       VISU::Result_var aResult;
       if (CORBA::is_nil(anObject)) {
        mySelectionObj = mySelectionObj->GetFather();
       }
-      SALOMEDSClient_ChildIterator* aIter = VisuGUI::GetStudyDocument()->NewChildIterator( mySelectionObj );
+      _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj);
 
-      for (aIter->InitEx(true); aIter->More(); aIter->Next() ) {
-       SALOMEDSClient_SObject* aChildSObj = aIter->Value();
-       CORBA::Object_var aChildObject = VISU::ClientSObjectToObject( aChildSObj );
+      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 (!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)) {
-             SALOMEDSClient_GenericAttribute* anAttr;
-             if ( aChildSObj->FindAttribute(anAttr, "AttributeName") ) {
-               SALOMEDSClient_AttributeName* aName = dynamic_cast<SALOMEDSClient_AttributeName*>( anAttr );
-               myPrsLst += QString(aName->Value());
+             _PTR(GenericAttribute) anAttr;
+             if (aChildSObj->FindAttribute(anAttr, "AttributeName")) {
+               _PTR(AttributeName) aName (anAttr);
+               myPrsLst += QString(aName->Value().c_str());
                myPrsList.append(aPrsObj);
                continue;
              }
@@ -123,32 +124,32 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (QWidget* parent)
          }
        }
        // else { // This is not a Prs object
-       SALOMEDSClient_GenericAttribute* anAttr;
+       _PTR(GenericAttribute) anAttr;
        if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) {
-         SALOMEDSClient_AttributeComment* aComment = dynamic_cast<SALOMEDSClient_AttributeComment*>( anAttr );
+         _PTR(AttributeComment) aComment (anAttr);
          string aComm = aComment->Value();
-         QString strIn(aComm.c_str());
+         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)) {
-             SALOMEDSClient_GenericAttribute* aNameAttr;
-             if ( aChildSObj->FindAttribute(aNameAttr, "AttributeName") ) {
-               SALOMEDSClient_AttributeName* aName = dynamic_cast<SALOMEDSClient_AttributeName*>( aNameAttr );
-               VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow( aChildObject );
-               switch(aType) {
+             _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());
+                 myFamilisLst += QString(aName->Value().c_str());
                  myFamilyList.append(aPrsObj);
                  break;
                case VISU::TGROUP:
-                 myGroupsLst += QString(aName->Value());
+                 myGroupsLst += QString(aName->Value().c_str());
                  myGroupList.append(aPrsObj);
                  break;
                case VISU::TENTITY:
-                 myEntitiesLst += QString(aName->Value());
+                 myEntitiesLst += QString(aName->Value().c_str());
                  myEntityList.append(aPrsObj);
                  break;
                }
@@ -159,7 +160,7 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (QWidget* parent)
       }
     }
   }
-*/
+
   //  connect(myUseSrcChk, SIGNAL(toggled(bool)), mySrcCombo, SLOT(setEnabled(bool)));
   aSrcLayout->addMultiCellWidget(mySrcCombo, 1, 1, 0, 1);
 
@@ -467,7 +468,7 @@ VISU::Mesh_ptr VisuGUI_StreamLinesDlg::createMesh (VISU::VISUType theType, QStri
   if (CORBA::is_nil(aResult)) {
     SUIT_MessageBox::warn1(VisuGUI::application()->desktop(), tr("VISU_WARNING"),
                            tr("WRN_NO_AVAILABLE_DATA"),
-                           tr("VISU_BUT_OK"));
+                           tr("BUT_OK"));
     return VISU::Mesh::_nil();
   }
   SALOMEDSClient_ChildIterator* aIter = VisuGUI::GetStudyDocument()->NewChildIterator( mySelectionObj );
@@ -526,13 +527,13 @@ VISU::Mesh_ptr VisuGUI_StreamLinesDlg::createMesh (VISU::VISUType theType, QStri
       }catch(...){
        SUIT_MessageBox::warn1 ( VisuGUI::application()->desktop(), tr("VISU_WARNING"),
                                tr("ERR_CANT_CREATE_ACTOR"),
-                               tr("VISU_BUT_OK") );
+                               tr("BUT_OK") );
       }
     }
   } else {
     SUIT_MessageBox::warn1(VisuGUI::application()->desktop(), tr("VISU_WARNING"),
                            tr("ERR_CANT_BUILD_PRESENTATION"),
-                           tr("VISU_BUT_OK"));
+                           tr("BUT_OK"));
   }
   return aMesh._retn();
 */