VR-Forces 4.0.4 Class Documentation
DtRemoteControlMenuItem

guiThreadVrfRemoteController.cxx

/*******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/

//\file guiThreadVrfRemoteController.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 "remoteControlConsole.h"

#include <vrfGuiCore/entityMapperKey.h>

#include <vrvCore/DtDe.h>
#include <vrvCore/DtVrvApplication.h>
#include <vrvUtil/DtDeInitializer.h>
#include <vrvCore/DtUserInterfaceAssembler.h>
#include <vrvCoreQt/DtMenuItem.h>
#include <vrvCoreQt/DtQtMenuAssembler.h>
#include <vrvCoreQt/DtMenu.h>

#include <QtGui/QMenu>
#include <QtGui/QMessageBox>

#include <boost/bind.hpp>

using namespace makVrv;

//New main menu. This menu will be used to hold the Remote Control Console menu item
class DtRemoteControlMenu : public DtMenu
{
public:
   DtRemoteControlMenu(DtDe& de)
   : DtMenu(de, "DtRemoteControlMenu")
   {
   }

   ~DtRemoteControlMenu()
   {
   }

   QMenu* createMenu( DtDe& de, QWidget* parent )
   {
      QMenu* menu = new QMenu(QObject::tr("Remote Control"), parent);

      return menu;
   }
};

//This menu item will create and display the remote control console dialog which will be an example of
//how to use the DtCrossThreadVrfRemoteControl (the GUI version of the DtVrfRemoteController)
class DtRemoteControlMenuItem : public DtMenuItem
{
public:
   DtRemoteControlMenuItem(DtDe& de)
   : DtMenuItem("DtRemoteControlMenuItem")
   , myConsole(0)
   , myDe(de)
   {
   }

   virtual ~DtRemoteControlMenuItem()
   {
      delete myConsole;
   }

     //Build a menu item (via an action).
   virtual QAction* createAction(DtDe&, QWidget* parent)
   {
      return new QAction(tr("Remote Control Console..."), parent);
   }

protected:
   void on_triggered()
   {
      QAction* action = dynamic_cast<QAction*>(sender());
      QWidget* parent = 0;
      if(action)
      {
         parent = action->parentWidget();
      }

      if (!myConsole)
      {
         myConsole = new DtRemoteControlConsole(myDe, parent);
      }

      myConsole->show();
      myConsole->raise();
   }

protected:
   DtRemoteControlConsole* myConsole;
   DtDe& myDe;
};

void initPluginMenus(DtVrvApplication& app, DtDe& de)
{
   //First, register the creators with the menu assember
   DtQtMenuAssembler::instance(de).registerMenu(new DtRemoteControlMenu(de));
   DtQtMenuAssembler::instance(de).registerMenu(new DtRemoteControlMenuItem(de));

   //Now, add the menu to the master mode configuration.  mainMenu indicates that
   //the example menu is going to be used as a top-level main menu rather than a
   //sub-menu.  Add it before the Task menu.  To leave off the path will
   //put the menu at the end of the menu bar
   app.masterModeMenuConfiguration().addMenuPathBefore(DtMenuPath::mainMenu("DtRemoteControlMenu"),
      DtMenuPath::mainMenu("DtTaskMenu"));

   //Now, register the DtRemoteControlMenuItem as an item of DtRemoteControlMenu
   app.masterModeMenuConfiguration().addMenuPath(
      DtMenuPath::mainMenu("DtRemoteControlMenu").item("DtRemoteControlMenuItem"));
}

bool initDeModule(DtDe* de)
{
   DtVrvApplication* igApp = DtVrvApplication::findFromDe(*de);
   if(igApp)
   {
      initPluginMenus(*igApp, *de);
      return true;
   }
   else
   {
      return false;
   }
}

void DtPluginInformation(DtVrfPluginInformation& info)
{
   info.pluginName = "Cross Thread Vrf Remote Control";
   info.pluginDescription = "This example shows how to use the DtCrossThreadVrfRemoteControl class to control the simulation back-ends.";
   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";
}

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)