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.
#include <vlpi/entityType.h>
#include <vlutil/vlString.h>
#include <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QDoubleValidator>
#include <QIntValidator>
using namespace makVrf;
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 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()
{
(DtVrfObjectManipulationManager::instance(myDe).currentObjectManipulationHandler());
}
void DtCustomControlObjectDefinitionDialogLogic::processPopulateDialog(
const makVrv::DtUniqueID&
id )
{
DtShapeObjectDefinitionDialogLogic::processPopulateDialog(id);
{
}
}
DtCustomControlObjectDefinitionDialog::DtCustomControlObjectDefinitionDialog(
makVrv::DtDe& de, QWidget* parent,
const QString& title, DtDialogInteractionMode
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;
}
createLogic()
{
return new DtCustomControlObjectDefinitionDialogLogic(myDe, this);
}
void DtCustomControlObjectDefinitionDialog::setupConnections()
{
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));
}
void DtCustomControlObjectDefinitionDialog::setupGui()
{
DtShapeObjectDefinitionDialog::setupGui();
QHBoxLayout* myQtHboxForParams = new QHBoxLayout();
myQtHboxForParams->setObjectName(QString::fromUtf8("myQtHboxForParams"));
myParamOneLabel->setObjectName(QString::fromUtf8("myParamOneLabel"));
myParamOneLabel->setToolTip(QApplication::translate("myUiImpl",
"Custom integer parameter.", 0));
myParamOneLabel->setText(QApplication::translate("myUiImpl",
"Integer:", 0));
myParamOneLineEdit->setObjectName(QString::fromUtf8("myParamOneLineEdit"));
myParamOneLineEdit->setValidator(new QIntValidator(myParamOneLineEdit));
myParamTwoLabel->setObjectName(QString::fromUtf8("myParamTwoLabel"));
myParamTwoLabel->setToolTip(QApplication::translate("myUiImpl",
"Custom double parameter.", 0));
myParamTwoLabel->setText(QApplication::translate("myUiImpl",
"Double:", 0));
myParamTwoLineEdit->setObjectName(QString::fromUtf8("myParamTwoLineEdit"));
myParamTwoLineEdit->setValidator(new QDoubleValidator(myParamTwoLineEdit));
myQtHboxForParams->addWidget(myParamOneLabel);
myQtHboxForParams->addWidget(myParamOneLineEdit);
myQtHboxForParams->addWidget(myParamTwoLabel);
myQtHboxForParams->addWidget(myParamTwoLineEdit);
myUiImpl.verticalLayout->insertLayout(4,myQtHboxForParams);
}
{
return new DtCustomControlObjectDefinitionDialog(de, parent, title, mode);
}
}