Added PropertyPosition and PropertyDirection classes. Basically PropertyVector classes with units.

This commit is contained in:
Eivind Kvedalen
2017-07-21 16:33:50 +02:00
committed by wmayer
parent 3a8ceb2929
commit 03c39f3a13
6 changed files with 130 additions and 0 deletions

View File

@@ -1256,6 +1256,8 @@ void Application::initTypes(void)
App ::PropertyMatrix ::init();
App ::PropertyVector ::init();
App ::PropertyVectorDistance ::init();
App ::PropertyPosition ::init();
App ::PropertyDirection ::init();
App ::PropertyVectorList ::init();
App ::PropertyPlacement ::init();
App ::PropertyPlacementList ::init();

View File

@@ -233,6 +233,69 @@ PropertyVectorDistance::~PropertyVectorDistance()
}
//**************************************************************************
// PropertyPosition
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(App::PropertyPosition , App::PropertyVector);
//**************************************************************************
// Construction/Destruction
PropertyPosition::PropertyPosition()
{
}
PropertyPosition::~PropertyPosition()
{
}
const boost::any PropertyPosition::getPathValue(const ObjectIdentifier &path) const
{
std::string p = path.getSubPathStr();
if (p == ".x" || p == ".y" || p == ".z") {
// Convert double to quantity
return Base::Quantity(boost::any_cast<double>(Property::getPathValue(path)), Unit::Length);
}
else
return Property::getPathValue(path);
}
//**************************************************************************
// PropertyPosition
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(App::PropertyDirection , App::PropertyVector);
//**************************************************************************
// Construction/Destruction
PropertyDirection::PropertyDirection()
{
}
PropertyDirection::~PropertyDirection()
{
}
const boost::any PropertyDirection::getPathValue(const ObjectIdentifier &path) const
{
std::string p = path.getSubPathStr();
if (p == ".x" || p == ".y" || p == ".z") {
// Convert double to quantity
return Base::Quantity(boost::any_cast<double>(Property::getPathValue(path)), Unit::Length);
}
else
return Property::getPathValue(path);
}
//**************************************************************************
// PropertyVectorList

View File

@@ -127,6 +127,53 @@ public:
}
};
class AppExport PropertyPosition: public PropertyVector
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyPosition();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyPosition();
const boost::any getPathValue(const ObjectIdentifier &path) const;
const char* getEditorName(void) const {
return "Gui::PropertyEditor::PropertyPositionItem";
}
};
class AppExport PropertyDirection: public PropertyVector
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyDirection();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyDirection();
const boost::any getPathValue(const ObjectIdentifier &path) const;
const char* getEditorName(void) const {
return "Gui::PropertyEditor::PropertyDirectionItem";
}
};
class AppExport PropertyVectorList: public PropertyLists
{

View File

@@ -136,6 +136,8 @@ void Gui::SoFCDB::init()
PropertyBoolItem ::init();
PropertyVectorItem ::init();
PropertyVectorDistanceItem ::init();
PropertyPositionItem ::init();
PropertyDirectionItem ::init();
PropertyMatrixItem ::init();
PropertyPlacementItem ::init();
PropertyEnumItem ::init();

View File

@@ -1344,6 +1344,9 @@ void PropertyVectorDistanceItem::propertyBound() {
};
}
PROPERTYITEM_SOURCE(Gui::PropertyEditor::PropertyPositionItem)
PROPERTYITEM_SOURCE(Gui::PropertyEditor::PropertyDirectionItem)
// ---------------------------------------------------------------

View File

@@ -473,6 +473,19 @@ private:
PropertyUnitItem* m_z;
};
class GuiExport PropertyPositionItem: public PropertyVectorDistanceItem
{
Q_OBJECT
PROPERTYITEM_HEADER
};
class GuiExport PropertyDirectionItem: public PropertyVectorDistanceItem
{
Q_OBJECT
PROPERTYITEM_HEADER
};
class GuiExport PropertyMatrixItem: public PropertyItem
{
Q_OBJECT