本文整理汇总了C++中CommandList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandList::add方法的具体用法?C++ CommandList::add怎么用?C++ CommandList::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandList
的用法示例。
在下文中一共展示了CommandList::add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snapMouseReleaseEvent
void RotateInteraction::snapMouseReleaseEvent(QMouseEvent * anEvent, Feature* /*Closer*/)
{
Q_UNUSED(anEvent);
if (Angle != 0.0 && Rotating.size() && !panning())
{
CommandList* theList;
theList = new CommandList(MainWindow::tr("Rotate Feature").arg(Rotating[0]->id().numId), Rotating[0]);
for (int i=0; i<Rotating.size(); ++i)
{
if (NodeOrigin && Rotating[i] == OriginNode)
continue;
Rotating[i]->setPosition(OriginalPosition[i]);
if (Rotating[i]->layer()->isTrack())
theList->add(new MoveNodeCommand(Rotating[i],rotatePosition(OriginalPosition[i], Angle), Rotating[i]->layer()));
else
theList->add(new MoveNodeCommand(Rotating[i],rotatePosition(OriginalPosition[i], Angle), document()->getDirtyOrOriginLayer(Rotating[i]->layer())));
}
document()->addHistory(theList);
view()->invalidate(true, false);
}
Angle = 0.0;
Rotating.clear();
OriginalPosition.clear();
clearNoSnap();
}
示例2: snapMouseReleaseEvent
void ScaleInteraction::snapMouseReleaseEvent(QMouseEvent * anEvent, Feature* /*Closer*/)
{
Q_UNUSED(anEvent);
if (Radius != 1.0 && Scaling.size() && !panning())
{
CommandList* theList;
theList = new CommandList(MainWindow::tr("Scale Feature").arg(Scaling[0]->id().numId), Scaling[0]);
for (int i=0; i<Scaling.size(); ++i)
{
if (NodeOrigin && Scaling[i] == OriginNode)
continue;
Scaling[i]->setPosition(OriginalPosition[i]);
if (Scaling[i]->layer()->isTrack())
theList->add(new MoveNodeCommand(Scaling[i],scalePosition(OriginalPosition[i], Radius), Scaling[i]->layer()));
else
theList->add(new MoveNodeCommand(Scaling[i],scalePosition(OriginalPosition[i], Radius), document()->getDirtyOrOriginLayer(Scaling[i]->layer())));
}
document()->addHistory(theList);
view()->invalidate(true, true, false);
}
view()->setInteracting(false);
Radius = 1.0;
Scaling.clear();
OriginalPosition.clear();
clearNoSnap();
}
示例3: on_RemoveTagButton_clicked
void PropertiesDock::on_RemoveTagButton_clicked()
{
QTableView* TagTable = 0;
switch (NowShowing)
{
case TrackPointUiShowing:
TagTable = TrackPointUi.TagView; break;
case RoadUiShowing:
TagTable = RoadUi.TagView; break;
case MultiShowing:
TagTable = MultiUi.TagView; break;
case RelationUiShowing:
TagTable = RelationUi.TagView; break;
default: break;
}
if (!TagTable) return;
QModelIndexList indexes = TagTable->selectionModel()->selectedIndexes();
if (indexes.isEmpty()) return;
CommandList *L = 0;
if (indexes.count()==1)
{
QModelIndex index = indexes.at(0);
QModelIndex idx = index.sibling(index.row(),0);
QVariant Content(theModel->data(idx,Qt::DisplayRole));
if (Content.isValid())
{
QString KeyName = Content.toString();
L = new CommandList(MainWindow::tr("Clear Tag '%1' on %2").arg(KeyName).arg(Selection[0]->id().numId), Selection[0]);
for (int i=0; i<Selection.size(); ++i)
if (Selection[i]->findKey(KeyName) != -1)
L->add(new ClearTagCommand(Selection[i],KeyName,Main->document()->getDirtyOrOriginLayer(Selection[i]->layer())));
}
}
else
{
L = new CommandList(MainWindow::tr("Clear %1 tags on %2").arg(indexes.count()).arg(Selection[0]->id().numId), Selection[0]);
while (!indexes.isEmpty()) {
QModelIndex index = indexes.takeLast();
QModelIndex idx = index.sibling(index.row(),0);
QVariant Content(theModel->data(idx,Qt::DisplayRole));
if (Content.isValid())
{
QString KeyName = Content.toString();
for (int i=0; i<Selection.size(); ++i)
if (Selection[i]->findKey(KeyName) != -1)
L->add(new ClearTagCommand(Selection[i],KeyName,Main->document()->getDirtyOrOriginLayer(Selection[i]->layer())));
}
}
}
if (!L) return;
if (L->empty()) {
delete L;
} else {
Main->document()->addHistory(L);
Main->invalidateView();
}
}
示例4: 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);
}
示例5: on_RemoveMemberButton_clicked
void PropertiesDock::on_RemoveMemberButton_clicked()
{
if (CurrentMembersView)
{
Relation* R = dynamic_cast<Relation*>(Selection[0]);
if (R) {
QModelIndexList indexes = CurrentMembersView->selectionModel()->selectedIndexes();
QModelIndex index;
foreach(index, indexes)
{
QModelIndex idx = index.sibling(index.row(),0);
QVariant Content(R->referenceMemberModel(Main)->data(idx,Qt::UserRole));
if (Content.isValid())
{
Feature* F = Content.value<Feature*>();
if (F) {
CommandList* L = new CommandList(MainWindow::tr("Remove member '%1' on %2").arg(F->description()).arg(R->description()), R);
if (R->find(F) < R->size())
L->add(new RelationRemoveFeatureCommand(R,F,Main->document()->getDirtyOrOriginLayer(R->layer())));
if (L->empty())
delete L;
else
{
Main->document()->addHistory(L);
Main->invalidateView();
return;
}
}
}
}
}
}
示例6: on_SourceTagButton_clicked
void PropertiesDock::on_SourceTagButton_clicked()
{
QStringList sl = Main->document()->getCurrentSourceTags();
if (!sl.size())
return;
QString src = Selection[0]->tagValue("source", "");
if (!src.isEmpty())
sl.prepend(src);
CommandList* L = new CommandList(MainWindow::tr("Set \"source\" tag on %1").arg(Selection[0]->id().numId), Selection[0]);
L->add(new SetTagCommand(Selection[0], "source", sl.join(";")));
Main->document()->addHistory(L);
Main->invalidateView();
}
示例7: mousePressEvent
void CreateDoubleWayInteraction::mousePressEvent(QMouseEvent* anEvent)
{
if (anEvent->buttons() & Qt::LeftButton)
{
if (!HaveFirst)
{
HaveFirst = true;
view()->setInteracting(true);
FirstPoint = XY_TO_COORD(anEvent->pos());
FirstDistance = DockData.RoadDistance->text().toDouble();
}
else if (R1)
{
int i1 = R1->size()-1;
int i2 = 1;
LineF P1(
COORD_TO_XY(R1->getNode(i1-1)),
COORD_TO_XY(R1->getNode(i1)));
LineF P2(
COORD_TO_XY(R2->getNode(i2-1)),
COORD_TO_XY(R2->getNode(i2)));
Coord PreviousPoint = PreviousPoints[R1->size()-1];
if (distance(COORD_TO_XY(PreviousPoint), LastCursor) > 1)
{
qreal rB = view()->pixelPerM()*DockData.RoadDistance->text().toDouble()/2;
qreal rA = FirstDistance * view()->pixelPerM()/2;
LineF FA1(COORD_TO_XY(PreviousPoint),LastCursor);
LineF FA2(FA1);
LineF FB1(FA1);
LineF FB2(FA1);
qreal Modifier = DockData.DriveRight->isChecked()?1:-1;
FA1.slide(rA*Modifier);
FA2.slide(-rA*Modifier);
FB1.slide(rB*Modifier);
FB2.slide(-rB*Modifier);
LineF N1(FA1.project(COORD_TO_XY(PreviousPoint)), FB1.project(LastCursor));
LineF N2(FA2.project(COORD_TO_XY(PreviousPoint)), FB2.project(LastCursor));
Node* A1;
Node* A2;
CommandList* L = new CommandList(MainWindow::tr("Add nodes to double-way Road %1").arg(R1->id().numId), R1);
A1 = R1->getNode(i1);
A2 = R2->getNode(i2-1);
L->add(new MoveNodeCommand(A1,XY_TO_COORD(
P1.intersectionWith(N1).toPoint())));
L->add(new MoveNodeCommand(A2,XY_TO_COORD(
P2.intersectionWith(N2).toPoint())));
Node* B1 = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(
FB1.project(LastCursor).toPoint()));
Node* B2 = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(
FB2.project(LastCursor).toPoint()));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),B1,true));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),B2,true));
L->add(new WayAddNodeCommand(R1,B1));
L->add(new WayAddNodeCommand(R2,B2,(int)0));
document()->addHistory(L);
view()->invalidate(true, true, false);
//FirstPoint = view()->projection().inverse(anEvent->pos());
PreviousPoints[R1->size()-1] = XY_TO_COORD(anEvent->pos());
FirstDistance = DockData.RoadDistance->text().toDouble();
}
}
else
{
Coord PreviousPoint = FirstPoint;
if (distance(COORD_TO_XY(PreviousPoint), LastCursor) > 1)
{
qreal rB = view()->pixelPerM()*DockData.RoadDistance->text().toDouble()/2;
qreal rA = FirstDistance * view()->pixelPerM()/2;
LineF FA1(COORD_TO_XY(PreviousPoint),LastCursor);
LineF FA2(FA1);
LineF FB1(FA1);
LineF FB2(FA1);
qreal Modifier = DockData.DriveRight->isChecked()?1:-1;
FA1.slide(rA*Modifier);
FA2.slide(-rA*Modifier);
FB1.slide(rB*Modifier);
FB2.slide(-rB*Modifier);
Node* A1 = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(
FA1.project(COORD_TO_XY(PreviousPoint)).toPoint()));
Node* A2 = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(
FA2.project(COORD_TO_XY(PreviousPoint)).toPoint()));
Node* B1 = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(
FB1.project(LastCursor).toPoint()));
Node* B2 = g_backend.allocNode(theMain->document()->getDirtyOrOriginLayer(), XY_TO_COORD(
FB2.project(LastCursor).toPoint()));
R1 = g_backend.allocWay(theMain->document()->getDirtyOrOriginLayer());
R2 = g_backend.allocWay(theMain->document()->getDirtyOrOriginLayer());
CommandList* L = new CommandList(MainWindow::tr("Create double-way Road %1").arg(R1->id().numId), R1);
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),A1,true));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),A2,true));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),B1,true));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),B2,true));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),R1,true));
L->add(new AddFeatureCommand(theMain->document()->getDirtyOrOriginLayer(),R2,true));
//.........这里部分代码省略.........