-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathiannix.h
248 lines (225 loc) · 8.4 KB
/
iannix.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
This file is part of IanniX, a graphical real-time open-source sequencer for digital art
Copyright (C) 2010-2015 — IanniX Association
Project Manager: Thierry Coduys (http://www.le-hub.org)
Development: Guillaume Jacquemin (https://www.buzzinglight.com)
This file was written by Guillaume Jacquemin.
IanniX is a 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
any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IANNIX_H
#define IANNIX_H
#include <QObject>
#include <QTimer>
#include <QTime>
#include <QFileDialog>
#include <QInputDialog>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QFileSystemWatcher>
#include <QApplication>
#include <QHostInfo>
#include <QSettings>
#include <QFontDialog>
#include <QWaitCondition>
#include <QDomDocument>
#include <QFileOpenEvent>
#include <QDesktopServices>
#include <QWindow>
#include <time.h>
#include "misc/application.h"
#include "gui/uimessagebox.h"
#include "gui/uiview.h"
#include "gui/uiinspector.h"
#include "gui/uihelp.h"
#include "messages/messagemanager.h"
#include "interfaces/interfacesyphon.h"
#include "interfaces/interfacedirect.h"
#include "interfaces/interfacehttp.h"
#include "interfaces/interfacemidi.h"
#include "interfaces/interfaceosc.h"
#include "interfaces/interfaceserial.h"
#include "interfaces/interfacetcp.h"
#include "interfaces/interfaceudp.h"
#ifdef WACOM_INSTALLED
#include "interfaces/extwacommanager.h"
#endif
class IanniX : public ApplicationCurrent, public NxObjectDispatchProperty, public MessageDispatcher {
Q_OBJECT
private:
QSettings *iniSettings, *globalSettings;
public:
explicit IanniX(const QString &_projectToLoad = "", QObject *parent = 0);
void readyToStart();
inline void dispatchProperty(const QString &_property, const QVariant &value) { dispatchProperty(qPrintable(_property), value); }
inline const QVariant getProperty(const QString &_property) const { return getProperty(qPrintable(_property)); }
inline void dispatchProperty(const char *_property, const QVariant &value) {
QHashIterator<QString, NxDocument*> documentIterator(documents);
while (documentIterator.hasNext()) {
documentIterator.next();
documentIterator.value()->dispatchProperty(_property, value);
}
}
inline const QVariant getProperty(const char *_property) const {
NxDocument *document = getWorkingDocument();
return document->getProperty(_property);
}
inline quint8 getType() const {
return ObjectsTypeScheduler;
}
inline const QString getTypeStr() const {
return "scheduler";
}
//OBJECT MANAGEMENT
private:
NxDocument *currentDocument, *workingDocument;
QHash<QString, NxDocument*> documents;
inline NxDocument* getCurrentDocument() const { return currentDocument; }
inline NxDocument* getWorkingDocument() const { return workingDocument; }
void setCurrentDocument(NxDocument *_currentDocument);
public:
NxGroup* addGroup(const QString & groupId);
void setObjectActivity(void *_object, quint8 activeOld);
void setObjectGroupId(void *_object, const QString & groupIdOld);
void setObjectId(void *_object, quint16 idOld);
void removeObject(NxObject *object);
quint16 getCount(qint8 objectType = -1);
void* getObjectById(quint16 id) {
return getWorkingDocument()->getObject(id);
}
public:
inline NxObjectDispatchProperty* getObject(const QString & objectIdStr, bool saveObject = true) const {
NxDocument *document = getWorkingDocument();
bool ok = false;
quint16 objectId = objectIdStr.toUInt(&ok);
if(ok) {
NxObject *object = document->getObject(objectId);
if(saveObject)
document->setCurrentObject(object);
return object;
}
else if(objectIdStr.toLower() == "all")
return document;
else if(objectIdStr.toLower() == "current")
return document->getCurrentObject();
else if(objectIdStr.toLower() == "selection")
return render->getSelection();
else if(objectIdStr.toLower() == "lastcurve")
return document->getCurrentCurve();
else {
if(document->groups.contains(objectIdStr))
return document->groups.value(objectIdStr);
}
return 0;
}
//FACTORY INTERFACE
private:
Message message;
QHash<QByteArray, Message> messagesCache;
QScriptEngine messageScriptEngine;
public slots:
const QVariant execute(const MessageIncomming & command, bool createNewObjectIfExists = false, bool needOutput = false);
const QVariant execute(const QString & command, ExecuteSource source, bool createNewObjectIfExists = false, bool needOutput = false);
void executeAsScript(const QString &script);
inline QString argvFullString(const QString &command, const QStringList &argv, quint16 index) const {
if(index >= 1) return command.mid(command.indexOf(argv.at(index), command.indexOf(argv.at(index-1))+argv.at(index-1).length())).trimmed();
else return command;
}
inline qreal argvDouble(const QStringList &argv, quint16 index) const {
if(index < argv.count()) return argv.at(index).toDouble();
else return 0;
}
QString incomingMessage(const MessageIncomming &source, bool needOutput = false, bool needToScript = true);
void openMessageEditor();
void send(const Message &message, QStringList *sentMessage = 0);
QMainWindow* getMainWindow() { return view; }
UiRenderPreview* getRenderPreview() { return view->getRenderPreview(); }
bool getPerformancePreview() { return view->getPerformancePreview(); }
//EXTERNAL INTERFACES
private:
#ifdef WACOM_INSTALLED
ExtWacomManager *wacom;
#endif
public:
InterfaceOsc *interfaceOsc;
bool projectIsLoaded;
QString projectToLoad;
void loadProject(const QString & projectFile = "");
//TIME MANAGEMENT
private:
UiRender *render;
QTimer *timer;
int timerTime, timerPerf;
private:
SchedulerActivity schedulerActivity;
public:
void setScheduler(SchedulerActivity _schedulerActivity);
protected:
void timerEvent(QTimerEvent *);
private slots:
void timerTick();
void timerTick(bool force);
void timerTick(qreal delta);
void timerTrig(void *object, bool force = false);
//USER INTERFACE
private:
Transport *transport;
UiInspector *inspector;
UiView *view;
QString waitForMessageValue;
bool waitingForMessageValue;
QIcon iconAppPlay, iconAppPause;
private:
QString updateAnonymousId;
QNetworkAccessManager *updateManager;
private slots:
void checkForUpdatesFinished(QNetworkReply*);
public:
bool forceUpdate, forbidUpdate;
void checkForUpdates();
const QString serialize() const;
public slots:
void forceGoto(qreal, bool midiSync = true);
void forceSchedulerTimer(qreal);
void forceOpenGLTimer(qreal);
void actionPlayPause();
void actionCC(QTreeWidgetItem*,int);
void actionNew();
void actionOpen();
void actionSave();
void actionSaveAndReload();
void actionSave_as();
void actionRefresh();
void currentDocumentChanged(UiSyncItem*);
void actionUndo();
void actionRedo();
void actionImportSVG(const QString &filename);
void actionImportBackground(const QString &filename);
void actionImportText(const QString &font, const QString &text);
void actionReloadScript();
void actionCloseEvent(QCloseEvent *event);
void actionUnmuteGroups();
void actionUnmuteObjects();
void actionUnsoloGroups();
void actionUnsoloObjects();
public slots:
QString waitForMessage();
void pushSnapshot();
void actionPaste();
void actionCopy();
signals:
void waitForMessageArrived();
//FAST IMPORT
public:
void actionImportSVG(const QDomElement &xmlElement, qreal scale);
};
#endif // IANNIX_H