![]() |
VR-Forces 4.0.4 Class Documentation
|
The Interface Manipulation example demonstrates the following:
The Interface Manipulation example creates a starting dialog that allows different options for the GUI to be entered into. One is the normal VRF GUI, one is a "Simple Scenario Player" that allows the user to load terrains or scenarios and observe them - but not interact with them. The other option created by this example is a "Simple Scenario Viewer" that allows the user only to observe simulation activity, but not to interact with it in any way.
/******************************************************************************* ** Copyright (c) 2011 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ //\file interfaceManipulationPluginInit.cxx //This file defines the generic DT_DLL_VRF_PLUGIN_EXPORT_MACRO. Use that macro when //you want to export symbols. Also, in your CMakeLists.txt file, make sure to //define the VRFPLUGIN_EXPORTS define to tell the compiler to define the macro as an //export #include <vrfGuiCore/vrfGuiExportPlugin.h> #include <vrvCore/DtToolbarConfiguration.h> #include <vrvCore/DtToolbarPath.h> #include <vrvCoreQt/DtQApplicationProvider.h> #include <vrfGuiCore/DtVrfContextMenuManagerSignaler.h> #include <vrfGuiCore/DtVrfObjectManipulationManager.h> #include <vrfGuiCoreQt/DtVrfScenarioManager.h> #include <vrfGuiCoreQt/DtVrfContextMenuManager.h> #include <vrfGuiCoreQt/DtSessionStartupDialog.h> #include <vrvCore/DtDe.h> #include <vrvCore/DtDriverManager.h> #include <vrvCore/DtInputDriver.h> #include <vrvCore/DtUserInterfaceAssembler.h> #include <vrvCore/DtVrvApplication.h> #include <vrvUtil/DtDeInitializer.h> #include <QtGui/QApplication> #include <QtGui/QDialog> #include <QtGui/QLayout> #include <QtGui/QPushButton> #include <QtGui/QLabel> #include <QtGui/QComboBox> #include <boost/bind.hpp> void sessionStartupDialogLoadOnlyMode(makVrf::DtSessionStartupDialog* d) { d->setAllowNewScenarioOnLocal(false); d->setAllowNewScenarioOnVR(false); } //Finalize setup of items that can only be done after initialization void postInitDeModule(makVrv::DtDe& de) { //Disable the terrain context menu de.driverManager().inputDriver().setTerrainContextEnabled(false); makVrf::DtVrfObjectManipulationManager::instance(de).setAllowEditing(false); } void createSimpleScenarioPlayer(makVrv::DtVrvApplication& app, makVrv::DtDe& de) { //Get rid of the auto hide panel. This allows users to create props and entities, which //this example does not want makVrv::DtUserInterfaceAssembler::instance(de).destroyBuilder( "DtAutoHidePanel", makVrv::DtUserInterfaceAssembler::instance(de).findWidgetBuilder("DtAutoHidePanel")); //When the session startup dialog is created, manipulate to only allow the load scenario options makVrf::DtVrfScenarioManager::instance(de).signal_sessionStartupBoxCreated.connect (boost::bind(&sessionStartupDialogLoadOnlyMode, _1)); //Disable all context menus makVrf::DtVrfContextMenuManager::instance(de).setEnabled(false); makVrv::DtMenuConfiguration simplePlayer; simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").item("DtOpenTerrainItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").item("DtLoadScenarioMenuItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").item("DtCloseScenarioMenuItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").separator("DtScenarioSeparator")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").item("DtExitItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtViewMenu").item("DtFullScreenItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtSimulationMenu")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtSimulationMenu").item("DtRewindScenarioMenuItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtSimulationMenu").item("DtPlayScenarioMenuItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtSimulationMenu").item("DtPauseScenarioMenuItem")); app.masterModeMenuConfiguration() = simplePlayer; //Clear out all toolbars except for observer settings makVrv::DtToolbarConfiguration toolbars; toolbars.addToolbarPath(makVrv::DtToolbarPath::row("Top_Row").toolbar("DtObserverSettingsToolbar")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").widget("DtObserverSelectionWidget")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").widget("DtObserverModeSelectionWidget")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").separator("DtObserverSettingsToolbarSeparator")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").widget("DtSetModelSetToolButton")); app.masterModeToolbarConfiguration() = toolbars; //Clear out page collections so there are no dock widgets app.masterModePageConfiguration() = makVrv::DtPageConfiguration(); } void createSimpleScenarioViewer(makVrv::DtVrvApplication& app, makVrv::DtDe& de) { //Get rid of the auto hide panel. This allows users to create props and entities, which //this example does not want makVrv::DtUserInterfaceAssembler::instance(de).destroyBuilder( "DtAutoHidePanel", makVrv::DtUserInterfaceAssembler::instance(de).findWidgetBuilder("DtAutoHidePanel")); //Do not show session startup dialog makVrf::DtVrfScenarioManager::instance(de).setDoNotShowSessionStartupDialog(true); //Disable all context menus makVrf::DtVrfContextMenuManager::instance(de).setEnabled(false); makVrv::DtMenuConfiguration simplePlayer; simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").item("DtExitItem")); simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtViewMenu").item("DtFullScreenItem")); //Clear out all toolbars except for observer settings makVrv::DtToolbarConfiguration toolbars; toolbars.addToolbarPath(makVrv::DtToolbarPath::row("Top_Row").toolbar("DtObserverSettingsToolbar")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").widget("DtObserverSelectionWidget")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").widget("DtObserverModeSelectionWidget")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").separator("DtObserverSettingsToolbarSeparator")); toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").widget("DtSetModelSetToolButton")); app.masterModeToolbarConfiguration() = toolbars; //Clear out the menus except exit and full screen app.masterModeMenuConfiguration() = simplePlayer; //Clear out page collections so there are no dock widgets app.masterModePageConfiguration() = makVrv::DtPageConfiguration(); } void chooseInterface(makVrv::DtVrvApplication& app, makVrv::DtDe& de) { //Create the qApplication if it has not already been created if (!qApp) { makVrv::DtQApplicationProvider& appProvider = makVrv::DtQApplicationProvider::instance(de); appProvider.qAppInstance(); } //Put up a dialog to allow the user to choose an interface type. Default, Player or Viewer. The choice //will then be used when the application is being initialized QDialog* dlg = new QDialog(0, Qt::Tool); QVBoxLayout* lay = new QVBoxLayout(dlg); dlg->setWindowTitle("Select User Interface"); lay->setMargin(4); lay->setSpacing(4); QComboBox* combo = new QComboBox(dlg); lay->addWidget(combo); combo->addItem("Default"); combo->addItem("Simple Scenario Player"); combo->addItem("Simple Scenario Viewer"); QSpacerItem* item = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding); QHBoxLayout* hLay = new QHBoxLayout; hLay->setMargin(0); hLay->setSpacing(0); lay->addLayout(hLay); hLay->addItem(item); QPushButton* ok = new QPushButton("&OK", dlg); QObject::connect(ok, SIGNAL(released()), dlg, SLOT(accept())); hLay->addWidget(ok); dlg->exec(); if (combo->currentIndex() == 1) { createSimpleScenarioPlayer(app, de); } else if (combo->currentIndex() == 2) { createSimpleScenarioViewer(app, de); } delete dlg; } bool initDeModule(makVrv::DtDe* de) { makVrv::DtVrvApplication* igApp = makVrv::DtVrvApplication::findFromDe(*de); if(igApp) { chooseInterface(*igApp, *de); return true; } else { return false; } } void DtPluginInformation(DtVrfPluginInformation& info) { info.pluginName = "Interface Manipulation"; info.pluginDescription = "This example shows how to manipulate the user interface."; info.pluginVersion = "1.00"; info.pluginCreator = "MAK Technologies"; info.pluginCreatorEmail = "sales@mak.com"; info.pluginContactWebPage = "www.mak.com"; info.pluginContactMailingAddress = "68 Moulton Street - Cambridge, MA 02138"; info.pluginContactPhone = "(617) 876 8085"; }