<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 Faces Solids Objects">
+ <multi_selector id="selection_list" tooltip="Select a set of objects"
+ type_choice="Vertices Edges Faces Solids Objects" use_choice="true">
<validator id="GeomValidators_Finite"/>
</multi_selector>
</feature>
FeaturesPlugin_RevolutionBoolean.h
FeaturesPlugin_RevolutionCut.h
FeaturesPlugin_RevolutionFuse.h
+ FeaturesPlugin_ValidatorExtrusionBase.h
FeaturesPlugin_ValidatorTransform.h
FeaturesPlugin_Validators.h
)
FeaturesPlugin_RevolutionBoolean.cpp
FeaturesPlugin_RevolutionCut.cpp
FeaturesPlugin_RevolutionFuse.cpp
+ FeaturesPlugin_ValidatorExtrusionBase.cpp
FeaturesPlugin_ValidatorTransform.cpp
FeaturesPlugin_Validators.cpp
)
../ModelAPI
../GeomAPI
../GeomAlgoAPI
+ ../GeomValidators
../Events
)
ModelAPI
GeomAPI
GeomAlgoAPI
+ GeomValidators
)
ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS)
#include <FeaturesPlugin_RevolutionFuse.h>
#include <FeaturesPlugin_Rotation.h>
#include <FeaturesPlugin_ValidatorTransform.h>
+#include <FeaturesPlugin_ValidatorExtrusionBase.h>
#include <FeaturesPlugin_Validators.h>
#include <ModelAPI_Session.h>
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
new FeaturesPlugin_ValidatorTransform);
+ aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionBase",
+ new FeaturesPlugin_ValidatorExtrusionBase);
aFactory->registerValidator("FeaturesPlugin_PipeLocationsValidator",
new FeaturesPlugin_PipeLocationsValidator);
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include "FeaturesPlugin_ValidatorExtrusionBase.h"
+
+#include "GeomValidators_FeatureKind.h"
+#include "GeomValidators_ShapeType.h"
+
+#include "ModelAPI_AttributeSelectionList.h"
+#include "ModelAPI_ResultPart.h"
+#include "ModelAPI_ResultBody.h"
+#include "ModelAPI_ResultCompSolid.h"
+#include "ModelAPI_Session.h"
+
+bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ bool aValid = true;
+
+ GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind();
+ // check whether the selection is on the sketch
+ bool aFeatureKindValid = aValidator->isValid(theAttribute, theArguments, theError);
+ if (!aFeatureKindValid) {
+ // check if selection has Face selected
+ GeomValidators_ShapeType* aShapeType = new GeomValidators_ShapeType();
+ std::list<std::string> anArguments;
+ anArguments.push_back("face");
+ aValid = aShapeType->isValid(theAttribute, anArguments, theError);
+ }
+ return aValid;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: FeaturesPlugin_ValidatorExtrusionBase.h
+// Created: 16 Sep 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef FeaturesPlugin_ValidatorExtrusionBase_H
+#define FeaturesPlugin_ValidatorExtrusionBase_H
+
+#include "ModelAPI_AttributeValidator.h"
+
+/** \class FeaturesPlugin_ValidatorExtrusionBase
+ * \ingroup Validators
+ * \brief A validator of selection
+ */
+class FeaturesPlugin_ValidatorExtrusionBase : public ModelAPI_AttributeValidator
+{
+ public:
+ /** \return true if attribute is valid
+ * \param theAttribute the checked attribute
+ * \param theArguments arguments of the attribute
+ * \param theError error message
+ */
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
+#endif
icon=":icons/sketch.png"
use_body="false"
tooltip="Create or edit a sketch"
- shape_types="vertex edge face wire objects">
+ shape_types="face objects">
</sketch_launcher>
+ <composite_multi_selector id="base"
+ label="Select a sketch face"
+ icon=":icons/sketch.png"
+ tooltip="Select a sketch face"
+ type_choice="Faces Objects">
+ <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+ </composite_multi_selector>
<toolbox id="CreationMethod">
<box id="BySizes" title="By sizes" icon=":icons/dimension_up_down_32x32.png">
- <composite_multi_selector id="base"
- label="Select a sketch face"
- icon=":icons/sketch.png"
- tooltip="Select a sketch face"
- type_choice="Faces">
- <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
- </composite_multi_selector>
<groupbox>
<doublevalue
id="to_size"
</groupbox>
</box>
<box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted_32x32.png">
- <composite_multi_selector id="base"
- label="Select a sketch face"
- icon=":icons/sketch.png"
- tooltip="Select a sketch face"
- type_choice="Faces">
- <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
- </composite_multi_selector>
<groupbox title="From">
<shape_selector id="from_object"
icon=":icons/plane.png"
<source>
<multi_selector id="group_list"
tooltip="Select a set of objects"
- type_choice="Vertices Edges Faces Solids">
+ type_choice="Vertices Edges Faces Solids"
+ use_choice="true">
<validator id="GeomValidators_BodyShapes" parameters="Sketch"/>
</multi_selector>
</source>
\ No newline at end of file
icon=":icons/sketch.png"
tooltip="Select a sketch face"
type_choice="Faces">
- <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
+ <validator id="GeomValidators_FeatureKind" parameters="Sketch"/>
</multi_selector>
<shape_selector id="axis_object"
icon=":icons/axis.png"
icon=":icons/sketch.png"
tooltip="Select a sketch face"
type_choice="Faces">
- <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
+ <validator id="GeomValidators_FeatureKind" parameters="Sketch"/>
</multi_selector>
<shape_selector id="axis_object"
icon=":icons/axis.png"
GeomValidators_ConstructionComposite.h
GeomValidators_DifferentShapes.h
GeomValidators_Face.h
+ GeomValidators_FeatureKind.h
GeomValidators_Finite.h
GeomValidators_PartitionArguments.h
GeomValidators_Plugin.h
GeomValidators_ConstructionComposite.cpp
GeomValidators_DifferentShapes.cpp
GeomValidators_Face.cpp
+ GeomValidators_FeatureKind.cpp
GeomValidators_Finite.cpp
GeomValidators_PartitionArguments.cpp
GeomValidators_Plugin.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_FeatureKind.cpp
+// Created: 22 March 2015
+// Author: Natalia Ermolaeva
+
+#include "GeomValidators_FeatureKind.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Object.h>
+
+bool GeomValidators_FeatureKind::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ bool isSketchEntities = true;
+ std::set<std::string> anEntityKinds;
+ std::string anEntityKindsStr;
+ std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+ for (; anIt != aLast; anIt++) {
+ anEntityKinds.insert(*anIt);
+ if (!anEntityKindsStr.empty())
+ anEntityKindsStr += ", ";
+ anEntityKindsStr += *anIt;
+ }
+
+ std::string anAttributeType = theAttribute->attributeType();
+ if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ // all context objects should be sketch entities
+ for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) {
+ AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+ ObjectPtr anObject = aSelectAttr->context();
+ // a context of the selection attribute is a feature result. It can be a case when the result
+ // of the feature is null, e.g. the feature is modified and has not been executed yet.
+ // The validator returns an invalid result here. The case is an extrusion built on a sketch
+ // feature. A new sketch element creation leads to an empty result.
+ if (!anObject.get())
+ isSketchEntities = false;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+ }
+ }
+ }
+ if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr aSelectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ ObjectPtr anObject = aSelectAttr->context();
+ // a context of the selection attribute is a feature result. It can be a case when the result
+ // of the feature is null, e.g. the feature is modified and has not been executed yet.
+ // The validator returns an invalid result here. The case is an extrusion built on a sketch
+ // feature. A new sketch element creation leads to an empty result.
+ if (!anObject.get())
+ isSketchEntities = false;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+ }
+ }
+ if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
+ AttributeRefListPtr aRefListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+ // all context objects should be sketch entities
+ for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) {
+ ObjectPtr anObject = aRefListAttr->object(i);
+ // a context of the selection attribute is a feature result. It can be a case when the result
+ // of the feature is null, e.g. the feature is modified and has not been executed yet.
+ // The validator returns an invalid result here. The case is an extrusion built on a sketch
+ // feature. A new sketch element creation leads to an empty result.
+ if (!anObject.get())
+ isSketchEntities = false;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+ }
+ }
+ }
+ if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
+ std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ isSketchEntities = false;
+ if (aRef->isObject()) {
+ ObjectPtr anObject = aRef->object();
+ if (anObject.get() != NULL) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ if (aFeature.get() != NULL)
+ isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+ }
+ }
+ }
+ if (!isSketchEntities) {
+ theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr;
+ }
+
+ return isSketchEntities;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_FeatureKind.h
+// Created: 22 March 2015
+// Author: Natalia Ermolaeva
+
+#ifndef GeomValidators_FeatureKind_H
+#define GeomValidators_FeatureKind_H
+
+#include <GeomValidators.h>
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_Attribute.h>
+
+/**
+ * Generic validator for any attribute of a feature.
+ */
+class GeomValidators_FeatureKind : public ModelAPI_AttributeValidator
+{
+public:
+ /// \return True if the attribute is valid. It checks whether the shape is a
+ /// body subshape. Does not allow select construction shapes.
+ /// \param[in] theAttribute an attribute to check
+ /// \param[in] theArguments a filter parameters
+ /// \param[out] theError error message.
+ GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
+#endif
#include <GeomValidators_ShapeType.h>
#include <GeomValidators_ZeroOffset.h>
#include <GeomValidators_IntersectionSelection.h>
+#include <GeomValidators_FeatureKind.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
aFactory->registerValidator("GeomValidators_ZeroOffset", new GeomValidators_ZeroOffset);
aFactory->registerValidator("GeomValidators_BooleanSelection", new GeomValidators_BooleanSelection);
aFactory->registerValidator("GeomValidators_IntersectionSelection", new GeomValidators_IntersectionSelection);
+ aFactory->registerValidator("GeomValidators_FeatureKind", new GeomValidators_FeatureKind);
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
QString aTypesStr = aPropertyTypes.c_str();
QStringList aShapeTypes = aTypesStr.split(' ', QString::SkipEmptyParts);
- myIsUseChoice = theData->getBooleanAttribute("use_choice", true);
+ myIsUseChoice = theData->getBooleanAttribute("use_choice", false);
if (!aShapeTypes.empty())
myTypeCombo->addItems(aShapeTypes);
aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
- aFactory->registerValidator("PartSet_SketchEntityValidator", new PartSet_SketchEntityValidator);
}
void PartSet_Module::registerFilters()
return true;
}
-bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const
-{
- bool isSketchEntities = true;
- std::set<std::string> anEntityKinds;
- std::string anEntityKindsStr;
- std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
- for (; anIt != aLast; anIt++) {
- anEntityKinds.insert(*anIt);
- if (!anEntityKindsStr.empty())
- anEntityKindsStr += ", ";
- anEntityKindsStr += *anIt;
- }
-
- std::string anAttributeType = theAttribute->attributeType();
- if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- // all context objects should be sketch entities
- for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) {
- AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
- ObjectPtr anObject = aSelectAttr->context();
- // a context of the selection attribute is a feature result. It can be a case when the result
- // of the feature is null, e.g. the feature is modified and has not been executed yet.
- // The validator returns an invalid result here. The case is an extrusion built on a sketch
- // feature. A new sketch element creation leads to an empty result.
- if (!anObject.get())
- isSketchEntities = false;
- else {
- FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
- isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
- }
- }
- }
- if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
- AttributeSelectionPtr aSelectAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
- ObjectPtr anObject = aSelectAttr->context();
- // a context of the selection attribute is a feature result. It can be a case when the result
- // of the feature is null, e.g. the feature is modified and has not been executed yet.
- // The validator returns an invalid result here. The case is an extrusion built on a sketch
- // feature. A new sketch element creation leads to an empty result.
- if (!anObject.get())
- isSketchEntities = false;
- else {
- FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
- isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
- }
- }
- if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
- AttributeRefListPtr aRefListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
- // all context objects should be sketch entities
- for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) {
- ObjectPtr anObject = aRefListAttr->object(i);
- // a context of the selection attribute is a feature result. It can be a case when the result
- // of the feature is null, e.g. the feature is modified and has not been executed yet.
- // The validator returns an invalid result here. The case is an extrusion built on a sketch
- // feature. A new sketch element creation leads to an empty result.
- if (!anObject.get())
- isSketchEntities = false;
- else {
- FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
- isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
- }
- }
- }
- if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
- std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- isSketchEntities = false;
- if (aRef->isObject()) {
- ObjectPtr anObject = aRef->object();
- if (anObject.get() != NULL) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
- if (aFeature.get() != NULL)
- isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
- }
- }
- }
- if (!isSketchEntities) {
- theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr;
- }
-
- return isSketchEntities;
-}
-
bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
};
-/**
-* \ingroup Validators
-* A validator which checks that objects selected for feature attributes are different (not the same)
-*/
-class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
-{
- public:
- //! Returns true if the attribute is good for the feature attribute
- //! \param theAttribute an attribute
- //! \param theArguments a list of arguments (names of attributes to check)
- //! \param theError an output error string
- virtual bool isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const;
-};
-
/**\class PartSet_CoincidentAttr
* \ingroup Validators
* \brief Validator to check whether there is a coincident constraint between
return true;
}
-void PartSet_WidgetSketchCreator::activateCustom()
-{
- //if (isSelectionMode()) {
- // ModuleBase_WidgetSelector::activateCustom();
- //connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
-
- //setVisibleSelectionControl(true);
- //}
- //else {
- // setVisibleSelectionControl(false);
- // emit focusOutWidget(this);
- //}
-}
-
void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
{
// hide current widget, activate the next widget
return aShapeTypes;
}
-void PartSet_WidgetSketchCreator::deactivate()
-{
- if (isSelectionMode())
- ModuleBase_WidgetSelector::deactivate();
-}
-
void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
{
ModuleBase_ModelWidget::setEditingMode(isEditing);
bool PartSet_WidgetSketchCreator::isSelectionMode() const
{
- //CompositeFeaturePtr aCompFeature =
- // std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
- //bool aHasSub = aCompFeature->numberOfSubs() > 0;
-
AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
- return !aHasValueInList;//aHasSub || aHasValueInList;
+ return !aHasValueInList;
}
void PartSet_WidgetSketchCreator::onSelectionChanged()
{
QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
- if (startSketchOperation(aSelected)) {
-
- }
- else {// if (aSelected.size() > 1) {
+ if (!startSketchOperation(aSelected)) {
QList<ModuleBase_ViewerPrs>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
bool aProcessed = false;
for (; anIt != aLast; anIt++) {
emit valuesChanged();
updateObject(myFeature);
setVisibleSelectionControl(false);
+ // manually deactivation because the widget was not activated as has no focus acceptin controls
+ deactivate();
emit focusOutWidget(this);
}
}
}
}
}
-//void PartSet_WidgetSketchCreator::onStarted()
-//{
-// disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
-//}
bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues)
{
return aSketchStarted;
aSketchStarted = true;
- // Check that model already has bodies
- /*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- XGUI_Displayer* aDisp = aWorkshop->displayer();
- QObjectPtrList aObjList = aDisp->displayedObjects();
- bool aHasBody = !myUseBody;
- ResultBodyPtr aBody;
- if(!aHasBody) {
- foreach(ObjectPtr aObj, aObjList) {
- aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
- if (aBody.get() != NULL) {
- aHasBody = true;
- break;
- }
- }
- }*/
- //if (aHasBody) {
- // Launch Sketch operation
- CompositeFeaturePtr aCompFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ // manually deactivation because the widget was not activated as has no focus acceptin controls
+ deactivate();
+
+ // Launch Sketch operation
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+
+ /// add sketch feature without current feature change.
+ /// it is important to do not change the current feature in order to
+ /// after sketch edition, the extrusion cut feature becomes current
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->activeDocument();
+ FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
+ FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
+
+ PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(aSketch, aValue);
+
+ aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
+
+ // start edit operation for the sketch
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (myModule->createOperation("Sketch"));
+ if (aFOperation)
+ aFOperation->setFeature(aSketch);
+ myModule->sendOperation(aFOperation);
- /// add sketch feature without current feature change.
- /// it is important to do not change the current feature in order to
- /// after sketch edition, the extrusion cut feature becomes current
- SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->activeDocument();
- FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
- FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
-
- PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(aSketch, aValue);
-
- aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
-
- // start edit operation for the sketch
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
- (myModule->createOperation("Sketch"));
- if (aFOperation)
- aFOperation->setFeature(aSketch);
- myModule->sendOperation(aFOperation);
- //connect(anOperation, SIGNAL(aborted()), aWorkshop->operationMgr(), SLOT(abortAllOperations()));
- //}
- /* else {
- // Break current operation
- std::string anOperationName = feature()->getKind();
- QString aTitle = tr( anOperationName.c_str() );
- QMessageBox::warning(this, aTitle,
- tr("There are no bodies found. Operation aborted."), QMessageBox::Ok);
- ModuleBase_Operation* aOp = myModule->workshop()->currentOperation();
- aOp->abort();
- }*/
return aSketchStarted;
}
if (isSelectionMode()) {
setVisibleSelectionControl(true);
- //CompositeFeaturePtr aCompFeature =
- // std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
- // if (aCompFeature->numberOfSubs() == 0)
- // return ModuleBase_ModelWidget::focusTo();
- //connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
// we need to call activate here as the widget has no focus accepted controls
// if these controls are added here, activate will happens automatically after focusIn()
- ModuleBase_WidgetSelector::activateCustom();
+ activateCustom();
return true;
}
else {
/// \return the state whether the widget can accept the focus
virtual bool focusTo();
- /// The methiod called when widget is deactivated
- virtual void deactivate();
-
/// Editing mode depends on mode of current operation. This value is defined by it.
virtual void setEditingMode(bool isEditing);
virtual bool restoreValueCustom();
- /// The methiod called when widget is activated
- virtual void activateCustom();
-
/// Visualization of the current control or others in PP
/// \param theSelectionControl state whether the control should be shown/hidden
void setVisibleSelectionControl(const bool theSelectionControl);
virtual void onSelectionChanged();
private slots:
- //void onStarted();
-
void onResumed(ModuleBase_Operation* theOp);
private:
{
bool isAccepted = false;
ModuleBase_Operation* aOperation = currentOperation();
+ // to avoid enter processing when operation has not been started yet
if (!aOperation)
- return false;
+ return isAccepted;
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
// only property panel enter is processed in order to do not process enter in application dialogs
bool isPPChild = isChildObject(theObject, aPanel);