From e19e7336cd0d3dd35a0eb7428474888b4a474ce4 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 31 Aug 2015 22:57:29 -0300 Subject: [PATCH] Added new property type: App::PropertyVectorDistance This works exactly as a normal PropertyVector, but it uses the Units-enabled GUI editor instead. --- src/App/Application.cpp | 1 + src/App/PropertyGeo.cpp | 21 ++++++++++++++ src/App/PropertyGeo.h | 38 +++++++++++++++++++++++++ src/Gui/propertyeditor/PropertyItem.cpp | 6 ++-- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 3bd6f60c3..927f577e2 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1073,6 +1073,7 @@ void Application::initTypes(void) App ::PropertyLinkSubList ::init(); App ::PropertyMatrix ::init(); App ::PropertyVector ::init(); + App ::PropertyVectorDistance ::init(); App ::PropertyVectorList ::init(); App ::PropertyPlacement ::init(); App ::PropertyPlacementLink ::init(); diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 0dd33b8a3..ff5315f87 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -175,6 +175,27 @@ void PropertyVector::Paste(const Property &from) } +//************************************************************************** +// PropertyVectorDistance +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +TYPESYSTEM_SOURCE(App::PropertyVectorDistance , App::PropertyVector); + +//************************************************************************** +// Construction/Destruction + + +PropertyVectorDistance::PropertyVectorDistance() +{ + +} + +PropertyVectorDistance::~PropertyVectorDistance() +{ + +} + + //************************************************************************** // PropertyVectorList //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h index cb3f3a5a1..c82650afa 100644 --- a/src/App/PropertyGeo.h +++ b/src/App/PropertyGeo.h @@ -100,6 +100,44 @@ private: }; +class AppExport PropertyVectorDistance: public PropertyVector +{ + TYPESYSTEM_HEADER(); + +public: + /** + * A constructor. + * A more elaborate description of the constructor. + */ + PropertyVectorDistance(); + + /** + * A destructor. + * A more elaborate description of the destructor. + */ + virtual ~PropertyVectorDistance(); + + /** Sets the property + */ + void setValue(const Base::Vector3d &vec); + void setValue(double x, double y, double z); + + /** This method returns a string representation of the property + */ + const Base::Vector3d &getValue(void) const; + const char* getEditorName(void) const { + return "Gui::PropertyEditor::PropertyVectorDistanceItem"; + } + + virtual unsigned int getMemSize (void) const { + return sizeof(Base::Vector3d); + } + +private: + Base::Vector3d _cVec; +}; + + class AppExport PropertyVectorList: public PropertyLists { TYPESYSTEM_HEADER(); diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 36adb58a7..23e0ad3bc 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1011,9 +1011,9 @@ void PropertyVectorDistanceItem::setValue(const QVariant& variant) Base::Quantity y = Base::Quantity(value.y, Base::Unit::Length); Base::Quantity z = Base::Quantity(value.z, Base::Unit::Length); QString data = QString::fromAscii("(%1, %2, %3)") - .arg(x.getUserString()) - .arg(y.getUserString()) - .arg(z.getUserString()); + .arg(x.getValue()) + .arg(y.getValue()) + .arg(z.getValue()); setPropertyValue(data); }