Use different colors for different parts of tool.
--HG-- branch : feature
This commit is contained in:
parent
16662a34d5
commit
5f49394236
|
@ -86,6 +86,8 @@ void VAbstractSpline::ChangedActivDraw(const QString &newName)
|
|||
{
|
||||
VDrawTool::ChangedActivDraw(newName);
|
||||
this->setEnabled(enabled);
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine,
|
||||
Qt::RoundCap));
|
||||
emit setEnabledPoint(enabled);
|
||||
}
|
||||
|
||||
|
@ -121,7 +123,8 @@ void VAbstractSpline::SetFactor(qreal factor)
|
|||
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine, Qt::RoundCap));
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine,
|
||||
Qt::RoundCap));
|
||||
this->setPath(ToolPath(PathDirection::Show));
|
||||
isHovered = true;
|
||||
QGraphicsPathItem::hoverEnterEvent(event);
|
||||
|
@ -136,7 +139,7 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPath(ToolPath());
|
||||
isHovered = false;
|
||||
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||
|
|
|
@ -164,32 +164,32 @@ protected:
|
|||
void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable)
|
||||
{
|
||||
SCASSERT(item != nullptr);
|
||||
if (id == item->id)
|
||||
{
|
||||
if (enable == false)
|
||||
{
|
||||
currentColor = baseColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentColor = color;
|
||||
}
|
||||
item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
}
|
||||
// if (id == item->id)
|
||||
// {
|
||||
// if (enable == false)
|
||||
// {
|
||||
// currentColor = baseColor;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// currentColor = color;
|
||||
// }
|
||||
// item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
// }
|
||||
}
|
||||
template <typename Item>
|
||||
void DisableItem(Item *item, bool disable)
|
||||
{
|
||||
SCASSERT(item != nullptr);
|
||||
if (disable)
|
||||
{
|
||||
currentColor = Qt::gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentColor = baseColor;
|
||||
}
|
||||
item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
// if (disable)
|
||||
// {
|
||||
// currentColor = Qt::gray;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// currentColor = baseColor;
|
||||
// }
|
||||
// item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
}
|
||||
private:
|
||||
Q_DISABLE_COPY(VDrawTool)
|
||||
|
|
|
@ -373,7 +373,7 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
*/
|
||||
void VToolArc::RefreshGeometry()
|
||||
{
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPath(ToolPath());
|
||||
|
||||
if (vis != nullptr)
|
||||
|
|
|
@ -41,12 +41,12 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
|
|||
Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0");
|
||||
Q_ASSERT_X(curve2id > 0, Q_FUNC_INFO, "curve2id <= 0");
|
||||
|
||||
firstCurve = new VSimpleCurve(curve1id, ¤tColor, SimpleCurvePoint::ForthPoint, &factor);
|
||||
firstCurve = new VSimpleCurve(curve1id, QColor(lineColor), SimpleCurvePoint::ForthPoint, &factor);
|
||||
firstCurve->setParentItem(this);
|
||||
connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
||||
connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
||||
|
||||
secondCurve = new VSimpleCurve(curve2id, ¤tColor, SimpleCurvePoint::FirstPoint, &factor);
|
||||
secondCurve = new VSimpleCurve(curve2id, QColor(lineColor), SimpleCurvePoint::FirstPoint, &factor);
|
||||
secondCurve->setParentItem(this);
|
||||
connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
||||
connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
||||
|
|
|
@ -296,6 +296,7 @@ void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurve
|
|||
{
|
||||
path.translate(-arc->GetP2().x(), -arc->GetP2().y());
|
||||
}
|
||||
curve->SetCurrentColor(QColor(lineColor));
|
||||
curve->setPath(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -307,6 +307,7 @@ void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCu
|
|||
{
|
||||
path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y());
|
||||
}
|
||||
curve->SetCurrentColor(QColor(lineColor));
|
||||
curve->setPath(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, Simp
|
|||
VSpline spl = splPath->GetSpline(splPath->Count());
|
||||
path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y());
|
||||
}
|
||||
curve->SetCurrentColor(QColor(lineColor));
|
||||
curve->setPath(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -239,6 +239,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
|
|||
{
|
||||
VDrawTool::ChangedActivDraw(newName);
|
||||
this->setEnabled(enabled);
|
||||
this->setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -289,7 +290,8 @@ void VToolLine::RefreshDataInFile()
|
|||
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyleToPenStyle(typeLine)));
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -300,7 +302,8 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -476,6 +479,6 @@ void VToolLine::RefreshGeometry()
|
|||
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint);
|
||||
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(secondPoint);
|
||||
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
|||
{
|
||||
VToolPoint::ChangedActivDraw(newName);
|
||||
this->setEnabled(enabled);
|
||||
mainLine->setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
mainLine->setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
|||
*/
|
||||
void VToolLinePoint::RefreshGeometry()
|
||||
{
|
||||
mainLine->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||
mainLine->setPen(QPen(CorrectColor(QColor(lineColor)), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
QPointF point = VDrawTool::data.GeometricObject<VPointF>(id)->toQPointF();
|
||||
|
|
|
@ -204,7 +204,7 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor));
|
||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthMainLine())/factor));
|
||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -227,7 +227,7 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
||||
{
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||
rec.translate(-rec.center().x(), -rec.center().y());
|
||||
this->setRect(rec);
|
||||
|
|
|
@ -52,8 +52,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
|
|||
:VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
|
||||
{
|
||||
baseColor = Qt::red;
|
||||
currentColor = baseColor;
|
||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
ignoreFullUpdate = true;
|
||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
|
|
|
@ -356,7 +356,7 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
*/
|
||||
void VToolSpline::RefreshGeometry()
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
if (isHovered)
|
||||
{
|
||||
this->setPath(ToolPath(PathDirection::Show));
|
||||
|
|
|
@ -47,7 +47,7 @@ const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
|
|||
*/
|
||||
VAbstractNode::VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
|
||||
const quint32 &idTool, QObject *parent)
|
||||
: VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool)
|
||||
: VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool), currentColor(Qt::black)
|
||||
{
|
||||
_referens = 0;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ protected:
|
|||
/** @brief idTool id tool. */
|
||||
quint32 idTool;
|
||||
|
||||
/** @brief currentColor current tool color. */
|
||||
QColor currentColor;
|
||||
|
||||
void AddToModeling(const QDomElement &domElement);
|
||||
virtual void decrementReferens();
|
||||
virtual void RemoveReferens();
|
||||
|
|
|
@ -97,7 +97,7 @@ const QString VAbstractTool::ColorYellow = QStringLiteral("yellow");
|
|||
* @param parent parent object.
|
||||
*/
|
||||
VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent)
|
||||
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), vis(nullptr)
|
||||
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), vis(nullptr)
|
||||
{
|
||||
SCASSERT(doc != nullptr);
|
||||
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange);
|
||||
|
|
|
@ -147,9 +147,6 @@ protected:
|
|||
/** @brief baseColor base color for tool. */
|
||||
Qt::GlobalColor baseColor;
|
||||
|
||||
/** @brief currentColor current tool color. */
|
||||
Qt::GlobalColor currentColor;
|
||||
|
||||
Visualization *vis;
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,18 +40,18 @@
|
|||
* @param currentColor current color.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VSimpleCurve::VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurvePoint pointPosition, qreal *factor,
|
||||
VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, qreal *factor,
|
||||
QObject *parent)
|
||||
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor),
|
||||
curvePosition(pointPosition), enabled(true)
|
||||
{
|
||||
if (factor == nullptr)
|
||||
{
|
||||
setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
|
||||
setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
|
||||
}
|
||||
else
|
||||
{
|
||||
setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/ *factor));
|
||||
setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor));
|
||||
}
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setAcceptHoverEvents(true);
|
||||
|
@ -62,7 +62,7 @@ void VSimpleCurve::ChangedActivDraw(const bool &flag)
|
|||
{
|
||||
enabled = flag;
|
||||
setEnabled(enabled);
|
||||
setPen(QPen(CorrectColor(*currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor));
|
||||
setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -102,11 +102,11 @@ void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||
Q_UNUSED(event);
|
||||
if (factor == nullptr)
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(*currentColor), qApp->toPixel(qApp->widthMainLine())));
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine())));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(*currentColor), qApp->toPixel(qApp->widthMainLine())/ *factor));
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine())/ *factor));
|
||||
}
|
||||
emit HoverPath(id, curvePosition, PathDirection::Show);
|
||||
}
|
||||
|
@ -121,16 +121,29 @@ void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
Q_UNUSED(event);
|
||||
if (factor == nullptr)
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(*currentColor), qApp->toPixel(qApp->widthHairLine())));
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(*currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor));
|
||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor));
|
||||
}
|
||||
|
||||
emit HoverPath(id, curvePosition, PathDirection::Hide);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QColor VSimpleCurve::GetCurrentColor() const
|
||||
{
|
||||
return currentColor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::SetCurrentColor(const QColor &value)
|
||||
{
|
||||
currentColor = value;
|
||||
setPen(QPen(CorrectColor(currentColor), pen().widthF()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QColor VSimpleCurve::CorrectColor(const QColor &color) const
|
||||
{
|
||||
|
|
|
@ -41,13 +41,17 @@ class VSimpleCurve : public QObject, public QGraphicsPathItem
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurvePoint curvePosition,
|
||||
VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition,
|
||||
qreal *factor = nullptr, QObject *parent = 0);
|
||||
void ChangedActivDraw(const bool &flag);
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimpleSplinePath)};
|
||||
|
||||
QColor GetCurrentColor() const;
|
||||
void SetCurrentColor(const QColor &value);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Choosed send id when clicked.
|
||||
|
@ -68,7 +72,7 @@ private:
|
|||
qreal *factor;
|
||||
|
||||
/** @brief currentColor current color. */
|
||||
Qt::GlobalColor *currentColor;
|
||||
QColor currentColor;
|
||||
|
||||
SimpleCurvePoint curvePosition;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user