Added new property type: App::PropertyVectorDistance

This works exactly as a normal PropertyVector, but it
uses the Units-enabled GUI editor instead.
This commit is contained in:
Yorik van Havre 2015-08-31 22:57:29 -03:00
parent 1ed0ec974a
commit e19e7336cd
4 changed files with 63 additions and 3 deletions

View File

@ -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();

View File

@ -175,6 +175,27 @@ void PropertyVector::Paste(const Property &from)
}
//**************************************************************************
// PropertyVectorDistance
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(App::PropertyVectorDistance , App::PropertyVector);
//**************************************************************************
// Construction/Destruction
PropertyVectorDistance::PropertyVectorDistance()
{
}
PropertyVectorDistance::~PropertyVectorDistance()
{
}
//**************************************************************************
// PropertyVectorList
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -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();

View File

@ -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);
}