Salome HOME
Copyright update 2022
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_PublishDlg.cxx
index 17c3a2b3f691cb14e947ed81dbe5550d9d791445..d31ecf834790a9c773c76ca4e6d5574166c53f1b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -78,7 +78,7 @@ GEOMToolsGUI_PublishDlg::GEOMToolsGUI_PublishDlg(QWidget* parent):
    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
    headerItem->setIcon( 2, QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) ) );
    myTreeWidget->setHeaderItem ( headerItem );
-   myTreeWidget->header()->setClickable( true );
+   myTreeWidget->header()->setSectionsClickable( true );
    myTreeWidget->header()->setSortIndicatorShown( true );
    myTreeWidget->header()->moveSection( 2, 0 );
    myTreeWidget->setSortingEnabled( true );
@@ -137,22 +137,22 @@ GEOMToolsGUI_PublishDlg::~GEOMToolsGUI_PublishDlg()
     if ( appStudy ) {
       _PTR(Study) aStudy = appStudy->studyDS();
       if ( aStudy ) {
-       GEOM_Displayer displayer ( appStudy );
-       QTreeWidgetItemIterator it( myTreeWidget );
-       while ( *it ) {
-         QString entry = myEntryToItem.key( *it );
-         _PTR(SObject) SO ( aStudy->FindObjectID( qPrintable( entry ) ) );
-         if ( SO ) {
-           GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
-           if ( CORBA::is_nil( aGeomObject ) ) continue;
-           if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {
-             Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
-             displayer.Erase( io );
+        GEOM_Displayer displayer;
+           QTreeWidgetItemIterator it( myTreeWidget );
+           while ( *it ) {
+             QString entry = myEntryToItem.key( *it );
+             _PTR(SObject) SO ( aStudy->FindObjectID( qUtf8Printable( entry ) ) );
+             if ( SO ) {
+               GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
+               if ( CORBA::is_nil( aGeomObject ) ) continue;
+               if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {
+                 Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
+                 displayer.Erase( io );
+               }
+             }
+             ++it;
            }
-         }
-         ++it;
-       }
-       displayer.UpdateViewer();
+           displayer.UpdateViewer();
       }
     }
   }
@@ -181,15 +181,7 @@ void GEOMToolsGUI_PublishDlg::initData() {
   if(!myGeomRoot)
     return;
 
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-  if(!appStudy ) 
-    return;
-
-  _PTR(Study) aStudy = appStudy->studyDS();
-  if(!aStudy)
-    return;
-
-  buildTree(aStudy, myGeomRoot);
+  buildTree(myGeomRoot);
 
   myTreeWidget->resizeColumnToContents(0);
   myTreeWidget->resizeColumnToContents(1);
@@ -227,7 +219,7 @@ QTreeWidgetItem* GEOMToolsGUI_PublishDlg::createItem(QTreeWidgetItem* theParent,
 // function : findParentItem()
 // purpose  :
 //=================================================================================
-QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, SalomeApp_DataObject* theObject, BufferedList& theList ) {
+QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(SalomeApp_DataObject* theObject, BufferedList& theList ) {
   
   QTreeWidgetItem* aResult = NULL;
   SalomeApp_DataObject* aParrent = dynamic_cast<SalomeApp_DataObject*>(theObject->parent());
@@ -236,14 +228,14 @@ QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, S
     if( !(aResult = myEntryToItem.value(targetEntry)) ) {
       if( aParrent != myGeomRoot ) {
         QString aName;
-        _PTR(SObject) aSO ( theStudy->FindObjectID(qPrintable(aParrent->entry())));
+        _PTR(SObject) aSO ( SalomeApp_Application::getStudy()->FindObjectID(qUtf8Printable(aParrent->entry())));
         _PTR(GenericAttribute) anAttr;
         if ( aSO->FindAttribute(anAttr, "AttributeName") ) {
           _PTR(AttributeName) anAttrName (anAttr);
           aName = anAttrName->Value().c_str();
         }
         theList.push_front(qMakePair(targetEntry, aName));
-        aResult = findParentItem(theStudy,aParrent,theList);
+        aResult = findParentItem(aParrent,theList);
       } else {
         //Publish List
         for(int i = 0; i < theList.size(); i++ ) {
@@ -266,7 +258,7 @@ QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, S
 // function : buildTree()
 // purpose  :
 //=================================================================================
-void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem) {
+void GEOMToolsGUI_PublishDlg::buildTree(SalomeApp_DataObject* theItem) {
   if(!theItem || theItem->isReference())
     return;
   
@@ -274,7 +266,7 @@ void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObje
 
     //If object hasn't "AttributeDrawable" => it visible
     bool isDrawable = true;
-    _PTR(SObject) SO ( theStudy->FindObjectID(qPrintable(theItem->entry())));
+    _PTR(SObject) SO ( SalomeApp_Application::getStudy()->FindObjectID(qUtf8Printable(theItem->entry())));
     _PTR(GenericAttribute) anAttr;
     if ( SO && SO->FindAttribute(anAttr, "AttributeDrawable") ) {
       _PTR(AttributeDrawable) aDrw (anAttr);
@@ -288,7 +280,7 @@ void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObje
         aName = aAttrName->Value().c_str();
       }
       BufferedList aList;
-      QTreeWidgetItem* parentItem = findParentItem(theStudy, theItem, aList);
+      QTreeWidgetItem* parentItem = findParentItem(theItem, aList);
       createItem(parentItem,qMakePair(theItem->entry(),aName),true);
     }
   }
@@ -296,7 +288,7 @@ void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObje
   DataObjectList listObj = theItem->children( false );
   DataObjectList::iterator itr = listObj.begin();
   while( itr != listObj.end()) {
-    buildTree(theStudy, dynamic_cast<SalomeApp_DataObject*>(*itr));
+    buildTree(dynamic_cast<SalomeApp_DataObject*>(*itr));
     itr++;
   }
 }
@@ -327,7 +319,7 @@ void GEOMToolsGUI_PublishDlg::clickOnApply() {
     QTreeWidgetItem* item = toProcess[i];
     if(item) {
       QString entry = myEntryToItem.key(item);
-      _PTR(SObject) SO ( aStudy->FindObjectID(qPrintable(entry)) );
+      _PTR(SObject) SO ( aStudy->FindObjectID(qUtf8Printable(entry)) );
       if(!SO) continue;
       _PTR(AttributeDrawable) aDrw = aBuilder->FindOrCreateAttribute( SO, "AttributeDrawable" );
       aDrw->SetDrawable( true );
@@ -342,10 +334,10 @@ void GEOMToolsGUI_PublishDlg::clickOnApply() {
       }
       // show references if any
       std::vector< _PTR(SObject) > vso = aStudy->FindDependances(SO);
-      for ( int i = 0; i < vso.size(); i++ ) {
-       _PTR(SObject) refObj = vso[i];
-       aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
-       aDrw->SetDrawable( true );
+      for ( size_t i = 0; i < vso.size(); i++ ) {
+        _PTR(SObject) refObj = vso[i];
+        aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
+        aDrw->SetDrawable( true );
       }
     }
   }
@@ -450,11 +442,11 @@ void GEOMToolsGUI_PublishDlg::onItemClicked(QTreeWidgetItem* theItem, int theCol
     _PTR(Study) aStudy = appStudy->studyDS();
     if ( !aStudy ) return;
     QString entry = myEntryToItem.key( theItem );
-    _PTR(SObject) SO ( aStudy->FindObjectID( qPrintable( entry ) ) );
+    _PTR(SObject) SO ( aStudy->FindObjectID( qUtf8Printable( entry ) ) );
     if ( !SO ) return;
     GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
     if ( CORBA::is_nil( aGeomObject ) ) return;
-    GEOM_Displayer displayer ( appStudy );
+    GEOM_Displayer displayer;
     SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
     Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
     if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {