SET(PROJECT_HEADERS
PartSet.h
PartSet_Constants.h
+ PartSet_ExternalObjectsMgr.h
PartSet_Module.h
PartSet_Tools.h
PartSet_WidgetSketchLabel.h
PartSet_Validators.h
PartSet_WidgetPoint2d.h
- PartSet_WidgetEditor.h
+ PartSet_WidgetEditor.h
+ PartSet_WidgetMultiSelector.h
PartSet_WidgetPoint2dDistance.h
PartSet_WidgetShapeSelector.h
PartSet_Filters.h
)
SET(PROJECT_SOURCES
+ PartSet_ExternalObjectsMgr.cpp
PartSet_Module.cpp
PartSet_Tools.cpp
PartSet_WidgetSketchLabel.cpp
PartSet_Validators.cpp
- PartSet_WidgetEditor.cpp
+ PartSet_WidgetEditor.cpp
+ PartSet_WidgetMultiSelector.cpp
PartSet_WidgetPoint2d.cpp
PartSet_WidgetPoint2dDistance.cpp
PartSet_WidgetShapeSelector.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_ExternalObjectsMgr.cpp
+// Created: 15 Apr 2015
+// Author: Natalia Ermolaeva
+
+#include "PartSet_ExternalObjectsMgr.h"
+#include "PartSet_Tools.h"
+
+#include <XGUI_Workshop.h>
+
+#include <QString>
+
+PartSet_ExternalObjectsMgr::PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue)
+: myUseExternal(theDefaultValue)
+{
+ QString aIsExternal(theExternal.c_str());
+ if (!aIsExternal.isEmpty()) {
+ QString aStr = aIsExternal.toUpper();
+ myUseExternal = (aStr == "TRUE") || (aStr == "YES");
+ }
+}
+
+ObjectPtr PartSet_ExternalObjectsMgr::externalObject(const ObjectPtr& theSelectedObject,
+ const GeomShapePtr& theShape,
+ const CompositeFeaturePtr& theSketch)
+{
+ ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
+ theSelectedObject, theSketch);
+ if (!aSelectedObject.get()) {
+ // Processing of external (non-sketch) object
+ aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
+ theSelectedObject, theSketch);
+ if (aSelectedObject.get())
+ myExternalObjects.append(aSelectedObject);
+ }
+ return aSelectedObject;
+}
+
+//********************************************************************
+void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature)
+{
+ QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
+ for (; anIt != aLast; anIt++) {
+ ObjectPtr anObject = *anIt;
+ if (anObject.get()) {
+ DocumentPtr aDoc = anObject->document();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ if (aFeature.get() != NULL) {
+ QObjectPtrList anObjects;
+ anObjects.append(aFeature);
+ // the external feature should be removed with all references, sketch feature should be ignored
+ std::set<FeaturePtr> anIgnoredFeatures;
+ anIgnoredFeatures.insert(theSketch);
+ // the current feature should be ignored, because it can use the external feature in the
+ // attributes and, therefore have a references to it. So, the delete functionality tries
+ // to delete this feature. Test case is creation of a constraint on external point,
+ // use in this control after an external point, the point of the sketch.
+ anIgnoredFeatures.insert(theFeature);
+ XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
+ }
+ }
+ }
+ myExternalObjects.clear();
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_ExternalObjectsMgr.h
+// Created: 15 Apr 2015
+// Author: Natalia Ermolaeva
+
+
+#ifndef PartSet_ExternalObjectsMgr_H
+#define PartSet_ExternalObjectsMgr_H
+
+#include "PartSet.h"
+
+#include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Object.h>
+#include <GeomAPI_Shape.h>
+
+#include <ModuleBase_Definitions.h>
+
+#include <string>
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetShapeSelector in order to provide
+* working with sketch specific objects.
+*/
+class PARTSET_EXPORT PartSet_ExternalObjectsMgr
+{
+ public:
+ /// Constructor
+ /// \param theExternal the external state
+ /// \param theDefaultValue the default value for the external object using
+ PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue);
+
+ virtual ~PartSet_ExternalObjectsMgr() {}
+
+ /// Returns the state whether the external object is used
+ bool useExternal() const { return myUseExternal; }
+
+ /// Finds or create and external object
+ /// \param theSelectedObject an object
+ /// \param theShape a selected shape, which is used in the selection attribute
+ /// \param theSketch a current sketch
+ /// \return the object
+ ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
+ const CompositeFeaturePtr& theSketch);
+
+ // Removes the external presentation from the model
+ /// \param theSketch a current sketch
+ /// \param theFeature a current feature
+ void removeExternal(const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature);
+
+protected:
+ /// An external object
+ QObjectPtrList myExternalObjects;
+
+ /// Boolean value about the neccessity of the external object use
+ bool myUseExternal;
+};
+
+#endif
\ No newline at end of file
#include <PartSet_WidgetPoint2d.h>
#include <PartSet_WidgetPoint2dDistance.h>
#include <PartSet_WidgetShapeSelector.h>
+#include <PartSet_WidgetMultiSelector.h>
#include <PartSet_WidgetEditor.h>
#include "PartSet_SketcherMgr.h"
#include "PartSet_MenuMgr.h"
new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
aWgt = aShapeSelectorWgt;
- } if (theType == WDG_DOUBLEVALUE_EDITOR) {
+ } if (theType == "sketch_multi_selector") {
+ PartSet_WidgetMultiSelector* aShapeSelectorWgt =
+ new PartSet_WidgetMultiSelector(theParent, workshop(), theWidgetApi, theParentId);
+ aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+ aWgt = aShapeSelectorWgt;
+ }
+ if (theType == WDG_DOUBLEVALUE_EDITOR) {
aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
}
return aWgt;
FeaturePtr aFeature = myCurrentSelection.begin().key();
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if (aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
+ if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
DataPtr aData = aSPFeature->data();
AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetMultiSelector.cpp
+// Created: 15 Apr 2015
+// Author: Natalia Ermolaeva
+
+#include "PartSet_WidgetMultiSelector.h"
+
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <ModuleBase_Definitions.h>
+#include <Config_WidgetAPI.h>
+
+#include <PartSet_Tools.h>
+#include <PartSet_ExternalObjectsMgr.h>
+#include <SketchPlugin_Feature.h>
+
+#include <SketchPlugin_ConstraintRigid.h>
+
+#include <XGUI_Workshop.h>
+
+PartSet_WidgetMultiSelector::PartSet_WidgetMultiSelector(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
+{
+ myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), false);
+}
+
+PartSet_WidgetMultiSelector::~PartSet_WidgetMultiSelector()
+{
+ delete myExternalObjectMgr;
+}
+
+//********************************************************************
+void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid)
+{
+ ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid);
+ myExternalObjectMgr->removeExternal(sketch(), myFeature);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetMultiSelector.h
+// Created: 15 Apr 2015
+// Author: Natalia Ermolaeva
+
+
+#ifndef PartSet_WidgetMultiSelector_H
+#define PartSet_WidgetMultiSelector_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_WidgetShapeSelector.h>
+
+#include <ModelAPI_CompositeFeature.h>
+
+class PartSet_ExternalObjectsMgr;
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetShapeSelector in order to provide
+* working with sketch specific objects.
+*/
+class PARTSET_EXPORT PartSet_WidgetMultiSelector: public ModuleBase_WidgetShapeSelector
+{
+Q_OBJECT
+ public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theWorkshop instance of workshop interface
+ /// \param theData the widget configuation. The attribute of the model widget is obtained from
+ /// \param theParentId is Id of a parent of the current attribute
+ PartSet_WidgetMultiSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData, const std::string& theParentId);
+
+ virtual ~PartSet_WidgetMultiSelector();
+
+ /// Set sketcher
+ /// \param theSketch a sketcher object
+ void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+
+ /// Retrurns installed sketcher
+ CompositeFeaturePtr sketch() const { return mySketch; }
+
+protected:
+ /// Creates a backup of the current values of the attribute
+ /// It should be realized in the specific widget because of different
+ /// parameters of the current attribute
+ /// \param theValid a boolean flag, if restore happens for valid parameters
+ void restoreAttributeValue(const bool theValid);
+
+protected:
+ PartSet_ExternalObjectsMgr* myExternalObjectMgr;
+ /// Pointer to a sketch
+ CompositeFeaturePtr mySketch;
+};
+
+#endif
\ No newline at end of file
#include <Config_WidgetAPI.h>
#include <PartSet_Tools.h>
+#include <PartSet_ExternalObjectsMgr.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_ConstraintRigid.h>
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const std::string& theParentId)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId), myUseExternal(true)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
{
- QString aIsExternal(theData->getProperty("use_external").c_str());
- if (!aIsExternal.isEmpty()) {
- QString aStr = aIsExternal.toUpper();
- myUseExternal = (aStr == "TRUE") || (aStr == "YES");
- }
+ myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), true);
+}
+
+PartSet_WidgetShapeSelector::~PartSet_WidgetShapeSelector()
+{
+ delete myExternalObjectMgr;
}
bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
// Do check that we can use external feature
- if ((aSPFeature.get() != NULL) && aSPFeature->isExternal() && (!myUseExternal))
+ if ((aSPFeature.get() != NULL) && aSPFeature->isExternal() && (!myExternalObjectMgr->useExternal()))
return false;
- if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myUseExternal) {
- aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
- theSelectedObject, mySketch);
- if (!aSelectedObject.get()) {
- // Processing of external (non-sketch) object
- aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
- theSelectedObject, mySketch);
- if (aSelectedObject.get())
- myExternalObject = aSelectedObject;
- }
+ if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myExternalObjectMgr->useExternal()) {
+ aSelectedObject = myExternalObjectMgr->externalObject(theSelectedObject, theShape, sketch());
} else {
// Processing of sketch object
DataPtr aData = myFeature->data();
void PartSet_WidgetShapeSelector::restoreAttributeValue(const bool theValid)
{
ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid);
- removeExternal();
-}
-
-//********************************************************************
-void PartSet_WidgetShapeSelector::removeExternal()
-{
- if (myExternalObject.get()) {
- DocumentPtr aDoc = myExternalObject->document();
- FeaturePtr aFeature = ModelAPI_Feature::feature(myExternalObject);
- if (aFeature.get() != NULL) {
- QObjectPtrList anObjects;
- anObjects.append(aFeature);
- // the external feature should be removed with all references, sketch feature should be ignored
- std::set<FeaturePtr> anIgnoredFeatures;
- anIgnoredFeatures.insert(sketch());
- // the current feature should be ignored, because it can use the external feature in the
- // attributes and, therefore have a references to it. So, the delete functionality tries
- // to delete this feature. Test case is creation of a constraint on external point,
- // use in this control after an external point, the point of the sketch.
- anIgnoredFeatures.insert(myFeature);
- XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
- }
- myExternalObject = ObjectPtr();
- }
+ myExternalObjectMgr->removeExternal(sketch(), myFeature);
}
#include <ModelAPI_CompositeFeature.h>
+class PartSet_ExternalObjectsMgr;
/**
* \ingroup Modules
PartSet_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData, const std::string& theParentId);
- virtual ~PartSet_WidgetShapeSelector() {}
+ virtual ~PartSet_WidgetShapeSelector();
/// Set sketcher
/// \param theSketch a sketcher object
/// \param theValid a boolean flag, if restore happens for valid parameters
void restoreAttributeValue(const bool theValid);
- // Removes the external presentation from the model
- void removeExternal();
-
protected:
+ PartSet_ExternalObjectsMgr* myExternalObjectMgr;
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
-
- /// An external object
- ObjectPtr myExternalObject;
-
- bool myUseExternal;
};
#endif
\ No newline at end of file