Announcement

Collapse
No announcement yet.

Is it possible remove and set again a SoGLRenderAction in viewer class?

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

  • vlagala@smrobotica.it
    replied
    Dear Mike,
    thank You very much for Your explanation.

    I'll follow Your suggestions.

    Best Regards,
    Vincenzo

    Leave a comment:


  • mikeheck
    replied
    Originally posted by [email protected] View Post
    Dear All,
    Please i'd like to know if is wrong or not, remove a previous GLRenderAction derived from the viewer and then set again with a new GLRenderAction type.

    for example:

    m_pHighlightRenderAction = new SoLineHighlightRenderAction();
    ((SoLineHighlightRenderAction*)m_pHighlightRenderA ction)->setColor(SbColor(1.f, .5f, 0.f));
    ((SoLineHighlightRenderAction*)m_pHighlightRenderA ction)->setLineWidth(2.5f);
    m_pViewer->setGLRenderAction(m_pHighlightRenderAction);

    ...

    delete m_pHighlightRenderAction;
    m_pHighlightRenderAction = new SoBoxHighlightRenderAction;
    m_pViewer->setGLRenderAction(m_pHighlightRenderAction);
    Hi Vincenzo,
    Yes, that is completely possible.
    BUT...
    Do NOT delete the current render action before calling the setGLRenderAction() method! That will certainly cause a crash because setGLRenderAction() calls methods on the current render action object in order to copy the current viewport (and other state) from the current render action to the new render action.

    One solution would be to create and store both the box and line highlight actions as member variables, and only delete them when the application exits. However, if you prefer to only keep one highlight action, you could do this:
    Code:
    SoGLRenderAction* currentAction = m_pViewer->getGLRenderAction();
    m_pHighlightRenderAction = new SoBoxHighlightRenderAction();
    m_pViewer->setGLRenderAction( m_pHighlightRenderAction );
    delete currentAction;
    Also note that you should NOT do this the first time you call setlGLRenderAction(). The setGLRenderAction() method will automatically destroy the "previous" render action if that render action was automatically created by Open Inventor.

    Regards,
    Mike

    Leave a comment:


  • Is it possible remove and set again a SoGLRenderAction in viewer class?

    Dear All,
    Please i'd like to know if is wrong or not, remove a previous GLRenderAction derived from the viewer and then set again with a new
    GLRenderAction type.

    for example:
    ....
    ..
    ....

    m_pHighlightRenderAction = new SoLineHighlightRenderAction();
    ((SoLineHighlightRenderAction*)m_pHighlightRenderA ction)->setColor(SbColor(1.f, .5f, 0.f));
    ((SoLineHighlightRenderAction*)m_pHighlightRenderA ction)->setLineWidth(2.5f);
    m_pViewer->setGLRenderAction(m_pHighlightRenderAction);
    ….
    ...

    delete
    m_pHighlightRenderAction;
    m_pHighlightRenderAction = new SoBoxHighlightRenderAction;
    m_pViewer->setGLRenderAction(m_pHighlightRenderAction);
    ...
    ..

    Thank You very much in advance.

    Regards,

    Vincenzo
Working...
X