Fixes for tools vizualizations.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-04 09:37:19 +03:00
parent 7aa9c0464e
commit 11641de911
15 changed files with 61 additions and 16 deletions

View File

@ -39,6 +39,10 @@ VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QG
ignoreFullUpdate = true;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::~VAbstractSpline()
{}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
@ -175,7 +179,7 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
DeleteTool();
break;
default:
break;

View File

@ -38,6 +38,7 @@ class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
Q_OBJECT
public:
VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VAbstractSpline();
static const QString TagName;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;}
@ -82,6 +83,8 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
private:
Q_DISABLE_COPY(VAbstractSpline)
};
#endif // VABSTRACTSPLINE_H

View File

@ -83,7 +83,7 @@ void VDrawTool::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
{
currentColor = Qt::black;
currentColor = baseColor;
}
else
{

View File

@ -239,6 +239,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
{
VDrawTool::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
}
//---------------------------------------------------------------------------------------------------------------------
@ -348,7 +349,7 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event)
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
DeleteTool();
break;
default:
break;

View File

@ -65,6 +65,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
{
VToolPoint::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -135,6 +135,8 @@ void VToolPoint::ChangedActivDraw(const QString &newName)
VDrawTool::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
namePoint->setBrush(QBrush(currentColor));
lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
}
//---------------------------------------------------------------------------------------------------------------------
@ -312,7 +314,7 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event)
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
DeleteTool();
break;
default:
break;

View File

@ -307,7 +307,16 @@ void VToolSinglePoint::FullUpdateFromFile()
void VToolSinglePoint::ChangedActivDraw(const QString &newName)
{
VToolPoint::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
if (nameActivDraw == newName)
{
this->setEnabled(true);
setColorLabel(Qt::black);
}
else
{
this->setEnabled(false);
setColorLabel(Qt::gray);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -84,6 +84,10 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Sour
}
}
//---------------------------------------------------------------------------------------------------------------------
VToolSpline::~VToolSpline()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.

View File

@ -38,9 +38,9 @@ class VToolSpline:public VAbstractSpline
{
Q_OBJECT
public:
VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr );
VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr );
virtual ~VToolSpline();
virtual void setDialog();
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolSpline *Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
@ -64,6 +64,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolSpline)
void RefreshGeometry ();
};

View File

@ -362,7 +362,7 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
DeleteTool();
break;
default:
break;

View File

@ -64,3 +64,12 @@ void VisToolLine::setPoint2Id(const quint32 &value)
{
point2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style)
{
SCASSERT (lineItem != nullptr);
lineItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style));
lineItem->setLine(line);
}

View File

@ -42,6 +42,9 @@ public:
void setPoint2Id(const quint32 &value);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLine)};
protected:
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
Qt::PenStyle style = Qt::SolidLine);
private:
Q_DISABLE_COPY(VisToolLine)
quint32 point2Id;

View File

@ -74,7 +74,7 @@ protected:
qreal FindVal(const QString &expression);
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color,
Qt::PenStyle style = Qt::SolidLine);
void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
Qt::PenStyle style = Qt::SolidLine);
template <typename Item>

View File

@ -235,6 +235,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
if (list.at(i)->type() <= VSimpleCurve::Type && list.at(i)->type() > QGraphicsItem::UserType)
{
emit itemClicked(list.at(i));
break;
}
}
}

View File

@ -297,12 +297,15 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item)
{
if (item != nullptr && item->isEnabled()==false)
if (item != nullptr)
{
return;
if (item->isEnabled()==false)
{
return;
}
}
if (currentItem == item)
if (currentItem == item && item != nullptr)
{
UpdateOptions();
return;
@ -312,10 +315,14 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item)
propertyToId.clear();
idToProperty.clear();
VAbstractTool *previousTool = dynamic_cast<VAbstractTool *>(currentItem);
if (previousTool != nullptr)
if (currentItem != nullptr)
{
previousTool->ShowVisualization(false); // hide for previous tool
VAbstractTool *previousTool = dynamic_cast<VAbstractTool *>(currentItem);
if (previousTool != nullptr)
{
previousTool->ShowVisualization(false); // hide for previous tool
}
}
currentItem = item;