VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Interface Manipulation (interfaceManipulation)

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 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.

/*******************************************************************************
** 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 <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#include <QtGui/QComboBox>
#include <boost/bind.hpp>
//new
#include <QtGui/qtoolbar.h>
#include <vlpi/entityType.h>
static int theUiType = 0;
// Toolbar for holding new pushbuttons
class newToolbarClass : public makVrv::DtToolbar
{
public:
newToolbarClass (makVrv::DtDe& de);
virtual ~newToolbarClass();
};
newToolbarClass::newToolbarClass(makVrv::DtDe& de)
: makVrv::DtToolbar(de, std::string("NewToolbar") )
{
}
newToolbarClass::~newToolbarClass()
{
}
{
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()
{
}
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)
{
}
//Finalize setup of items that can only be done after initialization
{
if (theUiType > 0)
{
//Disable the terrain context menu
if (theUiType == 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();
}
//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 = combo->currentIndex();
if (combo->currentIndex() == 0)
{
setupNewToolbar(app, de);
}
else if (combo->currentIndex() == 1)
{
createSimpleScenarioPlayer(app, de);
}
else if (combo->currentIndex() == 2)
{
createSimpleScenarioViewer(app, de);
}
else if (combo->currentIndex() == 3)
{
showMapAreaOnly(app, de);
}
delete dlg;
}
{
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 = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 USA";
info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)