void H3DNodePropertiesWidget::instantiateWidgets()
{
setUpdatesEnabled(false);
if(m_widgetState == NONE)
{
gridLayout->setContentsMargins(3,4,0,2);
gridLayout->setSpacing(2);
gridLayout->setColumnStretch(1,2);
m_mainLayout->addWidget(m_propertyWidget);
setUpdatesEnabled(true);
updateState();
m_widgetFactory = 0;
m_widgetState = ONLY_TF;
}
//THIS FOLLOWING CONDITION IS THE RESPOONSIBLE FOR CREATING ALL THE WIDGETS
// THAT CORRESPONDS TO THE ELLIPTICAL ITEM YOU SEE IN THE SCENE
else if(m_widgetState == ONLY_TF)
{
//!pull out the layout that has been created when the
//!widget instantiation state was = NONE
QGridLayout *gridLayout
= dynamic_cast<QGridLayout
*>
(m_propertyWidget
->layout
());
//!now get the properties of the nodes
QList<H3DProperty*> propertyList = m_h3dNode->getH3DNodeProperties();
//!create the widget for every property and put them in the vertical layout
int rows = 0;
/////////////////////////////////////////////////////////////////
//!The DEF label and the line edit is common to every elliptical graphical item
//!add the DEF node editing capabilities here
//resize the widget
// nodeDEFNameEdit->resize(QSize(156,86).expandedTo(minimumSizeHint()));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(nodeDEFname->sizePolicy().hasHeightForWidth());
nodeDEFname->setSizePolicy(sizePolicy);
horizontalLayout->addWidget(nodeDEFname);
horizontalLayout->addWidget(nodeDEFNameEdit);
gridLayout->addLayout(horizontalLayout,rows,0,1,1);
rows++;
/////////////////////////////////////////////////////////////////
//check first if the pointer is the valid one or not
if(!m_widgetFactory)
{
if(!Singleton<H3DPropertyWidgetFactory>::isInited())
{
Singleton<H3DPropertyWidgetFactory>::init(new H3DPropertyWidgetFactory());
}
m_widgetFactory = Singleton<H3DPropertyWidgetFactory>::getPtr();
}
//declare an iterator to browse through the property lists
QList<H3DProperty*>::iterator iter;
for(iter = propertyList.begin(); iter != propertyList.end();++iter)
{
H3DPropertyWidget *l_propertyWidget = dynamic_cast<H3DPropertyWidget*>((*iter)->createAndAddWidget(m_widgetFactory));
if(l_propertyWidget != 0)
{
m_widgets.push_back(l_propertyWidget);
connect(l_propertyWidget,SIGNAL(modified()),this,SLOT(propertyModified()));
QLabel *l_nameLabel
= const_cast<QLabel
*>
(l_propertyWidget
->getNameLabel
());
if(l_nameLabel)
{
gridLayout->addWidget(l_nameLabel,rows,0,1,1);
gridLayout->addWidget(l_propertyWidget,rows,1,1,1);
}
// else
// {
// gridLayout->addWidget(l_propertyWidget,rows,0,1,2);
// }
}
//!just increment the row value
++rows;
}
m_widgetFactory = 0;
setUpdatesEnabled(true);
updateState();
m_widgetState = ALL;
}
setUpdatesEnabled(true);
}
void H3DNodePropertiesWidget::instantiateWidgets()
{
setUpdatesEnabled(false);
if(m_widgetState == NONE)
{
m_propertyWidget = new QWidget;
QGridLayout *gridLayout = new QGridLayout(m_propertyWidget);
gridLayout->setContentsMargins(3,4,0,2);
gridLayout->setSpacing(2);
gridLayout->setColumnStretch(1,2);
m_mainLayout->addWidget(m_propertyWidget);
setUpdatesEnabled(true);
updateState();
m_widgetFactory = 0;
m_widgetState = ONLY_TF;
}
//THIS FOLLOWING CONDITION IS THE RESPOONSIBLE FOR CREATING ALL THE WIDGETS
// THAT CORRESPONDS TO THE ELLIPTICAL ITEM YOU SEE IN THE SCENE
else if(m_widgetState == ONLY_TF)
{
//!pull out the layout that has been created when the
//!widget instantiation state was = NONE
QGridLayout *gridLayout = dynamic_cast<QGridLayout*>(m_propertyWidget->layout());
//!now get the properties of the nodes
QList<H3DProperty*> propertyList = m_h3dNode->getH3DNodeProperties();
//!create the widget for every property and put them in the vertical layout
int rows = 0;
/////////////////////////////////////////////////////////////////
//!The DEF label and the line edit is common to every elliptical graphical item
//!add the DEF node editing capabilities here
QLabel *nodeDEFname = new QLabel(tr("DEF"));
QLineEdit *nodeDEFNameEdit = new QLineEdit(m_h3dNode->getNodeDEFName());
//resize the widget
// nodeDEFNameEdit->resize(QSize(156,86).expandedTo(minimumSizeHint()));
QSizePolicy sizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(nodeDEFname->sizePolicy().hasHeightForWidth());
nodeDEFname->setSizePolicy(sizePolicy);
QHBoxLayout *horizontalLayout = new QHBoxLayout();
horizontalLayout->addWidget(nodeDEFname);
horizontalLayout->addWidget(nodeDEFNameEdit);
gridLayout->addLayout(horizontalLayout,rows,0,1,1);
rows++;
/////////////////////////////////////////////////////////////////
//check first if the pointer is the valid one or not
if(!m_widgetFactory)
{
if(!Singleton<H3DPropertyWidgetFactory>::isInited())
{
Singleton<H3DPropertyWidgetFactory>::init(new H3DPropertyWidgetFactory());
}
m_widgetFactory = Singleton<H3DPropertyWidgetFactory>::getPtr();
}
//declare an iterator to browse through the property lists
QList<H3DProperty*>::iterator iter;
for(iter = propertyList.begin(); iter != propertyList.end();++iter)
{
H3DPropertyWidget *l_propertyWidget = dynamic_cast<H3DPropertyWidget*>((*iter)->createAndAddWidget(m_widgetFactory));
if(l_propertyWidget != 0)
{
m_widgets.push_back(l_propertyWidget);
connect(l_propertyWidget,SIGNAL(modified()),this,SLOT(propertyModified()));
QLabel *l_nameLabel = const_cast<QLabel*>(l_propertyWidget->getNameLabel());
if(l_nameLabel)
{
gridLayout->addWidget(l_nameLabel,rows,0,1,1);
gridLayout->addWidget(l_propertyWidget,rows,1,1,1);
}
// else
// {
// gridLayout->addWidget(l_propertyWidget,rows,0,1,2);
// }
}
//!just increment the row value
++rows;
}
m_widgetFactory = 0;
setUpdatesEnabled(true);
updateState();
m_widgetState = ALL;
}
setUpdatesEnabled(true);
}
To copy to clipboard, switch view to plain text mode
Bookmarks