本文整理汇总了C++中Way::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Way::add方法的具体用法?C++ Way::add怎么用?C++ Way::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Way
的用法示例。
在下文中一共展示了Way::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressEvent
void CreateRoundaboutInteraction::mousePressEvent(QMouseEvent * event)
{
if (event->buttons() & Qt::LeftButton)
{
if (!HaveCenter)
{
HaveCenter = true;
view()->setInteracting(true);
Center = XY_TO_COORD(event->pos());
}
else
{
calculatePoints();
if (Points.size() == 0) return;
QPointF Prev = Points[0];
Node* First = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(Prev.toPoint()));
Way* R = g_backend.allocWay(theMain->document()->getDirtyOrOriginLayer());
CommandList* L = new CommandList(MainWindow::tr("Create Roundabout %1").arg(R->id().numId), R);
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),R,true));
R->add(First);
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),First,true));
if (M_PREFS->getAutoSourceTag()) {
QStringList sl = theMain->document()->getCurrentSourceTags();
if (sl.size())
R->setTag("source", sl.join(";"));
}
// "oneway" is implied on roundabouts
//R->setTag("oneway","yes");
if (DockData.type->currentIndex() == 0)
R->setTag("junction","roundabout");
for (int i = 1; i < Points.size(); i++ ) {
QPointF Next = Points[i];
Node* New = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(Next.toPoint()));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),New,true));
R->add(New);
}
R->add(First);
for (FeatureIterator it(document()); !it.isEnd(); ++it) {
Way* W1 = CAST_WAY(it.get());
if (W1 && (W1 != R))
Way::createJunction(theMain->document(), L, R, W1, true);
}
theMain->properties()->setSelection(R);
document()->addHistory(L);
view()->setInteracting(false);
view()->invalidate(true, true, false);
theMain->launchInteraction(0);
}
}
else
Interaction::mousePressEvent(event);
}
示例2: extractLayer
void TrackLayer::extractLayer()
{
DrawingLayer* extL = new DrawingLayer(tr("Extract - %1").arg(name()));
extL->setUploadable(false);
TrackNode* P;
QList<TrackNode*> PL;
const qreal coordPer10M = (double(COORD_MAX) * 2 / 40080000) * 2;
for (int i=0; i < size(); i++) {
if (TrackSegment* S = dynamic_cast<TrackSegment*>(get(i))) {
if (S->size() < 2)
continue;
// Cope with walking tracks
qreal konstant = coordPer10M;
qreal meanSpeed = S->distance() / S->duration() * 3600;
if (meanSpeed < 10.)
konstant /= 3.;
PL.clear();
P = g_backend.allocTrackNode(extL, S->getNode(0)->position() );
P->setTime(S->getNode(0)->time());
P->setElevation(S->getNode(0)->elevation());
P->setSpeed(S->getNode(0)->speed());
PL.append(P);
int startP = 0;
P = g_backend.allocTrackNode(extL, S->getNode(1)->position() );
P->setTime(S->getNode(1)->time());
P->setElevation(S->getNode(1)->elevation());
P->setSpeed(S->getNode(1)->speed());
PL.append(P);
int endP = 1;
for (int j=2; j < S->size(); j++) {
P = g_backend.allocTrackNode(extL, S->getNode(j)->position() );
P->setTime(S->getNode(j)->time());
P->setElevation(S->getNode(j)->elevation());
P->setSpeed(S->getNode(j)->speed());
PL.append(P);
endP = PL.size()-1;
LineF l(PL[startP]->position(), PL[endP]->position());
for (int k=startP+1; k < endP; k++) {
qreal d = l.distance(PL[k]->position());
if (d < konstant) {
Node* P = PL[k];
PL.removeAt(k);
g_backend.deallocFeature(extL, P);
endP--;
} else
startP = k;
}
}
Way* R = g_backend.allocWay(extL);
R->setLastUpdated(Feature::OSMServer);
extL->add(R);
for (int i=0; i < PL.size(); i++) {
extL->add(PL[i]);
R->add(PL[i]);
}
}
}
p->theDocument->add(extL);
}