Exemplo n.º 1
0
 template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) {
     if (overlay->is3D()) {
         return static_cast<Base3DOverlay*>(overlay.get())->getBounds();
     } else {
         QRect bounds = static_cast<Overlay2D*>(overlay.get())->getBounds();
         return AABox(glm::vec3(bounds.x(), bounds.y(), 0.0f), glm::vec3(bounds.width(), bounds.height(), 0.1f));
     }
 }
Exemplo n.º 2
0
 template <> int payloadGetLayer(const Overlay::Pointer& overlay) {
     // MAgic number while we are defining the layering mechanism:
     const int LAYER_2D =  2;
     const int LAYER_3D_FRONT = 1;
     const int LAYER_3D = 0;
     if (overlay->is3D()) {
         return (static_cast<Base3DOverlay*>(overlay.get())->getDrawInFront() ? LAYER_3D_FRONT : LAYER_3D);
     } else {
         return LAYER_2D;
     }
 }
Exemplo n.º 3
0
 template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
     if (overlay->is3D() && !static_cast<Base3DOverlay*>(overlay.get())->getDrawOnHUD()) {
         if (static_cast<Base3DOverlay*>(overlay.get())->getDrawInFront()) {
             return ItemKey::Builder().withTypeShape().withLayered().build();
         } else {
             return ItemKey::Builder::opaqueShape();
         }
     } else {
         return ItemKey::Builder().withTypeShape().withViewSpace().build();
     }
 }
Exemplo n.º 4
0
 template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
     auto builder = ItemKey::Builder().withTypeShape();
     if (overlay->is3D()) {
         if (std::static_pointer_cast<Base3DOverlay>(overlay)->getDrawInFront()) {
             builder.withLayered();
         }
         if (overlay->getAlphaPulse() != 0.0f || overlay->getAlpha() != 1.0f) {
             builder.withTransparent();
         }
     } else {
         builder.withViewSpace();
     }
     return builder.build();
 }
void mitk::OverlayManager::AddOverlay(const Overlay::Pointer& overlay, BaseRenderer* renderer, bool ForceInForeground)
{
  std::pair<OverlaySet::iterator,bool> inSet;
  inSet = m_OverlaySet.insert(overlay);
  if(inSet.second)
  {
    if(ForceInForeground)
    {
      vtkRenderer* forgroundRenderer = m_ForegroundRenderer[renderer];
      overlay->AddToRenderer(renderer,forgroundRenderer);
    }
    else
      overlay->AddToBaseRenderer(renderer);
  }
}
void mitk::OverlayManager::RemoveOverlay(const Overlay::Pointer &overlay)
{
  OverlaySet::iterator overlayIt = m_OverlaySet.find(overlay);
  if( overlayIt == m_OverlaySet.end() )
    return;

  BaseRendererSet::iterator it;
  for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++)
  {
    overlay->RemoveFromBaseRenderer(*it);
    vtkRenderer* forgroundRenderer = m_ForegroundRenderer[*it];
    if(forgroundRenderer)
      overlay->RemoveFromRenderer(*it,forgroundRenderer);
  }

  m_OverlaySet.erase(overlayIt);
}
Exemplo n.º 7
0
void mitk::OverlayManager::AddOverlay(const Overlay::Pointer& overlay, BaseRenderer* renderer)
{
    std::pair<OverlaySet::iterator,bool> inSet;
    inSet = m_OverlaySet.insert(overlay);
    if(inSet.second)
    {
        overlay->AddToBaseRenderer(renderer);
    }
}
void mitk::OverlayManager::AddOverlay(const Overlay::Pointer& overlay, bool ForceInForeground)
{
  std::pair<OverlaySet::iterator,bool> inSet;
  inSet = m_OverlaySet.insert(overlay);
  if(inSet.second)
  {
    BaseRendererSet::iterator it;
    for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++ )
    {
      if(ForceInForeground)
      {
        vtkRenderer* forgroundRenderer = m_ForegroundRenderer[*it];
        overlay->AddToRenderer(*it,forgroundRenderer);
      }
      else
        overlay->AddToBaseRenderer(*it);
    }
  }
}
Exemplo n.º 9
0
 template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) {
     if (args) {
         if (overlay->getAnchor() == Overlay::MY_AVATAR) {
             auto batch = args->_batch;
             MyAvatar* avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
             glm::quat myAvatarRotation = avatar->getOrientation();
             glm::vec3 myAvatarPosition = avatar->getPosition();
             float angle = glm::degrees(glm::angle(myAvatarRotation));
             glm::vec3 axis = glm::axis(myAvatarRotation);
             float myAvatarScale = avatar->getScale();
             Transform transform = Transform();
             transform.setTranslation(myAvatarPosition);
             transform.setRotation(glm::angleAxis(angle, axis));
             transform.setScale(myAvatarScale);
             batch->setModelTransform(transform);
             overlay->render(args);
         } else {
             overlay->render(args);
         }
     }
 }
Exemplo n.º 10
0
    template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) {
        if (args) {
            if (overlay->getAnchor() == Overlay::MY_AVATAR) {
                glPushMatrix();
                MyAvatar* avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
                glm::quat myAvatarRotation = avatar->getOrientation();
                glm::vec3 myAvatarPosition = avatar->getPosition();
                float angle = glm::degrees(glm::angle(myAvatarRotation));
                glm::vec3 axis = glm::axis(myAvatarRotation);
                float myAvatarScale = avatar->getScale();

                glTranslatef(myAvatarPosition.x, myAvatarPosition.y, myAvatarPosition.z);
                glRotatef(angle, axis.x, axis.y, axis.z);
                glScalef(myAvatarScale, myAvatarScale, myAvatarScale);
                overlay->render(args);
                glPopMatrix();
            } else {
                overlay->render(args);
            }
        }
    }
Exemplo n.º 11
0
    template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
        auto builder = ItemKey::Builder().withTypeShape();
        if (overlay->is3D()) {
            auto overlay3D = std::static_pointer_cast<Base3DOverlay>(overlay);
            if (overlay3D->getDrawInFront() || overlay3D->getDrawHUDLayer()) {
                builder.withLayered();
            }
            if (overlay->isTransparent()) {
                builder.withTransparent();
            }
        } else {
            builder.withViewSpace();
        }

        if (!overlay->getVisible()) {
            builder.withInvisible();
        }

        builder.withTagBits(render::ItemKey::TAG_BITS_0); // Only draw overlays in main view

        return builder.build();
    }
Exemplo n.º 12
0
void mitk::OverlayManager::AddOverlay(const Overlay::Pointer& overlay)
{
    std::pair<OverlaySet::iterator,bool> inSet;
    inSet = m_OverlaySet.insert(overlay);
    if(inSet.second)
    {
        BaseRendererSet::iterator it;
        for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++ )
        {
            overlay->AddToBaseRenderer(*it);
        }
    }
}
Exemplo n.º 13
0
 template <> int payloadGetLayer(const Overlay::Pointer& overlay) {
     if (overlay->is3D()) {
         auto overlay3D = std::dynamic_pointer_cast<Base3DOverlay>(overlay);
         if (overlay3D->getDrawInFront()) {
             return Item::LAYER_3D_FRONT;
         } else if (overlay3D->getDrawHUDLayer()) {
             return Item::LAYER_3D_HUD;
         } else {
             return Item::LAYER_3D;
         }
     } else {
         return Item::LAYER_2D;
     }
 }
Exemplo n.º 14
0
 template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) {
     return overlay->getBounds();
 }
Exemplo n.º 15
0
 template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems) {
     return overlay->fetchMetaSubItems(subItems);
 }
Exemplo n.º 16
0
 template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay) {
     return overlay->getShapeKey();
 }
Exemplo n.º 17
0
 template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) {
     if (args) {
         overlay->render(args);
     }
 }