void BandWidgetTestWidget::addNewPoint()
{
    SettingArgument &argument = SettingArgument::Setting();
    qreal upRange = argument.getBWUpRange();
    qreal lowRange = argument.getBWLowRange();
    int testTimes = argument.getBWTestTimes();

    qreal px = (ui->graphicsView->width()-90)/(testTimes-1);
    qreal py  = (value-lowRange)*(ui->graphicsView->height()-40)/(upRange-lowRange);
    QGraphicsItem *item = scene->addEllipse(-5, -5, 10, 10, QPen(), QBrush(QColor(Qt::blue)));
    item->setPos(px*(count), -py);
    item->setGroup(group);
    pointArray[count] = item;

    //两点之间使用直线连接
    if (count != 0 &&  pointArray[count-1] != NULL) {
        QGraphicsItem *line;
        QPointF point1 = pointArray[count-1]->pos();
        QPointF point2 = pointArray[count]->pos();
        QPen pen(Qt::blue);
        pen.setWidth(3);
        line = scene->addLine(point1.x(), point1.y(), point2.x(), point2.y(), pen);
        line->setGroup(group);
    }
}
Exemplo n.º 2
0
void
dmz::QtPluginCanvasObject::unlink_objects (
      const Handle LinkHandle,
      const Handle AttributeHandle,
      const UUID &SuperIdentity,
      const Handle SuperHandle,
      const UUID &SubIdentity,
      const Handle SubHandle) {

   if (_canvasModule) {

      if (AttributeHandle == _linkAttributeHandle) {

         QGraphicsItem *superItem (_canvasModule->lookup_item (SuperHandle));
         QGraphicsItem *subItem (_canvasModule->lookup_item (SubHandle));

         if (superItem) {

            QGraphicsItemGroup *group (
               qgraphicsitem_cast <QGraphicsItemGroup *>(subItem));

            if (group) { superItem->setGroup (0); }
            else { superItem->setParentItem (0); }
         }
      }
   }
}