Salome HOME
Issue #3138: "Import" feature improvement
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 6bd2844a7f4c76d92169859d0d74d5f0e45e19c1..e7dcbfc72ac92d1569dc4fe0c05490a0456a615f 100644 (file)
@@ -80,6 +80,7 @@
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultField.h>
+#include <ModuleBase_IconFactory.h>
 
 //#include <PartSetPlugin_Part.h>
 
@@ -89,6 +90,7 @@
 
 #include <ExchangePlugin_ExportPart.h>
 #include <ExchangePlugin_ImportPart.h>
+#include <ExchangePlugin_Import.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -226,7 +228,15 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   // Load translations
   QStringList aLangs;
   aLangs << "*_en.ts"; // load by default eng translations
+
+  /// If version of OCCT is 7.4.0 or more then it means that
+  /// this is version of SALOME older then 9.4.0
+#if OCC_VERSION_HEX >= 0x070400
+  QString aCurrLang = aResMgr->language();
+#else
   QString aCurrLang = aResMgr->stringValue("language", "language", "en");
+#endif
+
   if(aCurrLang != "en") {
     aLangs << "*_" + aCurrLang + ".ts"; // then replace with translated files
   }
@@ -483,6 +493,13 @@ void XGUI_Workshop::initMenu()
                                           QIcon(), QKeySequence(),
                                           false, "MEN_DESK_FILE");
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportPart()));
+
+  aAction = salomeConnector()->addDesktopCommand("IMPORT_SHAPE_CMD", tr("Import shape..."),
+    tr("Import shape from a file"),
+    ModuleBase_IconFactory::loadIcon("icons/Exchange/import.png"),
+    QKeySequence(), false, "MEN_DESK_FILE");
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportShape()));
+
   salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
 
 #else
@@ -1289,6 +1306,16 @@ void XGUI_Workshop::onImportPart()
   }
 }
 
+//******************************************************
+void XGUI_Workshop::onImportShape()
+{
+  if (abortAllOperations()) {
+    ModuleBase_OperationFeature* anImportOp = dynamic_cast<ModuleBase_OperationFeature*>(
+        module()->createOperation(ExchangePlugin_Import::ID()));
+    operationMgr()->startOperation(anImportOp);
+  }
+}
+
 //******************************************************
 void XGUI_Workshop::onExportPart()
 {
@@ -1860,6 +1887,9 @@ void XGUI_Workshop::deleteObjects()
   }
 
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
+  if (anObjects.isEmpty())
+    return;
+
   if (!abortAllOperations())
     return;