std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
//std::cout<<"Execute circle "<<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
- std::shared_ptr<ModelAPI_ResultConstruction> aConstr1 = document()->createConstruction(
- data(), 0);
- aConstr1->setShape(aCenterPointShape);
- aConstr1->setIsInHistory(false);
- setResult(aConstr1, 0);
+ SketchPlugin_Sketch::createPoint2DResult(this, sketch(), CENTER_ID(), 0);
// make a visible circle
std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
attribute(CENTER_ID()));
if (!aCenter || !aCenter->isInitialized())
return;
+ // make a visible points
+ SketchPlugin_Sketch::createPoint2DResult(this, sketch(), CENTER_ID(), 0);
+
double anAngle = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
attribute(ANGLE_ID()))->value();
// Convert angle to radians
attribute(END_POINT_ID()));
if (!aStart || !aEnd || !aStart->isInitialized() || !aEnd->isInitialized())
return;
+
+ // make a visible points
+ SketchPlugin_Sketch::createPoint2DResult(this, sketch(), START_POINT_ID(), 0);
+ SketchPlugin_Sketch::createPoint2DResult(this, sketch(), END_POINT_ID(), 1);
+
std::shared_ptr<GeomAPI_XY> aShiftVec(new GeomAPI_XY(aEnd->x() - aStart->x(), aEnd->y() - aStart->y()));
// Wait all objects being created, then send update events
}
return ObjectPtr();
}
+
#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
}
}
}
+
+void SketchPlugin_Sketch::createPoint2DResult(ModelAPI_Feature* theFeature,
+ SketchPlugin_Sketch* theSketch,
+ const std::string& theAttributeID, const int theIndex)
+{
+ std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theFeature->attribute(theAttributeID));
+
+ if (!aPoint || !aPoint->isInitialized())
+ return;
+
+ std::shared_ptr<GeomAPI_Pnt> aCenter(theSketch->to3D(aPoint->x(), aPoint->y()));
+ //std::cout<<"Execute circle "<<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
+ // make a visible point
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+ std::shared_ptr<ModelAPI_ResultConstruction> aResult = theFeature->document()->createConstruction(
+ theFeature->data(), theIndex);
+ aResult->setShape(aCenterPointShape);
+ aResult->setIsInHistory(false);
+
+ theFeature->setResult(aResult, theIndex);
+}
SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+ /// \brief Create a result for the point in the attribute if the attribute is initialized
+ /// \param theAttributeID an attribute string
+ /// \param theIndex an index of the result
+ static void createPoint2DResult(ModelAPI_Feature* theFeature,
+ SketchPlugin_Sketch* theSketch,
+ const std::string& theAttributeID, const int theIndex);
};
#endif
<integervalue id="MultiTranslationCopies"
label="Number of copies"
tooltip="Number of copies"
- default="1" min="1">
+ default="1" min="1"
+ obligatory="0">
<validator id="GeomValidators_Positive"/>
</integervalue>
</feature>
<integervalue id="MultiRotationCopies"
label="Number of copies"
tooltip="Number of copies"
- default="1" min="1">
+ default="1" min="1"
+ obligatory="0">
<validator id="GeomValidators_Positive"/>
</integervalue>
</feature>