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)
{
namePoint = new VGraphicsSimpleTextItem(this);
namePoint->setBrush(Qt::black);
lineName = new QGraphicsLineItem(this);
lineName->setPen(QPen(Qt::black));
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VToolPoint::NameChangePosition);
this->setBrush(QBrush(Qt::NoBrush));
@ -73,7 +75,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName)
if (nameActivDraw == newName)
{
selectable = true;
currentColor = Qt::black;
currentColor = baseColor;
}
else
{
@ -150,7 +152,14 @@ void VToolPoint::RefreshLine()
LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
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))
{
lineName->setVisible(false);

View File

@ -34,10 +34,13 @@ VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64
QGraphicsItem * parent )
:VToolPoint(doc, data, id, parent), dialogSinglePoint(QSharedPointer<DialogSinglePoint>())
{
baseColor = Qt::red;
currentColor = baseColor;
ignoreFullUpdate = true;
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
setColorLabel(Qt::black);
if (typeCreation == Tool::FromGui)
{
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 )
{
ContextMenu(dialogSinglePoint, this, event, false);
@ -160,11 +169,13 @@ void VToolSinglePoint::ChangedActivDraw(const QString &newName)
{
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
VToolPoint::ChangedActivDraw(newName);
setColorLabel(Qt::black);
}
else
{
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
VToolPoint::ChangedActivDraw(newName);
setColorLabel(Qt::gray);
}
}

View File

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

View File

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