VR-Forces 4.1 Class Documentation
Custom Control Object Dialog

The DtCustomControlObjectDefinitionDialog and its associated logic and creator classes handles the creation, definition and function of the dialog associated with the creation of the custom control object. The dialog is derived from the DtShapeObjectDefinitionDialog and modified to display GUI elements allowing the user to input the custom parameters.


customControlObjectDefinitionDialog.h Header file

/******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
/******************************************************************************
** $RCSfile: DtCustomControlObjectDialog.h,v $ $Revision: 1.0 $ $State: Exp $
******************************************************************************/
//\file DtCustomControlObjectDialog.h
//\brief Contains DtCustomControlObjectDialog class.
#pragma once
#include <vlpi/entityType.h>
#include <string>
class QLineEdit;
namespace vrfCustomControlObjectExample
{
class DtCustomControlObjectDefinitionDialog;
const DtEntityType DtCustomControlObjectType = DtEntityType(18,-1,-1,1,0,0,101);
class DtCustomControlObjectDefinitionDialogLogic : public makVrf::DtShapeObjectDefinitionDialogLogic
{
public:
DtCustomControlObjectDefinitionDialogLogic(makVrv::DtDe& de, DtCustomControlObjectDefinitionDialog* iface);
virtual void setUserData(const std::string);
virtual std::string userData();
virtual void processUserDataChanged();
virtual void processPopulateDialog(const makVrv::DtUniqueID& id );
protected:
DtCustomControlObjectDefinitionDialog* myCustomDialog;
};
class DtCustomControlObjectDefinitionDialog : public makVrf::DtShapeObjectDefinitionDialog
{
Q_OBJECT
public:
virtual void init();
virtual int parameterOne();
virtual double parameterTwo();
virtual void setParameterOne(int);
virtual void setParameterTwo(double);
protected:
virtual void setupGui();
protected slots:
protected:
DtCustomControlObjectDefinitionDialogLogic* myCustomLogic;
};
class DtCustomControlObjectDefinitionDialogCreator : public makVrf::DtVrfObjectModifierDialogCreator
{
public:
QWidget* parent,
DtEntityType entityType,
const QString& title="",
};
}

customControlObjectDefinitionDialog.cxx

/******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
/******************************************************************************
** $RCSfile: DtCustomControlObjectDialog.cxx,v $ $Revision: 1.0 $ $State: Exp $
******************************************************************************/
//\file DtCustomControlObjectDialog.cxx
//\brief Contains DtCustomControlObjectDialog
#include <vlpi/entityType.h>
#include <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <vlutil/vlString.h>
using namespace makVrf;
//The Logic class should
namespace vrfCustomControlObjectExample
{
DtCustomControlObjectDefinitionDialogLogic::DtCustomControlObjectDefinitionDialogLogic(makVrv::DtDe& de, DtCustomControlObjectDefinitionDialog* iface)
, myCustomDialog(iface)
{
}
DtCustomControlObjectDefinitionDialogLogic::~DtCustomControlObjectDefinitionDialogLogic()
{
myCustomDialog = 0;
}
void DtCustomControlObjectDefinitionDialogLogic::setUserData(const std::string userData)
{
if (userData == "")
{
return;
}
DtString firstString(userData.c_str());
DtString secondString(userData.c_str());
firstString.snipBack(',');
secondString.snipFront(',');
myCustomDialog->setParameterOne(firstString.toInt());
myCustomDialog->setParameterTwo(secondString.toDouble());
}
std::string DtCustomControlObjectDefinitionDialogLogic::userData()
{
DtString fullString(myCustomDialog->parameterOne());
fullString = fullString + "," + myCustomDialog->parameterTwo();
return fullString.c_str();
}
void DtCustomControlObjectDefinitionDialogLogic::processUserDataChanged()
{
//This code is executed when either of the userData fields are modified
(DtVrfObjectManipulationManager::instance(myDe).currentObjectManipulationHandler());
handler->setUserData(userData());
}
{
DtShapeObjectDefinitionDialogLogic::processPopulateDialog(id);
setUserData(envStateView->state().myUserData);
}
//========Dialog class ===============
DtCustomControlObjectDefinitionDialog::DtCustomControlObjectDefinitionDialog(makVrv::DtDe& de, QWidget* parent,
const QString& title, DtDialogInteractionMode mode)
:DtShapeObjectDefinitionDialog(de, parent, title, mode)
, myCustomLogic(0)
, myParamOneLineEdit(0)
, myParamTwoLineEdit(0)
{
}
DtCustomControlObjectDefinitionDialog::~DtCustomControlObjectDefinitionDialog()
{
disconnect(myParamTwoLineEdit, SIGNAL(editingFinished()), this, SLOT(slot_onUserDataChanged()));
disconnect(myParamOneLineEdit, SIGNAL(editingFinished()), this, SLOT(slot_onUserDataChanged()));
myCustomLogic = 0;
myParamOneLineEdit = 0;
myParamTwoLineEdit = 0;
}
{
myCustomLogic = new DtCustomControlObjectDefinitionDialogLogic(myDe, this);
myLogic = myCustomLogic;
setupGui();
makVrv::DtQtDeMainWindow* qtMainWindow = dynamic_cast<makVrv::DtQtDeMainWindow*>(myParent);
qtMainWindow->addDockWidget(Qt::RightDockWidgetArea, this);
setupConnections();
myCustomLogic->setupGui();
setDockType(DtAutoHideDock::Dialog);
}
{
DtShapeObjectDefinitionDialog::setupConnections();
connect(myParamOneLineEdit, SIGNAL(editingFinished()), this, SLOT(slot_onUserDataChanged()));
connect(myParamTwoLineEdit, SIGNAL(editingFinished()), this, SLOT(slot_onUserDataChanged()));
}
void DtCustomControlObjectDefinitionDialog::slot_onUserDataChanged()
{
myCustomLogic->processUserDataChanged();
}
int DtCustomControlObjectDefinitionDialog::parameterOne()
{
return myParamOneLineEdit->text().toInt();
}
double DtCustomControlObjectDefinitionDialog::parameterTwo()
{
return myParamTwoLineEdit->text().toDouble();
}
void DtCustomControlObjectDefinitionDialog::setParameterOne(int inParameterOne)
{
myParamOneLineEdit->setText(QString::number(inParameterOne));
}
void DtCustomControlObjectDefinitionDialog::setParameterTwo(double inParameterTwo)
{
myParamTwoLineEdit->setText(QString::number(inParameterTwo));
}
{
DtShapeObjectDefinitionDialog::setupGui();
//Create an Hbox to be inserted
QHBoxLayout* myQtHboxForParams = new QHBoxLayout();
myQtHboxForParams->setObjectName(QString::fromUtf8("myQtHboxForParams"));
//Add and populate parameter one label
QLabel* myParamOneLabel = new QLabel();
myParamOneLabel->setObjectName(QString::fromUtf8("myParamOneLabel"));
myParamOneLabel->setToolTip(QApplication::translate("myUiImpl", "Custom Parameter One.", 0, QApplication::UnicodeUTF8));
myParamOneLabel->setText(QApplication::translate("myUiImpl", "Parameter One:", 0, QApplication::UnicodeUTF8));
//Add a lineEdit box for parameter one
myParamOneLineEdit = new QLineEdit();
myParamOneLineEdit->setObjectName(QString::fromUtf8("myParamOneLineEdit"));
//Add and populate parameter Two label
QLabel* myParamTwoLabel = new QLabel();
myParamTwoLabel->setObjectName(QString::fromUtf8("myParamTwoLabel"));
myParamTwoLabel->setToolTip(QApplication::translate("myUiImpl", "Custom Parameter Two.", 0, QApplication::UnicodeUTF8));
myParamTwoLabel->setText(QApplication::translate("myUiImpl", "Parameter Two:", 0, QApplication::UnicodeUTF8));
//Add a lineEdit box for parameter Two
myParamTwoLineEdit = new QLineEdit();
myParamTwoLineEdit->setObjectName(QString::fromUtf8("myParamTwoLineEdit"));
//Put these elements into the Hbox
myQtHboxForParams->addWidget(myParamOneLabel);
myQtHboxForParams->addWidget(myParamOneLineEdit);
myQtHboxForParams->addWidget(myParamTwoLabel);
myQtHboxForParams->addWidget(myParamTwoLineEdit);
//insert the new Hbox into the UI
myUiImpl.verticalLayout->insertLayout(4,myQtHboxForParams);
}
//===============CREATOR CLASS=========================
DtEntityType entityType, const QString& title,makVrf::DtCreationSignalType signalCreation, DtCreateAndEditObjectDialogInterface::DtDialogInteractionMode mode,
{
//Create the custom dialog, modify it depending on mode,
//and then hand the pointer back out
DtCustomControlObjectDefinitionDialog * thisObjectDefinitionDialog = new DtCustomControlObjectDefinitionDialog(de, parent, title, mode);
thisObjectDefinitionDialog->init();
thisObjectDefinitionDialog->setTitle(title);
thisObjectDefinitionDialog->setAllowOverlaySelection(true);
if (mode == DtCreateAndEditObjectDialogInterface::DtCreationMode)
{
thisObjectDefinitionDialog->populateOverlays();
//If signalCreation is set to creationAndStop then we are indicating that we only want one
//object created. This is used when creating entities in plans.
if (signalCreation == DtSignalCreationAndStop)
{
thisObjectDefinitionDialog->setCreateButtonVisible(true);
}
}
else if (mode == DtCreateAndEditObjectDialogInterface::DtEditingMode)
{
thisObjectDefinitionDialog->setUpdateButtonVisible(true);
thisObjectDefinitionDialog->setUpdateButtonText("OK");
thisObjectDefinitionDialog->setAttachObjectToMouse(editType != DtVrfObjectManipulationManager::Context);
}
return thisObjectDefinitionDialog;
}
}

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)