INTRODUCTION

Pie menu is used in CHaMUE_2 to provide quick and easy access to menu

options such as switching modes and switching tools. Menu system has

a tree structure. A menu tree has one distinct root. The root node

stores top level pie slices of each mode. A child slice can have its

own children (i.e. sub menu). Root node of one tree menu cannot be

used as the child slice of another tree menu (i.e. menu of one mode

cannot be used submenu of another mode). However multiple modes can

share the same menu tree and multiple menu trees can share child

slices and their subsequent children. Each mode in CHaMUE_2 has the

option of using the default mode's menu tree or to create its own tree.

 

PROTOTYPE

/* creates a new menu, root is true if it's a root menu, gstPoint c */

/* is optional, setting pie slice to color c */

     MenuNode(string name, bool root);

     MenuNode::MenuNode(string name, bool root, gstPoint c);

 

/* set the function to call when menu is clicked   */

     void MenuNode::setFunction(void (*someFunction) (void *),

                              void *someArg);

 

/* set the alwaysfunction, evoked when menu session ends    */

     static void setAlwaysFunction(void (*someFunction) (void *),

                                 void *arg);

 

     static void setPhantom(gstPHANToM *p)

 

 

EXAMPLE1

Note: red indicates mandatory, see CHaMUE_2doc.cpp for real menu setup example                            

 

/* create a menu root for your mode, set root to true   */

     MenuNode *yourMenuRoot = new MenuNode("yourMenuRootTitle", true);

 

/* create a menu, set root to false, and color to grey */

     MenuNode *yourSubMenuwithColor = new MenuNode("colorMenuTitle",

                                      false, gstPoint(0.9, 0.9, 0.9));

 

/* add your root menu to the world, m_pWorld is defined in chamue_2doc  */

     m_pWorld->addChild(yourMenuRoot);

 

/* give the root menu a phantom  */

     yourMenuRoot->setPhantom(phantom);

 

/* menu root's function is called when menu root is activated     */

/* we want to make scene untouchable. "this" refers to            */

/* chamue_2doc                                                    */

     yourMenuRoot->setFunction(this->MakeSceneUntouchable, m_pGeometrySep);

 

/* setAlwaysFunction sets the function that is called whenever    */

/* menu session ends, we want to make scene touchable again       */

     yourMenuRoot->setAlwaysFunction(this->MakeSceneTouchable, m_pGeometrySep);

 

/* create a submenu, set root to false    */

     MenuNode *switchModes = new MenuNode("Switch Modes", false);

 

 

/* add new submenu to the root   */

     yourMenuRoot->addItem(switchModes);

 

/* store the root in an array called menuRoots inside   */

/* chamue_2doc.cpp                                      */

/* MenuNode   *menuRoots[NUM_SYS_MODES]                 */

     menuRoots[yourModeNum] = yourMenuRoot;

 

 

EXAMPLE2 (from chamue_2doc.cpp)