void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
{
+ // the back reference from the previous object to the attribute should be removed
+ ObjectPtr anObject = object();
+ if (anObject.get() && anObject != theObject) {
+ FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ if (anOwnerFeature.get()) {
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
+ anObject->data());
+ aData->removeBackReference(anOwnerFeature, id());
+ }
+ }
+
if (theObject && (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject)) {
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
theObject->data());
myRef->Set(aData->label().Father());
myID->Set(""); // feature is identified by the empty ID
+
+ // do it before the transaction finish to make just created/removed objects know dependencies
+ // and reference from composite feature is removed automatically
+ FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ if (anOwnerFeature.get()) {
+ aData->addBackReference(anOwnerFeature, id(), false);
+ }
owner()->data()->sendAttributeUpdated(this);
} else if (theObject.get() == NULL) {
myRef->Set(myRef->Label()); // reference to itself means that object is null
aRes->setIsConcealed(false);
}
+void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrID)
+{
+ AttributePtr anAttribute = theFeature->data()->attribute(theAttrID);
+ if (myRefsToMe.find(anAttribute) == myRefsToMe.end())
+ return;
+
+ myRefsToMe.erase(anAttribute);
+}
+
void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID,
const bool theApplyConcealment)
{
+ // do not add the same attribute twice
+ AttributePtr anAttribute = theFeature->data()->attribute(theAttrID);
+ if (myRefsToMe.find(anAttribute) != myRefsToMe.end())
+ return;
+
myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
if (theApplyConcealment &&
ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
/// Removes all information about back references
void eraseBackReferences();
/// Adds a back reference (with identifier which attribute references to this object
+ /// It does not change the consealment flag of the data object result
+ /// \param theFeature feature referenced to this
+ /// \param theAttrID identifier of the attribute that is references from theFeature to this
+ void removeBackReference(FeaturePtr theFeature, std::string theAttrID);
+ /// Adds a back reference (with identifier which attribute references to this object
/// \param theFeature feature referenced to this
/// \param theAttrID identifier of the attribute that is references from theFeature to this
/// \param theApplyConcealment applies consealment flag changes
}
// event: feature is deleted
ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
+ // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
+ Events_Loop::loop()->flush(EVENT_DISP);
}
}
\r
#include <QString>\r
#include <QObject>\r
+#include <QMap>\r
\r
#include <string>\r
#include <map>\r
\r
/// Add menu atems for viewer into the given menu\r
/// \param theMenu a popup menu to be shown in the viewer\r
- virtual void addViewerItems(QMenu* theMenu) const {}\r
+ /// \param theStdActions a map of standard actions\r
+ /// \return true if items are added and there is no necessity to provide standard menu\r
+ virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const { return false; }\r
\r
/// Add menu atems for object browser into the given menu\r
/// \param theMenu a popup menu to be shown in the object browser\r
QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
bool isSet = false;
+ // 1. apply the selection to controls
for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
(aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
++aWIt) {
aFilledWgt = aWgt;
}
}
+ // 2. ignore not obligatory widgets
+ for (; aWIt != aWidgets.constEnd(); ++aWIt) {
+ aWgt = (*aWIt);
+ if (aWgt && aWgt->isObligatory())
+ continue;
+ aFilledWgt = aWgt;
+ }
+ // 3. activate the next obligatory widget
myPropertyPanel->activateNextWidget(aFilledWgt);
if (aFilledWgt)
emit activatedByPreselection();
return aCanDisplay;
}
-void PartSet_Module::addViewerItems(QMenu* theMenu) const
+bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
{
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
!PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- return;
+ return false;
ModuleBase_ISelection* aSelection = myWorkshop->selection();
QObjectPtrList aObjects = aSelection->selectedPresentations();
}
}
if (hasFeature) {
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- QAction* anAction = aWorkshop->contextMenuMgr()->action("DELETE_CMD");
- theMenu->addAction(anAction);
+ theMenu->addAction(theStdActions["DELETE_CMD"]);
}
}
bool isAuxiliary;
theMenu->addAction(anAction);
anAction->setChecked(isAuxiliary);
}
+ return true;
}
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
/// Add menu atems for viewer into the given menu
/// \param theMenu a popup menu to be shown in the viewer
- virtual void addViewerItems(QMenu* theMenu) const;
+ /// \param theStdActions a map of standard actions
+ /// \return true if items are added and there is no necessity to provide standard menu
+ virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
public slots:
/// SLOT, that is called by no more widget signal emitted by property panel
return thePoint2D->to3D(aC->pnt(), aX->dir(), aY);
}
-ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape,
- const ObjectPtr& theObject,
- CompositeFeaturePtr theSketch)
+ResultPtr PartSet_Tools::findFixedObjectByExternal(const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch)
{
+ ResultPtr aResult;
if (theShape.ShapeType() == TopAbs_EDGE) {
// Check that we already have such external edge
std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
aInEdge->setImpl(new TopoDS_Shape(theShape));
- ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
- if (aResult)
- return aResult;
+ aResult = findExternalEdge(theSketch, aInEdge);
+ }
+ if (theShape.ShapeType() == TopAbs_VERTEX) {
+ std::shared_ptr<GeomAPI_Vertex> aInVert = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex());
+ aInVert->setImpl(new TopoDS_Shape(theShape));
+ aResult = findExternalVertex(theSketch, aInVert);
+ }
+ return aResult;
+}
- // If not found then we have to create new
+ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch)
+{
+ if (theShape.ShapeType() == TopAbs_EDGE) {
Standard_Real aStart, aEnd;
Handle(V3d_View) aNullView;
FeaturePtr aMyFeature;
}
}
if (theShape.ShapeType() == TopAbs_VERTEX) {
- std::shared_ptr<GeomAPI_Vertex> aInVert = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex());
- aInVert->setImpl(new TopoDS_Shape(theShape));
- ResultPtr aResult = findExternalVertex(theSketch, aInVert);
- if (aResult)
- return aResult;
-
FeaturePtr aMyFeature = theSketch->addFeature(SketchPlugin_Point::ID());
if (aMyFeature) {
static std::shared_ptr<GeomAPI_Pnt> point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
CompositeFeaturePtr theSketch);
+ /// Finds a line (arc or circle) by given edge
+ /// \param theShape an edge
+ /// \param theObject a selected result object
+ /// \param theSketch a sketch feature
+ /// \return result of found feature or NULL
+ static ResultPtr findFixedObjectByExternal(const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch);
+
/// Creates a line (arc or circle) by given edge
/// Created line will have fixed constraint
/// \param theShape an edge
bool PartSet_WidgetConstraintShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
{
- ObjectPtr aSelectedObject = theSelectedObject;
+ // initially the method is wrote to create an external object. Since the parent widget creates it,
+ // the redefinition is not necessary anymore.
+ // TODO: remove the widget and use the parent one insted of it
+ return PartSet_WidgetShapeSelector::setObject(theSelectedObject, theShape);
+ /*ObjectPtr aSelectedObject = theSelectedObject;
FeaturePtr aFeature = ModelAPI_Feature::feature(aSelectedObject);
if (aFeature) {
return false;
}
}
- return ModuleBase_WidgetShapeSelector::setObject(aSelectedObject, theShape);
+ return ModuleBase_WidgetShapeSelector::setObject(aSelectedObject, theShape);*/
}
if (aSelectedFeature.get() != NULL) {
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
- if ((!aSPFeature) && (!aShape.IsNull()))
- PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+ if ((!aSPFeature) && (!aShape.IsNull())) {
+ ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
+ if (!aFixedObject.get())
+ aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+ }
}
double aX, aY;
if (getPoint2d(aView, aShape, aX, aY)) {
#include <PartSet_Tools.h>
#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_ConstraintRigid.h>
+
#include <XGUI_Workshop.h>
PartSet_WidgetShapeSelector::PartSet_WidgetShapeSelector(QWidget* theParent,
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull()) {
- // Processing of external (non-sketch) object
- createExternal(theSelectedObject, theShape);
- if (myExternalObject)
- aSelectedObject = myExternalObject;
- else
- return false;
+ 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;
+ }
} else {
// Processing of sketch object
DataPtr aData = myFeature->data();
removeExternal();
}
-//********************************************************************
-void PartSet_WidgetShapeSelector::createExternal(ObjectPtr theSelectedObject,
- GeomShapePtr theShape)
-{
- ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
- theSelectedObject, mySketch);
- if (aObj != myExternalObject) {
- removeExternal();
- myExternalObject = aObj;
- }
-}
-
//********************************************************************
void PartSet_WidgetShapeSelector::removeExternal()
{
/// \param theValid a boolean flag, if restore happens for valid parameters
void restoreAttributeValue(const bool theValid);
- // Removes the external presentation from the model
- /// \param theSelectedObject an object
- /// \param theShape a selected shape, which is used in the selection attribute
- void createExternal(ObjectPtr theSelectedObject, GeomShapePtr theShape);
-
// Removes the external presentation from the model
void removeExternal();
void SketchPlugin_ConstraintFillet::execute()
{
std::shared_ptr<ModelAPI_Data> aData = data();
+ ResultConstructionPtr aRC;
// Check the base objects are initialized
double aFilletRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
aData->attribute(SketchPlugin_Constraint::VALUE()))->value();
// Check the fillet shapes is not initialized yet
AttributeRefListPtr aRefListOfFillet = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
aData->attribute(SketchPlugin_Constraint::ENTITY_C()));
- if (aRefListOfFillet->size() > 0)
+ if (aRefListOfFillet->size() > 0) {
+ // update the Radius constraint
+ ObjectPtr aFilletArcObj = aRefListOfFillet->list().back();
+ aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFilletArcObj);
+ FeaturePtr aFilletArcFeature = aRC ? aRC->document()->feature(aRC) :
+ std::dynamic_pointer_cast<ModelAPI_Feature>(aFilletArcObj);
+
+ int aNbSubs = sketch()->numberOfSubs();
+ FeaturePtr aSubFeature;
+ for (int aSub = 0; aSub < aNbSubs; aSub++) {
+ aSubFeature = sketch()->subFeature(aSub);
+ if (aSubFeature->getKind() != SketchPlugin_ConstraintRadius::ID())
+ continue;
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+ aSubFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ if (!aRefAttr || !aRefAttr->isObject())
+ continue;
+ aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aRefAttr->object());
+ FeaturePtr aFeature = aRC ? aRC->document()->feature(aRC) :
+ std::dynamic_pointer_cast<ModelAPI_Feature>(aRefAttr->object());
+ if (aFeature == aFilletArcFeature) {
+ AttributeDoublePtr aRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aSubFeature->attribute(SketchPlugin_Constraint::VALUE()));
+ aRadius->setValue(aFilletRadius);
+ }
+ }
return;
+ }
// Obtain features for the base objects
FeaturePtr aFeatureA, aFeatureB;
- ResultConstructionPtr aRC =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseA->object());
+ aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseA->object());
if (aRC) aFeatureA = aRC->document()->feature(aRC);
aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseB->object());
if (aRC) aFeatureB = aRC->document()->feature(aRC);
ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent);
}
- // send events
- ModelAPI_EventCreator::get()->sendUpdated(FeaturePtr(this), anUpdateEvent);
- if (isUpdateFlushed)
- Events_Loop::loop()->setFlushed(anUpdateEvent, true);
- Events_Loop::loop()->flush(anUpdateEvent);
-
// make base features auxiliary
static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
aFeatureA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(true);
aFeatureB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(true);
ModelAPI_EventCreator::get()->sendUpdated(aFeatureA, aRedisplayEvent);
ModelAPI_EventCreator::get()->sendUpdated(aFeatureB, aRedisplayEvent);
- Events_Loop::loop()->flush(aRedisplayEvent);
+//// Events_Loop::loop()->flush(aRedisplayEvent);
+
+ // send events
+ if (isUpdateFlushed)
+ Events_Loop::loop()->setFlushed(anUpdateEvent, true);
+ Events_Loop::loop()->flush(anUpdateEvent);
}
AISObjectPtr SketchPlugin_ConstraintFillet::getAISObject(AISObjectPtr thePrevious)
new SketchPlugin_ExternalValidator);
aFactory->registerValidator("SketchPlugin_TangentAttr",
new SketchPlugin_TangentAttrValidator);
+ aFactory->registerValidator("SketchPlugin_NotFixed",
+ new SketchPlugin_NotFixedValidator);
+ aFactory->registerValidator("SketchPlugin_EqualAttr",
+ new SketchPlugin_EqualAttrValidator);
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
#include "SketchPlugin_Validators.h"
#include "SketchPlugin_ConstraintDistance.h"
#include "SketchPlugin_ConstraintCoincidence.h"
+#include "SketchPlugin_ConstraintRigid.h"
#include "SketchPlugin_Line.h"
#include "SketchPlugin_Arc.h"
+#include "SketchPlugin_Circle.h"
#include "SketcherPrs_Tools.h"
if (aOtherFea->getKind() != SketchPlugin_Arc::ID())
return false;
} else if (aRefFea->getKind() == SketchPlugin_Arc::ID()) {
- if (aOtherFea->getKind() != SketchPlugin_Line::ID())
+ if (aOtherFea->getKind() != SketchPlugin_Line::ID() &&
+ aOtherFea->getKind() != SketchPlugin_Arc::ID())
return false;
} else
return false;
return false;
}
+bool SketchPlugin_NotFixedValidator::isValid(
+ const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
+{
+ std::shared_ptr<SketchPlugin_Feature> aFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
+ if (!aFeature)
+ return true;
+
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ if (!aRefAttr)
+ return false;
+
+ SketchPlugin_Sketch* aSketch = aFeature->sketch();
+ int aNbFeatures = aSketch->numberOfSubs();
+ for (int anInd = 0; anInd < aNbFeatures; anInd++) {
+ FeaturePtr aSubFeature = aSketch->subFeature(anInd);
+ if (aSubFeature->getKind() != SketchPlugin_ConstraintRigid::ID() || aSubFeature == aFeature)
+ continue;
+ AttributeRefAttrPtr aRAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+ aSubFeature->attribute(SketchPlugin_ConstraintRigid::ENTITY_A()));
+ if (aRefAttr->isObject()) {
+ if (aRefAttr->object() == aRAttr->object())
+ return false;
+ } else if (aRefAttr->attr() == aRAttr->attr())
+ return false;
+ }
+ return true;
+}
+
+bool SketchPlugin_EqualAttrValidator::isValid(
+ const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+{
+ std::string aParamA = theArguments.front();
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ AttributeRefAttrPtr aRefAttr[2];
+ aRefAttr[0] = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ if (!aRefAttr)
+ return false;
+ aRefAttr[1] = aFeature->data()->refattr(aParamA);
+
+ if (!aRefAttr[0]->isObject() || !aRefAttr[1]->isObject())
+ return false;
+
+ int aType[2] = {0, 0}; // types of attributes: 0 - incorrect, 1 - line, 2 - circle, 3 - arc
+ std::list<std::string> anArguments;
+ for (int i = 0; i < 2; i++) {
+ ObjectPtr anObject = aRefAttr[i]->object();
+ aFeature = ModelAPI_Feature::feature(anObject);
+ if (!aFeature)
+ return false;
+
+ if (aFeature->getKind() == SketchPlugin_Line::ID()) {
+ aType[i] = 1;
+ continue;
+ }
+ if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+ aType[i] = 2;
+ continue;
+ }
+ if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ aType[i] = 3;
+ continue;
+ }
+ // wrong type of attribute
+ return false;
+ }
+
+ if ((aType[0] == 1 && aType[1] == 2) ||
+ (aType[0] == 2 && aType[1] == 1))
+ return false;
+ return true;
+}
};
+/**\class SketchPlugin_NotFixed
+ * \ingroup Validators
+ * \brief Validator for the rigid constraint input.
+ *
+ * It just checks there is no rigid constraint for the current feature.
+ */
+class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
+{
+ public:
+ //! returns true if attribute is not used in another rigid constraint
+ //! \param theAttribute the checked attribute
+ //! \param theArguments arguments of the attribute
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments) const;
+};
+
+/**\class SketchPlugin_EqualAttrValidator
+ * \ingroup Validators
+ * \brief Validator for the equal constraint input.
+ *
+ * It checks that attributes of the Equal constraint are correct.
+ */
+class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
+{
+ public:
+ //! returns true if attribute is valid
+ //! \param theAttribute the checked attribute
+ //! \param theArguments arguments of the attribute
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments) const;
+};
+
+
#endif
<shape_selector id="ConstraintEntityA" label="Object" tooltip="Select an object"
shape_types="edge vertex">
<validator id="PartSet_SketchEntityValidator" parameters="SketchPoint,SketchLine,SketchCircle,SketchArc"/>
+ <validator id="SketchPlugin_NotFixed"/>
</shape_selector>
<validator id="PartSet_RigidValidator"/>
</feature>
</feature>
<!-- SketchConstraintEqual -->
- <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects" icon=":icons/equal.png">
+ <feature id="SketchConstraintEqual" title="Equal"
+ tooltip="Create constraint defining equal lengths of two lines or line and arc or equal radii of two arcs or two circles or arc and circle"
+ icon=":icons/equal.png">
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select line, circle or arc" shape_types="edge">
</sketch_constraint_shape_selector>
<sketch_constraint_shape_selector id="ConstraintEntityB"
label="Last object" tooltip="Select line, circle or arc" shape_types="edge">
- <validator id="PartSet_SameTypeAttr" parameters="ConstraintEntityA"/>
+ <validator id="SketchPlugin_EqualAttr" parameters="ConstraintEntityA"/>
<validator id="PartSet_DifferentObjects"/>
</sketch_constraint_shape_selector>
</feature>
label="Last object" tooltip="Select line or arc" shape_types="edge">
</sketch_constraint_shape_selector>
- <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" default="0" min="0">
+ <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" default="1" min="0" obligatory="0">
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
</feature>
std::list<ObjectPtr> aBaseList = aBaseRefList->list();
std::list<ObjectPtr> aMirroredList = aMirroredRefList->list();
+ // remove all empty items
+ std::list<ObjectPtr>::iterator anIt = aBaseList.begin();
+ std::list<ObjectPtr>::iterator aTmpIt;
+ while (anIt != aBaseList.end()) {
+ aTmpIt = anIt;
+ anIt++;
+ if (!(*aTmpIt))
+ aBaseList.erase(aTmpIt);
+ }
+ anIt = aMirroredList.begin();
+ while (anIt != aMirroredList.end()) {
+ aTmpIt = anIt;
+ anIt++;
+ if (!(*aTmpIt))
+ aMirroredList.erase(aTmpIt);
+ }
if (aBaseList.empty() || aBaseList.size() != aMirroredList.size())
return false;
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Root.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Select3D_SensitivePoint.hxx>
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject);
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
{
+
}
return;
std::shared_ptr<GeomAPI_Pnt> aPoint = myPlane->to3D(aPnt->x(), aPnt->y());
-
- static Handle(Graphic3d_AspectMarker3d) aPtA = new Graphic3d_AspectMarker3d ();
- aPtA->SetType(Aspect_TOM_RING1);
- aPtA->SetScale(2.);
- aPtA->SetColor(myOwnColor);
+ myPoint = aPoint->impl<gp_Pnt>();
+
+ static Handle(Graphic3d_AspectMarker3d) aPtA;
+ if (aPtA.IsNull()) {
+ aPtA = new Graphic3d_AspectMarker3d ();
+ aPtA->SetType(Aspect_TOM_RING1);
+ aPtA->SetScale(2.);
+ aPtA->SetColor(myOwnColor);
+ }
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
aGroup->SetPrimitivesAspect(aPtA);
Handle(Graphic3d_ArrayOfPoints) aPntArray = new Graphic3d_ArrayOfPoints(1);
void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
+ Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10);
+ Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint);
+ aSelection->Add(aSp);
}
void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
private:
ModelAPI_Feature* myConstraint;
std::shared_ptr<GeomAPI_Ax3> myPlane;
+ gp_Pnt myPoint;
};
void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
{
- XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
- if (aObjects.size() > 0) {
- //if (aObjects.size() == 1)
- // theMenu->addAction(action("EDIT_CMD"));
- bool isVisible = false;
- bool isShading = false;
- bool canBeShaded = false;
- foreach(ObjectPtr aObject, aObjects)
- {
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
- if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
- isVisible = true;
- canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
- isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
- break;
+ bool aIsDone = false;
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aIsDone = aModule->addViewerItems(theMenu, myActions);
+
+ if (!aIsDone) {
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
+ if (aObjects.size() > 0) {
+ //if (aObjects.size() == 1)
+ // theMenu->addAction(action("EDIT_CMD"));
+ bool isVisible = false;
+ bool isShading = false;
+ bool canBeShaded = false;
+ foreach(ObjectPtr aObject, aObjects)
+ {
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
+ isVisible = true;
+ canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
+ isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
+ break;
+ }
}
+ if (isVisible) {
+ if (canBeShaded) {
+ if (isShading)
+ theMenu->addAction(action("WIREFRAME_CMD"));
+ else
+ theMenu->addAction(action("SHADING_CMD"));
+ }
+ theMenu->addSeparator();
+ theMenu->addAction(action("SHOW_ONLY_CMD"));
+ theMenu->addAction(action("HIDE_CMD"));
+ } else
+ theMenu->addAction(action("SHOW_CMD"));
+ //theMenu->addAction(action("DELETE_CMD"));
}
- if (isVisible) {
- if (canBeShaded) {
- if (isShading)
- theMenu->addAction(action("WIREFRAME_CMD"));
- else
- theMenu->addAction(action("SHADING_CMD"));
- }
- theMenu->addSeparator();
- theMenu->addAction(action("SHOW_ONLY_CMD"));
- theMenu->addAction(action("HIDE_CMD"));
- } else
- theMenu->addAction(action("SHOW_CMD"));
- //theMenu->addAction(action("DELETE_CMD"));
+ if (myWorkshop->canChangeColor())
+ theMenu->addAction(action("COLOR_CMD"));
+ if (myWorkshop->displayer()->objectsCount() > 0)
+ theMenu->addAction(action("HIDEALL_CMD"));
}
- if (myWorkshop->displayer()->objectsCount() > 0)
- theMenu->addAction(action("HIDEALL_CMD"));
if (!myWorkshop->isSalomeMode()) {
theMenu->addSeparator();
QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
aSubMenu->addActions(aMDI->actions());
}
}
- if (myWorkshop->canChangeColor())
- theMenu->addAction(action("COLOR_CMD"));
- ModuleBase_IModule* aModule = myWorkshop->module();
- if (aModule)
- aModule->addViewerItems(theMenu);
}
void XGUI_ContextMenuMgr::connectObjectBrowser() const
// Redisplay the visible object or the object of the current operation
bool isVisibleObject = myDisplayer->isVisible(aObj);
#ifdef DEBUG_FEATURE_REDISPLAY
- QString anObjInfo = objectInfo((aObj));
- qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
+ //QString anObjInfo = objectInfo((aObj));
+ //qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
#endif
if (isVisibleObject) { // redisplay visible object
//bool aHasPart = false;
bool isDisplayed = false;
for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
-
+ ObjectPtr anObject = *aIt;
+ // the validity of the data should be checked here in order to avoid display of the objects,
+ // which were created, then deleted, but flush for the creation event happens after that
+ if (!anObject->data() || !anObject->data()->isValid())
+ continue;
//ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
//if (aPart) {
//aHasPart = true;