# Checking which mode is active in mrview

**URL:** <https://community.mrtrix.org/t/checking-which-mode-is-active-in-mrview/2577>\
**Category:** Development\
**Created:** [June 3, 2019, 1:23pm UTC](https://community.mrtrix.org/t/checking-which-mode-is-active-in-mrview/2577 "2019-06-03T13:23:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darius](https://community.mrtrix.org/user_avatar/community.mrtrix.org/darius/32/3187_2.png) [@Darius](https://community.mrtrix.org/u/Darius)\
**Post date:** [June 3, 2019, 1:23pm UTC](https://community.mrtrix.org/t/checking-which-mode-is-active-in-mrview/2577/1 "2019-06-03T13:23:59Z")

</div>

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!  
Darius

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [June 5, 2019, 11:37am UTC](https://community.mrtrix.org/t/checking-which-mode-is-active-in-mrview/2577/2 "2019-06-05T11:37:07Z")

</div>

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](https://github.com/MRtrix3/mrtrix3/blob/master/src/gui/mrview/mode/base.h#L79), a member of the [Mode::Base](https://github.com/MRtrix3/mrtrix3/blob/master/src/gui/mrview/mode/base.h#L71-L219) class, which can take on any combination of the [flags listed here](https://github.com/MRtrix3/mrtrix3/blob/master/src/gui/mrview/mode/base.h#L44-L51).

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](https://github.com/MRtrix3/mrtrix3/blob/master/src/gui/mrview/tool/base.h#L131).

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

```auto
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?
