Salome HOME
Using files from package LightApp instead of files from package SalomeApp
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_BrowseNodeDlg.cxx
index 57ba90952b384f0822fd0258ac1c7df57575d900..334b7c3413510e01279c7fe68df157f9cabf7bec 100644 (file)
 
 using namespace std;
 
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDS_Study.hxx"
+#include <boost/shared_ptr.hpp>
+using namespace boost;
+
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SalomeApp_Study.h"
+#include "SUIT_Session.h"
+
+#include "SALOME_ListIO.hxx"
+
 #include "SUPERVGUI_BrowseNodeDlg.h"
 #include "SUPERVGUI_CanvasNode.h"
 #include "SUPERVGUI_CanvasPort.h"
@@ -66,10 +79,16 @@ bool SUPERVGUI_PortField::setNewValue() {
   if ( !myIsEditable ) return false;
 
   QString aTxt = myValue->text();
-  if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
+  //mkr : fix for bug IPAL9441
+  //if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
   
   if ( aTxt.find( "Unknown" ) < 0 ) {
-    return myPort->Input( Supervision.getEngine()->StringValue( aTxt ) );
+    SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+    if ( !aSupMod ) {
+      MESSAGE("NULL Supervision module!");
+      return false;
+    }
+    return myPort->Input( aSupMod->getEngine()->StringValue( aTxt ) );
   }
   return false;
 }
@@ -92,7 +111,7 @@ bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e )
  * Constructor (SUPERVGUI_CanvasNode)
  */
 SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode )
-  : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+  : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
 {
   myNodeCanvas = theNode;
 
@@ -107,9 +126,6 @@ void SUPERVGUI_BrowseNodeDlg::init()
 
   SUPERV_CNode aEngine = myNodeCanvas->getEngine();
   
-  mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
-//  mySelection->ClearIObjects();
-
   setName( "SUPERVGUI_BrowseNodeDlg" );
   setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() );
 
@@ -180,7 +196,11 @@ void SUPERVGUI_BrowseNodeDlg::init()
   if ( !myIsEditable )
     aBtnLayout->addStretch();
 
-  connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+  SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+  if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(), 
+                         SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+  else MESSAGE("NULL Supervision module!");
+  
   myNodeCanvas->getMain()->lockedGraph(true);
 }
 
@@ -253,22 +273,37 @@ void SUPERVGUI_BrowseNodeDlg::onFieldActivated()
 void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
 {
   if ( myActiveField ) {
-    if( mySelection->IObjectCount() == 1 ) {
-      Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
+    
+    SALOME_ListIO aList;
+    aList.Clear();
+
+    SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+    if ( !aSupMod ) {
+      MESSAGE("NULL Supervision module!");
+      return;
+    }
+
+    (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))
+      ->selectionMgr()->selectedObjects( aList );
+    
+    if( aList.Extent() == 1 ) {
+      Handle( SALOME_InteractiveObject ) anIO = aList.First();
       if ( anIO->hasEntry() ) {
-       SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
-       getStudyDocument()->FindObjectID( anIO->getEntry() );
+       _PTR(SObject) aObj ( dynamic_cast<SalomeApp_Study*>( aSupMod->getActiveStudy() )->
+                            studyDS()->FindObjectID( anIO->getEntry() ) );
          
-       SALOMEDS::GenericAttribute_var anAttr;
-       SALOMEDS::AttributeIOR_var     anIOR;
-       Standard_CString               ior = "";
+       _PTR(GenericAttribute) anAttr;
+       QString ior("");
          
        if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
-         anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
-         ior = anIOR->Value();
+         _PTR(AttributeIOR) anIOR ( anAttr );
+         ior = anIOR->Value().c_str();
        }
        else {
-         ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
+         SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aObj->GetStudy().get() );
+         SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aObj.get() );
+         if ( aSStudy && aSSObj )
+           ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
        }
        myActiveField->setData( ior );
       }
@@ -281,7 +316,7 @@ void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
  * Constructor (SUPERVGUI_CanvasPort)
  */
 SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
-  : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+  : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
 {
   myPortCanvas = thePort;
 
@@ -293,9 +328,6 @@ void SUPERVGUI_GetValueDlg::init()
   myOKBtn = 0;
   setSizeGripEnabled( true );
 
-  mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
-//  mySelection->ClearIObjects();
-
   setName( "SUPERVGUI_GetValueDlg" );
   setCaption( tr( "TIT_SETVALUE_PORT" ) );
   
@@ -345,8 +377,12 @@ void SUPERVGUI_GetValueDlg::init()
     aBtnLayout->addStretch();
 
   myField->updateGUI();
-  connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
   
+  SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+  if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(), 
+                         SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+  else MESSAGE("NULL Supervision module!");
   myPortCanvas->getMain()->lockedGraph(true);
 }
 
@@ -375,7 +411,7 @@ void SUPERVGUI_GetValueDlg::accept() {
     myPortCanvas->getMain()->getCanvas()->update();
   }
   else {
-    if ( QMessageBox::warning( QAD_Application::getDesktop(), 
+    if ( QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), 
                               tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
                               QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
       return;
@@ -401,22 +437,36 @@ void SUPERVGUI_GetValueDlg::reject() {
  */
 void SUPERVGUI_GetValueDlg::onSelectionChanged()
 {
-  if( mySelection->IObjectCount() == 1 ) {
-    Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
+  SALOME_ListIO aList;
+  aList.Clear();
+  
+  SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+  if ( !aSupMod ) {
+    MESSAGE("NULL Supervision module!");
+    return;
+  }
+  
+  (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))
+    ->selectionMgr()->selectedObjects( aList );
+  
+  if( aList.Extent() == 1 ) {
+    Handle( SALOME_InteractiveObject ) anIO = aList.First();
     if ( anIO->hasEntry() ) {
-      SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
-      getStudyDocument()->FindObjectID( anIO->getEntry() );
+      _PTR(SObject) aObj ( dynamic_cast<SalomeApp_Study*>( aSupMod->getActiveStudy() )->
+                          studyDS()->FindObjectID( anIO->getEntry() ) );
        
-      SALOMEDS::GenericAttribute_var anAttr;
-      SALOMEDS::AttributeIOR_var     anIOR;
-      Standard_CString               ior = "";
+      _PTR(GenericAttribute) anAttr;
+      QString ior("");
        
       if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
-       anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
-       ior = anIOR->Value();
+       _PTR(AttributeIOR) anIOR ( anAttr );
+       ior = anIOR->Value().c_str();
       }
       else {
-       ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
+       SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aObj->GetStudy().get() );
+       SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aObj.get() );
+       if ( aSStudy && aSSObj )
+         ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
       }
       myField->setData( ior );
     }
@@ -430,7 +480,7 @@ void SUPERVGUI_GetValueDlg::onSelectionChanged()
 // ----------------------------
 
 SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
-  :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+  :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
 {
   myPortCanvas = thePort;
   init();
@@ -529,7 +579,7 @@ void SUPERVGUI_StreamInDlg::accept() {
 
 //-------------------------------------------------------------------------
 SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
-  :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+  :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
 {
   myPortCanvas = thePort;
   init();