plugin.h 6.62 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
#ifndef _PLUGIN_H_
#define _PLUGIN_H_

#include <QtPlugin>
#include <QAction>
Sylvain Thery's avatar
Sylvain Thery committed
6
7
#include <GL/glew.h>

Pierre Kraemer's avatar
Pierre Kraemer committed
8
9

#include "types.h"
Sylvain Thery's avatar
Sylvain Thery committed
10
#include "schnapps.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
11

Thery Sylvain's avatar
Thery Sylvain committed
12
#include "dll.h"
Sylvain Thery's avatar
Sylvain Thery committed
13

Pierre Kraemer's avatar
Pierre Kraemer committed
14
15
16
17
18
19
namespace CGoGN
{

namespace SCHNApps
{

Sylvain Thery's avatar
Sylvain Thery committed
20
class SCHNAPPS_API Plugin : public QObject
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
{
	Q_OBJECT

	friend class SCHNApps;

public:
27
28
	Plugin();
	virtual ~Plugin();
Pierre Kraemer's avatar
Pierre Kraemer committed
29
30

public slots:
31
32
33
	QString getName();
	QString getFilePath();
	SCHNApps* getSCHNApps();
Pierre Kraemer's avatar
Pierre Kraemer committed
34
35

private:
36
37
38
	void setName(const QString& name);
	void setFilePath(const QString& f);
	void setSCHNApps(SCHNApps* s);
Pierre Kraemer's avatar
Pierre Kraemer committed
39
40
41
42
43
44
45
46

	virtual bool enable() = 0;
	virtual void disable() = 0;

protected:
	QString m_name;
	QString m_filePath;
	SCHNApps* m_schnapps;
Sylvain Thery's avatar
Sylvain Thery committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

//	void pythonRecording(const QString& slotName, const QString& returned = "",  const QString& param1 = "", const QString& param2 = "", const QString& param3 = "", const QString& param4 = "");

	//template <typename T1, typename T2, typename T3, typename T4>
	//inline void pythonRecording(QString slotName, QString returned = "", T1 param1 = "", T2 param2 = "", T3 param3 = "", T4 param4 = "");

	template <typename T1>
	inline void pythonRecording(QString slotName, QString returned, T1 param1);

	template <typename T1, typename T2>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2);

	template <typename T1, typename T2, typename T3>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3);

	template <typename T1, typename T2, typename T3, typename T4>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4);

	template <typename T1, typename T2, typename T3, typename T4, typename T5>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5);

Sylvain Thery's avatar
Sylvain Thery committed
68
69
70
71
	template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6);


Sylvain Thery's avatar
Sylvain Thery committed
72
	template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
Sylvain Thery's avatar
Sylvain Thery committed
73
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7, T8 param8, T9 param9, T10 param10, T11 param11);
Sylvain Thery's avatar
Sylvain Thery committed
74
75


Pierre Kraemer's avatar
Pierre Kraemer committed
76
77
};

Sylvain Thery's avatar
Sylvain Thery committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
template <typename T>
inline T pyR_stringify(T v)
{
	return v;
}

template <>
inline QString pyR_stringify(QString v)
{
	return "\"" + v + "\"";
}



template <typename T1>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
99
100
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
101
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
102
		}
Sylvain Thery's avatar
Sylvain Thery committed
103
104
105
106
107
108
109
110
111
112
113
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ");" << endl;
	}
}

template <typename T1, typename T2>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
114
115
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
116
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
117
		}
Sylvain Thery's avatar
Sylvain Thery committed
118
119
120
121
122
123
124
125
126
127
128
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ");" << endl;
	}
}

template <typename T1, typename T2, typename T3>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
129
130
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
131
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
132
		}
Sylvain Thery's avatar
Sylvain Thery committed
133
134
135
136
137
138
139
140
141
142
143
144
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", " << pyR_stringify(param3) << ");" << endl;
	}
}


template <typename T1, typename T2, typename T3, typename T4>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
145
146
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
147
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
148
		}
Sylvain Thery's avatar
Sylvain Thery committed
149
150
151
152
153
154
155
156
157
158
159
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", " << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ");" << endl;
	}
}

template <typename T1, typename T2, typename T3, typename T4, typename T5>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
160
161
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
162
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
163
		}
Sylvain Thery's avatar
Sylvain Thery committed
164
165
166
167
168
169
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", ";
		*rec << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ", " << pyR_stringify(param5) << ");" << endl;
	}
}


Sylvain Thery's avatar
Sylvain Thery committed
170
171
172
173
174
175
176
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
177
178
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
179
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
180
		}
Sylvain Thery's avatar
Sylvain Thery committed
181
182
183
184
185
186
187
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", ";
		*rec << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ", " << pyR_stringify(param5) << ", " << pyR_stringify(param6)  << ");" << endl;
	}
}



Sylvain Thery's avatar
Sylvain Thery committed
188
189
190
191
192
193
194
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7, T8 param8, T9 param9, T10 param10, T11 param11)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
Sylvain Thery's avatar
Sylvain Thery committed
195
196
		{
			m_schnapps->pythonVarDeclare(returned);
Sylvain Thery's avatar
Sylvain Thery committed
197
			*rec << returned << " = ";
Sylvain Thery's avatar
Sylvain Thery committed
198
		}
Sylvain Thery's avatar
Sylvain Thery committed
199
200
201
202
203
204
205
206
207
208
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", ";
		*rec << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ", " << pyR_stringify(param5) << ", ";
		*rec << pyR_stringify(param6) << ", " << pyR_stringify(param7) << ", " << pyR_stringify(param8) << ", ";
		*rec << pyR_stringify(param9) << ", " << pyR_stringify(param10) << ", " << pyR_stringify(param11) << ");" << endl;
	}
}
	



Pierre Kraemer's avatar
Pierre Kraemer committed
209
210
211
212
213
214
215
} // namespace SCHNApps

} // namespace CGoGN

Q_DECLARE_INTERFACE(CGoGN::SCHNApps::Plugin, "CGoGN.SCHNapps.Plugin")

#endif