ModelAPI_Session::get()->validators()->registerNotObligatory(
getKind(), ExchangePlugin_ImportFeature::MEMORY_BUFFER_ID());
}
+
+bool ExchangePlugin_ImportFeature::isEditable()
+{
+ AttributeStringPtr aImportTypeAttr = string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID());
+ std::string aFormat = aImportTypeAttr->value();
+
+ if (aFormat == "XAOMem")
+ // If the shape is imported from memory buffer, do not allow to edit the feature
+ return false;
+
+ return true;
+}
+
/*
* Computes or recomputes the results
*/
// use the geometry name or the file name for the feature
std::string aBodyName = aXaoGeometry->getName();
- if (aBodyName.empty() && !isMemoryImport)
- aBodyName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
+ if (aBodyName.empty()) {
+ if (isMemoryImport)
+ aBodyName = "ImportXAOMem";
+ else
+ aBodyName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
+ }
data()->setName(Locale::Convert::toWString(aBodyName));
ResultBodyPtr aResultBody = createResultBody(aGeomShape);
/// Request for initialization of data model of the feature: adding all attributes
EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
+ /// Return false in case of XAOMem import.
+ EXCHANGEPLUGIN_EXPORT virtual bool isEditable();
+
protected:
/// Performs the import of the file
EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName) override;
return myIsStable;
}
+bool ModelAPI_Feature::isEditable()
+{
+ return true;
+}
+
bool ModelAPI_Feature::customAction(const std::string& /*theActionId*/)
{
return false;
std::list<std::shared_ptr<ModelAPI_Result> > myResults;
///< is feature disabled or not
bool myIsDisabled;
- ///< is feature is stable (not editing)
+ ///< is feature stable (not editing)
bool myIsStable;
public:
/// Returns the feature is stable or not.
MODELAPI_EXPORT virtual bool isStable();
+ /// Returns the feature is editable or not. Most of features are editable.
+ MODELAPI_EXPORT virtual bool isEditable();
+
/// Performs some custom feature specific functionality (normally called by some GUI button)
/// \param theActionId an action key
/// \return a boolean value about it is performed
} else if (aObject->document() == aMgr->activeDocument()) {
if (hasParameter || hasFeature) {
- // disable Edit menu for groups under ImportResult feature
bool isEnabled = true;
- if (aFeature.get() && aFeature->getKind() == "Group")
- {
- std::shared_ptr<ModelAPI_CompositeFeature> anOwner =
- ModelAPI_Tools::compositeOwner (aFeature);
-
- if (anOwner.get() && anOwner->getKind() == "ImportResult")
- {
- myMenuMgr->action("EDIT_CMD")->setEnabled(false);
- isEnabled = false;
+ if (aFeature.get()) {
+ // disable Edit menu for not editable features
+ isEnabled = aFeature->isEditable();
+
+ // disable Edit menu for groups under ImportResult feature
+ if (aFeature->getKind() == "Group") {
+ std::shared_ptr<ModelAPI_CompositeFeature> anOwner =
+ ModelAPI_Tools::compositeOwner (aFeature);
+ if (anOwner.get() && anOwner->getKind() == "ImportResult") {
+ isEnabled = false;
+ }
}
}
- if (isEnabled)
- {
- myMenuMgr->action("EDIT_CMD")->setEnabled(true);
+ myMenuMgr->action("EDIT_CMD")->setEnabled(isEnabled);
+
+ if (isEnabled) {
theMenu->addAction(myMenuMgr->action("EDIT_CMD"));
if (aCurrentOp && aFeature.get()) {
if (aCurrentOp->id().toStdString() == aFeature->getKind())