[TD]Simplify Cosmetic List & PyObject handling

This commit is contained in:
wandererfan
2020-05-11 15:30:29 -04:00
committed by WandererFan
parent 31bb4d84b9
commit 1533ea01ba
13 changed files with 92 additions and 88 deletions

View File

@@ -63,14 +63,12 @@ PropertyCenterLineList::PropertyCenterLineList()
PropertyCenterLineList::~PropertyCenterLineList()
{
for (std::vector<CenterLine*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCenterLineList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
// for (unsigned int i = newSize; i < _lValueList.size(); i++)
// delete _lValueList[i];
_lValueList.resize(newSize);
}
@@ -79,15 +77,12 @@ int PropertyCenterLineList::getSize(void) const
return static_cast<int>(_lValueList.size());
}
void PropertyCenterLineList::setValue(const CenterLine* lValue)
void PropertyCenterLineList::setValue(CenterLine* lValue)
{
if (lValue) {
aboutToSetValue();
CenterLine* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
_lValueList[0] = lValue;
hasSetValue();
}
}
@@ -95,13 +90,9 @@ void PropertyCenterLineList::setValue(const CenterLine* lValue)
void PropertyCenterLineList::setValues(const std::vector<CenterLine*>& lValue)
{
aboutToSetValue();
std::vector<CenterLine*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
_lValueList[i] = lValue[i];
hasSetValue();
}
@@ -115,9 +106,6 @@ PyObject *PropertyCenterLineList::getPyObject(void)
void PropertyCenterLineList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
// Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<CenterLine*> values;
@@ -135,8 +123,6 @@ void PropertyCenterLineList::setPyObject(PyObject *value)
}
setValues(values);
// if (part2d)
// part2d->acceptCenterLine();
}
else if (PyObject_TypeCheck(value, &(CenterLinePy::Type))) {
CenterLinePy *pcObject = static_cast<CenterLinePy*>(value);
@@ -153,7 +139,7 @@ void PropertyCenterLineList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<CenterLineList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
for (int i = 0; i < getSize(); i++) {
writer.Stream() << writer.ind() << "<CenterLine type=\""
<< _lValueList[i]->getTypeId().getName() << "\">" << endl;
writer.incInd();