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 <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <vlutil/vlString.h>
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());
}
{
DtShapeObjectDefinitionDialogLogic::processPopulateDialog(id);
}
DtCustomControlObjectDefinitionDialog::DtCustomControlObjectDefinitionDialog(
makVrv::DtDe& de,
QWidget* parent,
const QString& title, DtDialogInteractionMode 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();
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();
QHBoxLayout* myQtHboxForParams = new QHBoxLayout();
myQtHboxForParams->setObjectName(QString::fromUtf8("myQtHboxForParams"));
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));
myParamOneLineEdit->setObjectName(QString::fromUtf8("myParamOneLineEdit"));
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));
myParamTwoLineEdit->setObjectName(QString::fromUtf8("myParamTwoLineEdit"));
myQtHboxForParams->addWidget(myParamOneLabel);
myQtHboxForParams->addWidget(myParamOneLineEdit);
myQtHboxForParams->addWidget(myParamTwoLabel);
myQtHboxForParams->addWidget(myParamTwoLineEdit);
myUiImpl.verticalLayout->insertLayout(4,myQtHboxForParams);
}
{
DtCustomControlObjectDefinitionDialog * thisObjectDefinitionDialog = new DtCustomControlObjectDefinitionDialog(de, parent, title, mode);
thisObjectDefinitionDialog->init();
thisObjectDefinitionDialog->setTitle(title);
thisObjectDefinitionDialog->setAllowOverlaySelection(true);
if (mode == DtCreateAndEditObjectDialogInterface::DtCreationMode)
{
thisObjectDefinitionDialog->populateOverlays();
{
thisObjectDefinitionDialog->setCreateButtonVisible(true);
}
}
else if (mode == DtCreateAndEditObjectDialogInterface::DtEditingMode)
{
thisObjectDefinitionDialog->setUpdateButtonVisible(true);
thisObjectDefinitionDialog->setUpdateButtonText("OK");
thisObjectDefinitionDialog->setAttachObjectToMouse(editType != DtVrfObjectManipulationManager::Context);
}
return thisObjectDefinitionDialog;
}
}