forked from NatronGitHub/Natron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKnobFile.h
268 lines (203 loc) · 6.88 KB
/
KnobFile.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of Natron <https://natrongithub.github.io/>,
* (C) 2018-2021 The Natron developers
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
*
* Natron 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 2 of the License, or
* (at your option) any later version.
*
* Natron 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 Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */
#ifndef NATRON_ENGINE_KNOBFILE_H
#define NATRON_ENGINE_KNOBFILE_H
// ***** BEGIN PYTHON BLOCK *****
// from <https://docs.python.org/3/c-api/intro.html#include-files>:
// "Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included."
#include <Python.h>
// ***** END PYTHON BLOCK *****
#include "Global/Macros.h"
#include <vector>
#include <map>
CLANG_DIAG_OFF(deprecated)
#include <QtCore/QObject>
CLANG_DIAG_ON(deprecated)
#include <QtCore/QMutex>
#include <QtCore/QString>
#include "Engine/KnobTypes.h"
#include "Engine/ViewIdx.h"
#include "Engine/EngineFwd.h"
NATRON_NAMESPACE_ENTER
/******************************KnobFile**************************************/
class KnobFile
: public QObject, public AnimatingKnobStringHelper
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &description,
int dimension,
bool declaredByPlugin = true)
{
return new KnobFile(holder, description, dimension, declaredByPlugin);
}
KnobFile(KnobHolder* holder,
const std::string &description,
int dimension,
bool declaredByPlugin);
virtual ~KnobFile();
static const std::string & typeNameStatic();
void setAsInputImage()
{
_isInputImage = true;
}
bool isInputImageFile() const
{
return _isInputImage;
}
void open_file()
{
Q_EMIT openFile();
}
void reloadFile();
/**
* @brief getRandomFrameName
* @param f The index of the frame.
*/
std::string getFileName(int time, ViewSpec view);
Q_SIGNALS:
void openFile();
private:
/**
* @brief a KnobFile is never animated but it's value may change, indicate this to the plug-in
**/
virtual bool evaluateValueChangeOnTimeChange() const OVERRIDE FINAL { return true; }
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
static const std::string _typeNameStr;
int _isInputImage;
};
/******************************KnobOutputFile**************************************/
class KnobOutputFile
: public QObject, public KnobStringBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &description,
int dimension,
bool declaredByPlugin = true)
{
return new KnobOutputFile(holder, description, dimension, declaredByPlugin);
}
KnobOutputFile(KnobHolder* holder,
const std::string &description,
int dimension,
bool declaredByPlugin);
static const std::string & typeNameStatic();
void setAsOutputImageFile()
{
_isOutputImage = true;
}
bool isOutputImageFile() const
{
return _isOutputImage;
}
void open_file()
{
Q_EMIT openFile(_sequenceDialog && _isOutputImage);
}
void rewriteFile();
void turnOffSequences()
{
_sequenceDialog = false;
}
bool isSequencesDialogEnabled() const
{
return _sequenceDialog;
}
QString generateFileNameAtTime(SequenceTime time, ViewSpec view);
Q_SIGNALS:
void openFile(bool);
private:
virtual bool evaluateValueChangeOnTimeChange() const OVERRIDE FINAL { return false; }
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
bool _isOutputImage;
bool _sequenceDialog;
};
/******************************KnobPath**************************************/
/**
* @brief The string value is encoded the following way:
* <Name>Lala</Name><Value>MyValue</Value>
**/
class KnobPath
: public KnobTable
{
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &description,
int dimension,
bool declaredByPlugin = true)
{
return new KnobPath(holder, description, dimension, declaredByPlugin);
}
KnobPath(KnobHolder* holder,
const std::string &description,
int dimension,
bool declaredByPlugin);
static const std::string & typeNameStatic();
void setMultiPath(bool b);
bool isMultiPath() const;
/*
@brief same as setMultiPath except that there will be only variable names, no values
*/
void setAsStringList(bool b);
bool getIsStringList() const;
void getPaths(std::list<std::string>* paths);
void prependPath(const std::string& path);
void appendPath(const std::string& path);
virtual int getColumnsCount() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return _isStringList ? 1 : 2;
}
virtual std::string getColumnLabel(int col) const OVERRIDE FINAL WARN_UNUSED_RETURN
{
switch (col) {
case 0:
return "Name";
case 1:
return "Value";
default:
return "";
}
}
virtual bool isCellEnabled(int row, int col, const QStringList& values) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isCellBracketDecorated(int row, int col) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool useEditButton() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return _isMultiPath && !_isStringList;
}
private:
static std::string generateUniquePathID(const std::list<std::vector<std::string> >& paths);
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
bool _isMultiPath;
bool _isStringList;
};
NATRON_NAMESPACE_EXIT
#endif // NATRON_ENGINE_KNOBFILE_H