VR-Vantage
Loading...
Searching...
No Matches
exampleCustom

Overview

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

Expected Result

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;
}
Contains makVrv::DtDe class.
#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
Contains makVrv::DtMenuPath class.
Contains makVrv::DtQtMenuAssembler class.
Contains makVrv::DtVrvApplication implementation.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
virtual bool isInMasterMode() const
Returns true if the DtDe is in master mode.
The initialization configuration for the makVrv::DtDe.
Definition DtDeInitializer.h:40
A configuration of a menu layout. A menu configuration manages an ordered collection of menu paths th...
Definition DtMenuConfiguration.h:44
void addMenuPathBefore(const DtMenuPath &newPath, const DtMenuPath &relativeTo, const MenuSortFlags &sortFlagsIfMenu=(MenuSortFlags)(SortAllAlphabetically|SortWithinSubmenus|SortBetweenSeparators))
Adds the menu path before a relative (they must share the same parent).
void addMenuPath(const DtMenuPath &, const MenuSortFlags &sortFlagsIfMenu=(MenuSortFlags)(SortAllAlphabetically|SortWithinSubmenus|SortBetweenSeparators))
Adds the menu path (as well as its entire family).
void addMenuPathAfter(const DtMenuPath &newPath, const DtMenuPath &relativeTo, const MenuSortFlags &sortFlagsIfMenu=(MenuSortFlags)(SortAllAlphabetically|SortWithinSubmenus|SortBetweenSeparators))
Adds the menu path after a relative (they must share the same parent).
static MenuPathBuilder menu(const std::string &name)
static MenuPathBuilder popupMenu(const std::string &name)
static MenuPathBuilder mainMenu(const std::string &name)
A configuration of the pages in the gui.
Definition DtPageConfiguration.h:26
void addPagePath(const DtPagePath &, int weight=-1)
Adds the menu path (as well as its entire family).
void addPageCollection(const std::string &collectionClassName, const DtUnicode &pageTitle, PageCollectionLocation location, bool visible, const std::string &pageClassToShow, bool closable=true, bool floatable=true, bool movable=true)
Add a new page collection to the configuration.
@ DockLeft
Definition DtPageConfiguration.h:44
static PagePathBuilder collection(const std::string &name)
Start a main menu.
A configuration of the toolbar layout.
Definition DtToolbarConfiguration.h:26
void addToolbarPath(const DtToolbarPath &)
Adds the toolbar path (as well as its entire family).
static ToolbarPathBuilder toolbar(const std::string &name)
static DtUnicode fromAscii(const std::string &ascii)
Definition DtUnicode.inl:285
This owns a list of display engine configurations.
Definition DtVrvApplicationConfiguration.h:33
void setMasterModePageConfiguration(const DtPageConfiguration &pageConfig)
void setMasterModeToolbarConfiguration(const DtToolbarConfiguration &toolbarConfig)
void setMasterModeMenuConfiguration(const DtMenuConfiguration &menuConfig)
The Root IG Application object. To run the IG simply create one, initialize it and call run.
Definition DtVrvApplication.h:58
static DtVrvApplication * findFromDe(DtDe &)
virtual void installPostPluginTransform(const ApplicationTransform &transform, const std::string &id)
Add a transformer that runs after plug-ins are loaded.
boost::function< void(DtDeInitializer &, DtDe &, DtVrvApplicationConfiguration &)> ApplicationTransform
Definition DtVrvApplication.h:147
DT_DLL_EXAMPLEACCESSORY void init(makVrv::DtDe &de)
Contains DLL export macros.
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16