Refactoring, correct disabling tool.
--HG-- branch : feature
This commit is contained in:
parent
5f49394236
commit
4f91c69127
|
@ -74,7 +74,11 @@ void VAbstractSpline::FullUpdateFromFile()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractSpline::Disable(bool disable)
|
void VAbstractSpline::Disable(bool disable)
|
||||||
{
|
{
|
||||||
DisableItem(this, disable);
|
enabled = !disable;
|
||||||
|
this->setEnabled(enabled);
|
||||||
|
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine,
|
||||||
|
Qt::RoundCap));
|
||||||
|
emit setEnabledPoint(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -84,11 +88,7 @@ void VAbstractSpline::Disable(bool disable)
|
||||||
*/
|
*/
|
||||||
void VAbstractSpline::ChangedActivDraw(const QString &newName)
|
void VAbstractSpline::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
VDrawTool::ChangedActivDraw(newName);
|
Disable(!(nameActivDraw == newName));
|
||||||
this->setEnabled(enabled);
|
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine,
|
|
||||||
Qt::RoundCap));
|
|
||||||
emit setEnabledPoint(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -177,20 +177,6 @@ protected:
|
||||||
// item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
// 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));
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VDrawTool)
|
Q_DISABLE_COPY(VDrawTool)
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,9 +59,7 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
|
||||||
*/
|
*/
|
||||||
void VToolCut::ChangedActivDraw(const QString &newName)
|
void VToolCut::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
Disable(!(nameActivDraw == newName));
|
||||||
firstCurve->ChangedActivDraw(enabled);
|
|
||||||
secondCurve->ChangedActivDraw(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -74,6 +72,14 @@ void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirecti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolCut::Disable(bool disable)
|
||||||
|
{
|
||||||
|
VToolPoint::Disable(disable);
|
||||||
|
firstCurve->ChangedActivDraw(enabled);
|
||||||
|
secondCurve->ChangedActivDraw(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 VToolCut::getCurveCutId() const
|
quint32 VToolCut::getCurveCutId() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,7 @@ public slots:
|
||||||
virtual void ChangedActivDraw(const QString &newName);
|
virtual void ChangedActivDraw(const QString &newName);
|
||||||
virtual void CurveChoosed(quint32 id)=0;
|
virtual void CurveChoosed(quint32 id)=0;
|
||||||
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
|
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
|
||||||
|
void Disable(bool disable);
|
||||||
protected:
|
protected:
|
||||||
/** @brief formula keep formula of length */
|
/** @brief formula keep formula of length */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
|
|
@ -227,7 +227,9 @@ void VToolLine::SetFactor(qreal factor)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolLine::Disable(bool disable)
|
void VToolLine::Disable(bool disable)
|
||||||
{
|
{
|
||||||
DisableItem(this, disable);
|
enabled = !disable;
|
||||||
|
this->setEnabled(enabled);
|
||||||
|
this->setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -237,9 +239,7 @@ void VToolLine::Disable(bool disable)
|
||||||
*/
|
*/
|
||||||
void VToolLine::ChangedActivDraw(const QString &newName)
|
void VToolLine::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
VDrawTool::ChangedActivDraw(newName);
|
Disable(!(nameActivDraw == newName));
|
||||||
this->setEnabled(enabled);
|
|
||||||
this->setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -69,11 +69,7 @@ VToolLinePoint::~VToolLinePoint()
|
||||||
*/
|
*/
|
||||||
void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
Disable(!(nameActivDraw == newName));
|
||||||
this->setEnabled(enabled);
|
|
||||||
mainLine->setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
|
||||||
LineStyleToPenStyle(typeLine)));
|
|
||||||
mainLine->setEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,6 +106,15 @@ void VToolLinePoint::SetFactor(qreal factor)
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolLinePoint::Disable(bool disable)
|
||||||
|
{
|
||||||
|
VToolPoint::Disable(disable);
|
||||||
|
mainLine->setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
||||||
|
LineStyleToPenStyle(typeLine)));
|
||||||
|
mainLine->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VToolLinePoint::GetAngle() const
|
qreal VToolLinePoint::GetAngle() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChangedActivDraw(const QString &newName);
|
virtual void ChangedActivDraw(const QString &newName);
|
||||||
virtual void SetFactor(qreal factor);
|
virtual void SetFactor(qreal factor);
|
||||||
|
void Disable(bool disable);
|
||||||
protected:
|
protected:
|
||||||
/** @brief formula string with length formula. */
|
/** @brief formula string with length formula. */
|
||||||
QString formulaLength;
|
QString formulaLength;
|
||||||
|
|
|
@ -132,9 +132,7 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
|
||||||
*/
|
*/
|
||||||
void VToolPoint::ChangedActivDraw(const QString &newName)
|
void VToolPoint::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
VDrawTool::ChangedActivDraw(newName);
|
Disable(!(nameActivDraw == newName));
|
||||||
this->setEnabled(enabled);
|
|
||||||
namePoint->setEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -173,7 +171,9 @@ void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolPoint::Disable(bool disable)
|
void VToolPoint::Disable(bool disable)
|
||||||
{
|
{
|
||||||
DisableItem(this, disable);
|
enabled = !disable;
|
||||||
|
this->setEnabled(enabled);
|
||||||
|
namePoint->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user