Пример #1
0
void VrmlNodeGroup::checkAndRemoveNodes(Viewer *viewer)
{
    if (d_childrenToRemove.size())
    {
        viewer->beginObject(name(), 0, this);
        int i, n = d_childrenToRemove.size();
        for (i = 0; i < n; i++)
        {
            Viewer::Object child_viewerObject = 0;
            VrmlNode *kid = d_childrenToRemove[i];
            if (kid->toGeometry())
                child_viewerObject = kid->toGeometry()->getViewerObject();
            else if (kid->toGroup())
                child_viewerObject = kid->toGroup()->d_viewerObject;
            else if (kid->toProto())
                child_viewerObject = kid->toProto()->getViewerObject();
            else if (kid->toShape())
                child_viewerObject = kid->toShape()->getViewerObject();
            if (child_viewerObject)
                viewer->removeChild(child_viewerObject);
        }
        viewer->endObject();
    }
    while (d_childrenToRemove.size())
    {
        d_childrenToRemove.removeNode(d_childrenToRemove[0]);
    }
}
Пример #2
0
void VrmlScene::sensitiveEvent( void *object,
				double timeStamp,
				bool isOver, bool isActive,
				double *point )
{
  VrmlNode *n = (VrmlNode *)object;

  if (n)
    {
      VrmlNodeAnchor *a = n->toAnchor();
      if ( a )
	{
	  // This should really be (isOver && !isActive && n->wasActive)
	  // (ie, button up over the anchor after button down over the anchor)
	  if (isActive && isOver)
	    {
	      a->activate();
	      //theSystem->inform("");
	    }
	  else if (isOver)
	    {
	      const char *description = a->description();
	      const char *url = a->url();
	      if (description && url)
		theSystem->inform("%s (%s)", description, url);
	      else if (description || url)
		theSystem->inform("%s", description ? description : url);
	      //else
	      //theSystem->inform("");
	    }
	  //else
	  //theSystem->inform("");
	}

      // The parent grouping node is registered for Touch/Drag Sensors
      else
	{
	  VrmlNodeGroup *g = n->toGroup();
	  if (g)
	    {
	      //theSystem->inform("");
	      g->activate( timeStamp, isOver, isActive, point );
	      setModified();
	    }
	}
      
    }

  //else
  //theSystem->inform("");
}