Skip to content

Commit

Permalink
Added new property type: App::PropertyVectorDistance
Browse files Browse the repository at this point in the history
This works exactly as a normal PropertyVector, but it
uses the Units-enabled GUI editor instead.
  • Loading branch information
yorikvanhavre committed Sep 1, 2015
1 parent 1ed0ec9 commit e19e733
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/App/Application.cpp
Expand Up @@ -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();
Expand Down
21 changes: 21 additions & 0 deletions src/App/PropertyGeo.cpp
Expand Up @@ -175,6 +175,27 @@ void PropertyVector::Paste(const Property &from)
}


//**************************************************************************
// PropertyVectorDistance
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

TYPESYSTEM_SOURCE(App::PropertyVectorDistance , App::PropertyVector);

//**************************************************************************
// Construction/Destruction


PropertyVectorDistance::PropertyVectorDistance()
{

}

PropertyVectorDistance::~PropertyVectorDistance()
{

}


//**************************************************************************
// PropertyVectorList
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
38 changes: 38 additions & 0 deletions src/App/PropertyGeo.h
Expand Up @@ -100,6 +100,44 @@ class AppExport PropertyVector: public Property
};


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();
Expand Down
6 changes: 3 additions & 3 deletions src/Gui/propertyeditor/PropertyItem.cpp
Expand Up @@ -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);
}

Expand Down

0 comments on commit e19e733

Please sign in to comment.