Commit 5ccaa333 authored by Martin Heistermann's avatar Martin Heistermann

setPropertyFromFile: use reference instead of pointer; cosmetics

parent 8c30c68e
......@@ -117,7 +117,7 @@ private:
virtual void saveProperty();
virtual bool parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int& n);
virtual void setPropertyFromFile(QTextStream* file_stream_, unsigned int n, PropertyVisualizer *propVis);
virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis);
/// Disables picking.
void resetPicking();
......
......@@ -305,7 +305,7 @@ bool OMPropertyModel<MeshT>::parseHeader(QString header, PropertyVisualizer*& pr
template<typename MeshT>
void OMPropertyModel<MeshT>::setPropertyFromFile(QTextStream* file_stream_, unsigned int n, PropertyVisualizer* propVis)
void OMPropertyModel<MeshT>::setPropertyFromFile(QTextStream& file_stream, unsigned int n, PropertyVisualizer* propVis)
{
#ifdef ENABLE_SKELETON_SUPPORT
if (propVis->getPropertyInfo().typeinfo() == proptype_SkinWeights)
......@@ -314,7 +314,7 @@ void OMPropertyModel<MeshT>::setPropertyFromFile(QTextStream* file_stream_, unsi
{
QString propertyText = "";
QString tmp;
while ((tmp = file_stream_->readLine()) != "")
while ((tmp = file_stream.readLine()) != "")
propertyText = propertyText + tmp;
propVis->setPropertyFromText(i, propertyText);
}
......@@ -322,7 +322,7 @@ void OMPropertyModel<MeshT>::setPropertyFromFile(QTextStream* file_stream_, unsi
else
#endif
{
SingleObjectPropertyModel::setPropertyFromFile(file_stream_, n, propVis);
SingleObjectPropertyModel::setPropertyFromFile(file_stream, n, propVis);
}
}
......
......@@ -262,20 +262,20 @@ void SingleObjectPropertyModel::saveProperty(unsigned int propId)
QString filename = getSaveFilename(propId);
if (filename == "") return;
QFile file_(filename);
if (!file_.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
QFile file(filename);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
std::cerr << "PropertyVis saveProperty(): cannot open file for writing" << std::endl;
return;
}
QTextStream file_stream_(&file_);
QTextStream file_stream(&file);
file_stream_ << propVis->getHeader() << '\n';
file_stream << propVis->getHeader() << '\n';
int n = propVis->getEntityCount();
for (int i = 0; i < n; ++i)
{
QString propertyText = propVis->getPropertyText(i);
file_stream_ << propertyText << '\n';
file_stream << propertyText << '\n';
}
}
......@@ -285,21 +285,21 @@ void SingleObjectPropertyModel::loadProperty()
QString filename = getLoadFilename();
if (filename == "") return;
QFile file_(filename);
if (!file_.open(QIODevice::ReadOnly | QIODevice::Text)) {
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
std::cerr << "PropertyVis loadProperty(): cannot open file for reading" << std::endl;
return;
}
QTextStream file_stream_(&file_);
QTextStream file_stream(&file);
QString header = file_stream_.readLine();
QString header = file_stream.readLine();
PropertyVisualizer* propVis;
unsigned int n;
if (parseHeader(header, propVis, n))
{
setPropertyFromFile(&file_stream_, n, propVis);
setPropertyFromFile(file_stream, n, propVis);
}
else
{
......@@ -308,11 +308,11 @@ void SingleObjectPropertyModel::loadProperty()
}
void SingleObjectPropertyModel::setPropertyFromFile(QTextStream* file_stream_, unsigned int n, PropertyVisualizer* propVis)
void SingleObjectPropertyModel::setPropertyFromFile(QTextStream& file_stream, unsigned int n, PropertyVisualizer* propVis)
{
for (unsigned int i = 0; i < n; ++i)
{
QString propertyText = file_stream_->readLine();
QString propertyText = file_stream.readLine();
propVis->setPropertyFromText(i, propertyText);
}
}
......
......@@ -170,7 +170,7 @@ protected:
void loadProperty();
/// Sets the property values from a given file.
virtual void setPropertyFromFile(QTextStream *file_stream_, unsigned int n, PropertyVisualizer *propVis);
virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis);
/**
* @brief Parses the property file header.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment