VR-Forces 4.0.4 Class Documentation
DtObjectDataInterfaceMenuItem

guiObjectDataInterface.cxx

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

//\file guiObjectDataInterface.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 "guiObjectDataConsole.h"

#include <vrvCore/DtDe.h>

#include <QtGui/QMenu>
#include <boost/bind.hpp>
#include <vrfGuiCoreQt/vrfMainMenu.h>

using namespace makVrf;

//This menu item will create and display the object information dialog which will be an example of
//how to use the DtObjectDataInterface class to retrieve information about an object
class DtObjectDataInterfaceMenuItem : public makVrv::DtMenuItem
{
public:
   DtObjectDataInterfaceMenuItem(makVrv::DtDe& de)
      : makVrv::DtMenuItem("DtObjectDataInterfaceMenuItem")
   , myConsole(0)
   , myDe(de)
   {
   }

   virtual ~DtObjectDataInterfaceMenuItem()
   {
      delete myConsole;
   }

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

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

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

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

protected:
   DtGuiObjectDataConsole* myConsole;
   makVrv::DtDe& myDe;
};


bool initDeModule(makVrv::DtDe* de)
{
   //First, register the creators with the menu
  
   DtVrfMainMenu::instance(*de).registerMenuItem(new DtObjectDataInterfaceMenuItem(*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
   DtVrfMainMenu::instance(*de).createSimpleMenuBefore("Data Interface",
      makVrv::DtMenuPath::mainMenu("DtObjectDataInterfaceControlMenu"),
      makVrv::DtMenuPath::mainMenu("DtTaskMenu"));

   //Now, add the DtRemoteControlMenuItem as an item of DtRemoteControlMenu
   DtVrfMainMenu::instance(*de).menuConfiguration().addMenuPath(
      makVrv::DtMenuPath::mainMenu("DtObjectDataInterfaceControlMenu").item("DtObjectDataInterfaceMenuItem"));

   return true;
}

void DtPluginInformation(DtVrfPluginInformation& info)
{
   info.pluginName = "Network Data Interface";
   info.pluginDescription = "This example shows how to use the Network Data Interface classes to retrieve information about simulation objects.";
   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)