VR-Vantage 2.4 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleCustomMenu

Table of Contents

This example shows how to build a custom Menu and menu items using the VR-Vantage application framework and existing parts and pieces.

Say you want to use the existing VR-Vantage application but create your own menus, menu items and sub menu items. The example shows the simplest possible way to achieve this by registering custom menus with VR-Vantage. Once the menus are created, one can add their own logic to the GUI items.

The basic strategy here is let the DtVrvApplication do its thing, then just customize the way it looks. Let it load plug-ins, settings, data, etc. and then just what GUI elements are assembled right before the code that assembles the GUI executes. In this way, you get all the benefits of the plug-in architecture, but all the control of programatically created GUI.

The trick to doing that is to install an application transform, which is really just a function that gets called at a certain point. In this example we are going to install a function that gets called right after the plug-ins are loaded and before the GUI is assembled.

Here is the function we want to install. It's signature has to be the same as the DtVrvApplication::ApplicationTransform funtor:

We install the functor into the DtVrvApplication in main before the applications initialize method is called.

Building the Example

VR-Vantage includes pre-built versions of the example application. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.

Running the Example

This example is an application. You can run it by running ./bin/exampleCustomMenu.exe (on Windows) or ./bin/exampleCustomMenu (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleCustomMenu.cxx

/*****************************************************************************
* Copyright (c) 2012 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <boost/bind.hpp>
#include "CustomMenu.h"
// Use the VR-Vantage namespace. All classes in VR-Vantage are in this namespace.
using namespace makVrv;
void initializeMenu( DtDeInitializer& deInit, DtDe& de,
{
// Register the Menu and Menu item so they can be added to the gui.
makVrv::DtMenuPath::mainMenu("DtCustomMenu") );
makVrv::DtMenuPath::mainMenu("DtCustomMenu").item("CustomMenuItem") );
// Tell the De not to show the startup screen. This must be done here
// because it will be overwritten if set with the rest of the configs.
}
int main( int argc, char* argv[] )
{
// Configure the Application
//config.setDeFeatures( DtDeInitializer::Features_Stealth );
// A DtVrvApplication wraps up all the components required to build a complete
// VR-Vantage application (DtDe, DtPluginManager, DtEventLoop, and a
// DtVrvApplicationConfiguration).
DtVrvApplication vrvApp(config);
// Install callback to set up the GUI.
// Install our application transform after the plug-ins are loaded and before the GUI is assembled.
&initializeMenu, _1, _2, _3 ), "exampleCustomMenu" );
// This causes the plug-in manager to load plug-ins, cause a Display Configuration
// to be realized, creates the default environment, etc.
vrvApp.initialize( argc, argv );
// Creates an event loop and begins running it, causing the creation of frames.
vrvApp.run();
return 0;
}


Copyright © 2005-2018 VT MAK. All Rights Reserved (www.mak.com)