56 #include <QGraphicsItem>
57 #include <QGraphicsLineItem>
58 #include <QGraphicsSceneMouseEvent>
59 #include <QGraphicsSimpleTextItem>
62 #include <QStaticStringData>
63 #include <QStringData>
64 #include <QStringDataPtr>
68 #include "../vmisc/vcommonsettings.h"
69 #include "../vmisc/vabstractapplication.h"
76 : QGraphicsScene(parent)
79 , m_previousTransform(QTransform())
80 , m_currentTransform(QTransform())
92 :QGraphicsScene ( sceneRect, parent )
95 , m_previousTransform(QTransform())
96 , m_currentTransform(QTransform())
110 QGraphicsScene::mouseMoveEvent(event);
120 if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
125 QGraphicsScene::mousePressEvent(event);
128 QGraphicsItem* pItem = itemAt(event->scenePos(), t);
135 if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
139 QGraphicsScene::mouseReleaseEvent(event);
147 QColor orginColor = (QColor(
qApp->Settings()->getAxisOrginColor()));
148 QPen originsPen(orginColor,
widthHairLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
149 QBrush axisTextBrush(orginColor);
150 const qreal arrowAngle = 35.0;
151 const qreal arrowLength = 12.0;
155 const QLineF lineX(QPointF(25, 0), QPointF(-5, 0));
156 QGraphicsLineItem *xLine1 =
new QGraphicsLineItem(lineX);
157 xLine1->setPen(originsPen);
158 xLine1->setFlag(QGraphicsItem::ItemIgnoresTransformations);
159 xLine1->setZValue(-1.0);
164 QLineF arrowLeftLine = lineX;
165 arrowLeftLine.setAngle(arrowLeftLine.angle()-arrowAngle);
166 arrowLeftLine.setLength(arrowLength);
167 QGraphicsLineItem *xLine2 =
new QGraphicsLineItem(arrowLeftLine);
168 xLine2->setPen(originsPen);
169 xLine2->setFlag(QGraphicsItem::ItemIgnoresTransformations);
170 xLine2->setZValue(-1.0);
175 QLineF arrowRightLine = lineX;
176 arrowRightLine.setAngle(arrowRightLine.angle()+arrowAngle);
177 arrowRightLine.setLength(arrowLength);
178 QGraphicsLineItem *xLine3 =
new QGraphicsLineItem(arrowRightLine);
179 xLine3->setPen(originsPen);
180 xLine3->setFlag(QGraphicsItem::ItemIgnoresTransformations);
181 xLine3->setZValue(-1.0);
186 QGraphicsSimpleTextItem *xOrigin =
new QGraphicsSimpleTextItem(QStringLiteral(
"X"), xLine1);
187 xOrigin->setBrush(axisTextBrush);
188 xOrigin->setFlag(QGraphicsItem::ItemIgnoresTransformations);
189 xOrigin->setZValue(-1.0);
190 xOrigin->setPos(25, -(xOrigin->boundingRect().height()/2));
196 const QLineF lineY(QPointF(0, 25), QPointF(0, -5));
197 QGraphicsLineItem *yLine1 =
new QGraphicsLineItem(lineY);
198 yLine1->setPen(originsPen);
199 yLine1->setFlag(QGraphicsItem::ItemIgnoresTransformations);
200 yLine1->setZValue(-1.0);
205 QLineF arrowLeftLine = lineY;
206 arrowLeftLine.setAngle(arrowLeftLine.angle()-arrowAngle);
207 arrowLeftLine.setLength(arrowLength);
208 QGraphicsLineItem *yLine2 =
new QGraphicsLineItem(arrowLeftLine);
209 yLine2->setPen(originsPen);
210 yLine2->setFlag(QGraphicsItem::ItemIgnoresTransformations);
211 yLine2->setZValue(-1.0);
216 QLineF arrowRightLine = lineY;
217 arrowRightLine.setAngle(arrowRightLine.angle()+arrowAngle);
218 arrowRightLine.setLength(arrowLength);
219 QGraphicsLineItem *yLine3 =
new QGraphicsLineItem(arrowRightLine);
220 yLine3->setPen(originsPen);
221 yLine3->setFlag(QGraphicsItem::ItemIgnoresTransformations);
222 yLine3->setZValue(-1.0);
227 QGraphicsSimpleTextItem *yOrigin =
new QGraphicsSimpleTextItem(QStringLiteral(
"Y"), yLine1);
228 yOrigin->setBrush(axisTextBrush);
229 yOrigin->setFlag(QGraphicsItem::ItemIgnoresTransformations);
230 yOrigin->setZValue(-1.0);
231 yOrigin->setPos(-(yOrigin->boundingRect().width()/2), 25);
239 foreach (QGraphicsItem *item,
origins)
241 item->setVisible(visible);
255 foreach(QGraphicsItem *item, items())
257 if(not item->isVisible())
261 rect = rect.united(item->sceneBoundingRect());
void EnableSplinePathItemHover(bool enable)
void chosenItem(quint32 id, const SceneObject &type)
chosenItem emit ChosenObject signal.
void SetDisableTools(bool disable, const QString &draftBlockName)
QTransform transform() const
transform return view transformation.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
void EnableItemMove(bool move)
void EnableArcItemHover(bool enable)
void EnablePointItemSelection(bool enable)
void EnableElArcItemHover(bool enable)
QRectF visibleItemsBoundingRect() const
void EnableLineItemHover(bool enabled)
void setOriginsVisible(bool visible)
void ToggleArcHover(bool enabled)
void enableTextItemSelection(bool enable)
QPointF getScenePos() const
void EnableNodeLabelItemHover(bool enabled)
void curvePiecesMode(bool mode)
void ItemClicked(QGraphicsItem *pItem)
void EnableSplineItemSelection(bool enable)
void mouseMove(const QPointF &scenePos)
mouseMove send new mouse position.
void EnableDetailItemHover(bool enabled)
void ItemSelection(const SelectionType &type)
void ToggleSplinePathSelection(bool enabled)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mousePressEvent mouse press events.
void EnablePointItemHover(bool enable)
void TogglePointHover(bool enabled)
void EnableDetailItemSelection(bool enabled)
QVector< QGraphicsItem * > origins
void EnableArcItemSelection(bool enable)
void enableTextItemHover(bool enable)
void EnableToolMove(bool move)
void ToggleElArcHover(bool enabled)
void ToggleElArcSelection(bool enabled)
void togglePieceSelection(bool enabled)
void ToggleNodePointSelection(bool enabled)
void EnableNodeLabelItemSelection(bool enabled)
void ToggleNodeLabelHover(bool enabled)
void EnableElArcItemSelection(bool enable)
void DisableItem(bool disable, const QString &draftBlockName)
void ToggleNodePointHover(bool enabled)
void SelectedObject(bool selected, quint32 object, quint32 tool)
void ToggleSplinePathHover(bool enabled)
void ToggleNodeLabelSelection(bool enabled)
void ChosenObject(quint32 id, SceneObject type)
ChosenObject send option choosed object.
void highlightPiece(quint32 id)
void ToggleSplineHover(bool enabled)
void ToggleLabelSelection(bool enabled)
void ToggleSplineSelection(bool enabled)
void EnableNodePointItemSelection(bool enabled)
void SelectedItem(bool selected, quint32 object, quint32 tool)
void EnableLineItemSelection(bool enable)
void togglePieceHover(bool enabled)
QTransform m_currentTransform
void ToggleArcSelection(bool enabled)
void ToggleLabelHover(bool enabled)
void HighlightItem(quint32 id)
QTransform m_previousTransform
_transform view transform value.
void setCurrentTransform(const QTransform &transform)
setCurrentTransform set view transformation.
void swapTransforms()
swapTransforms.
void EnableSplineItemHover(bool enable)
void EnableSplinePathItemSelection(bool enable)
void enablePiecesMode(bool mode)
void ItemsSelection(const SelectionType &type)
void ToggleLineSelection(bool enabled)
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mouseMoveEvent handle mouse move events.
VMainGraphicsScene(QObject *parent=nullptr)
VMainGraphicsScene default constructor.
void TogglePointSelection(bool enabled)
void ToggleLineHover(bool enabled)
void EnableNodePointItemHover(bool enabled)
const qreal widthHairLine