Salome HOME
Bug #1596: Export does not work
authornds <nds@opencascade.com>
Fri, 24 Jun 2016 08:33:39 +0000 (11:33 +0300)
committernds <nds@opencascade.com>
Fri, 24 Jun 2016 08:34:04 +0000 (11:34 +0300)
Warning in Sketch to delete invalid sketch features.

src/ExchangePlugin/plugin-Exchange.xml
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/PartSet/PartSet_SketcherMgr.cpp

index 531f36667288063f1b3d94196e13ddfb55ab08c7..f428938d91b73d60616ae4d115fc679032db1753 100755 (executable)
@@ -9,13 +9,7 @@
         </file_selector>
       </feature>
       <feature id="Export" title="Export" tooltip="Export to file" icon="icons/Exchange/export.png">
-        <export_file_selector id="file_path" type="save" title="Export file" path="">
-          <validator id="ExchangePlugin_ExportFormat" parameters="BREP|BRP:BREP,STEP|STP:STEP,IGES|IGS:IGES-5.1,IGES|IGS:IGES-5.3" />
-        </export_file_selector>
-        <multi_selector id="selection_list" tooltip="Select a set of objects"
-                        type_choice="Vertices Edges Wires Faces Shells Solids Compsolids Compounds Objects" use_choice="true">
-          <validator id="GeomValidators_Finite"/>
-        </multi_selector>
+        <source path="export_widget.xml" />
       </feature>
     </group>
   </workbench>
index 127ceb3f7d82690f86b6b1b8cc888198f7064c30..8f184df155f3ba01f7675709bc66f802ddfae800 100755 (executable)
@@ -1041,7 +1041,8 @@ bool hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures)
 bool askToDelete(const std::set<FeaturePtr> theFeatures,
                  const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
                  QWidget* theParent,
-                 std::set<FeaturePtr>& theReferencesToDelete)
+                 std::set<FeaturePtr>& theReferencesToDelete,
+                 const std::string& thePrefixInfo)
 {
   QString aNotActivatedDocWrn;
   std::string aNotActivatedNames;
@@ -1120,16 +1121,18 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
   aMessageBox.setDefaultButton(QMessageBox::No);
 
   QString aText;
+  if (!thePrefixInfo.empty())
+    aText = thePrefixInfo.c_str();
   QString aSep = ", ";
   if (!aPartFeatureNames.empty())
     aText += QString(QObject::tr("The following parts will be deleted: %1.\n")).arg(aPartFeatureNames.join(aSep));
   if (!aNotActivatedDocWrn.isEmpty())
     aText += aNotActivatedDocWrn;
   if (!anOtherFeatureNames.empty())
-    aText += QString(QObject::tr("Selected features are used in the following features: %1.\nThese features will be deleted.\n"))
+    aText += QString(QObject::tr("Features are used in the following features: %1.\nThese features will be deleted.\n"))
                      .arg(anOtherFeatureNames.join(aSep));
   if (!aParamFeatureNames.empty()) {
-    aText += QString(QObject::tr("Selected parameters are used in the following features: %1.\nThese features will be deleted.\nOr parameters could be replaced by their values.\n"))
+    aText += QString(QObject::tr("Parameters are used in the following features: %1.\nThese features will be deleted.\nOr parameters could be replaced by their values.\n"))
                      .arg(aParamFeatureNames.join(aSep));
     QPushButton *aReplaceButton = aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
   }
index 665ee6008bb95fd3392ff1871402c044b6428685..244afca4c685e59c9e049100fb7a461421f36941 100755 (executable)
@@ -295,7 +295,8 @@ bool MODULEBASE_EXPORT hasModuleDocumentFeature(const std::set<FeaturePtr>& theF
 bool MODULEBASE_EXPORT askToDelete(const std::set<FeaturePtr> aFeatures,
                                    const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
                                    QWidget* theParent,
-                                   std::set<FeaturePtr>& theReferencesToDelete);
+                                   std::set<FeaturePtr>& theReferencesToDelete,
+                                   const std::string& thePrefixInfo = "");
 
 /// Converts a list of objects to set of corresponded features. If object is result, it is ingored
 /// because the feauture only might be removed. But if result is in a parameter group, the feature
index 6059ab187e98bd6eab55ade4ea8a72b98ea9e3f8..29ff74c11f1366e531e570438be11aaede711783 100755 (executable)
@@ -875,7 +875,6 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   myCurrentSketch->setDisplayed(false);
 
   // Remove invalid sketch entities
-  /*
   std::set<FeaturePtr> anInvalidFeatures;
   ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
@@ -885,17 +884,30 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
         anInvalidFeatures.insert(aFeature);
     }
   }
-  std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
-  ModelAPI_Tools::findAllReferences(anInvalidFeatures, aReferences, false);
-  std::set<FeaturePtr> aFeatureRefsToDelete;
-  if (ModuleBase_Tools::askToDelete(anInvalidFeatures, aReferences, aConnector->desktop(), aFeatureRefsToDelete)) {
-    if (!aFeatureRefsToDelete.empty())
-      anInvalidFeatures.insert(aFeatureRefsToDelete.begin(), aFeatureRefsToDelete.end());
-    bool aDone = ModelAPI_Tools::removeFeatures(anInvalidFeatures, false);
+  if (!anInvalidFeatures.empty()) {
+    std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
+    ModelAPI_Tools::findAllReferences(anInvalidFeatures, aReferences, false);
+
+    std::set<FeaturePtr>::const_iterator anIt = anInvalidFeatures.begin(),
+                                         aLast = anInvalidFeatures.end();
+    // separate features to references to parameter features and references to others
+    QStringList anInvalidFeatureNames;
+    for (; anIt != aLast; anIt++) {
+      FeaturePtr aFeature = *anIt;
+      if (aFeature.get())
+        anInvalidFeatureNames.append(aFeature->name().c_str());
+    }
+    std::string aPrefixInfo = QString("Invalid features of the sketch will be deleted: %1.\n").
+                                  arg(anInvalidFeatureNames.join(", ")).toStdString().c_str();
+    std::set<FeaturePtr> aFeatureRefsToDelete;
+    if (ModuleBase_Tools::askToDelete(anInvalidFeatures, aReferences, aConnector->desktop(),
+                                      aFeatureRefsToDelete, aPrefixInfo)) {
+      if (!aFeatureRefsToDelete.empty())
+        anInvalidFeatures.insert(aFeatureRefsToDelete.begin(), aFeatureRefsToDelete.end());
+      ModelAPI_Tools::removeFeatures(anInvalidFeatures, false);
+    }
   }
-  else
-    return;
-  */
+
   // Display sketcher objects
   for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
     FeaturePtr aFeature = myCurrentSketch->subFeature(i);