Ejemplo n.º 1
0
void GeoTreeModel::addChildren(GeoObjectListItem* plyList,
                               GeoLib::PolylineVec const& polyline_vec,
                               size_t start_index,
                               size_t end_index)
{
	const std::vector<GeoLib::Polyline*> lines = *(polyline_vec.getVector());

	for (size_t i = start_index; i < end_index; i++)
	{
		QList<QVariant> line_data;
		line_data.reserve(4);
		line_data << "Line " + QString::number(i) << "" << "" << "";

		const GeoLib::Polyline &line(*(lines[i]));
		GeoTreeItem* lineItem(new GeoTreeItem(line_data, plyList, &line));
		plyList->appendChild(lineItem);

		int nPoints = static_cast<int>(lines[i]->getNumberOfPoints());
		for (int j = 0; j < nPoints; j++)
		{
			const GeoLib::Point pnt(*(line.getPoint(j)));
			QList<QVariant> pnt_data;
			pnt_data.reserve(4);
			pnt_data << static_cast<int>(line.getPointID(j))
			         << QString::number(pnt[0], 'f')
			         << QString::number(pnt[1], 'f')
			         << QString::number(pnt[2], 'f');

			lineItem->appendChild(new TreeItem(pnt_data, lineItem));
		}
	}

	for (auto pnt = polyline_vec.getNameIDMapBegin(); pnt != polyline_vec.getNameIDMapEnd(); ++pnt)
		QVariant pnt_data (plyList->child(pnt->second)->setData(1, QString::fromStdString(pnt->first)));

	INFO("%d polylines added.", end_index - start_index);
}