2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vmaingraphicsscene.h
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
#ifndef VMAINGRAPHICSSCENE_H
|
|
|
|
#define VMAINGRAPHICSSCENE_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
2013-07-03 14:29:26 +02:00
|
|
|
#include <QGraphicsScene>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QString>
|
|
|
|
#include <QTransform>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2015-06-15 13:43:41 +02:00
|
|
|
#include "../vmisc/def.h"
|
2013-07-25 14:00:51 +02:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-27 13:27:26 +01:00
|
|
|
* @brief The VMainGraphicsScene class main scene.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
class VMainGraphicsScene : public QGraphicsScene
|
|
|
|
{
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_OBJECT // NOLINT
|
2013-07-03 14:29:26 +02:00
|
|
|
public:
|
2016-11-29 18:39:40 +01:00
|
|
|
explicit VMainGraphicsScene(QObject *parent = nullptr);
|
2015-10-20 16:32:01 +02:00
|
|
|
explicit VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr);
|
2023-05-03 13:07:02 +02:00
|
|
|
auto getHorScrollBar() const -> qint32;
|
2014-02-26 09:18:59 +01:00
|
|
|
void setHorScrollBar(const qint32 &value);
|
2023-05-03 13:07:02 +02:00
|
|
|
auto getVerScrollBar() const -> qint32;
|
2014-02-26 09:18:59 +01:00
|
|
|
void setVerScrollBar(const qint32 &value);
|
2023-05-03 13:07:02 +02:00
|
|
|
auto transform() const -> QTransform;
|
2014-01-11 15:09:44 +01:00
|
|
|
void setTransform(const QTransform &transform);
|
2017-04-06 14:50:15 +02:00
|
|
|
void SetDisableTools(bool disable, const QString &namePP);
|
2023-05-03 13:07:02 +02:00
|
|
|
auto getScenePos() const -> QPointF;
|
2016-01-13 14:47:38 +01:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VisibleItemsBoundingRect() const -> QRectF;
|
2016-01-15 13:55:56 +01:00
|
|
|
void InitOrigins();
|
|
|
|
void SetOriginsVisible(bool visible);
|
2019-07-21 11:27:58 +02:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto IsNonInteractive() const -> bool;
|
2019-07-21 11:27:58 +02:00
|
|
|
void SetNonInteractive(bool nonInteractive);
|
|
|
|
|
2022-01-28 15:54:20 +01:00
|
|
|
void SetAcceptDrop(bool newAcceptDrop);
|
|
|
|
auto AcceptDrop() const -> bool;
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
public slots:
|
2014-06-12 09:22:29 +02:00
|
|
|
void ChoosedItem(quint32 id, const SceneObject &type);
|
2016-04-05 19:14:12 +02:00
|
|
|
void SelectedItem(bool selected, quint32 object, quint32 tool);
|
2015-02-09 10:54:19 +01:00
|
|
|
void EnableItemMove(bool move);
|
2015-04-23 17:06:17 +02:00
|
|
|
void EnableDetailsMode(bool mode);
|
2016-03-31 19:10:20 +02:00
|
|
|
void ItemsSelection(const SelectionType &type);
|
2016-10-12 13:43:08 +02:00
|
|
|
void HighlightItem(quint32 id);
|
2021-05-10 15:39:17 +02:00
|
|
|
void UpdatePiecePassmarks();
|
2016-03-31 16:01:41 +02:00
|
|
|
|
|
|
|
void ToggleLabelSelection(bool enabled);
|
|
|
|
void TogglePointSelection(bool enabled);
|
2016-04-05 19:14:12 +02:00
|
|
|
void ToggleLineSelection(bool enabled);
|
2016-03-31 16:01:41 +02:00
|
|
|
void ToggleArcSelection(bool enabled);
|
2016-12-20 12:04:56 +01:00
|
|
|
void ToggleElArcSelection(bool enabled);
|
2016-03-31 16:01:41 +02:00
|
|
|
void ToggleSplineSelection(bool enabled);
|
|
|
|
void ToggleSplinePathSelection(bool enabled);
|
|
|
|
void ToggleNodeLabelSelection(bool enabled);
|
|
|
|
void ToggleNodePointSelection(bool enabled);
|
|
|
|
void ToggleDetailSelection(bool enabled);
|
|
|
|
|
|
|
|
void ToggleLabelHover(bool enabled);
|
|
|
|
void TogglePointHover(bool enabled);
|
|
|
|
void ToggleLineHover(bool enabled);
|
|
|
|
void ToggleArcHover(bool enabled);
|
2016-12-20 12:04:56 +01:00
|
|
|
void ToggleElArcHover(bool enabled);
|
2016-03-31 16:01:41 +02:00
|
|
|
void ToggleSplineHover(bool enabled);
|
|
|
|
void ToggleSplinePathHover(bool enabled);
|
|
|
|
void ToggleNodeLabelHover(bool enabled);
|
|
|
|
void ToggleNodePointHover(bool enabled);
|
|
|
|
void ToggleDetailHover(bool enabled);
|
2013-08-13 18:48:36 +02:00
|
|
|
protected:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
2013-07-03 14:29:26 +02:00
|
|
|
signals:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-27 13:27:26 +01:00
|
|
|
* @brief mouseMove send new mouse position.
|
|
|
|
* @param scenePos new mouse position.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-07-15 15:51:15 +02:00
|
|
|
void mouseMove(const QPointF &scenePos);
|
2016-02-12 19:10:01 +01:00
|
|
|
|
|
|
|
void MouseLeftPressed();
|
|
|
|
void MouseLeftReleased();
|
2022-01-28 15:54:20 +01:00
|
|
|
void ItemByMousePress(QGraphicsItem* pItem);
|
|
|
|
void ItemByMouseRelease(QGraphicsItem* pItem);
|
|
|
|
void AddBackgroundImage(const QPointF &pos, const QString &fileName);
|
2016-02-12 19:10:01 +01:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-27 13:27:26 +01:00
|
|
|
* @brief ChoosedObject send option choosed object.
|
|
|
|
* @param id object id.
|
|
|
|
* @param type object scene type.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
void ChoosedObject(quint32 id, SceneObject type);
|
2016-04-05 19:14:12 +02:00
|
|
|
void SelectedObject(bool selected, quint32 object, quint32 tool);
|
2015-05-25 08:24:16 +02:00
|
|
|
void DisableItem(bool disable, const QString &namePP);
|
2015-02-09 10:54:19 +01:00
|
|
|
void EnableToolMove(bool move);
|
2015-04-23 17:06:17 +02:00
|
|
|
void CurveDetailsMode(bool mode);
|
2016-03-31 19:10:20 +02:00
|
|
|
void ItemSelection(const SelectionType &type);
|
2016-10-12 13:43:08 +02:00
|
|
|
void HighlightDetail(quint32 id);
|
2021-05-10 15:39:17 +02:00
|
|
|
void UpdatePassmarks();
|
2016-03-31 16:01:41 +02:00
|
|
|
|
|
|
|
void EnableLabelItemSelection(bool enable);
|
|
|
|
void EnablePointItemSelection(bool enable);
|
2016-04-05 19:14:12 +02:00
|
|
|
void EnableLineItemSelection(bool enable);
|
2016-03-31 16:01:41 +02:00
|
|
|
void EnableArcItemSelection(bool enable);
|
2016-12-20 12:04:56 +01:00
|
|
|
void EnableElArcItemSelection(bool enable);
|
2016-03-31 16:01:41 +02:00
|
|
|
void EnableSplineItemSelection(bool enable);
|
|
|
|
void EnableSplinePathItemSelection(bool enable);
|
|
|
|
void EnableNodeLabelItemSelection(bool enabled);
|
|
|
|
void EnableNodePointItemSelection(bool enabled);
|
|
|
|
void EnableDetailItemSelection(bool enabled);
|
|
|
|
|
|
|
|
void EnableLabelItemHover(bool enable);
|
|
|
|
void EnablePointItemHover(bool enable);
|
|
|
|
void EnableArcItemHover(bool enable);
|
2016-12-20 12:04:56 +01:00
|
|
|
void EnableElArcItemHover(bool enable);
|
2016-03-31 16:01:41 +02:00
|
|
|
void EnableSplineItemHover(bool enable);
|
|
|
|
void EnableSplinePathItemHover(bool enable);
|
|
|
|
void EnableNodeLabelItemHover(bool enabled);
|
|
|
|
void EnableNodePointItemHover(bool enabled);
|
|
|
|
void EnableDetailItemHover(bool enabled);
|
|
|
|
void EnableLineItemHover(bool enabled);
|
2016-08-15 17:19:21 +02:00
|
|
|
void DimensionsChanged();
|
2016-08-17 21:38:39 +02:00
|
|
|
void LanguageChanged();
|
2016-08-15 17:19:21 +02:00
|
|
|
|
2013-09-17 20:13:02 +02:00
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(VMainGraphicsScene) // NOLINT
|
2014-06-13 19:02:41 +02:00
|
|
|
/** @brief horScrollBar value horizontal scroll bar. */
|
2013-10-27 09:10:39 +01:00
|
|
|
qint32 horScrollBar;
|
2014-06-13 19:02:41 +02:00
|
|
|
|
|
|
|
/** @brief verScrollBar value vertical scroll bar. */
|
2013-10-27 09:10:39 +01:00
|
|
|
qint32 verScrollBar;
|
2014-06-13 19:02:41 +02:00
|
|
|
|
|
|
|
/** @brief _transform view transform value. */
|
2014-01-11 15:09:44 +01:00
|
|
|
QTransform _transform;
|
2014-07-15 15:51:15 +02:00
|
|
|
QPointF scenePos;
|
2016-01-15 13:55:56 +01:00
|
|
|
QVector<QGraphicsItem *> origins;
|
2019-07-21 11:27:58 +02:00
|
|
|
|
|
|
|
/** @brief m_nonInteractive all item on scene in non interactive. */
|
|
|
|
bool m_nonInteractive{false};
|
2022-01-28 15:54:20 +01:00
|
|
|
|
|
|
|
bool m_acceptDrop{false};
|
2013-07-03 14:29:26 +02:00
|
|
|
};
|
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getHorScrollBar return scene horizontal scrollbar.
|
|
|
|
* @return horizontal scrollbar.
|
|
|
|
*/
|
2023-05-03 13:07:02 +02:00
|
|
|
inline auto VMainGraphicsScene::getHorScrollBar() const -> qint32
|
2014-02-26 09:18:59 +01:00
|
|
|
{
|
|
|
|
return horScrollBar;
|
|
|
|
}
|
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief setHorScrollBar set scene horizontal scrollbar.
|
|
|
|
* @param value horizontal scrollbar.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline void VMainGraphicsScene::setHorScrollBar(const qint32 &value)
|
|
|
|
{
|
|
|
|
horScrollBar = value;
|
|
|
|
}
|
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief getVerScrollBar return scene vertical scrollbar.
|
|
|
|
* @return vertical scrollbar.
|
|
|
|
*/
|
2023-05-03 13:07:02 +02:00
|
|
|
inline auto VMainGraphicsScene::getVerScrollBar() const -> qint32
|
2014-02-26 09:18:59 +01:00
|
|
|
{
|
|
|
|
return verScrollBar;
|
|
|
|
}
|
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief setVerScrollBar set scene vertical scrollbar.
|
|
|
|
* @param value vertical scrollbar.
|
|
|
|
*/
|
2014-02-26 09:18:59 +01:00
|
|
|
inline void VMainGraphicsScene::setVerScrollBar(const qint32 &value)
|
|
|
|
{
|
|
|
|
verScrollBar = value;
|
|
|
|
}
|
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
#endif // VMAINGRAPHICSSCENE_H
|