Allow a user interact only with items from active pattern piece.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-02 16:34:49 +03:00
parent a9c496e065
commit 50f82eee27
9 changed files with 55 additions and 133 deletions

View File

@ -80,22 +80,11 @@ void VAbstractSpline::Disable(bool disable)
*/ */
void VAbstractSpline::ChangedActivDraw(const QString &newName) void VAbstractSpline::ChangedActivDraw(const QString &newName)
{ {
bool selectable = false;
if (nameActivDraw == newName)
{
selectable = true;
currentColor = Qt::black;
}
else
{
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
this->setAcceptHoverEvents (selectable);
emit setEnabledPoint(selectable);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
const bool selectable = (nameActivDraw == newName);
this->setEnabled(selectable);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
emit setEnabledPoint(selectable);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ qreal VDrawTool::factor = 1;
* @param id object id in container. * @param id object id in container.
*/ */
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id) VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id)
:VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false), :VAbstractTool(doc, data, id), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivPP()), dialog(nullptr) nameActivDraw(doc->GetNameActivPP()), dialog(nullptr)
{ {
connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);
@ -83,11 +83,11 @@ void VDrawTool::ChangedActivDraw(const QString &newName)
{ {
if (nameActivDraw == newName) if (nameActivDraw == newName)
{ {
ignoreContextMenuEvent = false; currentColor = Qt::black;
} }
else else
{ {
ignoreContextMenuEvent = true; currentColor = Qt::gray;
} }
} }

View File

@ -54,7 +54,6 @@ public:
/** @brief setDialog set dialog when user want change tool option. */ /** @brief setDialog set dialog when user want change tool option. */
virtual void setDialog() {} virtual void setDialog() {}
virtual void DialogLinkDestroy(); virtual void DialogLinkDestroy();
void ignoreContextMenu(bool enable);
static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data); static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data);
public slots: public slots:
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
@ -64,8 +63,6 @@ public slots:
virtual void FullUpdateFromGuiApply(); virtual void FullUpdateFromGuiApply();
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
protected: protected:
/** @brief ignoreContextMenuEvent ignore or not context menu events. */
bool ignoreContextMenuEvent;
/** @brief ignoreFullUpdate ignore or not full updates. */ /** @brief ignoreFullUpdate ignore or not full updates. */
bool ignoreFullUpdate; bool ignoreFullUpdate;
@ -95,8 +92,7 @@ protected:
{ {
SCASSERT(tool != nullptr); SCASSERT(tool != nullptr);
SCASSERT(event != nullptr); SCASSERT(event != nullptr);
if (ignoreContextMenuEvent == false)
{
QMenu menu; QMenu menu;
QAction *actionOption = menu.addAction(tr("Options")); QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove = nullptr; QAction *actionRemove = nullptr;
@ -140,7 +136,6 @@ protected:
DeleteTool(); DeleteTool();
} }
} }
}
template <typename Item> template <typename Item>
/** /**
* @brief ShowItem highlight tool. * @brief ShowItem highlight tool.
@ -183,14 +178,4 @@ private:
Q_DISABLE_COPY(VDrawTool) Q_DISABLE_COPY(VDrawTool)
}; };
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ignoreContextMenu set ignore contect menu tool.
* @param enable true - ignore.
*/
inline void VDrawTool::ignoreContextMenu(bool enable)
{
ignoreContextMenuEvent = enable;
}
#endif // VDRAWTOOL_H #endif // VDRAWTOOL_H

View File

@ -59,20 +59,11 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
*/ */
void VToolCut::ChangedActivDraw(const QString &newName) void VToolCut::ChangedActivDraw(const QString &newName)
{ {
bool flag = true; VToolPoint::ChangedActivDraw(newName);
if (nameActivDraw == newName) const bool flag = (nameActivDraw == newName);
{ this->setEnabled(flag);
currentColor = Qt::black;
flag = true;
}
else
{
currentColor = Qt::gray;
flag = false;
}
firstCurve->ChangedActivDraw(flag); firstCurve->ChangedActivDraw(flag);
secondCurve->ChangedActivDraw(flag); secondCurve->ChangedActivDraw(flag);
VToolPoint::ChangedActivDraw(newName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -237,20 +237,8 @@ void VToolLine::Disable(bool disable)
*/ */
void VToolLine::ChangedActivDraw(const QString &newName) void VToolLine::ChangedActivDraw(const QString &newName)
{ {
bool selectable = false;
if (nameActivDraw == newName)
{
selectable = true;
currentColor = Qt::black;
}
else
{
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
this->setAcceptHoverEvents (selectable);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -63,16 +63,8 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
*/ */
void VToolLinePoint::ChangedActivDraw(const QString &newName) void VToolLinePoint::ChangedActivDraw(const QString &newName)
{ {
if (nameActivDraw == newName)
{
currentColor = Qt::black;
}
else
{
currentColor = Qt::gray;
}
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -132,27 +132,9 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
*/ */
void VToolPoint::ChangedActivDraw(const QString &newName) void VToolPoint::ChangedActivDraw(const QString &newName)
{ {
bool selectable = false;
if (nameActivDraw == newName)
{
selectable = true;
currentColor = baseColor;
}
else
{
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
this->setAcceptHoverEvents (selectable);
namePoint->setFlag(QGraphicsItem::ItemIsMovable, selectable);
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, selectable);
namePoint->setBrush(QBrush(currentColor));
namePoint->setAcceptHoverEvents(selectable);
lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
namePoint->setBrush(QBrush(currentColor));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -306,18 +306,8 @@ void VToolSinglePoint::FullUpdateFromFile()
*/ */
void VToolSinglePoint::ChangedActivDraw(const QString &newName) void VToolSinglePoint::ChangedActivDraw(const QString &newName)
{ {
if (nameActivDraw == newName)
{
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
setColorLabel(Qt::black); this->setEnabled(nameActivDraw == newName);
}
else
{
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
VToolPoint::ChangedActivDraw(newName);
setColorLabel(Qt::gray);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -297,6 +297,11 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item)
{ {
if (item != nullptr && item->isEnabled()==false)
{
return;
}
if (currentItem == item) if (currentItem == item)
{ {
UpdateOptions(); UpdateOptions();