VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages

guiLocalCreateObjectMenu.h

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file guiLocalCreateObjectMenu.h
//This file defines all the menus and menu items that will be used for the object demo
//Note that this demo expectes to be working on ground-db.mtf
#pragma once
namespace makVrf
{
class DtVrfObjectFacadeInterface;
}
namespace makVrv
{
class DtIntervisibilityElement;
}
//New main menu. This menu will be used to hold the Object Demo menu items
{
public:
protected:
virtual QMenu* createMenu(makVrv::DtDe& de, QWidget* parent );
};
//Base class for creating object demo menu items. Override the create() method to create the
//appropriate local object
{
public:
DtGuiLocalCreateObjectMenuItem(makVrv::DtDe&, const std::string& item);
protected:
virtual void on_triggered();
virtual void remove();
//Called when an object is to be deleted. If our interface, set to 0 and uncheck menu item if checked
protected:
};
//Menu item for creating a line
{
public:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
protected:
};
//Menu item for creating an area
{
public:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
protected:
};
//Menu item for creating a waypoint
{
public:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
protected:
};
//Menu item for creating a M1A2
{
public:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
protected:
};
//Menu item for creating a Airbus 310
{
public:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
protected:
};
//Creates an intervisibility fan
{
public:
protected:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
virtual void on_triggered();
protected:
};
//Creates intervisibility line and attaches to M1A2 and Airbus
{
public:
protected:
//Build a menu item (via an action).
virtual QAction* createAction(makVrv::DtDe&, QWidget* parent);
virtual void on_aboutToShow();
virtual void on_triggered();
//Called when state views are removed, if m1a2 or airbus, also remove this line if
//created
protected:
};

guiLocalCreateObjectMenu.cxx

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file guiLocalCreateObjectMenu.cxx
#include <matrix/vlMath.h>
#include <QtWidgets/QMenu>
#include <QtWidgets/QAction>
using namespace makVrv;
using namespace makVrf;
: DtMenu(de, "DtGuiLocalCreateObjectMenu")
{
}
{
}
{
QMenu* menu = new QMenu(QObject::tr("Object Demo"), parent);
return menu;
}
//Base object demo menu item
: myDe(de)
, DtMenuItem(item)
, myAction(0)
{
}
{
if (!myDe.destructing())
{
DtGuiLocalObjectManager::instance(myDe).signal_objectAboutToBeDeleted.disconnect(boost::bind(&DtGuiLocalCreateObjectMenuItem::objectAboutToBeDeleted, this, _1));
}
}
{
if (((QAction*)sender())->isChecked())
{
DtGuiLocalObjectManager::instance(myDe).signal_objectAboutToBeDeleted.connect(boost::bind(&DtGuiLocalCreateObjectMenuItem::objectAboutToBeDeleted, this, _1));
//Set interface to be non-editable
{
DtGuiLocalObjectManager::instance(myDe).setEditable(myInterface->uniqueID(), false);
}
}
else if (myInterface)
{
remove();
}
}
{
if (myInterface == i)
{
if (myAction && myAction->isChecked())
{
myAction->setChecked(false);
}
}
}
{
{
DtGuiLocalObjectManager::instance(myDe).deleteLocal(myInterface->uniqueID());
DtGuiLocalObjectManager::instance(myDe).signal_objectAboutToBeDeleted.disconnect(boost::bind(&DtGuiLocalCreateObjectMenuItem::objectAboutToBeDeleted, this, _1));
}
}
//Menu item for creating a line
: DtGuiLocalCreateObjectMenuItem(de, "DtGuiLocalCreateObjectLine")
{
}
{
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create Line"), parent);
myAction->setCheckable(true);
return myAction;
}
{
//Add vertices for line
std::vector<DtVector> localLocations;
localLocations.push_back(DtVector(0, 0, 40));
localLocations.push_back(DtVector(700, 700, 45));
localLocations.push_back(DtVector(900, 350, 40));
//Set up some data to be used for creation
envData.setName("Demo Line");
envData.setLineWidth(10.);
envData.setOverlayParent("Object Demo");
//Use name as it appears on create menu. Also could have used type DtEntityType(17, 0, 0, 2, 1, 1, 0)
return DtGuiLocalObjectManager::instance(myDe).create(
DtCreateMenu::instance(myDe).nameToType("Route"), localLocations, 1, envData);
}
//Menu item for creating an area
: DtGuiLocalCreateObjectMenuItem(de, "DtGuiLocalCreateObjectArea")
{
}
{
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create Area"), parent);
myAction->setCheckable(true);
return myAction;
}
{
//Add vertices for line
std::vector<DtVector> localLocations;
localLocations.push_back(DtVector(-1000, -500, 0));
localLocations.push_back(DtVector(-500, -500, 0));
localLocations.push_back(DtVector(-500, 0, 0));
localLocations.push_back(DtVector(-1000, 0, 0));
//Set up some data to be used for creation
envData.setName("Demo Area");
envData.setLineWidth(10.);
envData.setOverlayParent("Object Demo");
envData.setColor(QColor(122, 122, 122, 122).rgba());
//Use name as it appears on create menu. Also could have used type DtEntityType(18, 0, 0, 1, 1, 0, 0)
return DtGuiLocalObjectManager::instance(myDe).create(
DtCreateMenu::instance(myDe).nameToType("Area"), localLocations, 1, envData);
}
//Menu item for creating a waypoint
: DtGuiLocalCreateObjectMenuItem(de, "DtGuiLocalCreateObjectWaypoint")
{
}
{
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create Waypoint"), parent);
myAction->setCheckable(true);
return myAction;
}
{
//Add vertices for line
std::vector<DtVector> localLocations;
localLocations.push_back(DtVector(0, 500, 17.));
//Set up some data to be used for creation
envData.setName("Demo Waypoint");
envData.setLineWidth(10.);
envData.setOverlayParent("Object Demo");
//Use name as it appears on create menu. Also could have used type DtEntityType(16, 0, 0, 1, 0, 0, 0)
return DtGuiLocalObjectManager::instance(myDe).create(
DtCreateMenu::instance(myDe).nameToType("Waypoint"), localLocations, 1, envData);
}
//Menu item for creating a M1A2
: DtGuiLocalCreateObjectMenuItem(de, "DtGuiLocalCreateObjectM1A2")
{
}
{
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create M1A2"), parent);
myAction->setCheckable(true);
return myAction;
}
{
DtEntityCreationData entData(DtCreateMenu::instance(myDe).nameToType("M1A2 Abrams MBT"), 1, DtVector(600, 600, 33.));
//Set up some data to be used for creation
entData.setName("Demo M1A2");
entData.setHeading(DtDeg2Rad(45.0));
//Use name as it appears on create menu.
entData.setOverlayParent("Object Demo");
DtEntityFacadeCollection* image = dynamic_cast<DtEntityFacadeCollection*>(DtGuiLocalObjectManager::instance(myDe).create(entData, makVrv::DtModelSetId::Unspecified, true));
return image;
}
//Menu item for creating a Airbus 310
: DtGuiLocalCreateObjectMenuItem(de, "DtGuiLocalCreateObjectAirbus310")
{
}
{
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create Airbus 310-304"), parent);
myAction->setCheckable(true);
return myAction;
}
{
DtEntityCreationData entData(DtCreateMenu::instance(myDe).nameToType("Airbus 310-304"), 1, DtVector(500, 0, 210.));
//Set up some data to be used for creation
entData.setName("Demo Airbus");
entData.setHeading(DtDeg2Rad(90.0));
//Use name as it appears on create menu.
entData.setOverlayParent("Object Demo");
DtEntityFacadeCollection* image = dynamic_cast<DtEntityFacadeCollection*>(DtGuiLocalObjectManager::instance(myDe).create(entData, makVrv::DtModelSetId::Unspecified, true));
return image;
}
//Creates an intervisibility fan
: DtMenuItem("DtGuiLocalCreateObjectFan")
, myDe(de)
, myElement(0)
, myAction(0)
{
}
{
if (!myDe.destructing())
{
DtIntervisibilitySignaler::instance(myDe).signal_elementAboutToBeDestroyed.disconnect(
}
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create Intervisibility Fan"), parent);
myAction->setCheckable(true);
return myAction;
}
{
if (e == myElement)
{
myElement = 0;
if (myAction && myAction->isChecked())
{
myAction->setChecked(false);
}
}
}
{
if (myAction->isChecked())
{
//Create the element via the intervisibility driver
DtIntervisibilityDriver* driver = DtIntervisibilityDriver::findDriver(myDe);
if (driver)
{
myElement = driver->createIntervisibilityFan(DtVector(700., 700., 30.), DtVector(700., 1200., 30.));
if (myElement)
{
DtGuiLocalObjectManager::instance(myDe).setEditable(myElement->elementID(), false);
}
DtIntervisibilitySignaler::instance(myDe).signal_elementAboutToBeDestroyed.connect(
}
}
else if (myElement)
{
DtIntervisibilitySignaler::instance(myDe).signal_elementAboutToBeDestroyed.disconnect(
DtGuiLocalObjectManager::instance(myDe).setEditable(myElement->elementID(), true);
DtIntervisibilityDriver* driver = DtIntervisibilityDriver::findDriver(myDe);
myElement = 0;
}
}
//Creates intervisibility line and attaches to M1A2 and Airbus
: DtMenuItem("DtGuiLocalCreateObjectAttachedLine")
, myDe(de)
, myElement(0)
, myAction(0)
{
DtVrfStateViewCollectionManager& svcMgr = DtVrfStateViewCollectionManager::instance( myDe );
}
{
}
{
if (myAction)
{
return myAction;
}
myAction = new QAction(tr("Create Intervisibility Line"), parent);
myAction->setCheckable(true);
return myAction;
}
{
if (myAction)
{
DtVrfStateViewCollectionManager& manager = DtVrfStateViewCollectionManager::instance(myDe);
myAction->setEnabled(manager.findStateView(DtUUID("Demo M1A2")) && manager.findStateView(DtUUID("Demo Airbus")));
if (myAction->isChecked() && !myAction->isEnabled())
{
// Block signals to prevent triggering of action
myAction->blockSignals(true);
myAction->setChecked(false);
myAction->blockSignals(false);
}
}
}
{
if (myAction->isChecked())
{
//Create the element via the intervisibility driver
DtIntervisibilityDriver* driver = DtIntervisibilityDriver::findDriver(myDe);
if (driver)
{
//Get the state views to attach to ids
DtVrfStateViewCollectionManager& manager = DtVrfStateViewCollectionManager::instance(myDe);
if (m1a2 && airbus)
{
myElement = driver->createIntervisibilityLine(m1a2->location(), airbus->location());
if (myElement)
{
DtGuiLocalObjectManager::instance(myDe).setEditable(myElement->elementID(), false);
}
}
}
}
else if (myElement)
{
DtGuiLocalObjectManager::instance(myDe).setEditable(myElement->elementID(), true);
DtIntervisibilityDriver* driver = DtIntervisibilityDriver::findDriver(myDe);
myElement = 0;
}
}
{
if (myElement)
{
if ((s.state().myMarkingText == "Demo Airbus") || (s.state().myMarkingText == "Demo M1A2"))
{
DtGuiLocalObjectManager::instance(myDe).setEditable(myElement->elementID(), true);
DtIntervisibilityDriver* driver = DtIntervisibilityDriver::findDriver(myDe);
myElement = 0;
}
}
}

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)