Checking which mode is active in mrview

Is there any simple option to check the current mode. I found the possibility to use window()->get_current_mode() but do not know how to continue from there.

I can check for the available features by using bitwise operations on the mode’s features but I assume there is a more straightforward option.

Thanks for your help!

OK, there’s a few things you can do here. If you only need to know whether it supports features of interest, you can query the features bitfield, a member of the Mode::Base class, which can take on any combination of the flags listed here.

If you need to know whether you’re in 3D render mode when rendering a tool, you can query the is_3D flag passed to your Tool’s draw() call.

If you absolutely must know which mode is current, you can resort to dynamic casting, e.g.:

Mode::Lightbox* mode = dynamic_cast<Mode::Lightbox*> (window()->get_current_mode());
if (!mode) { 
  // mode is NOT lightbox
else {
  // do something useful with lightbox

Hopefully one of these will hit the mark?

1 Like