diff --git a/src/App/Application.cpp b/src/App/Application.cpp
index c2f1c6bd8..bcce61567 100644
--- a/src/App/Application.cpp
+++ b/src/App/Application.cpp
@@ -1175,9 +1175,9 @@ void Application::initApplication(void)
Application::_pcSingleton = new Application(0,0,mConfig);
// set up Unit system default
- //ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
- // ("User parameter:BaseApp/Preferences/Units");
- //UnitsApi::setSchema((UnitSystem)hGrp->GetInt("UserSchema",0));
+ ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
+ ("User parameter:BaseApp/Preferences/Units");
+ UnitsApi::setSchema((UnitSystem)hGrp->GetInt("UserSchema",0));
// starting the init script
Interpreter().runString(Base::ScriptFactory().ProduceScript("FreeCADInit"));
diff --git a/src/App/FeatureTest.cpp b/src/App/FeatureTest.cpp
index d5e2be160..c98664685 100644
--- a/src/App/FeatureTest.cpp
+++ b/src/App/FeatureTest.cpp
@@ -28,8 +28,10 @@
#include
#include
+#include
#include "FeatureTest.h"
#include "Material.h"
+#include "Material.h"
#define new DEBUG_CLIENTBLOCK
using namespace App;
@@ -94,7 +96,12 @@ FeatureTest::FeatureTest()
ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
- ADD_PROPERTY(Quantity,(1.0));
+ ADD_PROPERTY(QuantityLength,(1.0));
+ QuantityLength.setUnit(Base::Unit::Length);
+ ADD_PROPERTY(QuantityMass,(1.0));
+ QuantityMass.setUnit(Base::Unit::Mass);
+ ADD_PROPERTY(QuantityAngle,(1.0));
+ QuantityAngle.setUnit(Base::Unit::Angle);
}
diff --git a/src/App/FeatureTest.h b/src/App/FeatureTest.h
index 71dbc9dc7..8d4676140 100644
--- a/src/App/FeatureTest.h
+++ b/src/App/FeatureTest.h
@@ -93,7 +93,9 @@ public:
App::PropertyInteger TypeAll;
App::PropertyInteger TypeTransient;
- App::PropertyQuantity Quantity;
+ App::PropertyQuantity QuantityLength;
+ App::PropertyQuantity QuantityMass;
+ App::PropertyQuantity QuantityAngle;
/** @name methods overide Feature */
//@{
diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp
index 6bf816469..668fd2beb 100644
--- a/src/App/PropertyUnits.cpp
+++ b/src/App/PropertyUnits.cpp
@@ -55,6 +55,11 @@ using namespace std;
TYPESYSTEM_SOURCE(App::PropertyQuantity, App::PropertyFloat);
+Base::Quantity PropertyQuantity::getQuantityValue(void) const
+{
+ return Quantity( _dValue,_Unit);
+}
+
const char* PropertyQuantity::getEditorName(void) const
{
@@ -69,7 +74,30 @@ PyObject *PropertyQuantity::getPyObject(void)
void PropertyQuantity::setPyObject(PyObject *value)
{
- setValue(UnitsApi::toDblWithUserPrefs(Length,value));
+ Base::Quantity quant;
+
+ if (PyString_Check(value))
+ quant = Quantity::parse(PyString_AsString(value));
+ else if (PyFloat_Check(value))
+ quant = Quantity(PyFloat_AsDouble(value),_Unit);
+ else if (PyInt_Check(value))
+ quant = Quantity((double)PyInt_AsLong(value),_Unit);
+ else if (PyObject_TypeCheck(value, &(QuantityPy::Type))) {
+ Base::QuantityPy *pcObject = static_cast(value);
+ quant = *(pcObject->getQuantityPtr());
+ }else
+ throw Base::Exception("Wrong type!");
+
+ Unit unit = quant.getUnit();
+ if(unit.isEmpty()){
+ setValue(quant.getValue());
+ return;
+ }
+
+ if (unit != _Unit)
+ throw Base::Exception("Not matching Unit!");
+
+ setValue(quant.getValue());
}
//**************************************************************************
diff --git a/src/App/PropertyUnits.h b/src/App/PropertyUnits.h
index 321e91d96..c550fef39 100644
--- a/src/App/PropertyUnits.h
+++ b/src/App/PropertyUnits.h
@@ -33,6 +33,7 @@
#include
#include
+#include
#include "PropertyStandard.h"
namespace Base {
@@ -52,6 +53,9 @@ class AppExport PropertyQuantity : public PropertyFloat
public:
PropertyQuantity(void){}
virtual ~PropertyQuantity(){}
+
+ Base::Quantity getQuantityValue(void) const;
+
virtual const char* getEditorName(void) const;
virtual PyObject *getPyObject(void);
diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp
index daec1d82e..4ddf5516d 100644
--- a/src/Base/Quantity.cpp
+++ b/src/Base/Quantity.cpp
@@ -27,6 +27,7 @@
#include
#include "Quantity.h"
#include "Exception.h"
+#include "UnitsApi.h"
// suppress annoying warnings from generated source files
#ifdef _MSC_VER
@@ -107,6 +108,11 @@ Quantity& Quantity::operator = (const Quantity &New)
return *this;
}
+double Quantity::getUserPrefered(QString &unitString)const
+{
+ return Base::UnitsApi::schemaPrefUnit(_Unit,unitString).getValue() * _Value;
+}
+
// === Parser & Scanner stuff ===============================================
// include the Scanner and the Parser for the Quantitys
diff --git a/src/Base/Quantity.h b/src/Base/Quantity.h
index 524d0e473..f1d566598 100644
--- a/src/Base/Quantity.h
+++ b/src/Base/Quantity.h
@@ -25,6 +25,7 @@
#define BASE_Quantity_H
#include "Unit.h"
+#include
namespace Base {
@@ -53,10 +54,16 @@ public:
Quantity pow(const Quantity&)const;
//@}
+ /// transfer to user prefered unit/potence
+ double getUserPrefered(QString &unitString = QString())const;
+ std::string getUserString(void)const;
+
static Quantity parse(const char* buffer);
const Unit & getUnit(void) const{return _Unit;}
+ void setUnit(const Unit &un){_Unit = un;}
double getValue(void) const{return _Value;}
+ void setValue(double val){_Value = val;}
protected:
double _Value;
diff --git a/src/Base/QuantityPy.xml b/src/Base/QuantityPy.xml
index 52adff129..7dfeaefc3 100644
--- a/src/Base/QuantityPy.xml
+++ b/src/Base/QuantityPy.xml
@@ -26,24 +26,37 @@ Quantity(string) -- arbitrary mixture of numbers and chars defining a Quantity
Quantity
-
-
-
- sets the quantity to the power
-
-
-
-
+
+
+
+ sets the quantity to the power
+
+
+
+
+
+
+ returns a quantity with the translation factor and a string with the prevered unit
+
+
+
+
Numeric Value of the Quantity (in internal system mm,kg,s)
-
-
- Unit of the Quantity
-
-
-
-
+
+
+ Unit of the Quantity
+
+
+
+
+
+ Unit of the Quantity
+
+
+
+
diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp
index 2a605ecd1..d0ccf2370 100644
--- a/src/Base/QuantityPyImp.cpp
+++ b/src/Base/QuantityPyImp.cpp
@@ -6,6 +6,7 @@
// inclusion of the generated files (generated out of QuantityPy.xml)
#include "QuantityPy.h"
+#include "UnitPy.h"
#include "QuantityPy.cpp"
using namespace Base;
@@ -51,10 +52,8 @@ int QuantityPy::PyInit(PyObject* args, PyObject* kwd)
const char* string;
if (PyArg_ParseTuple(args,"s", &string)) {
-
-
- return -1;
-
+ *self = Quantity::parse(string);
+ return 0;
}
PyErr_SetString(PyExc_TypeError, "Either three floats, tuple or Vector expected");
@@ -68,6 +67,11 @@ PyObject* QuantityPy::pow(PyObject * args)
return 0;
}
+PyObject* QuantityPy::getUserPrefered(PyObject *args)
+{
+ PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
+ return 0;
+}
PyObject* QuantityPy::number_add_handler(PyObject *self, PyObject *other)
{
@@ -126,24 +130,34 @@ PyObject* QuantityPy::number_multiply_handler(PyObject *self, PyObject *other)
Py::Float QuantityPy::getValue(void) const
{
- //return Py::Float();
- throw Py::AttributeError("Not yet implemented");
+ return Py::Float(getQuantityPtr()->getValue());
}
-void QuantityPy::setValue(Py::Float /*arg*/)
+void QuantityPy::setValue(Py::Float arg)
{
- throw Py::AttributeError("Not yet implemented");
+ getQuantityPtr()->setValue(arg);
}
Py::Object QuantityPy::getUnit(void) const
{
- //return Py::Object();
- throw Py::AttributeError("Not yet implemented");
+ return Py::Object(new UnitPy(new Unit(getQuantityPtr()->getUnit())));
}
-void QuantityPy::setUnit(Py::Object /*arg*/)
+void QuantityPy::setUnit(Py::Object arg)
{
- throw Py::AttributeError("Not yet implemented");
+ union PyType_Object pyType = {&(Base::UnitPy::Type)};
+ Py::Type UnitType(pyType.o);
+ if(!arg.isType(UnitType))
+ throw Py::AttributeError("Not yet implemented");
+
+ getQuantityPtr()->setUnit(*static_cast((*arg))->getUnitPtr());
+}
+
+
+Py::String QuantityPy::getUserString(void) const
+{
+ //return Py::String();
+ throw Py::AttributeError("Not yet implemented");
}
PyObject *QuantityPy::getCustomAttributes(const char* /*attr*/) const
diff --git a/src/Base/Unit.cpp b/src/Base/Unit.cpp
index e2fb01c23..9cdb99324 100644
--- a/src/Base/Unit.cpp
+++ b/src/Base/Unit.cpp
@@ -269,13 +269,21 @@ std::string Unit::getString(void) const
}
}
-
-
-
-
-
-
-
-
- return ret.str();
-}
\ No newline at end of file
+ return ret.str();
+}
+
+
+Unit Unit::Length(1);
+Unit Unit::Area(2);
+Unit Unit::Volume(3);
+Unit Unit::Mass(0,1);
+Unit Unit::Angle(0,0,0,0,0,0,0,1);
+
+Unit Unit::TimeSpan(0,0,1);
+Unit Unit::Velocity(1,0,-1);
+Unit Unit::Acceleration(1,0,-2);
+Unit Unit::Temperature(0,0,0,0,1);
+
+Unit Unit::ElectricCurrent(0,0,0,1);
+Unit Unit::AmountOfSubstance(0,0,0,0,0,1);
+Unit Unit::LuminoseIntensity(0,0,0,0,0,0,1);
diff --git a/src/Base/Unit.h b/src/Base/Unit.h
index ce5fb3fb7..a011c4658 100644
--- a/src/Base/Unit.h
+++ b/src/Base/Unit.h
@@ -75,6 +75,26 @@ public:
char getLengthDimension(void){return Sig.Length;}
std::string getString(void) const;
+ /** Predefined Unit types. */
+ //@{
+ /// Length unit
+ static Unit Length;
+ /// Mass unit
+ static Unit Mass;
+ /// Angle
+ static Unit Angle;
+
+ static Unit Area;
+ static Unit Volume;
+ static Unit TimeSpan;
+ static Unit Velocity;
+ static Unit Acceleration;
+ static Unit Temperature;
+
+ static Unit ElectricCurrent;
+ static Unit AmountOfSubstance;
+ static Unit LuminoseIntensity;
+
protected:
UnitSignature Sig;
};
diff --git a/src/Base/UnitsApi.cpp b/src/Base/UnitsApi.cpp
index 91b71eba8..740ca053f 100644
--- a/src/Base/UnitsApi.cpp
+++ b/src/Base/UnitsApi.cpp
@@ -130,6 +130,16 @@ double UnitsApi::translateUnit(const QString & str)
// === static translation methodes ==========================================
+QString UnitsApi::schemaTranslate(Base::Quantity quant)
+{
+ return UserPrefSystem->schemaTranslate(quant);
+}
+
+Base::Quantity UnitsApi::schemaPrefUnit(const Base::Unit &unit,QString &outUnitString)
+{
+ return UserPrefSystem->schemaPrefUnit(unit,outUnitString);
+}
+
QString UnitsApi::toStrWithUserPrefs(QuantityType t,double Value)
{
return UserPrefSystem->toStrWithUserPrefs(t,Value);
diff --git a/src/Base/UnitsApi.h b/src/Base/UnitsApi.h
index 40fdfb673..434940ae3 100644
--- a/src/Base/UnitsApi.h
+++ b/src/Base/UnitsApi.h
@@ -65,6 +65,8 @@ public:
static double translateUnit(const char*);
static double translateUnit(const QString &);
+ static QString schemaTranslate(Base::Quantity quant);
+ static Base::Quantity schemaPrefUnit(const Base::Unit &unit,QString &outUnitString);
/** @name Translation from internal to user prefs */
//@{
diff --git a/src/Base/UnitsSchema.h b/src/Base/UnitsSchema.h
index 117923161..121d68895 100644
--- a/src/Base/UnitsSchema.h
+++ b/src/Base/UnitsSchema.h
@@ -27,6 +27,8 @@
#include
#include
+#include "Quantity.h"
+
//#include "UnitsApi.h"
@@ -69,6 +71,10 @@ public:
* units parser.
*/
virtual QString toStrWithUserPrefs(QuantityType t,double Value)=0;
+
+ virtual QString schemaTranslate(Base::Quantity quant)=0;
+ // returns the prefered unit as string and the quantity to translate
+ virtual Base::Quantity schemaPrefUnit(const Base::Unit &unit,QString &outUnitString)=0;
};
diff --git a/src/Base/UnitsSchemaImperial1.cpp b/src/Base/UnitsSchemaImperial1.cpp
index 0056b6af1..5b3a8d521 100644
--- a/src/Base/UnitsSchemaImperial1.cpp
+++ b/src/Base/UnitsSchemaImperial1.cpp
@@ -62,3 +62,26 @@ QString UnitsSchemaImperial1::toStrWithUserPrefs(QuantityType t,double Value)
double UnitValue = Value/UnitsApi::getPrefFactorOf(t);
return QString::fromAscii("%1 %2").arg(UnitValue).arg(UnitsApi::getPrefUnitOf(t));
}
+
+QString UnitsSchemaImperial1::schemaTranslate(Base::Quantity quant)
+{
+ double UnitValue = quant.getValue();
+ Unit unit = quant.getUnit();
+
+ return QString::fromAscii("%1 %2").arg(UnitValue).arg(QString::fromAscii(unit.getString().c_str()));
+}
+
+Base::Quantity UnitsSchemaImperial1::schemaPrefUnit(const Base::Unit &unit,QString &outUnitString)
+{
+ if(unit == Unit::Length){
+ outUnitString = QString::fromAscii("\"");
+ return Base::Quantity(1/25.40,Unit::Length);
+ }else if(unit == Unit::Mass){
+ outUnitString = QString::fromAscii("lb");
+ return Base::Quantity(1/0.45359237,Unit::Length);
+ }else{
+ outUnitString = QString::fromAscii(unit.getString().c_str());
+ return Base::Quantity(1,unit);
+ }
+
+}
\ No newline at end of file
diff --git a/src/Base/UnitsSchemaImperial1.h b/src/Base/UnitsSchemaImperial1.h
index 63c9fc659..90183b2e0 100644
--- a/src/Base/UnitsSchemaImperial1.h
+++ b/src/Base/UnitsSchemaImperial1.h
@@ -42,6 +42,9 @@ public:
void setSchemaUnits(void);
void toStrWithUserPrefs(QuantityType t,double Value,QString &outValue,QString &outUnit);
QString toStrWithUserPrefs(QuantityType t,double Value);
+
+ virtual QString schemaTranslate(Base::Quantity quant);
+ Base::Quantity schemaPrefUnit(const Base::Unit &unit,QString &outUnitString);
};
diff --git a/src/Base/UnitsSchemaInternal.cpp b/src/Base/UnitsSchemaInternal.cpp
index e5794a7e6..89f0f2cfc 100644
--- a/src/Base/UnitsSchemaInternal.cpp
+++ b/src/Base/UnitsSchemaInternal.cpp
@@ -62,4 +62,22 @@ QString UnitsSchemaInternal::toStrWithUserPrefs(QuantityType t,double Value)
return QString::fromAscii("%1 %2").arg(UnitValue).arg(UnitsApi::getPrefUnitOf(t));
}
+QString UnitsSchemaInternal::schemaTranslate(Base::Quantity quant)
+{
+ double UnitValue = quant.getValue();
+ Unit unit = quant.getUnit();
+ return QString::fromAscii("%1 %2").arg(UnitValue).arg(QString::fromAscii(unit.getString().c_str()));
+}
+
+Base::Quantity UnitsSchemaInternal::schemaPrefUnit(const Base::Unit &unit,QString &outUnitString)
+{
+ if(unit == Unit::Length){
+ outUnitString = QString::fromAscii("mm");
+ return Base::Quantity(1.0,Unit::Length);
+ }else{
+ outUnitString = QString::fromAscii(unit.getString().c_str());
+ return Base::Quantity(1,unit);
+ }
+
+}
diff --git a/src/Base/UnitsSchemaInternal.h b/src/Base/UnitsSchemaInternal.h
index 3f45d6041..f73daa1eb 100644
--- a/src/Base/UnitsSchemaInternal.h
+++ b/src/Base/UnitsSchemaInternal.h
@@ -43,6 +43,9 @@ public:
void setSchemaUnits(void);
void toStrWithUserPrefs(QuantityType t,double Value,QString &outValue,QString &outUnit);
QString toStrWithUserPrefs(QuantityType t,double Value);
+
+ virtual QString schemaTranslate(Base::Quantity quant);
+ Base::Quantity schemaPrefUnit(const Base::Unit &unit,QString &outUnitString);
};
diff --git a/src/Base/UnitsSchemaMKS.cpp b/src/Base/UnitsSchemaMKS.cpp
index e5d0563b3..6157e00c2 100644
--- a/src/Base/UnitsSchemaMKS.cpp
+++ b/src/Base/UnitsSchemaMKS.cpp
@@ -62,4 +62,22 @@ QString UnitsSchemaMKS::toStrWithUserPrefs(QuantityType t,double Value)
return QString::fromAscii("%1 %2").arg(UnitValue).arg(UnitsApi::getPrefUnitOf(t));
}
+QString UnitsSchemaMKS::schemaTranslate(Base::Quantity quant)
+{
+ double UnitValue = quant.getValue();
+ Unit unit = quant.getUnit();
+ return QString::fromAscii("%1 %2").arg(UnitValue).arg(QString::fromAscii(unit.getString().c_str()));
+}
+
+Base::Quantity UnitsSchemaMKS::schemaPrefUnit(const Base::Unit &unit,QString &outUnitString)
+{
+ if(unit == Unit::Length){
+ outUnitString = QString::fromAscii("m");
+ return Base::Quantity(1/1000.0,Unit::Length);
+ }else{
+ outUnitString = QString::fromAscii(unit.getString().c_str());
+ return Base::Quantity(1,unit);
+ }
+
+}
\ No newline at end of file
diff --git a/src/Base/UnitsSchemaMKS.h b/src/Base/UnitsSchemaMKS.h
index d1bfd9c23..9cfe612b7 100644
--- a/src/Base/UnitsSchemaMKS.h
+++ b/src/Base/UnitsSchemaMKS.h
@@ -41,6 +41,9 @@ public:
void setSchemaUnits(void);
void toStrWithUserPrefs(QuantityType t,double Value,QString &outValue,QString &outUnit);
QString toStrWithUserPrefs(QuantityType t,double Value);
+
+ virtual QString schemaTranslate(Base::Quantity quant);
+ Base::Quantity schemaPrefUnit(const Base::Unit &unit,QString &outUnitString);
};
diff --git a/src/Gui/DlgSettingsUnitsImp.cpp b/src/Gui/DlgSettingsUnitsImp.cpp
index bb20b0861..798d2aefa 100644
--- a/src/Gui/DlgSettingsUnitsImp.cpp
+++ b/src/Gui/DlgSettingsUnitsImp.cpp
@@ -55,6 +55,8 @@ DlgSettingsUnitsImp::DlgSettingsUnitsImp(QWidget* parent)
QObject::connect(comboBox_ViewSystem, SIGNAL(currentIndexChanged(int)), this, SLOT(currentIndexChanged(int)));
+ tableWidget->setVisible(false);
+
}
/**
diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp
index 4fdd5cbbd..1655818e9 100644
--- a/src/Gui/propertyeditor/PropertyItem.cpp
+++ b/src/Gui/propertyeditor/PropertyItem.cpp
@@ -647,45 +647,85 @@ PropertyUnitItem::PropertyUnitItem()
{
}
+QVariant PropertyUnitItem::toString(const QVariant& Value) const
+{
+ double val = Value.toDouble();
+
+ QString unit;
+ const std::vector& prop = getPropertyData();
+ if (!prop.empty() && prop.front()->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
+ Base::Quantity value = static_cast(prop.front())->getQuantityValue();
+ value.getUserPrefered(unit);
+ unit.prepend(QLatin1String(" "));
+ }
+
+ QString data = QString::fromAscii("%1 %2").arg(val,0,'f',decimals()).arg(unit);
+
+ return QVariant(data);
+}
QVariant PropertyUnitItem::value(const App::Property* prop) const
{
- assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyLength::getClassTypeId()));
- //UnitType = Base::Length;
+ assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId()));
- double value = static_cast(prop)->getValue();
- QString nbr;
- nbr = Base::UnitsApi::toStrWithUserPrefs(Base::Length,value);
+ Base::Quantity value = static_cast(prop)->getQuantityValue();
+
+ return QVariant(value.getUserPrefered());
- return QVariant(nbr);
}
void PropertyUnitItem::setValue(const QVariant& value)
{
- if (!value.canConvert(QVariant::String))
+ if (!value.canConvert(QVariant::Double))
return;
- QString val = value.toString();
- QString data = QString::fromAscii("\"%1\"").arg(val);
+ double val = value.toDouble();
+
+ QString unit;
+ const std::vector& prop = getPropertyData();
+ if (prop.empty())
+ return;
+ else if (prop.front()->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
+ Base::Quantity value = static_cast(prop.front())->getQuantityValue();
+ value.getUserPrefered(unit);
+ unit.prepend(QLatin1String(" "));
+ }
+
+ QString data = QString::fromAscii("'%1%2'").arg(val,0,'f',decimals()).arg(unit);
setPropertyValue(data);
+
}
QWidget* PropertyUnitItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const
{
- QLineEdit *le = new QLineEdit(parent);
- le->setFrame(false);
- QObject::connect(le, SIGNAL(textChanged(const QString&)), receiver, method);
- return le;
+ QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
+ sb->setFrame(false);
+ sb->setDecimals(decimals());
+ QObject::connect(sb, SIGNAL(valueChanged(double)), receiver, method);
+ return sb;
+
}
void PropertyUnitItem::setEditorData(QWidget *editor, const QVariant& data) const
{
- QLineEdit *le = qobject_cast(editor);
- le->setText(data.toString());
+ QDoubleSpinBox *sb = qobject_cast(editor);
+ sb->setRange((double)INT_MIN, (double)INT_MAX);
+ sb->setValue(data.toDouble());
+ const std::vector& prop = getPropertyData();
+ if (prop.empty())
+ return;
+ else if (prop.front()->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
+ Base::Quantity value = static_cast(prop.front())->getQuantityValue();
+ QString unitString;
+ value.getUserPrefered(unitString);
+ unitString.prepend(QLatin1String(" "));
+ sb->setSuffix(unitString);
+ }
}
QVariant PropertyUnitItem::editorData(QWidget *editor) const
{
- QLineEdit *le = qobject_cast(editor);
- return QVariant(le->text());
+ QDoubleSpinBox *sb = qobject_cast(editor);
+ return QVariant(sb->value());
+
}
// --------------------------------------------------------------------
diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h
index 5a66dbda2..9f666cdb3 100644
--- a/src/Gui/propertyeditor/PropertyItem.h
+++ b/src/Gui/propertyeditor/PropertyItem.h
@@ -232,10 +232,10 @@ class GuiExport PropertyUnitItem: public PropertyItem
virtual QVariant editorData(QWidget *editor) const;
protected:
- //virtual QVariant toString(const QVariant&) const;
+ virtual QVariant toString(const QVariant&) const;
virtual QVariant value(const App::Property*) const;
virtual void setValue(const QVariant&);
- Base::QuantityType UnitType;
+ Base::Unit _Unit;
PropertyUnitItem();
};
diff --git a/src/Gui/resource.cpp b/src/Gui/resource.cpp
index 4a2676634..2f1059844 100644
--- a/src/Gui/resource.cpp
+++ b/src/Gui/resource.cpp
@@ -65,7 +65,7 @@ WidgetFactorySupplier::WidgetFactorySupplier()
new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );
- //new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );
+ new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") );
new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") );
diff --git a/src/Mod/Image/App/CMakeLists.txt b/src/Mod/Image/App/CMakeLists.txt
index b46f5a326..a029872af 100644
--- a/src/Mod/Image/App/CMakeLists.txt
+++ b/src/Mod/Image/App/CMakeLists.txt
@@ -8,6 +8,7 @@ include_directories(
${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${XERCESC_INCLUDE_DIR}
+ ${QT_INCLUDE_DIR}
)
set(Image_LIBS
diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt
index 31eb00219..28e7b43b2 100644
--- a/src/Mod/Part/App/CMakeLists.txt
+++ b/src/Mod/Part/App/CMakeLists.txt
@@ -18,6 +18,7 @@ include_directories(
${XERCESC_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
+ ${QT_INCLUDE_DIR}
)
link_directories(${OCC_LIBRARY_DIR})
diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt
index 24e7e2f21..e2783c49a 100644
--- a/src/Mod/PartDesign/App/CMakeLists.txt
+++ b/src/Mod/PartDesign/App/CMakeLists.txt
@@ -11,6 +11,7 @@ include_directories(
${ZLIB_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${XERCESC_INCLUDE_DIR}
+ ${QT_INCLUDE_DIR}
)
link_directories(${OCC_LIBRARY_DIR})