//fillAttribute(theZ, myz);
fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
+ fillAttribute(theX, theY, theZ, mypoint);
execute(false);
}
if (aMeth == "" || // default is XYZ
aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ()) {
- theDumper << point() << ")" << std::endl;
+ theDumper << point();
} else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_INTERSECTION()) {
const std::string anIntersectionType = intersectionType()->value();
if (anIntersectionType == ConstructionPlugin_Point::INTERSECTION_TYPE_BY_LINES())
virtual ~ConstructionAPI_Point();
INTERFACE_25(ConstructionPlugin_Point::ID(),
- point, ConstructionPlugin_Point::point3d(),
+ point, ConstructionPlugin_Point::POINT3D(),
GeomDataAPI_Point, /** Point attribute */,
creationMethod, ConstructionPlugin_Point::CREATION_METHOD(),
ModelAPI_AttributeString, /** Creation method */,
//==================================================================================================
void ConstructionPlugin_Point::initAttributes()
{
- data()->addAttribute(point3d(), GeomDataAPI_Point::typeId());
+ data()->addAttribute(POINT3D(), GeomDataAPI_Point::typeId());
data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByXYZ()
{
AttributePointPtr aPoint =
- std::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(point3d()));
+ std::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(POINT3D()));
return GeomAlgoAPI_PointBuilder::vertex(aPoint->x(), aPoint->y(), aPoint->z());
}
return MY_CREATION_METHOD_ID;
}
- inline static const std::string& point3d()
+ inline static const std::string& POINT3D()
{
static const std::string POINT_ATTR("point3d");
return POINT_ATTR;
return myExpression[2]->value();
}
+void GeomData_Point::setX(const double theX)
+{
+ if (!myIsInitialized) {
+ setCalculatedValue(theX, 0, 0);
+ } else if (x() != theX) {
+ myExpression[0]->setValue(theX);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+void GeomData_Point::setY(const double theY)
+{
+ if (!myIsInitialized) {
+ setCalculatedValue(0, theY, 0);
+ } else if (y() != theY) {
+ myExpression[1]->setValue(theY);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+void GeomData_Point::setZ(const double theZ)
+{
+ if (!myIsInitialized) {
+ setCalculatedValue(0, 0, theZ);
+ }
+ else if (z() != theZ) {
+ myExpression[2]->setValue(theZ);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+
std::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
{
std::shared_ptr<GeomAPI_Pnt> aResult(new GeomAPI_Pnt(x(), y(), z()));
}
}
+void GeomData_Point::setTextX(const std::string& theX)
+{
+ if (!myIsInitialized) {
+ static const std::string aDefaultText = "0";
+ setText(theX, aDefaultText, aDefaultText);
+ }
+ else if (textX() != theX) {
+ myExpression[0]->setText(theX);
+ // Send it to evaluator to convert into the double and store in the attribute
+ ModelAPI_AttributeEvalMessage::send(owner()->data()->attribute(id()), this);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+void GeomData_Point::setTextY(const std::string& theY)
+{
+ if (!myIsInitialized) {
+ static const std::string aDefaultText = "0";
+ setText(aDefaultText, theY, aDefaultText);
+ }
+ else if (textY() != theY) {
+ myExpression[1]->setText(theY);
+ // Send it to evaluator to convert into the double and store in the attribute
+ ModelAPI_AttributeEvalMessage::send(owner()->data()->attribute(id()), this);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+void GeomData_Point::setTextZ(const std::string& theZ)
+{
+ if (!myIsInitialized) {
+ static const std::string aDefaultText = "0";
+ setText(aDefaultText, aDefaultText, theZ);
+ }
+ else if (textZ() != theZ) {
+ myExpression[2]->setText(theZ);
+ // Send it to evaluator to convert into the double and store in the attribute
+ ModelAPI_AttributeEvalMessage::send(owner()->data()->attribute(id()), this);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
std::string GeomData_Point::textX()
{
return myExpression[0]->text();
GEOMDATA_EXPORT virtual double y() const;
/// Returns the Z double value
GEOMDATA_EXPORT virtual double z() const;
+ /// Defines the X coordinate value
+ GEOMDATA_EXPORT void setX(const double theX);
+ /// Defines the Y coordinate value
+ GEOMDATA_EXPORT void setY(const double theY);
+ /// Defines the Z coordinate value
+ GEOMDATA_EXPORT void setZ(const double theZ);
+
/// Returns the 3D point
GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Pnt> pnt();
GEOMDATA_EXPORT virtual void setText(const std::string& theX,
const std::string& theY,
const std::string& theZ);
+ /// Defines the X text value
+ GEOMDATA_EXPORT virtual void setTextX(const std::string& theX);
+ /// Defines the Y text value
+ GEOMDATA_EXPORT virtual void setTextY(const std::string& theY);
+ /// Defines the Z text value
+ GEOMDATA_EXPORT virtual void setTextZ(const std::string& theZ);
/// Returns the X text value
GEOMDATA_EXPORT virtual std::string textX();
GEOMDATAAPI_EXPORT virtual
void setCalculatedValue(const double theX, const double theY, const double theZ) = 0;
+ /// Defines the X coordinate value
+ GEOMDATAAPI_EXPORT virtual void setX(const double theX) = 0;
+ /// Defines the Y coordinate value
+ GEOMDATAAPI_EXPORT virtual void setY(const double theY) = 0;
+ /// Defines the Z coordinate value
+ GEOMDATAAPI_EXPORT virtual void setZ(const double theZ) = 0;
+
/// Defines the text values
GEOMDATAAPI_EXPORT virtual void setText(const std::string& theX,
const std::string& theY,
const std::string& theZ) = 0;
+ /// Defines the X text value
+ GEOMDATAAPI_EXPORT virtual void setTextX(const std::string& theX) = 0;
+ /// Defines the Y text value
+ GEOMDATAAPI_EXPORT virtual void setTextY(const std::string& theY) = 0;
+ /// Defines the Z text value
+ GEOMDATAAPI_EXPORT virtual void setTextZ(const std::string& theZ) = 0;
+
/// Returns the text value for X
GEOMDATAAPI_EXPORT virtual std::string textX() = 0;
/// Returns the text value for Y
##
from ModelAPI import *
+from GeomDataAPI import *
+
aSession = ModelAPI_Session.get()
aDoc = aSession.moduleDocument()
assert(not aSession.canUndo())
aSession.startOperation()
aFeature = aDoc.addFeature("Point")
-# Since validators are introduced we have to initialize all
-# the feature's attributes
-# aFeature.string("creation_method").setValue("by_xyz")
-aFeature.real("x").setValue(1.)
-aFeature.real("y").setValue(-1.)
-aFeature.real("z").setValue(0.)
+geomDataAPI_Point(aFeature.attribute("point3d")).setValue(1., -1., 0.)
aFeature.string("creation_method").setValue("by_xyz")
aFeatureName = aFeature.name()
# "2" is because Origin is the first point
#include "ModelHighAPI_Double.h"
#include <ModelAPI_AttributeDouble.h>
+#include <GeomDataAPI_Point.h>
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
case VT_STRING: theAttribute->setText(myString); return;
}
}
+
+void ModelHighAPI_Double::fillAttribute(
+ const std::shared_ptr<GeomDataAPI_Point> & thePoint,
+ const ModelHighAPI_Double & theX,
+ const ModelHighAPI_Double & theY,
+ const ModelHighAPI_Double & theZ) const
+{
+ switch (theX.myVariantType) {
+ case VT_DOUBLE: thePoint->setX(theX.myDouble); break;
+ case VT_STRING: thePoint->setTextX(theX.myString);
+ }
+ switch (theY.myVariantType) {
+ case VT_DOUBLE: thePoint->setY(theY.myDouble); break;
+ case VT_STRING: thePoint->setTextY(theY.myString);
+ }
+ switch (theZ.myVariantType) {
+ case VT_DOUBLE: thePoint->setZ(theZ.myDouble); break;
+ case VT_STRING: thePoint->setTextZ(theZ.myString);
+ }
+}
#include <string>
//--------------------------------------------------------------------------------------
class ModelAPI_AttributeDouble;
+class GeomDataAPI_Point;
//--------------------------------------------------------------------------------------
/**\class ModelHighAPI_Double
* \ingroup CPPHighAPI
MODELHIGHAPI_EXPORT
virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const;
+ /// Sets the zero-based coordinates of a point
+ MODELHIGHAPI_EXPORT virtual void fillAttribute(
+ const std::shared_ptr<GeomDataAPI_Point> & thePoint,
+ const ModelHighAPI_Double & theX,
+ const ModelHighAPI_Double & theY,
+ const ModelHighAPI_Double & theZ) const;
+
private:
enum VariantType { VT_DOUBLE, VT_STRING } myVariantType;
double myDouble;
theAttribute->setValue(anIndex, it->intValue()); // use only values, no text support in array
}
+void fillAttribute(const ModelHighAPI_Double & theX,
+ const ModelHighAPI_Double & theY,
+ const ModelHighAPI_Double & theZ,
+ const std::shared_ptr<GeomDataAPI_Point> & theAttribute)
+{
+ theX.fillAttribute(theAttribute, theX, theY, theZ);
+}
+
+
//==================================================================================================
GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr)
{
void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute);
+MODELHIGHAPI_EXPORT
+void fillAttribute(const ModelHighAPI_Double & theX,
+ const ModelHighAPI_Double & theY,
+ const ModelHighAPI_Double & theZ,
+ const std::shared_ptr<GeomDataAPI_Point> & theAttribute);
+
MODELHIGHAPI_EXPORT
GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr);