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


C++ KstPainter::drawLine方法代码示例

本文整理汇总了C++中KstPainter::drawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ KstPainter::drawLine方法的具体用法?C++ KstPainter::drawLine怎么用?C++ KstPainter::drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KstPainter的用法示例。


在下文中一共展示了KstPainter::drawLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pressMoveLayoutModeEndPoint

void KstTopLevelView::pressMoveLayoutModeEndPoint(const QPoint& pos, bool maintainAspect) {
  // FIXME: remove this!!  Should not know about any specific type
  // for now we only know how to deal with lines 

  QRect bounds = _pressTarget->_parent->geometry();
  QPoint npos = pos;

  //pos must be inside the parent
  npos.setX(QMAX(npos.x(), bounds.left()));
  npos.setX(QMIN(npos.x(), bounds.right()));
  npos.setY(QMIN(npos.y(), bounds.bottom()));
  npos.setY(QMAX(npos.y(), bounds.top()));

  if (KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget)) {
    QPoint movePoint, anchorPoint;
    QPoint *fromPoint, *toPoint;

    if (_pressDirection & UP) {
      // UP means we are on the start endpoint
      movePoint = line->from();
      anchorPoint = line->to();
      fromPoint = &movePoint;
      toPoint = &anchorPoint;
    } else { // (_pressDirection & DOWN)
      // DOWN means we are on the end endpoint
      movePoint = line->to();
      anchorPoint = line->from();
      fromPoint = &anchorPoint;
      toPoint = &movePoint;
    }

    if (maintainAspect) {
      movePoint = KstGfxMouseHandlerUtils::findNearestPtOnLine(anchorPoint, movePoint, npos, bounds);
    } else {
      movePoint = npos; // already enforced pos inside parent.
    }

    const QRect old(_prevBand);
    
    _prevBand.setTopLeft(*fromPoint);
    _prevBand.setBottomRight(*toPoint);

    if (old != _prevBand) {
      KstPainter p;
      p.begin(_w);
      p.setPen(QPen(Qt::black, 0, Qt::DotLine));
      p.setRasterOp(Qt::NotROP);
      if (old.topLeft() != QPoint(-1, -1)) {
        p.drawLine(old.topLeft(), old.bottomRight());
      } 
      p.drawLine(_prevBand.topLeft(), _prevBand.bottomRight());
      p.end();
    }
  }
}
开发者ID:,项目名称:,代码行数:55,代码来源:

示例2: paintSelf

void KstViewLine::paintSelf(KstPainter& p, const QRegion& bounds) {
  p.save();
  if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) {
    if (p.makingMask()) {
      p.setRasterOp(Qt::SetROP);
      KstViewObject::paintSelf(p, geometry());
    } else {
      const QRegion clip(clipRegion());
      KstViewObject::paintSelf(p, bounds - clip);
      p.setClipRegion(bounds & clip);
    }
  }

  // figure out which direction to draw the line
  const int w(_width * p.lineWidthAdjustmentFactor());
  QPen pen(_foregroundColor, w);
  pen.setCapStyle(_capStyle);
  pen.setStyle(_penStyle);
  p.setPen(pen);

  const QRect geom(geometry());
  int u = 0, v = 0;
  
  // Adjust for large widths.  We don't want the line clipped because it goes
  // out of the bounding box.
  if (w > 1 && geom.height() > 0) {
    double theta = atan(geom.width()/geom.height());
    if (theta >= 0 && theta <= M_PI/4) {
      u = int(fabs((w / 2.0) * (sin(theta) + cos(theta))));
      v = int(fabs((w / 2.0) * (1.5*sin(theta) + 0.5*cos(theta))));
    } else {
      u = int(fabs((w / 2.0) * (1.5*sin(theta) + 0.5*cos(theta))));
      v = int(fabs((w / 2.0) * (sin(theta) + cos(theta))));
    }
  }

  switch (_orientation) {
    case UpLeft:
    case DownRight:
      p.drawLine(geom.bottomRight() + QPoint(-u, -v), geom.topLeft() + QPoint(u, v));
      break;
    case UpRight:
    case DownLeft:
      p.drawLine(geom.bottomLeft() + QPoint(u, -v), geom.topRight() + QPoint(-u, v));
      break;
  }
  p.restore();
}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例3: drawShadow

void KstViewLine::drawShadow(KstPainter& p, const QPoint& pos) {
  QPoint point1, point2;
  QRect rect = geometry();
  rect.moveTopLeft(pos);
  if (_orientation == UpLeft || _orientation == DownRight) {
    point1 = pos;
    point2 = rect.bottomRight();
  } else {
    point1 = rect.topRight();
    point2 = rect.bottomLeft();
  }
  p.drawLine(point1, point2);
}
开发者ID:,项目名称:,代码行数:13,代码来源:


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