VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exampleCustom

Table of Contents

Overview

This example shows how to build a plugin that customizes the VR-Vantage UI.

Expected Result

exampleCustom.png
Custom Application Result

Example details

What if you wanted to build your own application that looked different that any of the existing VR-Vantage applications, yet also use all of the existing widgets, pages and other parts? The easist way to do that is to build a plugin that loads only the UI elements you want.

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 functor:

void postPluginTransform(DtDeInitializer& initializer, DtDe& de, DtVrvApplicationConfiguration& appConfig)
{
// Setup the pages
appConfig.setMasterModePageConfiguration(createCustomPages());
// Setup the menus
appConfig.setMasterModeMenuConfiguration(createCustomMenu());
// Setup the toolbars
appConfig.setMasterModeToolbarConfiguration(createCustomToolbar());
}

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 a plugin. For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleCustomUI.cxx

/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
using namespace makVrv;
DtPageConfiguration createCustomPages()
{
pages.addPageCollection("DtObjectsListPanel", DtUnicode::fromAscii("Objects List"), DtPageConfiguration::DockLeft, true, "DtOverlaysPage");
pages.addPagePath(DtPagePath::collection("DtObjectsListPanel").page("DtObjectsListPage"));
pages.addPagePath(DtPagePath::collection("DtObjectsListPanel").page("DtOverlaysPage"));
pages.addPageCollection("DtAttachmentPanel", DtUnicode::fromAscii("Attachments"), DtPageConfiguration::DockLeft, true, "DtAttachWidget");
pages.addPagePath(DtPagePath::collection("DtAttachmentPanel").page("DtAttachWidget"));
return pages;
}
DtMenuConfiguration createCustomMenu()
{
//*********************************************************************
//The File Menu.
//*********************************************************************
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").menu("DtNewMenu"));
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").menu("DtOpenMenu"));
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").separator("1"));
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").menu("DtAddMenu"));
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").separator("2"));
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").menu("DtCloseMenu"));
menus.addMenuPath(DtMenuPath::mainMenu("DtFileMenu").item("DtExitItem"));
menus.addMenuPathBefore(DtMenuPath::mainMenu("DtFileMenu").separator("ExitSeparator"),
DtMenuPath::mainMenu("DtFileMenu").item("DtExitItem"));
//Relative menus
menus.addMenuPath(DtMenuPath::menu("DtNewMenu").item("DtNewSceneItem"));
menus.addMenuPath(DtMenuPath::menu("DtNewMenu").item("DtNewTerrainItem"));
menus.addMenuPath(DtMenuPath::menu("DtOpenMenu").item("DtOpenSceneItem"));
menus.addMenuPath(DtMenuPath::menu("DtOpenMenu").item("DtOpenTerrainItem"));
menus.addMenuPath(DtMenuPath::menu("DtAddMenu").item("DtAddTerrainPatchMenuItem"));
menus.addMenuPath(DtMenuPath::menu("DtAddMenu").item("DtAddFeatureLayerItem"));
menus.addMenuPath(DtMenuPath::menu("DtCloseMenu").item("DtCloseTerrainItem"));
//*********************************************************************
//The Window Menu.
//*********************************************************************
menus.addMenuPath(DtMenuPath::mainMenu("DtViewMenu"));
menus.addMenuPath(DtMenuPath::mainMenu("DtViewMenu").item("DtAttachmentPanel"));
menus.addMenuPath(DtMenuPath::mainMenu("DtViewMenu").item("DtObjectsListPanel"));
//Add a separator after the DtObjectsListPanel.
menus.addMenuPathAfter(DtMenuPath::mainMenu("DtViewMenu").separator("1"),
DtMenuPath::mainMenu("DtViewMenu").item("DtObjectsListPanel"));
menus.addMenuPathAfter(DtMenuPath::mainMenu("DtViewMenu").item("DtTerrainToolbar"),
DtMenuPath::mainMenu("DtViewMenu").separator( "1" ) );
menus.addMenuPathAfter(DtMenuPath::mainMenu("DtViewMenu").item("DtSimulationConnectionsToolbar"),
DtMenuPath::mainMenu("DtViewMenu").item("DtDisplaySettingsToolbar"));
menus.addMenuPathAfter(DtMenuPath::mainMenu("DtViewMenu").separator("2"),
DtMenuPath::mainMenu("DtViewMenu").item("DtSimulationConnectionsToolbar"));
menus.addMenuPath(DtMenuPath::mainMenu("DtViewMenu").item("DtFullScreenItem"));
menus.addMenuPath(DtMenuPath::mainMenu("DtSettingsMenu"));
menus.addMenuPath(DtMenuPath::mainMenu("DtSettingsMenu").item("DtConnectionsMenuItem"));
//*********************************************************************
//The Help Menu.
//*********************************************************************
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").item("DtHelpItem"));
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").separator("1"));
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").item("DtAboutItem"));
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").separator("2"));
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").item("DtProductsWebSiteMenuItem"));
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").item("DtForumWebSiteMenuItem"));
menus.addMenuPath(DtMenuPath::mainMenu("DtHelpMenu").item("DtVersionWebSiteMenuItem"));
//*********************************************************************
//The right object context menu.
//*********************************************************************
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtObjectInfoItem"));
menus.addMenuPathAfter(DtMenuPath::popupMenu("DtObjectContextMenu").separator("1"),
DtMenuPath::popupMenu("DtObjectContextMenu").item("DtObjectInfoItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtTransparencyToggleItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachTetherItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachFollowItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachMimicItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachTrackItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachTetherTrackItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachMimicTrackItem"));
menus.addMenuPathAfter(DtMenuPath::popupMenu("DtObjectContextMenu").separator("2"),
DtMenuPath::popupMenu("DtObjectContextMenu").item("DtAttachMimicTrackItem"));
menus.addMenuPath(DtMenuPath::popupMenu("DtObjectContextMenu").item("DtCreateInsetViewItem"));
return menus;
}
DtToolbarConfiguration createCustomToolbar()
{
toolbars.addToolbarPath(DtToolbarPath::toolbar("DtTerrainToolbar").item("DtNewTerrainItem"));
toolbars.addToolbarPath(DtToolbarPath::toolbar("DtTerrainToolbar").item("DtOpenTerrainItem"));
toolbars.addToolbarPath(DtToolbarPath::toolbar("DtTerrainToolbar").item("DtCloseTerrainItem"));
toolbars.addToolbarPath(DtToolbarPath::toolbar("DtTerrainToolbar").separator("DtTerrainToolbarSeparator"));
toolbars.addToolbarPath(DtToolbarPath::toolbar("DtTerrainToolbar").item("DtAddTerrainPatchMenuItem"));
return toolbars;
}
void postPluginTransform(DtDeInitializer& initializer, DtDe& de, DtVrvApplicationConfiguration& appConfig)
{
// Setup the pages
appConfig.setMasterModePageConfiguration(createCustomPages());
// Setup the menus
appConfig.setMasterModeMenuConfiguration(createCustomMenu());
// Setup the toolbars
appConfig.setMasterModeToolbarConfiguration(createCustomToolbar());
}
void init(DtDe& de)
{
// Ensure that init only gets called once (not strictly necessary
// here, but this is good practice in general)
std::cout << "Loading custom GUI plugin" << std::endl;
if (de.isInMasterMode())
{
// Install our application transform to execute after the plug-ins
// are loaded and before the GUI is assembled.
if (app)
{
DtVrvApplication::ApplicationTransform functor = boost::bind(&postPluginTransform, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3);
app->installPostPluginTransform(functor, "SetupGUIPostPluginTransform");
}
}
}
bool initDeModule(DtDe* de)
{
init(*de);
return true;
}

[<< Examples] [Home] [Top of Page]


Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)