本文整理汇总了C++中PathObject::setTags方法的典型用法代码示例。如果您正苦于以下问题:C++ PathObject::setTags方法的具体用法?C++ PathObject::setTags怎么用?C++ PathObject::setTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathObject
的用法示例。
在下文中一共展示了PathObject::setTags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: import
bool TemplateTrack::import(QWidget* dialog_parent)
{
if (track.getNumWaypoints() == 0 && track.getNumSegments() == 0)
{
QMessageBox::critical(dialog_parent, tr("Error"), tr("The path is empty, there is nothing to import!"));
return false;
}
const Track::ElementTags& tags = track.tags();
DeleteObjectsUndoStep* undo_step = new DeleteObjectsUndoStep(map);
MapPart* part = map->getCurrentPart();
std::vector< Object* > result;
map->clearObjectSelection(false);
if (track.getNumWaypoints() > 0)
{
int res = QMessageBox::question(dialog_parent, tr("Question"), tr("Should the waypoints be imported as a line going through all points?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (res == QMessageBox::No)
{
for (int i = 0; i < track.getNumWaypoints(); i++)
result.push_back(importWaypoint(templateToMap(track.getWaypoint(i).map_coord), track.getWaypointName(i)));
}
else
{
PathObject* path = importPathStart();
for (int i = 0; i < track.getNumWaypoints(); i++)
path->addCoordinate(MapCoord(templateToMap(track.getWaypoint(i).map_coord)));
importPathEnd(path);
path->setTag(QStringLiteral("name"), QString{});
result.push_back(path);
}
}
int skipped_paths = 0;
for (int i = 0; i < track.getNumSegments(); i++)
{
const int segment_size = track.getSegmentPointCount(i);
if (segment_size == 0)
{
++skipped_paths;
continue; // Don't create path without objects.
}
PathObject* path = importPathStart();
QString name = track.getSegmentName(i);
if (!tags[name].isEmpty())
{
path->setTags(tags[name]);
}
else
{
path->setTag(QStringLiteral("name"), name);
}
for (int j = 0; j < segment_size; j++)
{
const TrackPoint& track_point = track.getSegmentPoint(i, j);
auto coord = MapCoord { templateToMap(track_point.map_coord) };
if (track_point.is_curve_start && j < segment_size - 3)
coord.setCurveStart(true);
path->addCoordinate(coord);
}
if (track.getSegmentPoint(i, 0).gps_coord == track.getSegmentPoint(i, segment_size-1).gps_coord)
{
path->closeAllParts();
}
importPathEnd(path);
result.push_back(path);
}
for (int i = 0; i < (int)result.size(); ++i) // keep as separate loop to get the correct (final) indices
undo_step->addObject(part->findObjectIndex(result[i]));
map->setObjectsDirty();
map->push(undo_step);
map->emitSelectionChanged();
map->emitSelectionEdited(); // TODO: is this necessary here?
if (skipped_paths)
{
QMessageBox::information(
dialog_parent,
tr("Import problems"),
tr("%n path object(s) could not be imported (reason: missing coordinates).", "", skipped_paths) );
}
return true;
}