Skip to content
Snippets Groups Projects
Commit f05ad6d7 authored by Juan Manuel Carmona Loaiza's avatar Juan Manuel Carmona Loaiza :ghost:
Browse files

ILayerView: Update the labels when updating the appearance

parent 3e41dc26
Branches
Tags
No related merge requests found
...@@ -56,6 +56,7 @@ void ILayerView::onPropertyChange(const QString &propertyName) ...@@ -56,6 +56,7 @@ void ILayerView::onPropertyChange(const QString &propertyName)
updateHeight(); updateHeight();
} else if (propertyName == LayerItem::P_MATERIAL) { } else if (propertyName == LayerItem::P_MATERIAL) {
updateColor(); updateColor();
updateLabel();
} }
IView::onPropertyChange(propertyName); IView::onPropertyChange(propertyName);
...@@ -86,6 +87,40 @@ void ILayerView::updateColor() ...@@ -86,6 +87,40 @@ void ILayerView::updateColor()
} }
} }
void ILayerView::updateLabel()
{
if(getInputPorts().size() < 1)
return;
NodeEditorPort *port = getInputPorts()[0];
QString material = "" ;
if(m_item->isTag(LayerItem::P_MATERIAL)){
QVariant v = m_item->getItemValue(LayerItem::P_MATERIAL);
if (v.isValid()) {
ExternalProperty mp = v.value<ExternalProperty>();
material = mp.text();
}
}
/* Thickness and roughness can be added, but the length of the string
* becomes prohibitive.
QString thickness = "" ;
if(m_item->isTag(LayerItem::P_THICKNESS))
thickness = m_item->getItemValue(LayerItem::P_THICKNESS).toString();
QString roughness = "" ;
if(m_item->isTag(LayerItem::P_ROUGHNESS)){
QVariant x = m_item->getItemValue(LayerItem::P_ROUGHNESS);
{...}
}
*/
QString infoToDisplay = material;
port->setLabel(infoToDisplay);
}
//! Detects movement of the ILayerView and sends possible drop areas to GraphicsScene //! Detects movement of the ILayerView and sends possible drop areas to GraphicsScene
//! for visualization. //! for visualization.
QVariant ILayerView::itemChange(GraphicsItemChange change, const QVariant &value) QVariant ILayerView::itemChange(GraphicsItemChange change, const QVariant &value)
...@@ -179,6 +214,7 @@ void ILayerView::update_appearance() ...@@ -179,6 +214,7 @@ void ILayerView::update_appearance()
{ {
updateHeight(); updateHeight();
updateColor(); updateColor();
updateLabel();
ConnectableView::update_appearance(); ConnectableView::update_appearance();
} }
......
...@@ -35,6 +35,8 @@ public: ...@@ -35,6 +35,8 @@ public:
virtual QString getLabel() const { return QString(); } virtual QString getLabel() const { return QString(); }
void updateLabel();
protected: protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value); QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment