Salome HOME
updated copyright message
[modules/geom.git] / src / GEOMGUI / GEOMGUI_TextTreeWdg.cxx
old mode 100755 (executable)
new mode 100644 (file)
index d69e7bb..5122539
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2015-2023  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -61,9 +61,9 @@ namespace
   {
   public:
 
-    DimensionsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) :
-      myStudy( theStudy ), myEntry( theEntry ) {
-      myAttr.LoadFromAttribute( theStudy, theEntry );
+    DimensionsProperty( const std::string& theEntry ) :
+      myEntry( theEntry ) {
+      myAttr.LoadFromAttribute( theEntry );
     }
     virtual int GetNumber() Standard_OVERRIDE {
       return myAttr.GetNumber();
@@ -78,13 +78,12 @@ namespace
       myAttr.SetVisible( theIndex, theIsVisible );
     }
     virtual void Save() Standard_OVERRIDE {
-      myAttr.SaveToAttribute( myStudy, myEntry );
+      myAttr.SaveToAttribute( myEntry );
     }
     GEOMGUI_DimensionProperty& Attr() { return myAttr; }
 
   private:
     GEOMGUI_DimensionProperty myAttr;
-    SalomeApp_Study* myStudy;
     std::string myEntry;
   };
 
@@ -93,10 +92,9 @@ namespace
   {
   public:
 
-    AnnotationsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) {
+    AnnotationsProperty( const std::string& theEntry ) {
       myEntry = theEntry.c_str();
-      myStudy = theStudy;
-      _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
+      _PTR(SObject) aSObj = SalomeApp_Application::getStudy()->FindObjectID( theEntry );
       if ( aSObj ) {
         myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
       }
@@ -132,7 +130,7 @@ namespace
 protected:
     GEOMGUI_AnnotationMgr* annotationMgr() const
     {
-      CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+      CAM_Application* anApp = dynamic_cast<CAM_Application*>(SUIT_Session::session()->activeApplication());
       GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
       if (!aModule) {
         return NULL;
@@ -143,7 +141,6 @@ protected:
 private:
     QString myEntry;
     Handle(GEOMGUI_AnnotationAttrs) myAttr;
-    SalomeApp_Study* myStudy;
   };
 }
 
@@ -156,10 +153,9 @@ private:
 // purpose  :
 //=================================================================================
 GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
-  : myDisplayer(NULL)
 {
   myStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-  myDisplayer = GEOM_Displayer( myStudy );
+  myDisplayer = GEOM_Displayer();
 
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   myVisibleIcon = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) );
@@ -179,11 +175,8 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
   headerItem->setIcon( 1, myVisibleIcon );
   setHeaderItem ( headerItem ); 
   header()->moveSection( 1, 0 );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-  header()->setResizeMode( 1, QHeaderView::ResizeToContents );
-#else
   header()->setSectionResizeMode( 1, QHeaderView::ResizeToContents );
-#endif
+
   QStringList rootNames;
   rootNames << tr("GEOM_DIMENSIONS") << "";
   myDimensionsItem = new QTreeWidgetItem( this, rootNames );
@@ -319,7 +312,7 @@ void GEOMGUI_TextTreeWdg::updateAnnotationBranch( const QString& theEntry )
 //=================================================================================
 void GEOMGUI_TextTreeWdg::updateObjectName( const QString& theEntry )
 {
-  QTreeWidgetItem* anObjectItem;
+  QTreeWidgetItem* anObjectItem = 0;
 
   QHash<QString, QTreeWidgetItem*> anObjects = getObjects( DimensionShape );
   if ( anObjects.contains( theEntry ) )
@@ -402,13 +395,13 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
 //=================================================================================
 QSharedPointer<GEOMGUI_TextTreeWdg::VisualProperty>
   GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType,
-                                          SalomeApp_Study* theStudy,
+                                          SalomeApp_Study* /*theStudy*/,
                                           const std::string& theEntry )
 {
   switch ( theBranchType )
   {
-    case DimensionShape  : return QSharedPointer<VisualProperty>( new DimensionsProperty( theStudy, theEntry ) );
-    case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theStudy, theEntry ) );
+    case DimensionShape  : return QSharedPointer<VisualProperty>( new DimensionsProperty( theEntry ) );
+    case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theEntry ) );
     default: break;
   }
   return QSharedPointer<VisualProperty>();
@@ -448,7 +441,8 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
 
   QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
 
-  CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+  SalomeApp_Application* anApp =
+    dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
   if ( aProp->GetIsVisible( aDimIndex ) ) {
     aModule->GetAnnotationMgr()->Erase(anEntry.c_str(), aDimIndex);
@@ -829,7 +823,7 @@ bool GEOMGUI_TextTreeWdg::setShapeItemVisibility( QSharedPointer<VisualProperty>
 //=================================================================================
 void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
 {
-  Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toLatin1().constData(), "GEOM", "TEMP_IO" );
+  Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toUtf8().constData(), "GEOM", "TEMP_IO" );
   myDisplayer.Redisplay( io );
 }