Example #1
0
void ZSparseObject::display(ZPainter &painter, int z, EDisplayStyle option) const
{
  if (m_stackGrid.isEmpty() || z < 0) {
    ZObject3dScan::display(painter, z, option);
  } else {
    UNUSED_PARAMETER(option);
    z -= iround(painter.getZOffset());
    QPen pen(m_color);
    painter.setPen(pen);

    size_t stripeNumber = getStripeNumber();
    for (size_t i = 0; i < stripeNumber; ++i) {
      const ZObject3dStripe &stripe = getStripe(i);
      if (stripe.getZ() == z) {
        int nseg = stripe.getSegmentNumber();
        for (int j = 0; j < nseg; ++j) {
          int x0 = stripe.getSegmentStart(j);
          int x1 = stripe.getSegmentEnd(j);
          int y = stripe.getY();
          for (int x = x0; x <= x1; ++x) {
            int v = getVoxelValue(x, y, z);
            painter.setPen(QColor(v, v, v));
            painter.drawPoint(QPoint(x, y));
          }
        }
      }
    }
  }
}