-
Notifications
You must be signed in to change notification settings - Fork 15
/
NodalScene.h
89 lines (72 loc) · 2.53 KB
/
NodalScene.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Copyright 2020-2021 Benoit Pelletier
*
* This file is part of Sound Generator.
*
* Sound Generator 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.
*
* Sound Generator 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 Sound Generator. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef NODALSCENE_H
#define NODALSCENE_H
#include <QGraphicsScene>
class NodeItem;
class LinkItem;
class QUndoStack;
class AudioSettings;
class NodalScene : public QGraphicsScene
{
Q_OBJECT
public:
NodalScene(QObject* parent = nullptr);
virtual ~NodalScene() override;
NodeItem* createComponent(QString _componentName, qreal _width = 200.0);
NodeItem* createPassThrough(LinkItem* _link);
void addNodeItem(NodeItem *_item);
void removeNodeItem(NodeItem* _item);
void save(QString fileName, const AudioSettings& settings);
void load(QString fileName, AudioSettings& settings);
int clearItems(int from = 0);
void reset();
inline NodeItem* getOutput() { return m_nodeList[0]; }
inline void setCreationPosition(QPointF position) { m_creationPosition = position; }
inline void setContextPosition(QPointF position) { m_contextPosition = position; }
inline void isContextMenu(bool value) { m_isContextMenu = value; }
public slots:
int deleteSelection();
void selectAll();
void deselectAll();
void copyComponents();
void pasteComponents();
void undoCommand();
void redoCommand();
void setDirty() { emit dirtyChanged(); }
signals:
void dirtyChanged();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private:
NodeItem *createNode(QString componentName, qreal width = 200.0);
private:
QPointF m_creationPosition;
QPointF m_nextPastePosition;
QPointF m_contextPosition;
QVector<NodeItem*> m_nodeList;
bool m_isContextMenu;
QUndoStack* m_undoStack;
QList<QGraphicsItem*> m_movingItems;
QList<QPointF> m_movingItemPositions;
QList<QGraphicsItem*> m_previousSelectedItems;
};
#endif // NODALSCENE_H