]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Provide tables exporting for V3.0.X
authorjfa <jfa@opencascade.com>
Mon, 1 Aug 2005 11:56:51 +0000 (11:56 +0000)
committerjfa <jfa@opencascade.com>
Mon, 1 Aug 2005 11:56:51 +0000 (11:56 +0000)
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx

index 627949eae0f4d0c8359b9bd52dd5ca2e9b8366a2..41f32151e8f4dfd4d36771dce89bd99a9a79ce34 100644 (file)
@@ -39,6 +39,11 @@ msgstr "Failed to activate MED engine!"
 msgid "ERR_CANT_BUILD_PRESENTATION"
 msgstr "The object can't be built"
 
+msgid "ERR_CANT_CREATE_ACTOR"
+msgstr "Can't create actor for this presentation"
+
+# Preferences for VISU module (VisuGUI.cxx)
+
 msgid "VISU_SCALAR_BAR"
 msgstr "Scalar Bar"
 
@@ -351,8 +356,8 @@ msgstr "Arrange Actors"
 msgid "VisuGUI::ERR_ERROR_IN_THE_FILE"
 msgstr "Error in the file"
 
-msgid "ERR_CANT_CREATE_ACTOR"
-msgstr "Can't create actor for this presentation"
+msgid "VisuGUI::ERR_ERROR_DURING_EXPORT"
+msgstr "Error has been occured during exporting to file"
 
 msgid "VisuGUI::ERR_ACTIVATE_VIEW3D"
 msgstr "Please activate 3D view before"
index d2c810d2b2910a61e24619d92e6b2d252214b2b0..5b8741102b44b02d66e67f94fb08b7de2a9aae9c 100644 (file)
@@ -277,6 +277,102 @@ VisuGUI::
 OnExportTableToFile()
 {
   if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
+
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+
+  SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+
+  if (aListIO.Extent() > 0) {
+    const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+    if (anIO->hasEntry()) {
+      _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+      if (!aSObj) return;
+
+      // find table attribute
+      bool isTOR = true;
+      _PTR(GenericAttribute) anAttr;
+
+      if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
+        isTOR = false;
+        if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+          // if the current SObject is a table title
+          // we take a father contaning the table
+          aSObj = aSObj->GetFather();
+
+          if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
+            isTOR = true;
+          } else {
+            if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+              return;
+            }
+          }
+        }
+      }
+
+      // get table title in order to have default name of the file
+      QString aTitle;
+      if (isTOR) {
+        _PTR(AttributeTableOfReal) aTabAttr (anAttr);
+        if (!aTabAttr) return;
+        aTitle = aTabAttr->GetTitle();
+      } else {
+       _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
+       if (!aTabAttr) return;
+        aTitle = aTabAttr->GetTitle();
+      }
+      aTitle.simplifyWhiteSpace();
+      aTitle = aTitle.replace(QRegExp(" "), "_");
+
+      // get default path for the file
+      SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+      QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
+      if (aDir.isEmpty()) {
+        aDir = aResourceMgr->stringValue("VISU","InputDir","");
+        if (aDir.isEmpty()) {
+          aDir = getenv("CSF_PATHData");
+        }
+      }
+      QString aPath = Qtx::addSlash(aDir) + aTitle;
+
+      // get name for the file
+      QStringList aFilter;
+      aFilter.append("Table Files (*.xls)");
+
+      QFileInfo aFileInfo =
+        SUIT_FileDlg::getFileName(GetDesktop(this),
+                                  aPath,
+                                  aFilter,
+                                  tr("MEN_EXPORT_TABLE"), // "Export Table To File"
+                                  false);
+
+      // export
+      QString aFile = aFileInfo.filePath();
+      if (!aFile.isEmpty()) {
+        application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
+       aDir = Qtx::dir(aFile, true);
+        aResourceMgr->setValue("VISU", "OutputDir", aDir);
+
+       try {
+         GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
+          application()->putInfo(aFile + " " + tr("INF_DONE"));
+       } catch(std::exception& ex) {
+         INFOS(ex.what());
+         SUIT_MessageBox::warn1(GetDesktop(this),
+                                 tr("WRN_VISU"),
+                                tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
+                                tr("BUT_OK"));
+       } catch(...) {
+         INFOS(tr("ERR_ERROR_DURING_EXPORT"));
+         SUIT_MessageBox::warn1(GetDesktop(this),
+                                 tr("WRN_VISU"),
+                                tr("ERR_ERROR_DURING_EXPORT"),
+                                tr("BUT_OK") );
+       }
+      }
+    }
+  }
 }
 
 void
@@ -431,7 +527,7 @@ CreatePrs3d(SalomeApp_Module* theModule,
   QApplication::restoreOverrideCursor();
   if(aPrs3d){
     SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
-    int aValue = aResourceMgr->integerValue("Visu:BuildDefaultPrs3d",0);
+    int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
     if(!aValue){
       if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
         aDlg->initFromPrsObject(aPrs3d);