本文整理汇总了C++中PathObject::closeAllParts方法的典型用法代码示例。如果您正苦于以下问题:C++ PathObject::closeAllParts方法的具体用法?C++ PathObject::closeAllParts怎么用?C++ PathObject::closeAllParts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathObject
的用法示例。
在下文中一共展示了PathObject::closeAllParts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doImport
void Importer::doImport(bool load_symbols_only, const QString& map_path)
{
import(load_symbols_only);
// Object post processing:
// - make sure that there is no object without symbol
// - make sure that all area-only path objects are closed
// - make sure that there are no special points in wrong places (e.g. curve starts inside curves)
for (int p = 0; p < map->getNumParts(); ++p)
{
MapPart* part = map->getPart(p);
for (int o = 0; o < part->getNumObjects(); ++o)
{
Object* object = part->getObject(o);
if (object->getSymbol() == NULL)
{
addWarning(Importer::tr("Found an object without symbol."));
if (object->getType() == Object::Point)
object->setSymbol(map->getUndefinedPoint(), true);
else if (object->getType() == Object::Path)
object->setSymbol(map->getUndefinedLine(), true);
else
{
// There is no undefined symbol for this type of object, delete the object
part->deleteObject(o, false);
--o;
continue;
}
}
if (object->getType() == Object::Path)
{
PathObject* path = object->asPath();
Symbol::Type contained_types = path->getSymbol()->getContainedTypes();
if (contained_types & Symbol::Area && !(contained_types & Symbol::Line))
path->closeAllParts();
for (MapCoordVector::size_type i = 0; i < path->getCoordinateCount(); ++i)
{
if (path->getCoordinate(i).isCurveStart())
{
if (i+3 >= path->getCoordinateCount())
{
path->getCoordinate(i).setCurveStart(false);
continue;
}
if (path->getCoordinate(i + 1).isClosePoint() || path->getCoordinate(i + 1).isHolePoint() ||
path->getCoordinate(i + 2).isClosePoint() || path->getCoordinate(i + 2).isHolePoint())
{
path->getCoordinate(i).setCurveStart(false);
continue;
}
path->getCoordinate(i + 1).setCurveStart(false);
path->getCoordinate(i + 1).setDashPoint(false);
path->getCoordinate(i + 2).setCurveStart(false);
path->getCoordinate(i + 2).setDashPoint(false);
i += 2;
}
if (i > 0 && path->getCoordinate(i).isHolePoint())
{
if (path->getCoordinate(i-1).isHolePoint())
path->deleteCoordinate(i, false);
}
}
}
}
}
// Symbol post processing
for (int i = 0; i < map->getNumSymbols(); ++i)
{
if (!map->getSymbol(i)->loadFinished(map))
throw FileFormatException(Importer::tr("Error during symbol post-processing."));
}
// Template loading: try to find all template files
bool have_lost_template = false;
for (int i = 0; i < map->getNumTemplates(); ++i)
{
Template* temp = map->getTemplate(i);
bool loaded_from_template_dir = false;
temp->tryToFindAndReloadTemplateFile(map_path, &loaded_from_template_dir);
if (loaded_from_template_dir)
addWarning(Importer::tr("Template \"%1\" has been loaded from the map's directory instead of the relative location to the map file where it was previously.").arg(temp->getTemplateFilename()));
if (temp->getTemplateState() != Template::Loaded)
have_lost_template = true;
}
if (have_lost_template)
{
#if defined(Q_OS_ANDROID)
addWarning(tr("At least one template file could not be found."));
#else
addWarning(tr("At least one template file could not be found.") + " " +
tr("Click the red template name(s) in the Templates -> Template setup window to locate the template file name(s)."));
#endif
//.........这里部分代码省略.........
示例2: 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;
}