VR-Forces 4.0.4 Class Documentation
Spot Report Manipulation Example

The Spot Report example demonstrates the following:

The Spot Report Manipulation example demonstrates how to manipulate the selection of spot report objects

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

//\file spotReportManipulationPlugin.cxx

//This file defines the generic DT_DLL_VRF_PLUGIN_EXPORT_MACRO.  Use that macro when
//you want to export symbols.
#include <vrfGuiCore/vrfGuiExportPlugin.h>

#include <vrfGuiCore/DtVrfSpotReportManager.h>
#include <vrfGuiCore/DtVrfStateViewCollectionManager.h>
#include <vrfGuiCore/DtVrfObjectManipulationManager.h>
#include <vrfGuiCoreQt/DtVrfContextMenuManager.h>
#include <vrvCore/DtSelectionManager.h>
#include <vrvCoreQt/DtQApplicationProvider.h>
#include <vrvCore/DtDeMainWindow.h>

#include <QtGui/QMainWindow>
#include <QtGui/QStatusBar>

using namespace makVrf;

//This function is called by our plugin structure to make changes to the front end.
//To make sure all items are initialized properly, the bulk of the work will be done in the
//postInit entry point.  This function needs to be defined in order to be considered a valid plugin
bool initDeModule(makVrv::DtDe* de)
{
   return true;
}

void slot_onCurrentSelectionChanged(
   const makVrv::DtSelectionManager::IdSet& selectedSet, makVrv::DtDe* de)
{
   makVrv::DtDeMainWindow* mainWindow = &makVrv::DtDeMainWindowProvider::instance(*de).igMainWindow();
   QMainWindow* main = dynamic_cast<QMainWindow*>(mainWindow);

   if (main)
   {
      main->statusBar()->showMessage("");
      main->statusBar()->hide();
   }

   makVrv::DtSelectionManager::IdSet::const_iterator it = selectedSet.begin();
   for(; it != selectedSet.end(); ++it)
   {
      //Get data from the state view collection manager.  If the item is a spot report, put up a dialog
      //announcing selection
      if (DtVrfStateViewCollectionManager::instance(*de).findSpotReportStateView(*it))
      {
         makVrv::DtDeMainWindow* mainWindow = &makVrv::DtDeMainWindowProvider::instance(*de).igMainWindow();
         QMainWindow* main = dynamic_cast<QMainWindow*>(mainWindow);

         if (main)
         {
            main->statusBar()->show();
            main->statusBar()->showMessage("A spot report was selected");

            return;
         }
      }
   }
}

void slot_unhandledEdit(makVrv::DtElementID id, makVrv::DtDe* de)
{
   makVrv::DtDeMainWindow* mainWindow = &makVrv::DtDeMainWindowProvider::instance(*de).igMainWindow();
   QMainWindow* main = dynamic_cast<QMainWindow*>(mainWindow);

   if (main)
   {
      if (DtVrfStateViewCollectionManager::instance(*de).findSpotReportStateView(id))
      {
         main->statusBar()->show();
         main->statusBar()->showMessage("A spot report was double clicked on");
      }
      else
      {
         main->statusBar()->hide();
      }
   }
}

void slot_unhandledRightClick(makVrv::DtQtMenuAssembler& menuAssembler, makVrv::DtMenuConfiguration& menus,
                     const makVrv::DtSelectionManager::IdSet& idSet, makVrv::DtDe* de)
{
   makVrv::DtDeMainWindow* mainWindow = &makVrv::DtDeMainWindowProvider::instance(*de).igMainWindow();
   QMainWindow* main = dynamic_cast<QMainWindow*>(mainWindow);

   if (main)
   {
      if (DtVrfStateViewCollectionManager::instance(*de).findSpotReportStateView(*idSet.begin()))
      {
         main->statusBar()->show();
         main->statusBar()->showMessage("A spot report was right clicked on");
      }
      else
      {
         main->statusBar()->hide();
      }
   }
}

//Set up the fact that spot reports can be selected and connections for what to do when they are
//selected
void postInitDeModule(makVrv::DtDe& de)
{
   makVrv::DtSelectionManager::instance(de).signal_currentSelectionChanged.connect(boost::bind(
         &slot_onCurrentSelectionChanged, _1, &de));

   //A signal is sent when a type is not editable.  This is a signal that, potentially, a spot report
   //was double clicked on, so, see if it was
   DtVrfObjectManipulationManager::instance(de).signal_unhandledEdit.connect(
      boost::bind(&slot_unhandledEdit, _1, &de));

   //And, connect for right click receipt.  This will be called because spot reports are not currently
   //handled by the system for right click menus
   DtVrfContextMenuManager::instance(de).signal_unhandledRightClick.connect(
      boost::bind(&slot_unhandledRightClick, _1, _2, _3, &de));

   DtVrfSpotReportManager::instance(de).setSpotReportsSelectable(true);
}

//This function is also called by our plugin structure and prints out information about this plugin
//to the logs. It's a good indicator that the plugin loaded if you are looking at the logs. 
void DtPluginInformation(DtVrfPluginInformation& info)
{
   info.pluginName = "Spot Report Manipulation";
   info.pluginDescription = "This example shows how to work with the selection of spot reports.";
   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)