Skip to content

Commit

Permalink
Merge RB-2.0 and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKepzie committed Apr 4, 2016
2 parents 38e6c6d + 114b32e commit ce9b355
Show file tree
Hide file tree
Showing 161 changed files with 10,094 additions and 3,617 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Version 2.0:
Frédéric Devernay <devernay@github>
Alexandre Gauthier-Foichat <MrKepzie@github>
Ole-André Rodlie <olear@github> (Openfx-Arena Plug-Ins)
Axel Airo-Farulla <AxelAF@github>
Axel Airo-Farulla <Eaknyt@github>

#Artists:

Expand Down
12 changes: 11 additions & 1 deletion Documentation/source/PythonReference/NatronEngine/App.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See :ref:`detailed<app.details>` description...

Functions
^^^^^^^^^

* def :meth:`addProjectLayer<NatronEngine.App.addProjectLayer>` (layer)
* def :meth:`addFormat<NatronEngine.App.addFormat>` (formatSpec)
* def :meth:`createNode<NatronEngine.App.createNode>` (pluginID[, majorVersion=-1[, group=None]])
* def :meth:`createReader<NatronEngine.App.createReader>` (filename[, group=None])
Expand Down Expand Up @@ -132,6 +132,16 @@ You can get a specific :doc:`parameter<Param>` of the project settings with the
Member functions description
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. method:: NatronEngine.App.addProjectLayer(layer)

:param layer: :class:`ImageLayer<NatronEngine.ImageLayer>`

Appends a new project-wide layer. It will be available to all layer menus of all nodes.
Each layer menu must be refreshed individually with either a right click on the menu or
by changing nodes connections to get access to the new layer. Layer names are unique:
even if you add duplicates to the layers list, only the first one in the list with that name
will be available in the menus.

.. method:: NatronEngine.App.addFormat(formatSpec)

:param formatSpec: :class:`str<NatronEngine.std::string>`
Expand Down
65 changes: 62 additions & 3 deletions Engine/AppInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ struct AppInstancePrivate
mutable QMutex renderQueueMutex;
std::list<RenderQueueItem> renderQueue, activeRenders;

mutable QMutex invalidExprKnobsMutex;
std::list<KnobWPtr> invalidExprKnobs;

AppInstancePrivate(int appID,
AppInstance* app)
: _publicInterface(app)
Expand All @@ -136,6 +139,9 @@ struct AppInstancePrivate
, _creatingTree(0)
, renderQueueMutex()
, renderQueue()
, activeRenders()
, invalidExprKnobsMutex()
, invalidExprKnobs()
{
}

Expand Down Expand Up @@ -739,7 +745,7 @@ AppInstance::loadPythonScript(const QFileInfo& file)
if (errCatcher) {
errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref
assert(errorObj);
error = NATRON_PYTHON_NAMESPACE::PY3String_asString(errorObj);
error = NATRON_PYTHON_NAMESPACE::PyString_asString(errorObj);
PyObject* unicode = PyUnicode_FromString("");
PyObject_SetAttrString(errCatcher, "value", unicode);
Py_DECREF(errorObj);
Expand Down Expand Up @@ -842,7 +848,11 @@ AppInstance::createNodeFromPythonModule(Plugin* plugin,
if (!moduleName.isEmpty()) {
setGroupLabelIDAndVersion(node,modulePath, moduleName);
}


// If there's a serialization, restore the serialization of the group node because the Python script probably overriden any state
if (serialization) {
containerNode->loadKnobs(*serialization);
}

} //FlagSetter fs(true,&_imp->_creatingGroup,&_imp->creatingGroupMutex);

Expand Down Expand Up @@ -890,7 +900,7 @@ AppInstance::createReader(const std::string& filename, CreateNodeReason reason,
#else

std::map<std::string,std::string> readersForFormat;
appPTR->getCurrentSettings()->getFileFormatsForWritingAndWriter(&readersForFormat);
appPTR->getCurrentSettings()->getFileFormatsForReadingAndReader(&readersForFormat);
QString fileCpy = QString::fromUtf8(filename.c_str());
std::string ext = QtCompat::removeFileExtension(fileCpy).toLower().toStdString();
std::map<std::string,std::string>::iterator found = readersForFormat.find(ext);
Expand Down Expand Up @@ -1905,6 +1915,55 @@ AppInstance::newProject()
return app;
}

void
AppInstance::addInvalidExpressionKnob(const KnobPtr& knob)
{
QMutexLocker k(&_imp->invalidExprKnobsMutex);
for (std::list<KnobWPtr>::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) {
if (it->lock().get()) {
return;
}
}
_imp->invalidExprKnobs.push_back(knob);
}

void
AppInstance::removeInvalidExpressionKnob(const KnobI* knob)
{
QMutexLocker k(&_imp->invalidExprKnobsMutex);
for (std::list<KnobWPtr>::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) {
if (it->lock().get() == knob) {
_imp->invalidExprKnobs.erase(it);
break;
}
}
}

void
AppInstance::recheckInvalidExpressions()
{
std::list<KnobPtr> knobs;
{
QMutexLocker k(&_imp->invalidExprKnobsMutex);
for (std::list<KnobWPtr>::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) {
KnobPtr k = it->lock();
if (k) {
knobs.push_back(k);
}
}
}
std::list<KnobWPtr> newInvalidKnobs;
for (std::list<KnobPtr>::iterator it = knobs.begin(); it!=knobs.end(); ++it) {
if (!(*it)->checkInvalidExpressions()) {
newInvalidKnobs.push_back(*it);
}
}
{
QMutexLocker k(&_imp->invalidExprKnobsMutex);
_imp->invalidExprKnobs = newInvalidKnobs;
}
}

NATRON_NAMESPACE_EXIT;

NATRON_NAMESPACE_USING;
Expand Down
6 changes: 6 additions & 0 deletions Engine/AppInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ class AppInstance

public:

void addInvalidExpressionKnob(const KnobPtr& knob);
void removeInvalidExpressionKnob(const KnobI* knob);
void recheckInvalidExpressions();

virtual void clearViewersLastRenderedTexture() {}

virtual void toggleAutoHideGraphInputs() {}
Expand Down Expand Up @@ -439,6 +443,8 @@ class AppInstance

void removeRenderFromQueue(OutputEffectInstance* writer);

virtual void reloadScriptEditorFonts() {}

public Q_SLOTS:

void quit();
Expand Down
61 changes: 42 additions & 19 deletions Engine/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ static bool findAndRunScriptFile(const QString& path,const QStringList& files,co
if (errCatcher) {
errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref
assert(errorObj);
error = NATRON_PYTHON_NAMESPACE::PY3String_asString(errorObj);
error = NATRON_PYTHON_NAMESPACE::PyString_asString(errorObj);
PyObject* unicode = PyUnicode_FromString("");
PyObject_SetAttrString(errCatcher, "value", unicode);
Py_DECREF(errorObj);
Expand Down Expand Up @@ -2460,15 +2460,28 @@ char2wchar(char* arg)


std::string
NATRON_PYTHON_NAMESPACE::PY3String_asString(PyObject* obj)
NATRON_PYTHON_NAMESPACE::PyString_asString(PyObject* obj)
{

std::string ret;
if (PyUnicode_Check(obj)) {
PyObject * temp_bytes = PyUnicode_AsEncodedString(obj, "ASCII", "strict"); // Owned reference
if (temp_bytes != NULL) {
char* cstr = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer

if (PyString_Check(obj)) {
char* buf = PyString_AsString(obj);
if (buf) {
ret += std::string(buf);
}
} else if (PyUnicode_Check(obj)) {
/*PyObject * temp_bytes = PyUnicode_AsEncodedString(obj, "ASCII", "strict"); // Owned reference
if (temp_bytes != NULL) {
char* cstr = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
ret.append(cstr);
Py_DECREF(temp_bytes);
}*/
PyObject* utf8pyobj = PyUnicode_AsUTF8String(obj); // newRef
if (utf8pyobj) {
char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer
ret.append(cstr);
Py_DECREF(temp_bytes);
Py_DECREF(utf8pyobj);
}
} else if (PyBytes_Check(obj)) {
char* cstr = PyBytes_AS_STRING(obj); // Borrowed pointer
Expand Down Expand Up @@ -3106,7 +3119,7 @@ NATRON_PYTHON_NAMESPACE::interpretPythonScript(const std::string& script,std::st
if (errCatcher && error) {
errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref
assert(errorObj);
*error = PY3String_asString(errorObj);
*error = PyString_asString(errorObj);
PyObject* unicode = PyUnicode_FromString("");
PyObject_SetAttrString(errCatcher, "value", unicode);
Py_DECREF(errorObj);
Expand All @@ -3116,7 +3129,7 @@ NATRON_PYTHON_NAMESPACE::interpretPythonScript(const std::string& script,std::st
if (outCatcher && output) {
outObj = PyObject_GetAttrString(outCatcher,"value"); //get the stdout from our catchOut object, new ref
assert(outObj);
*output = PY3String_asString(outObj);
*output = PyString_asString(outObj);
PyObject* unicode = PyUnicode_FromString("");
PyObject_SetAttrString(outCatcher, "value", unicode);
Py_DECREF(outObj);
Expand Down Expand Up @@ -3156,9 +3169,7 @@ NATRON_PYTHON_NAMESPACE::compilePyScript(const std::string& script,PyObject** co
}
#endif


std::string
NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(const std::string& str)
static std::string makeNameScriptFriendlyInternal(const std::string& str, bool allowDots)
{
if (str == "from") {
return "pFrom";
Expand All @@ -3183,13 +3194,25 @@ NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(const std::string& str)
}

///Non alpha-numeric characters are not allowed in python
else if (str[i] == '_' || std::isalnum(str[i], loc)) {
else if (str[i] == '_' || std::isalnum(str[i], loc) || (allowDots && str[i] == '.')) {
cpy.push_back(str[i]);
}
}
return cpy;
}

std::string
NATRON_PYTHON_NAMESPACE::makeNameScriptFriendlyWithDots(const std::string& str)
{
return makeNameScriptFriendlyInternal(str, true);
}

std::string
NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(const std::string& str)
{
return makeNameScriptFriendlyInternal(str, false);
}

PythonGILLocker::PythonGILLocker()
// : state(PyGILState_UNLOCKED)
{
Expand Down Expand Up @@ -3317,25 +3340,25 @@ static bool getGroupInfosInternal(const std::string& modulePath,

assert(labelObj);

*pluginLabel = NATRON_PYTHON_NAMESPACE::PY3String_asString(labelObj);
*pluginLabel = NATRON_PYTHON_NAMESPACE::PyString_asString(labelObj);
Py_XDECREF(labelObj);

if (idObj) {
*pluginID = NATRON_PYTHON_NAMESPACE::PY3String_asString(idObj);
*pluginID = NATRON_PYTHON_NAMESPACE::PyString_asString(idObj);
deleteScript.append("del pluginID\n");
Py_XDECREF(idObj);
}

if (iconObj) {
*iconFilePath = NATRON_PYTHON_NAMESPACE::PY3String_asString(iconObj);
*iconFilePath = NATRON_PYTHON_NAMESPACE::PyString_asString(iconObj);
QFileInfo iconInfo(QString::fromUtf8(modulePath.c_str()) + QString::fromUtf8(iconFilePath->c_str()));
*iconFilePath = iconInfo.canonicalFilePath().toStdString();

deleteScript.append("del templateIcon\n");
Py_XDECREF(iconObj);
}
if (iconGrouping) {
*grouping = NATRON_PYTHON_NAMESPACE::PY3String_asString(iconGrouping);
*grouping = NATRON_PYTHON_NAMESPACE::PyString_asString(iconGrouping);
deleteScript.append("del templateGrouping\n");
Py_XDECREF(iconGrouping);
}
Expand All @@ -3354,7 +3377,7 @@ static bool getGroupInfosInternal(const std::string& modulePath,


if (pluginDescriptionObj) {
*description = NATRON_PYTHON_NAMESPACE::PY3String_asString(pluginDescriptionObj);
*description = NATRON_PYTHON_NAMESPACE::PyString_asString(pluginDescriptionObj);
deleteScript.append("del description\n");
Py_XDECREF(pluginDescriptionObj);
}
Expand Down Expand Up @@ -3476,7 +3499,7 @@ NATRON_PYTHON_NAMESPACE::getFunctionArguments(const std::string& pyFunc,std::str
PyObject* itemObj = PyList_GetItem(argListObj, i);
assert(itemObj);
if (itemObj) {
std::string itemName = PY3String_asString(itemObj);
std::string itemName = PyString_asString(itemObj);
assert(!itemName.empty());
if (!itemName.empty()) {
args->push_back(itemName);
Expand Down
5 changes: 4 additions & 1 deletion Engine/AppManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ class AppManager

bool isSpawnedFromCrashReporter() const;

virtual void reloadScriptEditorFonts() {}

public Q_SLOTS:

Expand Down Expand Up @@ -686,7 +687,9 @@ bool interpretPythonScript(const std::string& script, std::string* error, std::s

//void compilePyScript(const std::string& script,PyObject** code);

std::string PY3String_asString(PyObject* obj);
std::string PyString_asString(PyObject* obj);

std::string makeNameScriptFriendlyWithDots(const std::string& str);

std::string makeNameScriptFriendly(const std::string& str);

Expand Down
26 changes: 13 additions & 13 deletions Engine/Bezier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2072,31 +2072,31 @@ Bezier::setKeyframe(double time)
double x, y;
double leftDerivX, rightDerivX, leftDerivY, rightDerivY;

(*it)->getPositionAtTime(true, time, ViewIdx(0), &x, &y, true);
(*it)->setPositionAtTime(true, time, x, y);
(*it)->getPositionAtTime(false, time, ViewIdx(0), &x, &y, true);
(*it)->setPositionAtTime(false, time, x, y);

(*it)->getLeftBezierPointAtTime(true, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
(*it)->getRightBezierPointAtTime(true, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
(*it)->setLeftBezierPointAtTime(true, time, leftDerivX, leftDerivY);
(*it)->setRightBezierPointAtTime(true, time, rightDerivX, rightDerivY);
(*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
(*it)->getRightBezierPointAtTime(false, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
(*it)->setLeftBezierPointAtTime(false, time, leftDerivX, leftDerivY);
(*it)->setRightBezierPointAtTime(false, time, rightDerivX, rightDerivY);
}

if (useFeather) {
for (BezierCPs::iterator it = _imp->featherPoints.begin(); it != _imp->featherPoints.end(); ++it) {
double x, y;
double leftDerivX, rightDerivX, leftDerivY, rightDerivY;

(*it)->getPositionAtTime(true, time, ViewIdx(0),&x, &y, true);
(*it)->setPositionAtTime(true, time, x, y);
(*it)->getPositionAtTime(false, time, ViewIdx(0),&x, &y, true);
(*it)->setPositionAtTime(false, time, x, y);

(*it)->getLeftBezierPointAtTime(true, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
(*it)->getRightBezierPointAtTime(true, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
(*it)->setLeftBezierPointAtTime(true, time, leftDerivX, leftDerivY);
(*it)->setRightBezierPointAtTime(true, time, rightDerivX, rightDerivY);
(*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
(*it)->getRightBezierPointAtTime(false, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
(*it)->setLeftBezierPointAtTime(false, time, leftDerivX, leftDerivY);
(*it)->setRightBezierPointAtTime(false, time, rightDerivX, rightDerivY);
}
}
}
_imp->setMustCopyGuiBezier(true);
// _imp->setMustCopyGuiBezier(true);
Q_EMIT keyframeSet(time);
}

Expand Down
Loading

0 comments on commit ce9b355

Please sign in to comment.