Fixed issue #40.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-07 14:54:50 +02:00
parent e92afd0f89
commit e8d1c28a15
4 changed files with 24 additions and 3 deletions

View File

@ -34,7 +34,9 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphics
QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0) QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0)
{ {
namePoint = new VGraphicsSimpleTextItem(this); namePoint = new VGraphicsSimpleTextItem(this);
namePoint->setBrush(Qt::black);
lineName = new QGraphicsLineItem(this); lineName = new QGraphicsLineItem(this);
lineName->setPen(QPen(Qt::black));
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VToolPoint::NameChangePosition); &VToolPoint::NameChangePosition);
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
@ -73,7 +75,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName)
if (nameActivDraw == newName) if (nameActivDraw == newName)
{ {
selectable = true; selectable = true;
currentColor = Qt::black; currentColor = baseColor;
} }
else else
{ {
@ -150,7 +152,14 @@ void VToolPoint::RefreshLine()
LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - scenePos())); lineName->setLine(QLineF(p1, pRec - scenePos()));
lineName->setPen(QPen(currentColor, widthHairLine/factor)); if(currentColor == Qt::gray)
{
lineName->setPen(QPen(currentColor, widthHairLine/factor));
}
else
{
lineName->setPen(QPen(Qt::black, widthHairLine/factor));
}
if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4)) if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4))
{ {
lineName->setVisible(false); lineName->setVisible(false);

View File

@ -34,10 +34,13 @@ VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64
QGraphicsItem * parent ) QGraphicsItem * parent )
:VToolPoint(doc, data, id, parent), dialogSinglePoint(QSharedPointer<DialogSinglePoint>()) :VToolPoint(doc, data, id, parent), dialogSinglePoint(QSharedPointer<DialogSinglePoint>())
{ {
baseColor = Qt::red;
currentColor = baseColor;
ignoreFullUpdate = true; ignoreFullUpdate = true;
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, false); this->setFlag(QGraphicsItem::ItemIsFocusable, false);
setColorLabel(Qt::black);
if (typeCreation == Tool::FromGui) if (typeCreation == Tool::FromGui)
{ {
AddToFile(); AddToFile();
@ -124,6 +127,12 @@ void VToolSinglePoint::decrementReferens()
} }
} }
void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color)
{
namePoint->setBrush(color);
lineName->setPen(QPen(color, widthHairLine/factor));
}
void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
{ {
ContextMenu(dialogSinglePoint, this, event, false); ContextMenu(dialogSinglePoint, this, event, false);
@ -160,11 +169,13 @@ void VToolSinglePoint::ChangedActivDraw(const QString &newName)
{ {
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
setColorLabel(Qt::black);
} }
else else
{ {
this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsSelectable, false);
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
setColorLabel(Qt::gray);
} }
} }

View File

@ -117,6 +117,7 @@ private:
* @brief dialogSinglePoint * @brief dialogSinglePoint
*/ */
QSharedPointer<DialogSinglePoint> dialogSinglePoint; QSharedPointer<DialogSinglePoint> dialogSinglePoint;
void setColorLabel(const Qt::GlobalColor & color);
}; };
#endif // VTOOLSINGLEPOINT_H #endif // VTOOLSINGLEPOINT_H

View File

@ -278,7 +278,7 @@ protected:
/** /**
* @brief baseColor * @brief baseColor
*/ */
const Qt::GlobalColor baseColor; Qt::GlobalColor baseColor;
/** /**
* @brief currentColor * @brief currentColor
*/ */