コード例 #1
0
/* Adds all groups and shapes to the tree as items. */
void PolygonView::setShape(Shape3D * shape) {
  EM_CERR("PolygonView::setShape");
  this->disableButtons();
  p_Shape = shape;
  if (shape == NULL)  return;

  ListItem * shapeitem = new ListItem(p_PolygonListView, "shape");
  shapeitem->setOpen(TRUE);

  int polyindex = 0;
  Polygon3D * poly = shape->getPolygon(polyindex);
  // all polys
  while (poly != NULL) {
    QString str;
    if (polyindex < 100 && polyindex >= 10) {
      str = "0" + QString().setNum(polyindex);
    } else if (polyindex < 10) {
      str = "00" + QString().setNum(polyindex);
    } else {
      str = QString().setNum(polyindex);
    }

    ListItem * polyitem = new ListItem(shapeitem, str + " polygon");
    polyitem->setObject(poly, LISTITEM_POLYGON);
    // hash it
    m_hPolyListItem.insert(pair<Polygon3D*, ListItem*>(poly, polyitem));
		
    polyindex++;
    poly = shape->getPolygon(polyindex);
  }
}
コード例 #2
0
void PolygonView::setPolygon(Shape3D * shape, Polygon3D * poly) {
  EM_CERR("PolygonView::setPolygon");
  p_VertexListView->clear();
  assert(shape != NULL);
  assert(poly != NULL);
  p_Polygon = poly;

  int index = 0;
  int vtxindex = poly->getIndex(index);
  Vertex3D * vtx = shape->getVertex3D(vtxindex);
  Color * color = poly->getColor(index);
  TexCoord * texcoord = poly->getTexCoord(index);
  while (vtx != NULL) {
    assert(color != NULL);
    assert(texcoord != NULL);
    QString str = QString().setNum(index) +
      " vtx " + 
      QString().setNum(vtx->x, 'g', 2) + " " +
      QString().setNum(vtx->y, 'g', 2) + " " +
      QString().setNum(vtx->z, 'g', 2) + " " +
      " color " +
      QString().setNum(color->r, 'g', 2) + " " +
      QString().setNum(color->g, 'g', 2) + " " +
      QString().setNum(color->b, 'g', 2) + " " +
      QString().setNum(color->a, 'g', 2) + " " +
      " tex " + 
      QString().setNum(texcoord->u, 'g', 2) + " " +
      QString().setNum(texcoord->v, 'g', 2);
    ListItem * vtxitem = new ListItem(p_VertexListView, str);
    vtxitem->setObject(INT2OBJ(vtxindex), LISTITEM_VERTEX);
	
    index++;
    vtxindex = poly->getIndex(index);
    vtx = shape->getVertex3D(vtxindex);
    color = poly->getColor(index);
    texcoord = poly->getTexCoord(index);
  }
  p_VertexListView->show();
}