diff --git a/src/app/options.h b/src/app/options.h index d2de5312e..601214707 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -81,6 +81,7 @@ enum class Vis : unsigned char { ControlPointSpline = 29, // increase this value if need more positions in Tool enum GraphicsSimpleTextItem, + SimpleSplinePath, Line, Path, ToolAlongLine, @@ -96,9 +97,7 @@ enum class Vis : unsigned char ToolPointOfIntersection, ToolShoulderPoint, ToolSpline, - ToolTriangle, - SimpleCurvePoint, - SimpleSplinePath + ToolTriangle }; enum class Source : char { FromGui, FromFile, FromTool }; diff --git a/src/app/visualization/visualization.pri b/src/app/visualization/visualization.pri index b3397108a..f811878f2 100644 --- a/src/app/visualization/visualization.pri +++ b/src/app/visualization/visualization.pri @@ -1,7 +1,6 @@ HEADERS += \ visualization/vgraphicssimpletextitem.h \ visualization/vcontrolpointspline.h \ - visualization/vsimplesplinepath.h \ visualization/vsimplecurve.h \ visualization/visline.h \ visualization/vistoolline.h \ @@ -24,7 +23,6 @@ HEADERS += \ SOURCES += \ visualization/vgraphicssimpletextitem.cpp \ visualization/vcontrolpointspline.cpp \ - visualization/vsimplesplinepath.cpp \ visualization/vsimplecurve.cpp \ visualization/visline.cpp \ visualization/vistoolline.cpp \ diff --git a/src/app/visualization/vsimplecurve.h b/src/app/visualization/vsimplecurve.h index bf6cb6683..d33afb269 100644 --- a/src/app/visualization/vsimplecurve.h +++ b/src/app/visualization/vsimplecurve.h @@ -47,7 +47,7 @@ public: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual int type() const {return Type;} - enum { Type = UserType + static_cast(Vis::SimpleCurvePoint)}; + enum { Type = UserType + static_cast(Vis::SimpleSplinePath)}; signals: /** * @brief Choosed send id when clicked. diff --git a/src/app/visualization/vsimplesplinepath.cpp b/src/app/visualization/vsimplesplinepath.cpp deleted file mode 100644 index 68ca539be..000000000 --- a/src/app/visualization/vsimplesplinepath.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************ - ** - ** @file vsimplesplinepath.cpp - ** @author Roman Telezhynskyi - ** @date 17 12, 2013 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "vsimplesplinepath.h" -#include "../widgets/vapplication.h" -#include -#include -#include - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief VSimpleSplinePath constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id spline path id. - * @param factor scale factor. - */ -VSimpleSplinePath::VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor) - :VAbstractTool(doc, data, id), QGraphicsPathItem(), factor(factor) -{} - -//--------------------------------------------------------------------------------------------------------------------- -void VSimpleSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - /* From question on StackOverflow - * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected - * - * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way - * I can think of is derive your own items from the build-in ones and override the paint() function:*/ - QStyleOptionGraphicsItem myOption(*option); - myOption.state &= ~QStyle::State_Selected; - QGraphicsPathItem::paint(painter, &myOption, widget); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ -void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, SceneObject::SplinePath); - } - QGraphicsPathItem::mouseReleaseEvent(event); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ -void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/ *factor)); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ -void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); -} diff --git a/src/app/visualization/vsimplesplinepath.h b/src/app/visualization/vsimplesplinepath.h deleted file mode 100644 index 3ff124b0a..000000000 --- a/src/app/visualization/vsimplesplinepath.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************ - ** - ** @file vsimplesplinepath.h - ** @author Roman Telezhynskyi - ** @date 17 12, 2013 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#ifndef VSIMPLESPLINEPATH_H -#define VSIMPLESPLINEPATH_H - -#include -#include "../tools/vabstracttool.h" - -/** - * @brief The VSimpleSplinePath class for simple spline path. This object used when we cut spline path and want show - * peaces. - */ -class VSimpleSplinePath : public VAbstractTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor); - virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); - - virtual int type() const {return Type;} - enum { Type = UserType + static_cast(Vis::SimpleSplinePath)}; -protected: - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); -private: - Q_DISABLE_COPY(VSimpleSplinePath) - /** @brief factor scale factor. */ - qreal *factor; -}; - -#endif // VSIMPLESPLINEPATH_H diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index 4a7ef658b..07c61aaa5 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -33,7 +33,9 @@ #include #include #include "../tools/vabstracttool.h" +#include "../visualization/vsimplecurve.h" +#include #include #include @@ -223,7 +225,19 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) case Qt::NoModifier: if (showToolOptions) { - emit itemClicked(itemAt(mousePress->pos())); + QList list = items(mousePress->pos()); + if (list.size() == 0) + { + emit itemClicked(nullptr); + break; + } + for (int i = 0; i < list.size(); ++i) + { + if (list.at(i)->type() <= VSimpleCurve::Type && list.at(i)->type() > QGraphicsItem::UserType) + { + emit itemClicked(list.at(i)); + } + } } break; default: