当前位置: 首页>>代码示例>>C++>>正文


C++ Wire::addPoint方法代码示例

本文整理汇总了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);
}
开发者ID:Krerg,项目名称:VizPROC,代码行数:84,代码来源:wire.cpp


注:本文中的Wire::addPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。