Refactoring, correct disabling tool.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-02-06 14:31:40 +02:00
parent 5f49394236
commit 4f91c69127
8 changed files with 35 additions and 36 deletions

View file

@ -74,7 +74,11 @@ void VAbstractSpline::FullUpdateFromFile()
//---------------------------------------------------------------------------------------------------------------------
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)
{
VDrawTool::ChangedActivDraw(newName);
this->setEnabled(enabled);
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine,
Qt::RoundCap));
emit setEnabledPoint(enabled);
Disable(!(nameActivDraw == newName));
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -177,20 +177,6 @@ protected:
// 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:
Q_DISABLE_COPY(VDrawTool)
};

View file

@ -59,9 +59,7 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
*/
void VToolCut::ChangedActivDraw(const QString &newName)
{
VToolPoint::ChangedActivDraw(newName);
firstCurve->ChangedActivDraw(enabled);
secondCurve->ChangedActivDraw(enabled);
Disable(!(nameActivDraw == newName));
}
//---------------------------------------------------------------------------------------------------------------------
@ -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
{

View file

@ -53,6 +53,7 @@ public slots:
virtual void ChangedActivDraw(const QString &newName);
virtual void CurveChoosed(quint32 id)=0;
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
void Disable(bool disable);
protected:
/** @brief formula keep formula of length */
QString formula;

View file

@ -227,7 +227,9 @@ void VToolLine::SetFactor(qreal factor)
//---------------------------------------------------------------------------------------------------------------------
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)
{
VDrawTool::ChangedActivDraw(newName);
this->setEnabled(enabled);
this->setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
Disable(!(nameActivDraw == newName));
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -69,11 +69,7 @@ VToolLinePoint::~VToolLinePoint()
*/
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);
Disable(!(nameActivDraw == newName));
}
//---------------------------------------------------------------------------------------------------------------------
@ -110,6 +106,15 @@ void VToolLinePoint::SetFactor(qreal factor)
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
{

View file

@ -56,6 +56,7 @@ public:
public slots:
virtual void ChangedActivDraw(const QString &newName);
virtual void SetFactor(qreal factor);
void Disable(bool disable);
protected:
/** @brief formula string with length formula. */
QString formulaLength;

View file

@ -132,9 +132,7 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
*/
void VToolPoint::ChangedActivDraw(const QString &newName)
{
VDrawTool::ChangedActivDraw(newName);
this->setEnabled(enabled);
namePoint->setEnabled(enabled);
Disable(!(nameActivDraw == newName));
}
//---------------------------------------------------------------------------------------------------------------------
@ -173,7 +171,9 @@ void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VToolPoint::Disable(bool disable)
{
DisableItem(this, disable);
enabled = !disable;
this->setEnabled(enabled);
namePoint->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------