]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #539: import step - *.stp files
authorSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Fri, 8 May 2015 12:26:05 +0000 (15:26 +0300)
committerSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Fri, 8 May 2015 12:56:06 +0000 (15:56 +0300)
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_Validators.cpp
src/ExchangePlugin/ExchangePlugin_Validators.h
src/ExchangePlugin/plugin-Exchange.xml
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp

index f3f53a273e26fe136ecae73b051a9fdb9531c797..57a4e933a058b31ead2c19e0a7ee0f55607b2b01 100644 (file)
@@ -87,7 +87,7 @@ bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
   TopoDS_Shape aShape;
   if (aFormatName == "BREP") {
     aShape = BREPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
-  } else if (aFormatName == "STEP") {
+  } else if (aFormatName == "STEP" || aFormatName == "STP") {
     aShape = STEPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
   }
    // Check if shape is valid
index c001a0c3f41585bd42416e2b7ca68ec4822807d3..5dc974e72a4cf7f793d8f5c18a5910d2909a224f 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <list>
 #include <string>
+#include <sstream>
 #include <algorithm>
 
 bool ExchangePlugin_ImportFormatValidator::parseFormats(const std::list<std::string>& theArguments,
@@ -26,9 +27,12 @@ bool ExchangePlugin_ImportFormatValidator::parseFormats(const std::list<std::str
       result = false;
       continue;
     }
-    std::string aFormat = anArg.substr(0, aSepPos);
-    std::transform(aFormat.begin(), aFormat.end(), aFormat.begin(), toupper);
-    outFormats.push_back(aFormat);
+    std::string aFormatList = anArg.substr(0, aSepPos);
+    std::transform(aFormatList.begin(), aFormatList.end(), aFormatList.begin(), toupper);
+    std::istringstream aStream(aFormatList);
+    std::string aFormat;
+    while (std::getline(aStream, aFormat, '|'))
+      outFormats.push_back(aFormat);
   }
   return result;
 }
index f8db19fc21857ae0e17ecea369e868b4340d7b93..3f1bb793b76ca9adfeaec7b35912438d7409ca64 100644 (file)
@@ -26,7 +26,7 @@ class ExchangePlugin_ImportFormatValidator : public ModelAPI_AttributeValidator
    * and list of corresponding plugins: "BREPImport", "STEPImport"
    */
   static bool parseFormats(const std::list<std::string>& theArguments,
-                             std::list<std::string>& outFormats);
+                           std::list<std::string>& outFormats);
 public:
   /**
    * Returns true is the file-name attribute correctly corresponds to the set of
index 76a107e8230d67d755e1c65764a5234881cb0d59..36f2801d51ffa6f19e3daf5623bbb18327cc0be7 100644 (file)
@@ -8,7 +8,7 @@
           id="import_file_selector"
           title="Import file"
           path="">
-          <validator id="ExchangePlugin_ImportFormat" parameters="BREP:BREPImport,STEP:STEPImport" />
+          <validator id="ExchangePlugin_ImportFormat" parameters="BREP:BREPImport,STEP|STP:STEPImport" />
         </file_selector>
       </feature>
     </group>
index ac79ba82330ead050dcd9f6b306741734b812950..f997592d15fae760edef41500a49dc33b5c04aac 100644 (file)
 
 #include <Config_WidgetAPI.h>
 
-#include <QGridLayout>
 #include <QFileDialog>
+#include <QGridLayout>
+#include <QLabel>
 #include <QLineEdit>
 #include <QList>
 #include <QObject>
 #include <QPushButton>
+#include <QRegExp>
 #include <QString>
-#include <QLabel>
 
 #include <memory>
 #include <string>
@@ -131,7 +132,9 @@ QString ModuleBase_WidgetFileSelector::formatsString() const
   QStringList aValidatorFormats = getValidatorFormats();
 
   foreach(QString eachFormat, aValidatorFormats)  {
-    aResult << QString("%1 files (*.%1)").arg(eachFormat);
+    QStringList aFormatList = eachFormat.split("|");
+    aResult << QString("%1 files (%2)").arg(aFormatList.value(0))
+        .arg(QStringList(aFormatList).replaceInStrings(QRegExp("^(.*)$"), "*.\\1").join(" "));
   }
   aResult << QString("All files (*.*)");
   return aResult.join(";;");