VR-Forces 4.0.4 Class Documentation
Modify Set Example

The Modify Set example demonstrates the following:

To observe the plugin:

  1. Start vrfGui and vrfSim
  2. Create an M1A2 entity
  3. Select the entity and Set > Location...
  4. Observe the combo-box labeled "Example Combo". It should have options "Item 1" and "Item 2"
/*******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/

//\file modifySetPlugin.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 <vrfGuiCoreQt/DtVrfTaskSetDialogManager.h>
#include <vrfGuiCoreQt/DtTaskSetMenuItems.h>
#include <vrfGuiCoreQt/DtSetLocationDialog.h>

#include <vrvCore/DtDe.h>

#include <QtGui/QComboBox>
#include <QtGui/QLabel>
#include <QtGui/QLayout>

//Override of task move to dialog.  Will hide choice of path plan or regular movement mode
class MySetLocationDialog : public makVrf::DtSetLocationDialog
{
public:
   MySetLocationDialog(makVrv::DtDe& de, QWidget* parent, const Qt::WindowFlags& flags = 0)
   : makVrf::DtSetLocationDialog(de, parent, flags)
   {
   }

protected:
   //Override the contents method, calling the parent method first to create the contents, then
   //hide the movement box
   virtual QWidget* contents(const std::vector<makVrv::DtSimEntry*>& data)
   {
      QWidget* canvas = makVrf::DtSetLocationDialog::contents(data);

      QHBoxLayout* comboLayout = new QHBoxLayout;

      comboLayout->setMargin(0);
      comboLayout->setSpacing(2);

      QLabel* label = new QLabel(tr("Example Combo"), this);
      comboLayout->addWidget(label);

      QComboBox* combo = new QComboBox(this);
      comboLayout->addWidget(combo);

      combo->addItem(tr("Item 1"));
      combo->addItem(tr("Item 2"));

      myContentLayout->addLayout(comboLayout);

      return canvas;
   }
};

//Override of creator for task move to dialog.  Will create new instance
//of the move to dialog
class MySetLocationDialogCreator : public makVrf::DtSetLocationDialogCreator
{
public:
   virtual makVrf::DtTaskSetDialogInterface* create(makVrv::DtDe& de, QWidget* parent)
   {
      return new MySetLocationDialog(de, parent, theTaskSetCreationFlags);
   }
};

bool initDeModule(makVrv::DtDe* de)
{
   //The DtVrfTaskSetDialogManager is the class that holds all the creators
   //for task and set dialogs.  Install an override creator here to create
   //an instance of the move to dialog
   makVrf::DtVrfTaskSetDialogManager& manager = makVrf::DtVrfTaskSetDialogManager::instance(*de);

   //And add the new creator
   manager.addDialogCreator(DtSetLocationAction, new MySetLocationDialogCreator);

   return true;
}

void DtPluginInformation(DtVrfPluginInformation& info)
{
   info.pluginName = "Modify Set";
   info.pluginDescription = "This example shows how to modify an existing set dialog (set location) to add your own functionality.";
   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)