Warning in Sketch to delete invalid sketch features.
</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>
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;
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);
}
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
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++) {
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);