コード例 #1
0
ファイル: zcircle.cpp プロジェクト: Vaa3D/vaa3d_tools
void ZCircle::display(QPainter *painter, int n, Display_Style style) const
{
  UNUSED_PARAMETER(style);
#if defined(_QT_GUI_USED_)
  double adjustedRadius = m_r + m_defaultPenWidth * 0.5;
  QRectF rect;
  if (hasVisualEffect(VE_BOUND_BOX)) {
    rect.setLeft(m_center.x() - adjustedRadius);
    rect.setTop(m_center.y() - adjustedRadius);
    rect.setWidth(adjustedRadius + adjustedRadius);
    rect.setHeight(adjustedRadius + adjustedRadius);
  }

  bool visible = false;

  if (n == -1) {
    visible = true;
  } else {
    if (isCuttingPlane(m_center.z(), m_r, n)) {
      double h = fabs(m_center.z() - n);
      if (m_r > h) {
        double r = sqrt(m_r * m_r - h * h);
        adjustedRadius = r + m_defaultPenWidth * 0.5;
        visible = true;
      } else { //too small, show at least one plane
        adjustedRadius = m_defaultPenWidth * 0.5;
        visible = true;
      }
    }
  }

  if (visible) {
    if (hasVisualEffect(VE_BOUND_BOX)) {
      painter->drawRect(rect);
    }

    if (!hasVisualEffect(VE_NO_CIRCLE)) {
      painter->drawEllipse(QPointF(m_center.x(), m_center.y()),
                           adjustedRadius, adjustedRadius);
    }
  }
#endif
}
コード例 #2
0
void ZCircle::displayHelper(ZPainter *painter, int stackFocus, EDisplayStyle style) const
{
  UNUSED_PARAMETER(style);
#if defined(_QT_GUI_USED_)
  double adjustedRadius = getAdjustedRadius(m_r);

  double dataFocus = stackFocus - painter->getZOffset();
  bool visible = false;

  const QBrush &oldBrush = painter->getBrush();
  const QPen &oldPen = painter->getPen();

  double alpha = oldPen.color().alphaF();

  if (stackFocus == -1) {
    visible = true;
  } else {
    if (isCuttingPlane(m_center.z(), m_r, dataFocus, m_zScale)) {
      double h = fabs(m_center.z() - dataFocus) / m_zScale;
      double r = 0.0;
      if (m_r > h) {
        r = sqrt(m_r * m_r - h * h);
        adjustedRadius = getAdjustedRadius(r);
        //adjustedRadius = r + getPenWidth() * 0.5;
        visible = true;
      } else { //too small, show at least one plane
        //adjustedRadius = getPenWidth() * 0.5;
        r = 0.1;
        adjustedRadius = getAdjustedRadius(r);
        visible = true;
      }
      if (hasVisualEffect(VE_OUT_FOCUS_DIM)) {
        alpha *= r * r / m_r / m_r;
        //alpha *= alpha;
      }
    }
  }

  if (visible) {
    if (!hasVisualEffect(VE_NO_CIRCLE)) {
      //qDebug() << painter->brush().color();
      QColor color = painter->getPenColor();
      color.setAlphaF(alpha);
      painter->setPen(color);
      painter->drawEllipse(QPointF(m_center.x(), m_center.y()),
                           adjustedRadius, adjustedRadius);
    }
  }

  if (hasVisualEffect(VE_BOUND_BOX)) {
    QRectF rect;
    double halfSize = adjustedRadius;
    if (m_usingCosmeticPen) {
      halfSize += 0.5;
    }
    rect.setLeft(m_center.x() - halfSize);
    rect.setTop(m_center.y() - halfSize);
    rect.setWidth(halfSize * 2);
    rect.setHeight(halfSize * 2);

    painter->setBrush(Qt::NoBrush);

    QPen pen = oldPen;
    if (visible) {
      pen.setStyle(Qt::SolidLine);
    } else {
      pen.setStyle(Qt::DotLine);
    }
    pen.setCosmetic(m_usingCosmeticPen);
    painter->setPen(pen);

#if 0 //for future versions
    QPen pen = oldPen;
    QVector<qreal> pattern;
    pattern << 1 << 2;
    pen.setDashPattern(pattern);
    painter->setPen(pen);
    painter->drawRect(rect);

    pen.setColor(Qt::black);
    pen.setDashOffset(1.5);
    painter->setPen(pen);
#endif

    //QPainter::CompositionMode oldMode = painter->compositionMode();
    //painter->setCompositionMode(QPainter::RasterOp_SourceXorDestination);
    painter->drawRect(rect);

    //painter->setCompositionMode(oldMode);
  }

  painter->setBrush(oldBrush);
  painter->setPen(oldPen);
#endif
}
コード例 #3
0
bool ZCircle::isCuttingPlane(double n, double zScale)
{
  return isCuttingPlane(m_center.z(), m_r, n, zScale);
}