Пример #1
0
void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVec)
{
	const std::vector<GeoLib::Point*>* points = pointVec.getVector();

	QList<QVariant> geoData;
	geoData << QVariant(geoName) << "" << "" << "" << "";
	GeoTreeItem* geo (new GeoTreeItem(geoData, _rootItem));
	_lists.push_back(geo);
	_rootItem->appendChild(geo);

	QList<QVariant> pointData;
	pointData << "Points" << "" << "" << "" << "";
	GeoObjectListItem* pointList = new GeoObjectListItem(pointData, geo, points, GeoLib::GEOTYPE::POINT);
	geo->appendChild(pointList);

	size_t nPoints = points->size();

	for (size_t j = 0; j < nPoints; j++)
	{
		const GeoLib::Point &pnt(*(*points)[j]);
		QList<QVariant> pnt_data;
		pnt_data.reserve(5);
		pnt_data << static_cast<unsigned>(j)
		         << QString::number(pnt[0], 'f')
		         << QString::number(pnt[1], 'f')
		         << QString::number(pnt[2], 'f')
		         << "";
		pointList->appendChild(new GeoTreeItem(pnt_data,
		                                       pointList,
		                                       static_cast<const GeoLib::Point*>(&pnt)));
	}

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

	INFO("Geometry \"%s\" built. %d points added.", geoName.toStdString().c_str(), nPoints);

	reset();
}
Пример #2
0
void GeoTreeModel::addPointList(QString geoName, const GeoLib::PointVec* pointVec)
{
	const std::vector<GeoLib::Point*>* points = pointVec->getVector();

	QList<QVariant> geoData;
	geoData << QVariant(geoName) << "" << "" << "" << "";
	GeoTreeItem* geo (new GeoTreeItem(geoData, _rootItem));
	_lists.push_back(geo);
	_rootItem->appendChild(geo);

	QList<QVariant> pointData;
	pointData << "Points" << "" << "" << "" << "";
	GeoObjectListItem* pointList = new GeoObjectListItem(pointData, geo, points, GeoLib::POINT);
	geo->appendChild(pointList);

	size_t nPoints = points->size();

	for (size_t j = 0; j < nPoints; j++)
	{
		const GeoLib::Point &pnt(*(*points)[j]);
		std::string pnt_name("");
		pointVec->getNameOfElementByID(j, pnt_name);
		QList<QVariant> pnt_data;
		pnt_data << static_cast<unsigned>(j)
		         << QString::number(pnt[0], 'f')
		         << QString::number(pnt[1], 'f')
		         << QString::number(pnt[2], 'f')
		         << QString::fromStdString(pnt_name);
		GeoTreeItem* point(new GeoTreeItem(pnt_data,
		                                   pointList,
		                                   static_cast<const GeoLib::Point*>(&pnt)));
		pointList->appendChild(point);
	}

	std::cout << "Geometry \"" << geoName.toStdString() << "\" built." << std::endl;
	std::cout << nPoints << " points added." << std::endl;

	reset();
}