Support to write vector list and float lists in old format, fix issues in property editor, move back to float for curvature type
This commit is contained in:
@@ -601,7 +601,8 @@ void Document::Save (Base::Writer &writer) const
|
||||
writer.Stream() << "<Document SchemaVersion=\"4\" ProgramVersion=\""
|
||||
<< App::Application::Config()["BuildVersionMajor"] << "."
|
||||
<< App::Application::Config()["BuildVersionMinor"] << "R"
|
||||
<< App::Application::Config()["BuildRevision"] << "\" FileVersion=\"1\">" << endl;
|
||||
<< App::Application::Config()["BuildRevision"]
|
||||
<< "\" FileVersion=\"" << writer.getFileVersion() << "\">" << endl;
|
||||
|
||||
PropertyContainer::Save(writer);
|
||||
|
||||
|
||||
@@ -296,8 +296,18 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const
|
||||
Base::OutputStream str(writer.Stream());
|
||||
uint32_t uCt = (uint32_t)getSize();
|
||||
str << uCt;
|
||||
for (std::vector<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << it->x << it->y << it->z;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
for (std::vector<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << it->x << it->y << it->z;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
float x = (float)it->x;
|
||||
float y = (float)it->y;
|
||||
float z = (float)it->z;
|
||||
str << x << y << z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1122,8 +1122,16 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const
|
||||
Base::OutputStream str(writer.Stream());
|
||||
uint32_t uCt = (uint32_t)getSize();
|
||||
str << uCt;
|
||||
for (std::vector<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << *it;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
for (std::vector<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << *it;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
float v = (float)*it;
|
||||
str << v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ using namespace zipios;
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Writer::Writer(void)
|
||||
: indent(0),forceXML(false)
|
||||
: indent(0),forceXML(false),fileVersion(1)
|
||||
{
|
||||
indBuf[0] = '\0';
|
||||
}
|
||||
@@ -98,6 +98,16 @@ bool Writer::isForceXML(void)
|
||||
return forceXML;
|
||||
}
|
||||
|
||||
void Writer::setFileVersion(int v)
|
||||
{
|
||||
fileVersion = v;
|
||||
}
|
||||
|
||||
int Writer::getFileVersion() const
|
||||
{
|
||||
return fileVersion;
|
||||
}
|
||||
|
||||
std::string Writer::addFile(const char* Name,const Base::Persistence *Object)
|
||||
{
|
||||
// always check isForceXML() before requesting a file!
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
void setForceXML(bool on);
|
||||
/// check on state
|
||||
bool isForceXML(void);
|
||||
void setFileVersion(int);
|
||||
int getFileVersion() const;
|
||||
|
||||
/// insert a file as CDATA section in the XML file
|
||||
void insertAsciiFile(const char* FileName);
|
||||
@@ -106,6 +108,7 @@ protected:
|
||||
char indBuf[256];
|
||||
|
||||
bool forceXML;
|
||||
int fileVersion;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ void Gui::SoFCDB::init()
|
||||
PropertyAngleItem ::init();
|
||||
PropertyBoolItem ::init();
|
||||
PropertyVectorItem ::init();
|
||||
PropertyDoubleVectorItem ::init();
|
||||
PropertyMatrixItem ::init();
|
||||
PropertyPlacementItem ::init();
|
||||
PropertyEnumItem ::init();
|
||||
|
||||
@@ -864,7 +864,7 @@ PropertyVectorItem::PropertyVectorItem()
|
||||
|
||||
QVariant PropertyVectorItem::toString(const QVariant& prop) const
|
||||
{
|
||||
const Base::Vector3f& value = prop.value<Base::Vector3f>();
|
||||
const Base::Vector3d& value = prop.value<Base::Vector3d>();
|
||||
QString data = QString::fromAscii("[%1 %2 %3]")
|
||||
.arg(QLocale::system().toString(value.x, 'f', 2))
|
||||
.arg(QLocale::system().toString(value.y, 'f', 2))
|
||||
@@ -903,7 +903,7 @@ QWidget* PropertyVectorItem::createEditor(QWidget* parent, const QObject* /*rece
|
||||
void PropertyVectorItem::setEditorData(QWidget *editor, const QVariant& data) const
|
||||
{
|
||||
QLineEdit* le = qobject_cast<QLineEdit*>(editor);
|
||||
const Base::Vector3f& value = data.value<Base::Vector3f>();
|
||||
const Base::Vector3d& value = data.value<Base::Vector3d>();
|
||||
QString text = QString::fromAscii("[%1 %2 %3]")
|
||||
.arg(QLocale::system().toString(value.x, 'f', 2))
|
||||
.arg(QLocale::system().toString(value.y, 'f', 2))
|
||||
@@ -949,109 +949,6 @@ void PropertyVectorItem::setZ(double z)
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyDoubleVectorItem, Gui::PropertyEditor::PropertyItem);
|
||||
|
||||
PropertyDoubleVectorItem::PropertyDoubleVectorItem()
|
||||
{
|
||||
m_x = static_cast<PropertyFloatItem*>(PropertyFloatItem::create());
|
||||
m_x->setParent(this);
|
||||
m_x->setPropertyName(QLatin1String("x"));
|
||||
this->appendChild(m_x);
|
||||
m_y = static_cast<PropertyFloatItem*>(PropertyFloatItem::create());
|
||||
m_y->setParent(this);
|
||||
m_y->setPropertyName(QLatin1String("y"));
|
||||
this->appendChild(m_y);
|
||||
m_z = static_cast<PropertyFloatItem*>(PropertyFloatItem::create());
|
||||
m_z->setParent(this);
|
||||
m_z->setPropertyName(QLatin1String("z"));
|
||||
this->appendChild(m_z);
|
||||
}
|
||||
|
||||
QVariant PropertyDoubleVectorItem::toString(const QVariant& prop) const
|
||||
{
|
||||
const Base::Vector3d& value = prop.value<Base::Vector3d>();
|
||||
QString data = QString::fromAscii("[%1 %2 %3]")
|
||||
.arg(QLocale::system().toString(value.x, 'f', 2))
|
||||
.arg(QLocale::system().toString(value.y, 'f', 2))
|
||||
.arg(QLocale::system().toString(value.z, 'f', 2));
|
||||
return QVariant(data);
|
||||
}
|
||||
|
||||
QVariant PropertyDoubleVectorItem::value(const App::Property* prop) const
|
||||
{
|
||||
// no real property class is using this
|
||||
return QVariant::fromValue<Base::Vector3d>(Base::Vector3d());
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setValue(const QVariant& value)
|
||||
{
|
||||
if (!value.canConvert<Base::Vector3d>())
|
||||
return;
|
||||
const Base::Vector3d& val = value.value<Base::Vector3d>();
|
||||
QString data = QString::fromAscii("(%1, %2, %3)")
|
||||
.arg(val.x,0,'f',decimals())
|
||||
.arg(val.y,0,'f',decimals())
|
||||
.arg(val.z,0,'f',decimals());
|
||||
setPropertyValue(data);
|
||||
}
|
||||
|
||||
QWidget* PropertyDoubleVectorItem::createEditor(QWidget* parent, const QObject* /*receiver*/, const char* /*method*/) const
|
||||
{
|
||||
QLineEdit *le = new QLineEdit(parent);
|
||||
le->setFrame(false);
|
||||
le->setReadOnly(true);
|
||||
return le;
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setEditorData(QWidget *editor, const QVariant& data) const
|
||||
{
|
||||
QLineEdit* le = qobject_cast<QLineEdit*>(editor);
|
||||
const Base::Vector3d& value = data.value<Base::Vector3d>();
|
||||
QString text = QString::fromAscii("[%1 %2 %3]")
|
||||
.arg(QLocale::system().toString(value.x, 'f', 2))
|
||||
.arg(QLocale::system().toString(value.y, 'f', 2))
|
||||
.arg(QLocale::system().toString(value.z, 'f', 2));
|
||||
le->setText(text);
|
||||
}
|
||||
|
||||
QVariant PropertyDoubleVectorItem::editorData(QWidget *editor) const
|
||||
{
|
||||
QLineEdit *le = qobject_cast<QLineEdit*>(editor);
|
||||
return QVariant(le->text());
|
||||
}
|
||||
|
||||
double PropertyDoubleVectorItem::x() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().x;
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setX(double x)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3d(x, y(), z())));
|
||||
}
|
||||
|
||||
double PropertyDoubleVectorItem::y() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().y;
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setY(double y)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3d(x(), y, z())));
|
||||
}
|
||||
|
||||
double PropertyDoubleVectorItem::z() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().z;
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setZ(double z)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3d(x(), y(), z)));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyMatrixItem, Gui::PropertyEditor::PropertyItem);
|
||||
|
||||
PropertyMatrixItem::PropertyMatrixItem()
|
||||
@@ -1481,12 +1378,12 @@ PropertyPlacementItem::PropertyPlacementItem() : init_axis(false), changed_value
|
||||
m_a->setParent(this);
|
||||
m_a->setPropertyName(QLatin1String("Angle"));
|
||||
this->appendChild(m_a);
|
||||
m_d = static_cast<PropertyDoubleVectorItem*>(PropertyDoubleVectorItem::create());
|
||||
m_d = static_cast<PropertyVectorItem*>(PropertyVectorItem::create());
|
||||
m_d->setParent(this);
|
||||
m_d->setPropertyName(QLatin1String("Axis"));
|
||||
m_d->setReadOnly(true);
|
||||
this->appendChild(m_d);
|
||||
m_p = static_cast<PropertyDoubleVectorItem*>(PropertyDoubleVectorItem::create());
|
||||
m_p = static_cast<PropertyVectorItem*>(PropertyVectorItem::create());
|
||||
m_p->setParent(this);
|
||||
m_p->setPropertyName(QLatin1String("Position"));
|
||||
m_p->setReadOnly(true);
|
||||
|
||||
@@ -335,39 +335,6 @@ private:
|
||||
PropertyFloatItem* m_z;
|
||||
};
|
||||
|
||||
class GuiExport PropertyDoubleVectorItem: public PropertyItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double x READ x WRITE setX DESIGNABLE true USER true)
|
||||
Q_PROPERTY(double y READ y WRITE setY DESIGNABLE true USER true)
|
||||
Q_PROPERTY(double z READ z WRITE setZ DESIGNABLE true USER true)
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
|
||||
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
|
||||
virtual QVariant editorData(QWidget *editor) const;
|
||||
|
||||
double x() const;
|
||||
void setX(double x);
|
||||
double y() const;
|
||||
void setY(double y);
|
||||
double z() const;
|
||||
void setZ(double z);
|
||||
|
||||
protected:
|
||||
virtual QVariant toString(const QVariant&) const;
|
||||
virtual QVariant value(const App::Property*) const;
|
||||
virtual void setValue(const QVariant&);
|
||||
|
||||
protected:
|
||||
PropertyDoubleVectorItem();
|
||||
|
||||
private:
|
||||
PropertyFloatItem* m_x;
|
||||
PropertyFloatItem* m_y;
|
||||
PropertyFloatItem* m_z;
|
||||
};
|
||||
|
||||
class GuiExport PropertyMatrixItem: public PropertyItem
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -510,8 +477,8 @@ private:
|
||||
bool changed_value;
|
||||
Base::Vector3d rot_axis;
|
||||
PropertyAngleItem * m_a;
|
||||
PropertyDoubleVectorItem* m_d;
|
||||
PropertyDoubleVectorItem* m_p;
|
||||
PropertyVectorItem* m_d;
|
||||
PropertyVectorItem* m_p;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,7 @@ using namespace PartDesign;
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Draft, PartDesign::DressUp)
|
||||
|
||||
const App::PropertyFloatConstraint::Constraints floatAngle = {0.0,89.9,0.1};
|
||||
const App::PropertyFloatConstraint::Constraints floatAngle = {0.0,89.99,0.1};
|
||||
|
||||
Draft::Draft()
|
||||
{
|
||||
|
||||
@@ -70,8 +70,8 @@ Data::Segment* PointKernel::getSubElement(const char* Type, unsigned long n) con
|
||||
|
||||
void PointKernel::transformGeometry(const Base::Matrix4D &rclMat)
|
||||
{
|
||||
std::vector<Base::Vector3f>& kernel = getBasicPoints();
|
||||
for (std::vector<Base::Vector3f>::iterator it = kernel.begin(); it != kernel.end(); ++it)
|
||||
std::vector<value_type>& kernel = getBasicPoints();
|
||||
for (std::vector<value_type>::iterator it = kernel.begin(); it != kernel.end(); ++it)
|
||||
*it = rclMat * (*it);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void PointKernel::operator = (const PointKernel& Kernel)
|
||||
|
||||
unsigned int PointKernel::getMemSize (void) const
|
||||
{
|
||||
return _Points.size() * sizeof(Base::Vector3d);
|
||||
return _Points.size() * sizeof(value_type);
|
||||
}
|
||||
|
||||
void PointKernel::Save (Base::Writer &writer) const
|
||||
@@ -112,7 +112,7 @@ void PointKernel::SaveDocFile (Base::Writer &writer) const
|
||||
uint32_t uCt = (uint32_t)size();
|
||||
str << uCt;
|
||||
// store the data without transforming it
|
||||
for (std::vector<Base::Vector3f>::const_iterator it = _Points.begin(); it != _Points.end(); ++it) {
|
||||
for (std::vector<value_type>::const_iterator it = _Points.begin(); it != _Points.end(); ++it) {
|
||||
str << it->x << it->y << it->z;
|
||||
}
|
||||
}
|
||||
@@ -176,12 +176,12 @@ void PointKernel::getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
PointKernel::const_point_iterator::const_point_iterator
|
||||
(const PointKernel* kernel, std::vector<Base::Vector3f>::const_iterator index)
|
||||
(const PointKernel* kernel, std::vector<kernel_type>::const_iterator index)
|
||||
: _kernel(kernel), _p_it(index)
|
||||
{
|
||||
if(_p_it != kernel->_Points.end())
|
||||
{
|
||||
Base::Vector3d vertd(_p_it->x, _p_it->y, _p_it->z);
|
||||
value_type vertd(_p_it->x, _p_it->y, _p_it->z);
|
||||
this->_point = _kernel->_Mtrx * vertd;
|
||||
}
|
||||
}
|
||||
@@ -207,17 +207,19 @@ PointKernel::const_point_iterator::operator=(const PointKernel::const_point_iter
|
||||
|
||||
void PointKernel::const_point_iterator::dereference()
|
||||
{
|
||||
Base::Vector3d vertd(_p_it->x, _p_it->y, _p_it->z);
|
||||
value_type vertd(_p_it->x, _p_it->y, _p_it->z);
|
||||
this->_point = _kernel->_Mtrx * vertd;
|
||||
}
|
||||
|
||||
const Base::Vector3d& PointKernel::const_point_iterator::operator*()
|
||||
const PointKernel::const_point_iterator::value_type&
|
||||
PointKernel::const_point_iterator::operator*()
|
||||
{
|
||||
dereference();
|
||||
return this->_point;
|
||||
}
|
||||
|
||||
const Base::Vector3d* PointKernel::const_point_iterator::operator->()
|
||||
const PointKernel::const_point_iterator::value_type*
|
||||
PointKernel::const_point_iterator::operator->()
|
||||
{
|
||||
dereference();
|
||||
return &(this->_point);
|
||||
|
||||
@@ -134,15 +134,15 @@ public:
|
||||
class PointsExport const_point_iterator
|
||||
{
|
||||
public:
|
||||
typedef Base::Vector3f value_single;
|
||||
typedef PointKernel::value_type kernel_type;
|
||||
typedef Base::Vector3d value_type;
|
||||
typedef std::vector<value_single>::const_iterator iter_type;
|
||||
typedef std::vector<kernel_type>::const_iterator iter_type;
|
||||
typedef iter_type::difference_type difference_type;
|
||||
typedef iter_type::iterator_category iterator_category;
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
|
||||
const_point_iterator(const PointKernel*, std::vector<value_single>::const_iterator index);
|
||||
const_point_iterator(const PointKernel*, std::vector<kernel_type>::const_iterator index);
|
||||
const_point_iterator(const const_point_iterator& pi);
|
||||
//~const_point_iterator();
|
||||
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
void dereference();
|
||||
const PointKernel* _kernel;
|
||||
value_type _point;
|
||||
std::vector<value_single>::const_iterator _p_it;
|
||||
std::vector<kernel_type>::const_iterator _p_it;
|
||||
};
|
||||
|
||||
typedef const_point_iterator const_iterator;
|
||||
|
||||
@@ -444,10 +444,10 @@ void PropertyCurvatureList::setValues(const std::vector<CurvatureInfo>& lValues)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
std::vector<double> PropertyCurvatureList::getCurvature( int mode ) const
|
||||
std::vector<float> PropertyCurvatureList::getCurvature( int mode ) const
|
||||
{
|
||||
const std::vector<Points::CurvatureInfo>& fCurvInfo = getValues();
|
||||
std::vector<double> fValues;
|
||||
std::vector<float> fValues;
|
||||
fValues.reserve(fCurvInfo.size());
|
||||
|
||||
// Mean curvature
|
||||
|
||||
@@ -155,7 +155,7 @@ private:
|
||||
/** Curvature information. */
|
||||
struct PointsExport CurvatureInfo
|
||||
{
|
||||
double fMaxCurvature, fMinCurvature;
|
||||
float fMaxCurvature, fMinCurvature;
|
||||
Base::Vector3f cMaxCurvDir, cMinCurvDir;
|
||||
};
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
int getSize(void) const {return _lValueList.size();}
|
||||
void setValue(const CurvatureInfo&);
|
||||
void setValues(const std::vector<CurvatureInfo>&);
|
||||
std::vector<double> getCurvature( int tMode) const;
|
||||
std::vector<float> getCurvature( int tMode) const;
|
||||
|
||||
/// index operator
|
||||
const CurvatureInfo& operator[] (const int idx) const {return _lValueList.operator[] (idx);}
|
||||
|
||||
Reference in New Issue
Block a user