VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Interface Manipulation (interfaceManipulation)

Table of Contents

The Interface Manipulation example demonstrates the following:

Modifying the vrfGUI User Interface

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 but with a new toobar, 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.

How to Run the Example

Usage

In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin.

To view the new behavior:

  1. Start VR-Forces GUI and SIM.
  2. A Select User Interface dialog will be displayed, before the vrfGui gets displayed.
  3. Select one of the available options - e.g. Normal With new Toolbar and press the OK button.
  4. VR-Forces GUI and SIM applications will start.
  5. Create a new scenario - e.g. EntityLevel SMS on Ground_DB II terrain.
  6. The GUI will have a new toolbar with a button 'Create Route' displayed.
  7. You should be able to press the 'Create Route' button and create a new route.

Classes

myButtonWidgetCreates a new 'Create Route' toolbar button.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#include <QPushButton>
namespace makVrv
{
class DtDe;
}
: public QPushButton
{
Q_OBJECT
public:
myButtonWidget( makVrv::DtDe& de, const QString & text, QWidget* parent = 0);
virtual ~myButtonWidget();
public slots:
protected:
};


/*******************************************************************************
** Copyright (c) 2012 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 <vrvCore/DtDe.h>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QLabel>
#include <QtWidgets/QComboBox>
#include <boost/bind.hpp>
//new
#include <QtWidgets/QToolBar>
#include <vlpi/entityType.h>
// Command line argument that specifies the ui type
DtCmdLine::ValueArg<int>* theUiType;
// Toolbar for holding new pushbuttons
class newToolbarClass : public makVrv::DtToolbar
{
public:
newToolbarClass (makVrv::DtDe& de);
virtual ~newToolbarClass();
virtual QToolBar* createToolbar(makVrv::DtDe&, QWidget* parent);
};
newToolbarClass::newToolbarClass(makVrv::DtDe& de)
: makVrv::DtToolbar(de, std::string("NewToolbar") )
{
}
newToolbarClass::~newToolbarClass()
{
}
QToolBar* newToolbarClass::createToolbar(makVrv::DtDe&, QWidget* parent)
{
QToolBar* tb = new QToolBar("NewToolbar", parent);
tb->setWindowTitle("New Toolbar");
return tb;
}
// Push button for creating route
const QString & text, QWidget* parent /* = 0 */)
: QPushButton(text, parent)
, myDe(de)
{
connect(
this, SIGNAL(clicked()),
this, SLOT(slot_onClicked()) );
}
{
DtWarn("Button clicked\n");
DtEntityType(17, 0, 0, 2, 0, 0, 0), 1);
}
class MyButtonWidgetBuilder : public makVrv::DtWidgetBuilder
{
public:
MyButtonWidgetBuilder(makVrv::DtDe& de);
virtual ~MyButtonWidgetBuilder();
virtual QWidget* create(makVrv::DtDe& de, QWidget* parent,
const Qt::WindowFlags& flags = 0);
};
//......................................................................
MyButtonWidgetBuilder::MyButtonWidgetBuilder(makVrv::DtDe& de)
: DtWidgetBuilder()
{
}
MyButtonWidgetBuilder::~MyButtonWidgetBuilder()
{
}
QWidget* MyButtonWidgetBuilder::create( makVrv::DtDe& de, QWidget* parent,
const Qt::WindowFlags& flags)
{
return new myButtonWidget(de, "Create Route", parent);
}
void setupNewToolbar(makVrv::DtVrvApplication& app, makVrv::DtDe& de)
{
makVrv::DtToolbar * tb = new newToolbarClass(de);
makVrv::DtToolbarPath::toolbar("NewToolbar").item("DtRangeRingsItem"));
MyButtonWidgetBuilder* bwb = new MyButtonWidgetBuilder(de);
"CreateRouteButton", bwb);
makVrv::DtToolbarPath::toolbar("NewToolbar").widget("CreateRouteButton"));
}
void sessionStartupDialogLoadOnlyMode(makVrf::DtSessionStartupDialog* d)
{
}
// Add new command line argument where the user can specify their argument for the ui type
{
theUiType = new ValueArg<int>("", "uiType",
"Type of UI to use (0 - Normal, 1 - Simple Scenario, 2 - Scenario Viewer, 3 - Map Area Only",false,-1,"int");
}
//Finalize setup of items that can only be done after initialization
{
if (theUiType->getValue() > 0)
{
//Disable the terrain context menu
if (theUiType->getValue() == 3)
{
}
}
}
void createSimpleScenarioPlayer(makVrv::DtVrvApplication& app, makVrv::DtDe& de)
{
//When the session startup dialog is created, manipulate to only allow the load scenario options
(boost::bind(&sessionStartupDialogLoadOnlyMode, _1));
//Disable all context menus
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
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"));
// New
toolbars.addToolbarPath(makVrv::DtToolbarPath::toolbar("DtObserverSettingsToolbar").item("DtRangeRingsItem"));
//Clear out page collections so there are no dock widgets
}
void createSimpleScenarioViewer(makVrv::DtVrvApplication& app, makVrv::DtDe& de)
{
//Do not show session startup dialog
//Disable all context menus
simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtFileMenu").item("DtExitItem"));
simplePlayer.addMenuPath(makVrv::DtMenuPath::mainMenu("DtViewMenu").item("DtFullScreenItem"));
//Clear out all toolbars except for observer settings
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"));
//Clear out the menus except exit and full screen
app.masterModeMenuConfiguration() = simplePlayer;
//Clear out page collections so there are no dock widgets
}
void showMapAreaOnly(makVrv::DtVrvApplication& app, makVrv::DtDe& de)
{
app.masterModeMenuConfiguration() = simplePlayer;
}
void chooseInterface(makVrv::DtVrvApplication& app, makVrv::DtDe& de)
{
//Create the qApplication if it has not already been created
if (!qApp)
{
appProvider.qAppInstance();
}
if (!theUiType->isSet())
{
//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("Normal With New Toolbar");
combo->addItem("Simple Scenario Player");
combo->addItem("Simple Scenario Viewer");
combo->addItem("Map Area Only");
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();
theUiType->setValue(combo->currentIndex());
delete dlg;
}
if (theUiType->getValue() == 0)
{
setupNewToolbar(app, de);
}
else if (theUiType->getValue() == 1)
{
createSimpleScenarioPlayer(app, de);
}
else if (theUiType->getValue() == 2)
{
createSimpleScenarioViewer(app, de);
}
else if (theUiType->getValue() == 3)
{
showMapAreaOnly(app, de);
}
}
{
if(igApp)
{
chooseInterface(*igApp, *de);
return true;
}
else
{
return false;
}
}
{
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 = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)