VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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) 2013 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
//\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 int parameterOne();
virtual double parameterTwo();
virtual void setParameterOne(int);
virtual void setParameterTwo(double);
protected:
virtual void setupGui();
protected slots:
protected:
};
class DtCustomControlObjectDefinitionDialogCreator : public makVrf::DtShapeObjectDefinitionDialogCreator
{
public:
virtual makVrf::DtCreateAndEditObjectDialogInterface* createDialog(makVrv::DtDe& de, QWidget* parent, const QString& title,
};
}

customControlObjectDefinitionDialog.cxx

/******************************************************************************
** Copyright (c) 2013 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
//\file DtCustomControlObjectDialog.cxx
//\brief Contains DtCustomControlObjectDialog
#include <vlpi/entityType.h>
#include <vlutil/vlString.h>
// Qt includes
#include <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QDoubleValidator>
#include <QIntValidator>
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)
, myParamOneLineEdit(0)
, myParamTwoLineEdit(0)
{
}
DtCustomControlObjectDefinitionDialog::~DtCustomControlObjectDefinitionDialog()
{
disconnect(myParamTwoLineEdit, SIGNAL(textChanged(const QString&)),
this, SLOT(slot_onUserDataChanged()));
disconnect(myParamOneLineEdit, SIGNAL(textChanged(const QString&)),
this, SLOT(slot_onUserDataChanged()));
myParamOneLineEdit = 0;
myParamTwoLineEdit = 0;
}
{
return new DtCustomControlObjectDefinitionDialogLogic(myDe, this);
}
{
DtShapeObjectDefinitionDialog::setupConnections();
connect(myParamOneLineEdit, SIGNAL(textChanged(const QString&)),
this, SLOT(slot_onUserDataChanged()));
connect(myParamTwoLineEdit, SIGNAL(textChanged(const QString&)),
this, SLOT(slot_onUserDataChanged()));
}
void DtCustomControlObjectDefinitionDialog::slot_onUserDataChanged()
{
DtCustomControlObjectDefinitionDialogLogic* logic =
dynamic_cast<DtCustomControlObjectDefinitionDialogLogic*>(myLogic);
if (logic)
{
logic->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 integer parameter.", 0));
myParamOneLabel->setText(QApplication::translate("myUiImpl",
"Integer:", 0));
//Add a lineEdit box for parameter one
myParamOneLineEdit = new QLineEdit();
myParamOneLineEdit->setObjectName(QString::fromUtf8("myParamOneLineEdit"));
myParamOneLineEdit->setValidator(new QIntValidator(myParamOneLineEdit));
//Add and populate parameter Two label
QLabel* myParamTwoLabel = new QLabel();
myParamTwoLabel->setObjectName(QString::fromUtf8("myParamTwoLabel"));
myParamTwoLabel->setToolTip(QApplication::translate("myUiImpl",
"Custom double parameter.", 0));
myParamTwoLabel->setText(QApplication::translate("myUiImpl",
"Double:", 0));
//Add a lineEdit box for parameter Two
myParamTwoLineEdit = new QLineEdit();
myParamTwoLineEdit->setObjectName(QString::fromUtf8("myParamTwoLineEdit"));
myParamTwoLineEdit->setValidator(new QDoubleValidator(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=========================
{
return new DtCustomControlObjectDefinitionDialog(de, parent, title, mode);
}
}

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)