Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Utils.cxx
index 7dbc44c72ba63c0bd19d3d95c8c6bd3ea7e9f810..6ef3fddaba7a997dc382efafca8821f0239269cd 100644 (file)
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 
 #include <qstring.h>
 
 #include "SMESHGUI_Utils.h"
+#include "SMESHGUI.h"
 
 #include "OB_Browser.h"
 
 #include "SUIT_Desktop.h"
 #include "SUIT_Application.h"
 #include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
 
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "SalomeApp_Application.h"
 #include "SalomeApp_Module.h"
 #include "SalomeApp_Study.h"
@@ -50,7 +52,7 @@ namespace SMESH{
     return theModule->application()->desktop();
   }
 
-  SalomeApp_SelectionMgr*
+  LightApp_SelectionMgr*
   GetSelectionMgr(const SalomeApp_Module* theModule)
   {
     return theModule->getApp()->selectionMgr();
@@ -69,7 +71,7 @@ namespace SMESH{
   }
 
   CORBA::Object_var 
-  DataOwnerToObject(const SalomeApp_DataOwnerPtr& theOwner)
+  DataOwnerToObject(const LightApp_DataOwnerPtr& theOwner)
   {
     CORBA::Object_var anObj;
     if(theOwner){
@@ -99,8 +101,8 @@ namespace SMESH{
   {
     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
       (SUIT_Session::session()->activeApplication());
-    if (app && app->activeViewManager())
-      return app->activeViewManager()->getActiveView();
+    if (app && app->desktop() )
+      return app->desktop()->activeWindow();
     else
       return NULL;
   }
@@ -153,6 +155,32 @@ namespace SMESH{
     if (aComment)
       aComment->SetValue(theValue);
   }
+  
+  void setFileName (_PTR(SObject) theSObject, const char* theValue)
+  {
+    _PTR(Study) aStudy = GetActiveStudyDocument();
+    if (aStudy->GetProperties()->IsLocked())
+      return;
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    _PTR(GenericAttribute) anAttr =
+      aBuilder->FindOrCreateAttribute(theSObject, "AttributeExternalFileDef");
+    _PTR(AttributeExternalFileDef) aFileName = anAttr;
+    if (aFileName)
+      aFileName->SetValue(theValue);
+  }
+  
+  void setFileType (_PTR(SObject) theSObject, const char* theValue)
+  {
+    _PTR(Study) aStudy = GetActiveStudyDocument();
+    if (aStudy->GetProperties()->IsLocked())
+      return;
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    _PTR(GenericAttribute) anAttr =
+      aBuilder->FindOrCreateAttribute(theSObject, "AttributeFileType");
+    _PTR(AttributeFileType) aFileType = anAttr;
+    if (aFileType)
+      aFileType->SetValue(theValue);
+  }
 
   CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject,
                                      _PTR(Study)   theStudy)
@@ -195,7 +223,7 @@ namespace SMESH{
     return app->orb()->string_to_object(theIOR);
   }
 
-  int GetNameOfSelectedIObjects(SalomeApp_SelectionMgr* theMgr, QString& theName)
+  int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName)
   {
     if (!theMgr)
       return 0;
@@ -226,7 +254,7 @@ namespace SMESH{
     return theSObject->GetFather();
   }
 
-  void ModifiedMesh (_PTR(SObject) theSObject, bool theIsRight)
+  void ModifiedMesh (_PTR(SObject) theSObject, bool theIsNotModif, bool isEmptyMesh)
   {
     _PTR(Study) aStudy = GetActiveStudyDocument();
     if (aStudy->GetProperties()->IsLocked())
@@ -236,10 +264,12 @@ namespace SMESH{
     _PTR(GenericAttribute) anAttr =
       aBuilder->FindOrCreateAttribute(theSObject,"AttributePixMap");
     _PTR(AttributePixMap) aPixmap = anAttr;
-    if (theIsRight) {
+    if (theIsNotModif) {
       aPixmap->SetPixMap("ICON_SMESH_TREE_MESH");
-    } else {
+    } else if ( isEmptyMesh ) {
       aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN");
+    } else {
+      aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_PARTIAL");
     }
 
     _PTR(ChildIterator) anIter = aStudy->NewChildIterator(theSObject);
@@ -251,16 +281,34 @@ namespace SMESH{
          _PTR(SObject) aSObj1 = anIter1->Value();
          anAttr = aBuilder->FindOrCreateAttribute(aSObj1, "AttributePixMap");
          aPixmap = anAttr;
-         if (theIsRight) {
-           aPixmap->SetPixMap("ICON_SMESH_TREE_MESH");
-         } else {
-           aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN");
-         }
+          if (theIsNotModif) {
+            aPixmap->SetPixMap("ICON_SMESH_TREE_MESH");
+          } else if ( isEmptyMesh ) {
+            aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN");
+          } else {
+            aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_PARTIAL");
+          }
        }
       }
     }
   }
 
+  void ShowHelpFile (QString theHelpFileName)
+  {
+    LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+    if (app) {
+      SMESHGUI* gui = SMESHGUI::GetSMESHGUI();
+      app->onHelpContextModule(gui ? app->moduleName(gui->moduleName()) : QString(""),
+                               theHelpFileName);
+    }
+    else {
+      SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+                             QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(theHelpFileName),
+                             QObject::tr("BUT_OK"));
+      }
+  }
+
 //  void UpdateObjBrowser (bool)
 //  {
 //    //SMESHGUI::activeStudy()->updateObjBrowser(true);