Announcement

Collapse
No announcement yet.

Extending SoPickStyle class

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extending SoPickStyle class

    Dear Mike,
    Dear Users,

    Please, i'd like to extend the SoPickStyle class, in order to manage better the unpickable shapes:
    i'd like to have unpickable shapes (points and normals unvailable using RayPick action), but selectable (using SoSelection node);

    so i derived a class from SoPickStyle and using a flag "force_shape_selection" in order to try to force the selection by SoSelection Node
    now i have a doubt:
    in my class i have the ovveride of the following function:
    doAction,
    callback
    and pick.


    Can i manage inside the SoRayPick extended class the "force pick"
    or i must ovveride also the SoShape nodes, managing the shouldRayPick function?

    Or maybe is there another way that is unknown to me?

    I hope i well explained all, but if you need futher informations, don't hesitate to ask.

    Best Regards,

    Vincenzo

  • #2
    update:

    after writing the following code:

    Code:
    void SoPickStyleExt::pick(SoPickAction* action)
    {
    if (style.getValue() == UNPICKABLE)
    {
    if (canSelect() && action)
    {
    if (action->getPathAppliedTo())
    {
    pTo3DView->GetViewer()->getViewerSceneManager()->getGLRenderAction()->apply(action->getPathAppliedTo());
    }
    else if (action->getNodeAppliedTo())
    {
    pTo3DView->GetViewer()->getViewerSceneManager()->getGLRenderAction()->apply(action->getNodeAppliedTo());
    }
    else
    {
    ASSERT(FALSE);
    }
    
    return;
    }
    }
    
    __super::pick(action);
    }
    where pTo3DView is the main class containing the SoWinFullViewer member to show the 3D scene graph,

    i've got the following warning messages:


    Inventor error: SoGLRenderAction::setUpState called without valid context

    Inventor error: SoGLRenderAction called without valid context

    Inventor error: SoGLRenderAction::setUpState called without valid context

    Inventor error: SoGLRenderAction called without valid context

    Inventor error: SoGLRenderAction::setUpState called without valid context

    Inventor error: SoGLRenderAction called without valid context

    Inventor error: SoGLRenderAction::setUpState called without valid context

    Inventor error: SoGLRenderAction called without valid context

    Please, can i call the render action directly or i must set up something else?

    Is it the right way or there is a better way to have the same beahviour?

    Thank You very much.

    Vincenzo

    Comment


    • #3
      Another Update:

      after reading docs and googling

      Code:
      void SoPickStyleExt::pick(SoPickAction* action)
      {
      if (style.getValue() == UNPICKABLE)
      {
      if (canSelect() && action)
      {
      
      //SbThreadAutoLock lock(classMutex);
      
      
      pTo3DView->GetViewer()->bindNormalContext();
      
      
      if (!action->getState())
      action->setUpState();
      
      
      if (action->isOfType(SoRayPickAction::getClassTypeId()))
      {
      if (((SoRayPickAction*)action)->isRadiusEnableForTriangles())
      {
      __super::pick(action);
      return;
      }
      }
      
      action->getState()->push();
      
      if (action->getPathAppliedTo())
      {
      //pTo3DView->GetViewer()->getViewerSceneManager()->getGLRenderAction()->apply(action->getPathAppliedTo());
      if (action->getSceneManager())
      action->getSceneManager()->getGLRenderAction()->apply(action->getPathAppliedTo());
      
      }
      else if (action->getNodeAppliedTo())
      {
      // if (!pTo3DView->GetViewer()->getViewerSceneManager()->getGLRenderAction()->getState())
      // pTo3DView->GetViewer()->getViewerSceneManager()->getGLRenderAction()->setUpState();
      //pTo3DView->GetViewer()->getViewerSceneManager()->getGLRenderAction()->apply(action->getNodeAppliedTo());
      if (action->getSceneManager())
      action->getSceneManager()->getGLRenderAction()->apply(action->getNodeAppliedTo());
      
      
      //g_PitagoraAppSceneGraph.m_pSelectionNode->select(action->getNodeAppliedTo());
      }
      else
      {
      ASSERT(FALSE);
      }
      
      action->getState()->pop();
      
      //if (bNoContext_oGL)
      //{
      // context->unbind();
      // if (context->getRefCount() > 0)
      // context->unref();
      //}
      
      return;
      }
      }
      
      __super::pick(action);
      }
      using the above code i have not warning/error messages, but still remain my question about the best ways to do this behaviour...

      Regards,
      Vincenzo

      Comment

      Working...
      X