本文整理汇总了C++中Wire::addPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Wire::addPoint方法的具体用法?C++ Wire::addPoint怎么用?C++ Wire::addPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wire
的用法示例。
在下文中一共展示了Wire::addPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connectWire
void Wire::connectWire(Wire *w, int wirePart)
{
//добавляем провод в список проводов
this->wires->append(w);
//устанавливаем такой же список и на присоединяемый провод
delete w->getConnectedWires();
w->setWireList(wires);
QPoint* last = w->getPath()->last();
QPoint* beforeLast = w->getPath()->at(w->getPath()->size()-2);
//присоединяем в ближайшей точке
QPoint *tmp1 = this->path->at(--wirePart);
QPoint *tmp2 = this->path->at(++wirePart);
//делим провод на 2
Wire* secondWire = new Wire();
int index=0;
if(abs(tmp1->x()-last->x())+abs(tmp1->y()-last->y())<10) {
if(last->x()==beforeLast->x()) {
last->setX(tmp1->x());
last->setY(tmp1->y());
beforeLast->setX(tmp1->x());
index = wirePart-1;
} else {
last->setX(tmp1->x());
last->setY(tmp1->y());
beforeLast->setY(tmp1->y());
index = wirePart-1;
}
} else if (abs(tmp2->x()-last->x())+abs(tmp2->y()-last->y())<10){
index = wirePart;
if(last->x()==beforeLast->x()) {
last->setX(tmp2->x());
last->setY(tmp2->y());
beforeLast->setX(tmp2->x());
} else {
last->setX(tmp2->x());
last->setY(tmp2->y());
beforeLast->setY(tmp2->y());
}
} else {
//если нету ближайшей точки, то присоединяем так
if(tmp1->x()==tmp2->x()) {
last->setX(tmp1->x());
} else if(tmp1->y()==tmp2->y()) {
last->setY(tmp1->y());
} else {
//emmit error
}
index = wirePart;
secondWire->addPoint(new QPoint(last->x(),last->y()));
}
if(this->wireConnector!=NULL) {
secondWire->setWireConnector(this->wireConnector);
}
//надо добавить в список отрисовываемых объектов
this->wireConnector = new WireConnector(last->x(),last->y());
for(int i=index;i!=this->path->size();i++) {
QPoint *point = path->at(i);
secondWire->addPoint(point);
}
if(connected2!=NULL) {
secondWire->endConnection(this->connected2);
//вот это поворот
this->connected2=NULL;
}
int count = this->path->size()-index;
for(int i=0;i<(count);i++) {
this->path->removeLast();
}
this->path->append(new QPoint(last->x(),last->y()));
this->wires->append(secondWire);
secondWire->setWireList(wires);
emit addWire(secondWire);
}