GeomAPI_ProjectPointOnCurve aProj(aPoint, aCircle);
Standard_Integer aNbPoint = aProj.NbPoints();
if (aNbPoint > 0) {
- double aMinDistance = 0, aDistance;
+ double aMinDistance = Precision::Infinite(), aDistance;
for (Standard_Integer j = 1; j <= aNbPoint; j++) {
gp_Pnt aNewPoint = aProj.Point(j);
aDistance = aNewPoint.Distance(aPoint);
- if (!aMinDistance || aDistance < aMinDistance) {
+ if (aDistance < aMinDistance) {
aMinDistance = aDistance;
aResult = std::shared_ptr<GeomAPI_Pnt>(
new GeomAPI_Pnt(aNewPoint.X(), aNewPoint.Y(), aNewPoint.Z()));
// return;
ObjectPtr aValue = value();
if (!myIsInitialized || aValue != theObject) {
- myIsInitialized = true;
REMOVE_BACK_REF(aValue);
TDF_Label anObjLab;
ObjectPtr Model_AttributeReference::value()
{
- if (isInitialized()) {
- Handle(TDataStd_Comment) aDocID;
- if (myRef->Label().FindAttribute(TDataStd_Comment::GetID(), aDocID)) { // external ref
- int anID = atoi(TCollection_AsciiString(aDocID->Get()).ToCString());
- DocumentPtr aRefDoc = Model_Application::getApplication()->document(anID);
- if (aRefDoc.get()) {
- Handle(TDataStd_AsciiString) anEntry;
- if (myRef->Label().FindAttribute(TDataStd_AsciiString::GetID(), anEntry)) {
- std::shared_ptr<Model_Document> aDR = std::dynamic_pointer_cast<Model_Document>(aRefDoc);
- TDF_Label aRefLab;
- TDF_Tool::Label(aDR->objects()->featuresLabel().Data(), anEntry->Get().ToCString(), aRefLab);
- if (!aRefLab.IsNull()) {
- return aDR->objects()->object(aRefLab);
- }
+ Handle(TDataStd_Comment) aDocID;
+ if (myRef->Label().FindAttribute(TDataStd_Comment::GetID(), aDocID)) { // external ref
+ int anID = atoi(TCollection_AsciiString(aDocID->Get()).ToCString());
+ DocumentPtr aRefDoc = Model_Application::getApplication()->document(anID);
+ if (aRefDoc.get()) {
+ Handle(TDataStd_AsciiString) anEntry;
+ if (myRef->Label().FindAttribute(TDataStd_AsciiString::GetID(), anEntry)) {
+ std::shared_ptr<Model_Document> aDR = std::dynamic_pointer_cast<Model_Document>(aRefDoc);
+ TDF_Label aRefLab;
+ TDF_Tool::Label(aDR->objects()->featuresLabel().Data(), anEntry->Get().ToCString(), aRefLab);
+ if (!aRefLab.IsNull()) {
+ return aDR->objects()->object(aRefLab);
}
}
- } else { // internal ref
- std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
- owner()->document());
- if (aDoc) {
- TDF_Label aRefLab = myRef->Get();
- if (!aRefLab.IsNull()) { // it may happen with old document, issue #285
- return aDoc->objects()->object(aRefLab);
- }
+ }
+ } else { // internal ref
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+ owner()->document());
+ if (aDoc) {
+ TDF_Label aRefLab = myRef->Get();
+ if (!aRefLab.IsNull()) { // it may happen with old document, issue #285
+ return aDoc->objects()->object(aRefLab);
}
}
}
- // not initialized
return FeaturePtr();
}
#include <ModelGeomAlgo_Point2D.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_Constraint.h>
#include <SketchPlugin_Point.h>
#include <ModuleBase_IViewWindow.h>
}
}
+//********************************************************************
+bool PartSet_WidgetSubShapeSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
+{
+ bool aResult = ModuleBase_WidgetSelector::setSelectionCustom(thePrs);
+
+ //if (aResult)
+ //GeomShapePtr aBaseShape = *anIt;
+ // myCurrentSubShape->setShape(aBaseShape);
+
+ FeaturePtr aFeature = feature();
+ AttributePoint2DPtr anAPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ AttributePoint2DPtr aBPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFeature->attribute(SketchPlugin_Constraint::ENTITY_B()));
+
+
+ //GeomDataAPI_Point2D anAPointAttr = aFeature->attribute(SketchPlugin_Constraint::ENTITY_A())
+ //data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), GeomDataAPI_Point2D::typeId());
+ //data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), GeomDataAPI_Point2D::typeId());
+
+ return aResult;
+}
+
//********************************************************************
void PartSet_WidgetSubShapeSelector::getHighlighted(
QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues)
/// \param theValues a list of presentations
virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
+ /// Fills the attribute with the value of the selected owner
+ /// \param thePrs a selected owner
+ virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+
protected:
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
//#include <GeomAPI_Lin2d.h>
//#include <GeomAPI_Pnt2d.h>
//#include <GeomAPI_XY.h>
-//#include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Point2D.h>
//#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeReference.h>
//#include <ModelAPI_AttributeRefList.h>
void SketchPlugin_ConstraintSplit::initAttributes()
{
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), GeomDataAPI_Point2D::typeId());
//data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
//data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttrList::typeId());
* \brief Feature for creation of a new constraint filleting two objects which have coincident point
*
* This constraint has three attributes:
- * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() for the filleting objects;
- * SketchPlugin_Constraint::VALUE() contains radius of filleting circular arc
+ * SketchPlugin_Constraint::VALUE() contains reference object to be splitted
+ * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() for the points of split;
*
* Also the constraint has attribute SketchPlugin_Constraint::ENTITY_C()
* which contains created list objects forming the fillet
<!-- SketchConstraintSplit -->
<feature id="SketchConstraintSplit" title="Split" tooltip="Create constraints defining split of linear segment, arc or circle" icon="icons/Sketch/split.png">
<sketch_sub_shape_selector
- id="ConstraintEntityA"
+ id="ConstraintValue"
label="Split feature"
tooltip="Select feature for split"
shape_types="edge"