Ignore visualization if need show tool under visualization.

--HG--
branch : feature
This commit is contained in:
dismine 2014-09-03 19:09:59 +03:00
parent 6fb280663a
commit aee0c1fed6
6 changed files with 18 additions and 159 deletions

View File

@ -81,6 +81,7 @@ enum class Vis : unsigned char
{ {
ControlPointSpline = 29, // increase this value if need more positions in Tool enum ControlPointSpline = 29, // increase this value if need more positions in Tool enum
GraphicsSimpleTextItem, GraphicsSimpleTextItem,
SimpleSplinePath,
Line, Line,
Path, Path,
ToolAlongLine, ToolAlongLine,
@ -96,9 +97,7 @@ enum class Vis : unsigned char
ToolPointOfIntersection, ToolPointOfIntersection,
ToolShoulderPoint, ToolShoulderPoint,
ToolSpline, ToolSpline,
ToolTriangle, ToolTriangle
SimpleCurvePoint,
SimpleSplinePath
}; };
enum class Source : char { FromGui, FromFile, FromTool }; enum class Source : char { FromGui, FromFile, FromTool };

View File

@ -1,7 +1,6 @@
HEADERS += \ HEADERS += \
visualization/vgraphicssimpletextitem.h \ visualization/vgraphicssimpletextitem.h \
visualization/vcontrolpointspline.h \ visualization/vcontrolpointspline.h \
visualization/vsimplesplinepath.h \
visualization/vsimplecurve.h \ visualization/vsimplecurve.h \
visualization/visline.h \ visualization/visline.h \
visualization/vistoolline.h \ visualization/vistoolline.h \
@ -24,7 +23,6 @@ HEADERS += \
SOURCES += \ SOURCES += \
visualization/vgraphicssimpletextitem.cpp \ visualization/vgraphicssimpletextitem.cpp \
visualization/vcontrolpointspline.cpp \ visualization/vcontrolpointspline.cpp \
visualization/vsimplesplinepath.cpp \
visualization/vsimplecurve.cpp \ visualization/vsimplecurve.cpp \
visualization/visline.cpp \ visualization/visline.cpp \
visualization/vistoolline.cpp \ visualization/vistoolline.cpp \

View File

@ -47,7 +47,7 @@ public:
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::SimpleCurvePoint)}; enum { Type = UserType + static_cast<int>(Vis::SimpleSplinePath)};
signals: signals:
/** /**
* @brief Choosed send id when clicked. * @brief Choosed send id when clicked.

View File

@ -1,94 +0,0 @@
/************************************************************************
**
** @file vsimplesplinepath.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vsimplesplinepath.h"
#include "../widgets/vapplication.h"
#include <QGraphicsSceneMouseEvent>
#include <QPen>
#include <QStyleOptionGraphicsItem>
//---------------------------------------------------------------------------------------------------------------------
/**
* @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));
}

View File

@ -1,58 +0,0 @@
/************************************************************************
**
** @file vsimplesplinepath.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VSIMPLESPLINEPATH_H
#define VSIMPLESPLINEPATH_H
#include <QGraphicsPathItem>
#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<int>(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

View File

@ -33,7 +33,9 @@
#include <QApplication> #include <QApplication>
#include <QScrollBar> #include <QScrollBar>
#include "../tools/vabstracttool.h" #include "../tools/vabstracttool.h"
#include "../visualization/vsimplecurve.h"
#include <QGraphicsItem>
#include <QMouseEvent> #include <QMouseEvent>
#include <qmath.h> #include <qmath.h>
@ -223,7 +225,19 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
case Qt::NoModifier: case Qt::NoModifier:
if (showToolOptions) if (showToolOptions)
{ {
emit itemClicked(itemAt(mousePress->pos())); QList<QGraphicsItem *> 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; break;
default: default: