string anID = aData->id(theAttr);
if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
return; // nothing is changed
+ REMOVE_BACK_REF(theAttr->owner());
myRef->Set(aData->label().Father());
myID->Set(aData->id(theAttr).c_str());
+ ADD_BACK_REF(theAttr->owner());
owner()->data()->sendAttributeUpdated(this);
}
{
// 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)) {
+ REMOVE_BACK_REF(anObject);
+
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
theObject->data());
myRef->Set(aData->label().Father());
if (anOwnerFeature.get()) {
aData->addBackReference(anOwnerFeature, id(), false);
}
+ ADD_BACK_REF(theObject);
owner()->data()->sendAttributeUpdated(this);
} else if (theObject.get() == NULL) {
+ REMOVE_BACK_REF(anObject);
myRef->Set(myRef->Label()); // reference to itself means that object is null
myID->Set(""); // feature is identified by the empty ID
owner()->data()->sendAttributeUpdated(this);
myRef->Append(aData->label().Father()); // store label of the object
// 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());
- }
+ ADD_BACK_REF(theObject);
owner()->data()->sendAttributeUpdated(this);
}
ObjectPtr anObj = aDoc->object(aLIter.Value());
if (anObj.get() == NULL) {
myRef->Remove(aLIter.Value());
+ REMOVE_BACK_REF(theObject);
break;
}
}
{
if(!theObject)
return;
- if (!myIsInitialized || value() != theObject) {
+ ObjectPtr aValue = value();
+ if (!myIsInitialized || aValue != theObject) {
+ REMOVE_BACK_REF(aValue);
+
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
- theObject->data());
+ theObject->data());
TDF_Label anObjLab = aData->label().Father(); // object label
if (owner()->document() == theObject->document()) { // same document, use reference attribute
}
// 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);
- }
+ ADD_BACK_REF(theObject);
owner()->data()->sendAttributeUpdated(this);
}
if (theSubShape.get() && !theSubShape->isNull() && theSubShape->isEdge()) {
const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
if (aSubShape.ShapeType() == TopAbs_EDGE)
- isDegeneratedEdge = BRep_Tool::Degenerated(TopoDS::Edge(aSubShape));
+ isDegeneratedEdge = BRep_Tool::Degenerated(TopoDS::Edge(aSubShape)) == Standard_True;
}
if (!theContext.get() || isDegeneratedEdge) {
// to keep the reference attribute label
const bool theApplyConcealment = true);
};
+/// Generic method to register back reference, used in referencing attributes.
+/// Without concealment change, it will be done later, on synchronization.
+#define ADD_BACK_REF(TARGET) \
+ if (TARGET.get() != NULL) { \
+ FeaturePtr anAttributeOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner()); \
+ if (anAttributeOwnerFeature.get()) { \
+ std::shared_ptr<Model_Data> aTargetData = std::dynamic_pointer_cast<Model_Data>( \
+ (TARGET)->data()); \
+ aTargetData->addBackReference(anAttributeOwnerFeature, id(), false); \
+ } \
+ }
+
+/// Generic method to unregister back reference, used in referencing attributes.
+/// Without concealment change, it will be done later, on synchronization.
+#define REMOVE_BACK_REF(TARGET) \
+ if (TARGET.get() != NULL) { \
+ FeaturePtr anAttOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner()); \
+ if (anAttOwnerFeature.get()) { \
+ std::shared_ptr<Model_Data> aTargetData = std::dynamic_pointer_cast<Model_Data>( \
+ (TARGET)->data()); \
+ aTargetData->removeBackReference(anAttOwnerFeature, id()); \
+ } \
+ }
+
#endif
// the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
- ModuleBase_ISelection* aSel = aConnector->selection();
+ ModuleBase_ISelection* aSel = workshop()->selection();
QObjectPtrList aSelectedObj = aSel->selectedPresentations();
// if there are no selected objects in the viewer, that means that the selection in another
// place cased this method. It is necessary to return the false value to understande in above
/// \param isChecked if true, the feature is a construction
void setAuxiliary(const bool isChecked);
-
+ /// Returns state of constraints showing flag
bool isConstraintsShown() const { return myIsConstraintsShown; }
#include <GeomAPI_XYZ.h>
#include <SketchPlugin_Sketch.h>
+#include <SketcherPrs_Tools.h>
#include <Precision.hxx>
#include <gp_Pln.hxx>
// Get default selection modes
QIntList aModes;
- aModes.append(AIS_DSM_Text);
- aModes.append(AIS_DSM_Line);
+ aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
+ aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
+ aModes.append(SketcherPrs_Tools::Sel_Constraint);
aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine) {
- aPnt_B = aPoint_B->pnt();
- aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
- }
+ //std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+ // aData, SketchPlugin_Constraint::ENTITY_A());
+ //if (aLine) {
+ // aPnt_B = aPoint_B->pnt();
+ // aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
+ //}
} else if (aPoint_A && !aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine) {
- aPnt_A = aPoint_A->pnt();
- aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
- }
+ //std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+ // aData, SketchPlugin_Constraint::ENTITY_B());
+ //if (aLine) {
+ // aPnt_A = aPoint_A->pnt();
+ // aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
+ //}
}
if (!aPnt_A || !aPnt_B)
return false;
if (aPointA && aPointB) { // both points
aDistance = aPointA->pnt()->distance(aPointB->pnt());
} else {
- if (!aPointA && aPointB) { //Line and point
- std::shared_ptr<SketchPlugin_Line> aLine =
- SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine) {
- aDistance = aLine->distanceToPoint(aPointB->pnt());
- }
- } else if (aPointA && !aPointB) { // Point and line
- std::shared_ptr<SketchPlugin_Line> aLine =
- SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine) {
- aDistance = aLine->distanceToPoint(aPointA->pnt());
- }
- }
+// if (!aPointA && aPointB) { //Line and point
+// std::shared_ptr<SketchPlugin_Line> aLine =
+// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+// if (aLine) {
+// aDistance = aLine->distanceToPoint(aPointB->pnt());
+// }
+// } else if (aPointA && !aPointB) { // Point and line
+// std::shared_ptr<SketchPlugin_Line> aLine =
+// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
+// if (aLine) {
+// aDistance = aLine->distanceToPoint(aPointA->pnt());
+// }
+// }
}
return aDistance;
}
#include <Config_PropManager.h>
#include <Events_Loop.h>
+static const std::string PREVIOUS_VALUE("FilletPreviousRadius");
+
/// \brief Attract specified point on theNewArc to the attribute of theFeature
static void recalculateAttributes(FeaturePtr theNewArc, const std::string& theNewArcAttribute,
FeaturePtr theFeature, const std::string& theFeatureAttribute);
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId());
+ data()->addAttribute(PREVIOUS_VALUE, ModelAPI_AttributeDouble::typeId());
// initialize attribute not applicable for user
data()->attribute(SketchPlugin_Constraint::ENTITY_C())->setInitialized();
+ data()->attribute(PREVIOUS_VALUE)->setInitialized();
+ std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(PREVIOUS_VALUE))->setValue(0.0);
}
void SketchPlugin_ConstraintFillet::execute()
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);
+ // Update radius constraint only if the value is changed in fillet's attribute
+ double aPrevRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(PREVIOUS_VALUE))->value();
+ if (aFilletRadius != aPrevRadius) {
+ AttributeDoublePtr aRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aSubFeature->attribute(SketchPlugin_Constraint::VALUE()));
+ aRadius->setValue(aFilletRadius);
+ std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(PREVIOUS_VALUE))->setValue(aFilletRadius);
+ }
+ break;
}
}
return;
return aDelta;
}
+const std::string& SketchPlugin_Line::getKind()
+{
+ static std::string MY_KIND = SketchPlugin_Line::ID();
+ return MY_KIND;
+}
+
bool SketchPlugin_Line::isFixed() {
return data()->selection(EXTERNAL_ID())->context().get() != NULL;
}
}
/// Returns the kind of a feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
- {
- static std::string MY_KIND = SketchPlugin_Line::ID();
- return MY_KIND;
- }
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind();
/// Returns true is sketch element is under the rigid constraint
SKETCHPLUGIN_EXPORT virtual bool isFixed();
std::dynamic_pointer_cast<GeomDataAPI_Point>(aConstrAttr->attr());
std::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aConstrAttr->attr());
- std::shared_ptr<SketchPlugin_Point> aSketchPoint =
- std::dynamic_pointer_cast<SketchPlugin_Point>(aFeature);
- if (aPoint || aPoint2D || aSketchPoint) {
+ if (aPoint || aPoint2D || aFeature->getKind() == SketchPlugin_Point::ID()) {
// Create SolveSpace constraint structure
Slvs_Constraint aConstraint = Slvs_MakeConstraint(
++myConstrMaxID, myID, aConstrType, myWorkplane.h, 0.0,
#include <GeomAPI_Dir.h>
#include <GeomAPI_Pnt2d.h>
-#include <SketchPlugin_Point.h>
-#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Constraint.h>
#include <AIS_Drawer.hxx>
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject);
-SketcherPrs_Coincident::SketcherPrs_Coincident(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
{
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);
+ if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
+ 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)
#define SketcherPrs_Coincident_H
#include <GeomAPI_Ax3.h>
+#include <ModelAPI_Feature.h>
#include <AIS_InteractiveObject.hxx>
#include <Standard_DefineHandle.hxx>
-class SketchPlugin_Constraint;
-
DEFINE_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject)
public:
/// Constructor
/// \param theResult a result object
- Standard_EXPORT SketcherPrs_Coincident(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Coincident(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
Standard_EXPORT virtual void SetColor(const Quantity_Color& aColor);
const Standard_Integer aMode) ;
private:
- SketchPlugin_Constraint* myConstraint;
+ ModelAPI_Feature* myConstraint;
std::shared_ptr<GeomAPI_Ax3> myPlane;
gp_Pnt myPoint;
};
static Handle(Image_AlienPixMap) MyPixMap;
-SketcherPrs_Equal::SketcherPrs_Equal(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Equal::SketcherPrs_Equal(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
#include "SketcherPrs_SymbolPrs.h"
-class SketchPlugin_Constraint;
-class SketchPlugin_Sketch;
-
DEFINE_STANDARD_HANDLE(SketcherPrs_Equal, SketcherPrs_SymbolPrs)
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_Equal(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Equal(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
DEFINE_STANDARD_RTTI(SketcherPrs_Equal)
protected:
#include "SketcherPrs_LengthDimension.h"
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
-AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
+AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
const std::shared_ptr<GeomAPI_Ax3>& thePlane) \
{ \
std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
-AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
+AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
{
std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
return aAISObj;
}
-AISObjectPtr SketcherPrs_Factory::verticalConstraint(SketchPlugin_Constraint* theConstraint,
+AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
{
std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
#include "SketcherPrs.h"
+#include <ModelAPI_Feature.h>
+
#include <GeomAPI_Ax3.h>
#include <GeomAPI_AISObject.h>
-class SketchPlugin_Constraint;
-
#define GET_CONSTRAINT_PRS(NAME) \
- static AISObjectPtr NAME(SketchPlugin_Constraint* theConstraint, \
+ static AISObjectPtr NAME(ModelAPI_Feature* theConstraint, \
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
static Handle(Image_AlienPixMap) MyPixMap;
-SketcherPrs_HVDirection::SketcherPrs_HVDirection(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_HVDirection::SketcherPrs_HVDirection(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane,
bool isHorisontal)
: SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsHorisontal(isHorisontal)
#define SketcherPrs_HVDirection_H
#include "SketcherPrs_SymbolPrs.h"
-
-class SketchPlugin_Constraint;
-class SketchPlugin_Sketch;
+#include <ModelAPI_Feature.h>
DEFINE_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs)
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_HVDirection(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_HVDirection(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane,
bool isHorisontal);
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension);
-SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln),
myConstraint(theConstraint), myPlane(thePlane)
aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+ FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
aData, SketchPlugin_Constraint::ENTITY_A());
if (aLine) {
aPnt_B = aPoint_B->pnt();
aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
}
} else if (aPoint_A && !aPoint_B) {
- std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
+ FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
aData, SketchPlugin_Constraint::ENTITY_B());
if (aLine) {
aPnt_A = aPoint_A->pnt();
}
return false;
}
+
+
+
+void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer theMode)
+{
+ Standard_Integer aMode;
+ switch (theMode) {
+ case SketcherPrs_Tools::Sel_Dimension_All:
+ aMode = 0;
+ break;
+ case SketcherPrs_Tools::Sel_Dimension_Line:
+ aMode = 1;
+ break;
+ case SketcherPrs_Tools::Sel_Dimension_Text:
+ aMode = 2;
+ break;
+ default:
+ aMode = theMode;
+ }
+ AIS_LengthDimension::ComputeSelection(aSelection, aMode);
+}
#define SketcherPrs_LinearDimension_H
#include <GeomAPI_Ax3.h>
+#include <ModelAPI_Feature.h>
#include <AIS_LengthDimension.hxx>
#include <Standard_DefineHandle.hxx>
-class SketchPlugin_Constraint;
-
DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
/**
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_LengthDimension(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
std::string constraintType() const;
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+ /// Redefinition of virtual function
+ Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer aMode);
+
private:
bool getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2) const;
/// Constraint feature
- SketchPlugin_Constraint* myConstraint;
+ ModelAPI_Feature* myConstraint;
/// Plane of the current sketcher
std::shared_ptr<GeomAPI_Ax3> myPlane;
static Handle(Image_AlienPixMap) MyPixMap;
-SketcherPrs_Parallel::SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Parallel::SketcherPrs_Parallel(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
#include "SketcherPrs_SymbolPrs.h"
-class SketchPlugin_Constraint;
-class SketchPlugin_Sketch;
-
DEFINE_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs)
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_Parallel(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Parallel(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
DEFINE_STANDARD_RTTI(SketcherPrs_Parallel)
protected:
static Handle(Image_AlienPixMap) MyPixMap;
-SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Perpendicular(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
DEFINE_STANDARD_RTTI(SketcherPrs_Perpendicular)
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Radius, AIS_RadiusDimension);
-SketcherPrs_Radius::SketcherPrs_Radius(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), myPlane(thePlane)
{
AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);
}
+
+void SketcherPrs_Radius::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer theMode)
+{
+ Standard_Integer aMode;
+ switch (theMode) {
+ case SketcherPrs_Tools::Sel_Dimension_All:
+ aMode = 0;
+ break;
+ case SketcherPrs_Tools::Sel_Dimension_Line:
+ aMode = 1;
+ break;
+ case SketcherPrs_Tools::Sel_Dimension_Text:
+ aMode = 2;
+ break;
+ default:
+ aMode = theMode;
+ }
+ AIS_RadiusDimension::ComputeSelection(aSelection, aMode);
+}
#define SketcherPrs_Radius_H
#include <GeomAPI_Ax3.h>
+#include <ModelAPI_Feature.h>
#include <AIS_RadiusDimension.hxx>
#include <Standard_DefineHandle.hxx>
-class SketchPlugin_Constraint;
-
DEFINE_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension)
/**
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_Radius(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
DEFINE_STANDARD_RTTI(SketcherPrs_Radius)
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+ /// Redefinition of virtual function
+ Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+ const Standard_Integer aMode);
+
private:
/// Constraint feature
- SketchPlugin_Constraint* myConstraint;
+ ModelAPI_Feature* myConstraint;
/// Plane of the current sketcher
std::shared_ptr<GeomAPI_Ax3> myPlane;
-SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Rigid::SketcherPrs_Rigid(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
#include "SketcherPrs_SymbolPrs.h"
#include <ModelAPI_Object.h>
-
-class SketchPlugin_Constraint;
-class SketchPlugin_Sketch;
+#include <ModelAPI_Feature.h>
DEFINE_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs)
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Rigid(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
std::map<const char*, Handle(Image_AlienPixMap)> SketcherPrs_SymbolPrs::myIconsMap;
-SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
{
void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
- ClearSelected();
- for (int i = 1; i <= mySPoints.Length(); i++)
- aSelection->Add(mySPoints.Value(i));
+ //ClearSelected();
+ if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
+ for (int i = 1; i <= mySPoints.Length(); i++)
+ aSelection->Add(mySPoints.Value(i));
+ }
}
#define SketcherPrs_SymbolPrs_H
#include "SketcherPrs_SensitivePoint.h"
+#include <ModelAPI_Feature.h>
#include <AIS_InteractiveObject.hxx>
#include <GeomAPI_Ax3.h>
#include <OpenGl_Workspace.hxx>
-class SketchPlugin_Constraint;
class OpenGl_Context;
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
virtual ~SketcherPrs_SymbolPrs();
Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
- Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
+ Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }
Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
protected:
/// Constraint feature
- SketchPlugin_Constraint* myConstraint;
+ ModelAPI_Feature* myConstraint;
/// Plane of the current sketcher
std::shared_ptr<GeomAPI_Ax3> myPlane;
static Handle(Image_AlienPixMap) MyPixMap;
-SketcherPrs_Tangent::SketcherPrs_Tangent(SketchPlugin_Constraint* theConstraint,
+SketcherPrs_Tangent::SketcherPrs_Tangent(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: SketcherPrs_SymbolPrs(theConstraint, thePlane)
{
#define SketcherPrs_Tangent_H
#include "SketcherPrs_SymbolPrs.h"
-
-class SketchPlugin_Constraint;
-class SketchPlugin_Sketch;
+#include <ModelAPI_Feature.h>
DEFINE_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs)
/// Constructor
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
- Standard_EXPORT SketcherPrs_Tangent(SketchPlugin_Constraint* theConstraint,
+ Standard_EXPORT SketcherPrs_Tangent(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
DEFINE_STANDARD_RTTI(SketcherPrs_Tangent)
namespace SketcherPrs_Tools {
-ObjectPtr getResult(SketchPlugin_Constraint* theFeature, const std::string& theAttrName)
+ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
{
std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
}
-std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
- const std::string& theAttribute)
+std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
+ const std::string& theAttribute)
{
std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
}
//*************************************************************************************
-std::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
- const std::string& theAttribute)
+FeaturePtr getFeatureLine(DataPtr theData,
+ const std::string& theAttribute)
{
- std::shared_ptr<SketchPlugin_Line> aLine;
+ FeaturePtr aLine;
if (!theData)
return aLine;
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
+ std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
if (anAttr) {
FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
if (aFeature && aFeature->getKind() == SketchPlugin_Line::ID()) {
- aLine = std::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+ return aFeature;
}
}
return aLine;
}
//*************************************************************************************
-std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
- const std::shared_ptr<SketchPlugin_Line>& theLine,
- const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const FeaturePtr theLine,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
- std::shared_ptr<ModelAPI_Data> aData = theLine->data();
+ DataPtr aData = theLine->data();
std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_Line::START_ID()));
std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
MyArrowSize = theSize;
}
-};
\ No newline at end of file
+};
#include <GeomAPI_Shape.h>
#include <GeomAPI_Pnt2d.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_Feature.h>
#include <string>
-class SketchPlugin_Constraint;
-class SketchPlugin_Line;
class GeomDataAPI_Point2D;
#define MyTextHeight 20
namespace SketcherPrs_Tools {
- SKETCHERPRS_EXPORT ObjectPtr getResult(SketchPlugin_Constraint* theFeature,
- const std::string& theAttrName);
+/// Enumeration with modes for activation of selection custom presentations
+enum SelectionModes {
+ /// Start of enumeration
+ Sel_Mode_First = 100,
+
+ /// Selection mode for all constraints exclude dimensions
+ Sel_Constraint,
+
+ /// Selection mode for whole dimension
+ Sel_Dimension_All,
+
+ /// Selection mode for line of dimension
+ Sel_Dimension_Line,
+
+ /// Selection mode foe text of dimension
+ Sel_Dimension_Text
+};
+
+ SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
+ const std::string& theAttrName);
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
- SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(SketchPlugin_Constraint* theFeature,
+ SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
const std::string& theAttrName);
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
- const std::shared_ptr<SketchPlugin_Line>& theLine,
+ const FeaturePtr theLine,
const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
- SKETCHERPRS_EXPORT std::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
- const std::string& theAttribute);
+ SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
+ const std::string& theAttribute);
/// Obtain the point object from specified constraint parameter
SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
SKETCHERPRS_EXPORT void setArrowSize(double theSize);
};
-#endif
\ No newline at end of file
+#endif
// Convert shape types to selection types
QIntList aModes;
foreach(int aType, theTypes) {
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
+ if (aType > TopAbs_SHAPE)
+ aModes.append(aType);
+ else
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
}
aDisp->activateObjects(aModes);
//TODO: We have to open Local context because at neutral point filters don't work (bug 25340)