implement a direct way to set single or double precision when writing/reading properties using floating point numbers
This commit is contained in:
@@ -62,6 +62,7 @@ public:
|
||||
Immutable = 1, // can't modify property
|
||||
ReadOnly = 2, // for property editor
|
||||
Hidden = 3, // for property editor
|
||||
Single = 4, // for save/load of floating point numbers
|
||||
User1 = 28, // user-defined status
|
||||
User2 = 29, // user-defined status
|
||||
User3 = 30, // user-defined status
|
||||
@@ -143,6 +144,15 @@ public:
|
||||
inline bool isReadOnly() const {
|
||||
return testStatus(App::Property::ReadOnly);
|
||||
}
|
||||
/// Sets precision of properties using floating point
|
||||
/// numners to single, the default is double.
|
||||
void setSinglePrecision(bool single) {
|
||||
setStatus(App::Property::Single, single);
|
||||
}
|
||||
/// Gets precision of properties using floating point numbers
|
||||
inline bool isSinglePrecision() const {
|
||||
return testStatus(App::Property::Single);
|
||||
}
|
||||
//@}
|
||||
|
||||
/// Returns a new copy of the property (mainly for Undo/Redo and transactions)
|
||||
|
||||
@@ -418,7 +418,7 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const
|
||||
Base::OutputStream str(writer.Stream());
|
||||
uint32_t uCt = (uint32_t)getSize();
|
||||
str << uCt;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
if (!isSinglePrecision()) {
|
||||
for (std::vector<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << it->x << it->y << it->z;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ void PropertyVectorList::RestoreDocFile(Base::Reader &reader)
|
||||
uint32_t uCt=0;
|
||||
str >> uCt;
|
||||
std::vector<Base::Vector3d> values(uCt);
|
||||
if (reader.getFileVersion() > 0) {
|
||||
if (!isSinglePrecision()) {
|
||||
for (std::vector<Base::Vector3d>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str >> it->x >> it->y >> it->z;
|
||||
}
|
||||
@@ -917,7 +917,7 @@ void PropertyPlacementList::SaveDocFile (Base::Writer &writer) const
|
||||
Base::OutputStream str(writer.Stream());
|
||||
uint32_t uCt = (uint32_t)getSize();
|
||||
str << uCt;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
if (!isSinglePrecision()) {
|
||||
for (std::vector<Base::Placement>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << it->getPosition().x << it->getPosition().y << it->getPosition().z
|
||||
<< it->getRotation()[0] << it->getRotation()[1] << it->getRotation()[2] << it->getRotation()[3] ;
|
||||
@@ -943,7 +943,7 @@ void PropertyPlacementList::RestoreDocFile(Base::Reader &reader)
|
||||
uint32_t uCt=0;
|
||||
str >> uCt;
|
||||
std::vector<Base::Placement> values(uCt);
|
||||
if (reader.getFileVersion() > 0) {
|
||||
if (!isSinglePrecision()) {
|
||||
for (std::vector<Base::Placement>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
Base::Vector3d pos;
|
||||
double q0, q1, q2, q3;
|
||||
|
||||
@@ -1380,7 +1380,7 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const
|
||||
Base::OutputStream str(writer.Stream());
|
||||
uint32_t uCt = (uint32_t)getSize();
|
||||
str << uCt;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
if (!isSinglePrecision()) {
|
||||
for (std::vector<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << *it;
|
||||
}
|
||||
@@ -1399,7 +1399,7 @@ void PropertyFloatList::RestoreDocFile(Base::Reader &reader)
|
||||
uint32_t uCt=0;
|
||||
str >> uCt;
|
||||
std::vector<double> values(uCt);
|
||||
if (reader.getFileVersion() > 0) {
|
||||
if (!isSinglePrecision()) {
|
||||
for (std::vector<double>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str >> *it;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user