From d1d148043348bb1154185aeb6264cc59f71367f6 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Thu, 24 Mar 2016 16:04:04 +0100 Subject: [PATCH 01/30] gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bb4dc3175c..8f77926ac5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ build64 sed* *latex* DerivedData +ceres.xcodeproj +openMVG.xcodeproj Natron.xcodeproj Natron-bin.xcodeproj NatronRenderer-bin.xcodeproj From 63355673e4c0b547a6ddb3e6c95d1fc6416a3d87 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Thu, 24 Mar 2016 18:16:19 +0100 Subject: [PATCH 02/30] Fix #1255 --- Gui/RotoUndoCommand.cpp | 7 ++----- Gui/RotoUndoCommand.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Gui/RotoUndoCommand.cpp b/Gui/RotoUndoCommand.cpp index 284b4300b6..aef61ea848 100644 --- a/Gui/RotoUndoCommand.cpp +++ b/Gui/RotoUndoCommand.cpp @@ -364,13 +364,10 @@ AddPointUndoCommand::AddPointUndoCommand(RotoGui* roto, : QUndoCommand() , _firstRedoCalled(false) , _roto(roto) - , _oldCurve() , _curve(curve) , _index(index) , _t(t) { - _oldCurve.reset( new Bezier(curve->getContext(),curve->getScriptName(),curve->getParentLayer(), false) ); - _oldCurve->clone(curve.get()); } @@ -381,7 +378,7 @@ AddPointUndoCommand::~AddPointUndoCommand() void AddPointUndoCommand::undo() { - _curve->clone(_oldCurve.get()); + _curve->removeControlPointByIndex(_index + 1); _roto->setSelection( _curve, std::make_pair( CpPtr(),CpPtr() ) ); _roto->evaluate(true); setText( QObject::tr("Add point to %1 of %2").arg(QString::fromUtf8( _curve->getLabel().c_str() )).arg( _roto->getNodeName() ) ); @@ -390,7 +387,7 @@ AddPointUndoCommand::undo() void AddPointUndoCommand::redo() { - _oldCurve->clone(_curve.get()); + boost::shared_ptr cp = _curve->addControlPointAfterIndex(_index,_t); boost::shared_ptr newFp = _curve->getFeatherPointAtIndex(_index + 1); diff --git a/Gui/RotoUndoCommand.h b/Gui/RotoUndoCommand.h index 9c3517b12c..11836b1a9a 100644 --- a/Gui/RotoUndoCommand.h +++ b/Gui/RotoUndoCommand.h @@ -148,7 +148,7 @@ class AddPointUndoCommand bool _firstRedoCalled; //< false by default RotoGui* _roto; - boost::shared_ptr _oldCurve,_curve; + boost::shared_ptr _curve; int _index; double _t; }; From 17f113ce34dece7fe8f2583a5e5430181f0fc8cd Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Thu, 24 Mar 2016 18:35:52 +0100 Subject: [PATCH 03/30] Fix #1252 --- Engine/Node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 13d12b7d32..0d08467e56 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -3064,7 +3064,7 @@ Node::findPluginFormatKnobs(const KnobsVec & knobs,bool loadingSerialization) std::vector formats; int defValue; getApp()->getProject()->getProjectFormatEntries(&formats, &defValue); - refreshFormatParamChoice(formats, defValue, !loadingSerialization); + refreshFormatParamChoice(formats, defValue, loadingSerialization); } } } From cc3d61d7deaf372a027468d9faeddf0d0e1b8d4b Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Thu, 24 Mar 2016 18:51:53 +0100 Subject: [PATCH 04/30] Fix a bug where normalised params could not get serialised if there value would be the default normalised value --- Engine/Knob.h | 4 ++++ Engine/KnobImpl.h | 10 +++++++++- Engine/KnobTypes.cpp | 14 ++++++++++++++ Engine/KnobTypes.h | 4 ++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Engine/Knob.h b/Engine/Knob.h index 260473b3b1..961d69e013 100644 --- a/Engine/Knob.h +++ b/Engine/Knob.h @@ -1555,6 +1555,10 @@ class Knob protected: + virtual bool computeValuesHaveModifications(int dimension, + const T& value, + const T& defaultValue) const; + virtual bool hasModificationsVirtual(int /*dimension*/) const { return false; } public: diff --git a/Engine/KnobImpl.h b/Engine/KnobImpl.h index cd4975c946..d00459f255 100644 --- a/Engine/KnobImpl.h +++ b/Engine/KnobImpl.h @@ -2765,6 +2765,14 @@ Knob::dequeueValuesSet(bool disableEvaluation) return ret; } +template +bool Knob::computeValuesHaveModifications(int /*dimension*/, + const T& value, + const T& defaultValue) const +{ + return value != defaultValue; +} + template void Knob::computeHasModifications() { @@ -2794,7 +2802,7 @@ void Knob::computeHasModifications() ///Check expressions too in the future if (!hasModif) { QMutexLocker k(&_valueMutex); - if (_values[i] != _defaultValues[i]) { + if (computeValuesHaveModifications(i, _values[i], _defaultValues[i])) { hasModif = true; } } diff --git a/Engine/KnobTypes.cpp b/Engine/KnobTypes.cpp index 9408e83718..1abb7f84e5 100644 --- a/Engine/KnobTypes.cpp +++ b/Engine/KnobTypes.cpp @@ -506,6 +506,20 @@ KnobDouble::normalize(int dimension, } } +bool +KnobDouble::computeValuesHaveModifications(int dimension, + const double& value, + const double& defaultValue) const +{ + if (_defaultValuesAreNormalized) { + double tmp = defaultValue; + denormalize(dimension, 0, &tmp); + return value != tmp; + } else { + return value != defaultValue; + } +} + /******************************KnobButton**************************************/ KnobButton::KnobButton(KnobHolder* holder, diff --git a/Engine/KnobTypes.h b/Engine/KnobTypes.h index 8c5198c360..bd00026c77 100644 --- a/Engine/KnobTypes.h +++ b/Engine/KnobTypes.h @@ -309,6 +309,10 @@ public Q_SLOTS: private: + virtual bool computeValuesHaveModifications(int dimension, + const double& value, + const double& defaultValue) const OVERRIDE FINAL; + virtual bool canAnimate() const OVERRIDE FINAL; virtual const std::string & typeName() const OVERRIDE FINAL; From 9f64c94594d62a3c5b6f7744ef20244b65039b05 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 25 Mar 2016 10:06:52 +0100 Subject: [PATCH 05/30] Add function to retrieve current viewer and current tab widget to python --- Engine/EffectInstance.cpp | 2 +- .../natronengine_module_wrapper.cpp | 8 +-- Engine/NatronEngine/natronengine_python.h | 8 +-- Gui/Gui.h | 5 +- Gui/Gui05.cpp | 14 +++++ Gui/Gui20.cpp | 4 ++ Gui/GuiPrivate.cpp | 1 + Gui/GuiPrivate.h | 1 + Gui/Histogram.cpp | 2 +- Gui/NatronGui/guiapp_wrapper.cpp | 60 +++++++++++++++++++ Gui/NatronGui/natrongui_module_wrapper.cpp | 4 +- Gui/NatronGui/natrongui_python.h | 4 +- Gui/PyGuiApp.cpp | 28 +++++++++ Gui/PyGuiApp.h | 4 ++ Gui/ViewerTab10.cpp | 3 + Gui/ViewerTab40.cpp | 3 + Gui/typesystem_natronGui.xml | 11 ++++ 17 files changed, 147 insertions(+), 15 deletions(-) diff --git a/Engine/EffectInstance.cpp b/Engine/EffectInstance.cpp index ea25db79a5..e2d83c613e 100644 --- a/Engine/EffectInstance.cpp +++ b/Engine/EffectInstance.cpp @@ -2471,7 +2471,7 @@ EffectInstance::Implementation::renderHandler(const EffectDataTLSPtr& tls, it->second.tmpImage->getPremultiplication(), it->second.tmpImage->getFieldingOrder(), false)); - it->second.tmpImage->upscaleMipMap(downscaledRectToRender, originalInputImage->getMipMapLevel(), 0, tmp.get()); + originalInputImage->upscaleMipMap(downscaledRectToRender, originalInputImage->getMipMapLevel(), 0, tmp.get()); mappedOriginalInputImage = tmp; } } diff --git a/Engine/NatronEngine/natronengine_module_wrapper.cpp b/Engine/NatronEngine/natronengine_module_wrapper.cpp index 796948bd13..291fcc53bf 100644 --- a/Engine/NatronEngine/natronengine_module_wrapper.cpp +++ b/Engine/NatronEngine/natronengine_module_wrapper.cpp @@ -35,10 +35,8 @@ static PyMethodDef NatronEngine_methods[] = { }; // Classes initialization functions ------------------------------------------------------------ -void init_UserParamHolder(PyObject* module); void init_PyCoreApplication(PyObject* module); void init_Group(PyObject* module); -void init_Effect(PyObject* module); void init_App(PyObject* module); void init_AppSettings(PyObject* module); void init_ItemBase(PyObject* module); @@ -46,6 +44,8 @@ void init_Layer(PyObject* module); void init_BezierCurve(PyObject* module); void init_Roto(PyObject* module); void init_ImageLayer(PyObject* module); +void init_UserParamHolder(PyObject* module); +void init_Effect(PyObject* module); void init_Param(PyObject* module); void init_AnimatedParam(PyObject* module); void init_BooleanParam(PyObject* module); @@ -606,10 +606,8 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) #endif // Initialize classes in the type system - init_UserParamHolder(module); init_PyCoreApplication(module); init_Group(module); - init_Effect(module); init_App(module); init_AppSettings(module); init_ItemBase(module); @@ -617,6 +615,8 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) init_BezierCurve(module); init_Roto(module); init_ImageLayer(module); + init_UserParamHolder(module); + init_Effect(module); init_Param(module); init_AnimatedParam(module); init_BooleanParam(module); diff --git a/Engine/NatronEngine/natronengine_python.h b/Engine/NatronEngine/natronengine_python.h index 07bb81de93..45d0577bfd 100644 --- a/Engine/NatronEngine/natronengine_python.h +++ b/Engine/NatronEngine/natronengine_python.h @@ -100,6 +100,7 @@ CLANG_DIAG_ON(uninitialized) #define SBK_STRINGPARAM_IDX 53 #define SBK_STRINGPARAM_TYPEENUM_IDX 54 #define SBK_BOOLEANPARAM_IDX 5 +#define SBK_USERPARAMHOLDER_IDX 56 #define SBK_IMAGELAYER_IDX 19 #define SBK_ROTO_IDX 51 #define SBK_ITEMBASE_IDX 25 @@ -109,9 +110,8 @@ CLANG_DIAG_ON(uninitialized) #define SBK_APPSETTINGS_IDX 2 #define SBK_GROUP_IDX 17 #define SBK_APP_IDX 1 -#define SBK_PYCOREAPPLICATION_IDX 47 -#define SBK_USERPARAMHOLDER_IDX 56 #define SBK_EFFECT_IDX 15 +#define SBK_PYCOREAPPLICATION_IDX 47 #define SBK_NatronEngine_IDX_COUNT 57 // This variable stores all Python types exported by this module. @@ -187,6 +187,7 @@ template<> inline PyTypeObject* SbkType() { return template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_STRINGPARAM_TYPEENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_STRINGPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_BOOLEANPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_USERPARAMHOLDER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_IMAGELAYER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_ROTO_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_ITEMBASE_IDX]); } @@ -196,9 +197,8 @@ template<> inline PyTypeObject* SbkType() { return rei template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_APPSETTINGS_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_GROUP_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_APP_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PYCOREAPPLICATION_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_USERPARAMHOLDER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_EFFECT_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PYCOREAPPLICATION_IDX]); } } // namespace Shiboken diff --git a/Gui/Gui.h b/Gui/Gui.h index f111943dba..c6d549c4b9 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -111,7 +111,10 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void setLastSelectedGraph(NodeGraph* graph); NodeGraph* getLastSelectedGraph() const; - + + void setActiveViewer(ViewerTab* viewer); + ViewerTab* getActiveViewer() const; + boost::shared_ptr getLastSelectedNodeCollection() const; /** diff --git a/Gui/Gui05.cpp b/Gui/Gui05.cpp index a8be9ee2bd..dbd21a7299 100644 --- a/Gui/Gui05.cpp +++ b/Gui/Gui05.cpp @@ -281,6 +281,20 @@ Gui::getLastSelectedGraph() const return _imp->_lastFocusedGraph; } +void +Gui::setActiveViewer(ViewerTab* viewer) +{ + assert( QThread::currentThread() == qApp->thread() ); + _imp->_activeViewer = viewer; +} + +ViewerTab* +Gui::getActiveViewer() const +{ + assert( QThread::currentThread() == qApp->thread() ); + return _imp->_activeViewer; +} + boost::shared_ptr Gui::getLastSelectedNodeCollection() const { diff --git a/Gui/Gui20.cpp b/Gui/Gui20.cpp index f7c6771faa..a38fd6be4b 100644 --- a/Gui/Gui20.cpp +++ b/Gui/Gui20.cpp @@ -482,6 +482,10 @@ Gui::removeViewerTab(ViewerTab* tab, assert(tab); unregisterTab(tab); + if (tab == _imp->_activeViewer) { + _imp->_activeViewer = 0; + } + NodeGraph* graph = 0; NodeGroup* isGrp = 0; boost::shared_ptr collection; diff --git a/Gui/GuiPrivate.cpp b/Gui/GuiPrivate.cpp index 7177febde7..a6b3b3d51d 100644 --- a/Gui/GuiPrivate.cpp +++ b/Gui/GuiPrivate.cpp @@ -209,6 +209,7 @@ GuiPrivate::GuiPrivate(GuiAppInstance* app, , _viewerTabsMutex() , _viewerTabs() , _masterSyncViewer(0) +, _activeViewer(0) , _histogramsMutex() , _histograms() , _nextHistogramIndex(1) diff --git a/Gui/GuiPrivate.h b/Gui/GuiPrivate.h index 7e8473e725..11a0101ea7 100644 --- a/Gui/GuiPrivate.h +++ b/Gui/GuiPrivate.h @@ -153,6 +153,7 @@ struct GuiPrivate ///Used when all viewers are synchronized to determine which one triggered the sync ViewerTab* _masterSyncViewer; + ViewerTab* _activeViewer; ///a list of ptrs to all histograms mutable QMutex _histogramsMutex; diff --git a/Gui/Histogram.cpp b/Gui/Histogram.cpp index a92bb6c290..36e9714ed2 100644 --- a/Gui/Histogram.cpp +++ b/Gui/Histogram.cpp @@ -478,7 +478,7 @@ boost::shared_ptr HistogramPrivate::getHistogramImage(RectI* imagePortion return boost::shared_ptr(); } else if (index == 1) { //current viewer - viewer = widget->getGui()->getNodeGraph()->getLastSelectedViewer(); + viewer = widget->getGui()->getActiveViewer(); } else { boost::shared_ptr ret; diff --git a/Gui/NatronGui/guiapp_wrapper.cpp b/Gui/NatronGui/guiapp_wrapper.cpp index 689aa6e512..1e8d3a00e2 100644 --- a/Gui/NatronGui/guiapp_wrapper.cpp +++ b/Gui/NatronGui/guiapp_wrapper.cpp @@ -184,6 +184,64 @@ static PyObject* Sbk_GuiAppFunc_deselectNode(PyObject* self, PyObject* pyArg) return 0; } +static PyObject* Sbk_GuiAppFunc_getActiveTabWidget(PyObject* self) +{ + ::GuiApp* cppSelf = 0; + SBK_UNUSED(cppSelf) + if (!Shiboken::Object::isValid(self)) + return 0; + cppSelf = ((::GuiApp*)Shiboken::Conversions::cppPointer(SbkNatronGuiTypes[SBK_GUIAPP_IDX], (SbkObject*)self)); + PyObject* pyResult = 0; + + // Call function/method + { + + if (!PyErr_Occurred()) { + // getActiveTabWidget()const + PyTabWidget * cppResult = const_cast(cppSelf)->getActiveTabWidget(); + pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronGuiTypes[SBK_PYTABWIDGET_IDX], cppResult); + + // Ownership transferences. + Shiboken::Object::getOwnership(pyResult); + } + } + + if (PyErr_Occurred() || !pyResult) { + Py_XDECREF(pyResult); + return 0; + } + return pyResult; +} + +static PyObject* Sbk_GuiAppFunc_getActiveViewer(PyObject* self) +{ + ::GuiApp* cppSelf = 0; + SBK_UNUSED(cppSelf) + if (!Shiboken::Object::isValid(self)) + return 0; + cppSelf = ((::GuiApp*)Shiboken::Conversions::cppPointer(SbkNatronGuiTypes[SBK_GUIAPP_IDX], (SbkObject*)self)); + PyObject* pyResult = 0; + + // Call function/method + { + + if (!PyErr_Occurred()) { + // getActiveViewer()const + PyViewer * cppResult = const_cast(cppSelf)->getActiveViewer(); + pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronGuiTypes[SBK_PYVIEWER_IDX], cppResult); + + // Ownership transferences. + Shiboken::Object::getOwnership(pyResult); + } + } + + if (PyErr_Occurred() || !pyResult) { + Py_XDECREF(pyResult); + return 0; + } + return pyResult; +} + static PyObject* Sbk_GuiAppFunc_getDirectoryDialog(PyObject* self, PyObject* args, PyObject* kwds) { ::GuiApp* cppSelf = 0; @@ -1306,6 +1364,8 @@ static PyMethodDef Sbk_GuiApp_methods[] = { {"clearSelection", (PyCFunction)Sbk_GuiAppFunc_clearSelection, METH_VARARGS|METH_KEYWORDS}, {"createModalDialog", (PyCFunction)Sbk_GuiAppFunc_createModalDialog, METH_NOARGS}, {"deselectNode", (PyCFunction)Sbk_GuiAppFunc_deselectNode, METH_O}, + {"getActiveTabWidget", (PyCFunction)Sbk_GuiAppFunc_getActiveTabWidget, METH_NOARGS}, + {"getActiveViewer", (PyCFunction)Sbk_GuiAppFunc_getActiveViewer, METH_NOARGS}, {"getDirectoryDialog", (PyCFunction)Sbk_GuiAppFunc_getDirectoryDialog, METH_VARARGS|METH_KEYWORDS}, {"getFilenameDialog", (PyCFunction)Sbk_GuiAppFunc_getFilenameDialog, METH_VARARGS|METH_KEYWORDS}, {"getRGBColorDialog", (PyCFunction)Sbk_GuiAppFunc_getRGBColorDialog, METH_NOARGS}, diff --git a/Gui/NatronGui/natrongui_module_wrapper.cpp b/Gui/NatronGui/natrongui_module_wrapper.cpp index 640b7726cf..ce1c8ac380 100644 --- a/Gui/NatronGui/natrongui_module_wrapper.cpp +++ b/Gui/NatronGui/natrongui_module_wrapper.cpp @@ -35,9 +35,9 @@ static PyMethodDef NatronGui_methods[] = { }; // Classes initialization functions ------------------------------------------------------------ +void init_PyViewer(PyObject* module); void init_PyGuiApplication(PyObject* module); void init_GuiApp(PyObject* module); -void init_PyViewer(PyObject* module); void init_PyTabWidget(PyObject* module); void init_PyModalDialog(PyObject* module); void init_PyPanel(PyObject* module); @@ -497,9 +497,9 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronGui) #endif // Initialize classes in the type system + init_PyViewer(module); init_PyGuiApplication(module); init_GuiApp(module); - init_PyViewer(module); init_PyTabWidget(module); init_PyModalDialog(module); init_PyPanel(module); diff --git a/Gui/NatronGui/natrongui_python.h b/Gui/NatronGui/natrongui_python.h index dbeefb6fb8..c34fa91041 100644 --- a/Gui/NatronGui/natrongui_python.h +++ b/Gui/NatronGui/natrongui_python.h @@ -56,11 +56,11 @@ CLANG_DIAG_ON(uninitialized) // Type indices #define SBK_PYTABWIDGET_IDX 4 -#define SBK_PYVIEWER_IDX 5 #define SBK_GUIAPP_IDX 0 #define SBK_PYGUIAPPLICATION_IDX 1 #define SBK_PYPANEL_IDX 3 #define SBK_PYMODALDIALOG_IDX 2 +#define SBK_PYVIEWER_IDX 5 #define SBK_NatronGui_IDX_COUNT 6 // This variable stores all Python types exported by this module. @@ -90,11 +90,11 @@ namespace Shiboken // PyType functions, to get the PyObjectType for a type T template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYTABWIDGET_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYVIEWER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_GUIAPP_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYGUIAPPLICATION_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYPANEL_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYMODALDIALOG_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYVIEWER_IDX]); } } // namespace Shiboken diff --git a/Gui/PyGuiApp.cpp b/Gui/PyGuiApp.cpp index 9cd33381ff..42f2611905 100644 --- a/Gui/PyGuiApp.cpp +++ b/Gui/PyGuiApp.cpp @@ -93,6 +93,16 @@ GuiApp::getTabWidget(const std::string& name) const return 0; } +PyTabWidget* +GuiApp::getActiveTabWidget() const +{ + TabWidget* tab = _app->getGui()->getLastEnteredTabWidget(); + if (!tab) { + return 0; + } + return new PyTabWidget(tab); +} + bool GuiApp::moveTab(const std::string& scriptName,PyTabWidget* pane) { @@ -463,6 +473,24 @@ GuiApp::getViewer(const std::string& scriptName) const return new PyViewer(ptr); } +PyViewer* +GuiApp::getActiveViewer() const +{ + ViewerTab* tab = _app->getGui()->getActiveViewer(); + if (!tab) { + return 0; + } + ViewerInstance* instance = tab->getInternalNode(); + if (!instance) { + return 0; + } + NodePtr node = instance->getNode(); + if (!node) { + return 0; + } + return new PyViewer(node); +} + PyPanel* GuiApp::getUserPanel(const std::string& scriptName) const diff --git a/Gui/PyGuiApp.h b/Gui/PyGuiApp.h index 49edd590b8..8824a08c70 100644 --- a/Gui/PyGuiApp.h +++ b/Gui/PyGuiApp.h @@ -119,6 +119,8 @@ class GuiApp : public App PyTabWidget* getTabWidget(const std::string& name) const; + PyTabWidget* getActiveTabWidget() const; + bool moveTab(const std::string& scriptName,PyTabWidget* pane); void registerPythonPanel(PyPanel* panel,const std::string& pythonFunction); @@ -146,6 +148,8 @@ class GuiApp : public App PyViewer* getViewer(const std::string& scriptName) const; + PyViewer* getActiveViewer() const; + PyPanel* getUserPanel(const std::string& scriptName) const; void renderBlocking(Effect* writeNode,int firstFrame, int lastFrame,int frameStep = 1); diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 85dd991507..08628b64f7 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -534,6 +534,9 @@ ViewerTab::leaveEvent(QEvent* e) void ViewerTab::keyPressEvent(QKeyEvent* e) { + if (getGui()) { + getGui()->setActiveViewer(this); + } bool accept = true; diff --git a/Gui/ViewerTab40.cpp b/Gui/ViewerTab40.cpp index cde1b0070b..5455ab8d55 100644 --- a/Gui/ViewerTab40.cpp +++ b/Gui/ViewerTab40.cpp @@ -636,6 +636,9 @@ void ViewerTab::onMousePressCalledInViewer() { takeClickFocus(); + if (getGui()) { + getGui()->setActiveViewer(this); + } } void diff --git a/Gui/typesystem_natronGui.xml b/Gui/typesystem_natronGui.xml index 49b101432d..48872e0968 100644 --- a/Gui/typesystem_natronGui.xml +++ b/Gui/typesystem_natronGui.xml @@ -31,6 +31,12 @@ + + + + + + std::list<Effect*> effects = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES); @@ -50,6 +56,11 @@ + + + + + From 74b4af836c1d88dc7522395683c5a1cb87948dfa Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 25 Mar 2016 17:08:02 +0100 Subject: [PATCH 06/30] Add preferences to disable file dialog prompt when creating a write node. Only enabled for 2.1 --- Engine/Node.cpp | 39 ++++- Engine/Settings.cpp | 382 +++++++++++++++++++++++-------------------- Engine/Settings.h | 32 ++-- Engine/WriteNode.cpp | 5 +- Gui/Gui20.cpp | 40 +++-- 5 files changed, 294 insertions(+), 204 deletions(-) diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 0d08467e56..4ac551707a 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -3478,16 +3478,24 @@ Node::findOrCreateChannelEnabled(const boost::shared_ptr& mainPage) bool foundAll = foundEnabled[0] && foundEnabled[1] && foundEnabled[2] && foundEnabled[3]; + bool isWriter = _imp->effect->isWriter(); + if (foundAll) { for (int i = 0; i < 4; ++i) { - if (foundEnabled[i]->getParentKnob() == mainPage) { - //foundEnabled[i]->setAddNewLine(i == 3); - mainPage->removeKnob(foundEnabled[i].get()); - mainPage->insertKnob(i,foundEnabled[i]); + + // Writers already have their checkboxes places correctly + if (!isWriter) { + if (foundEnabled[i]->getParentKnob() == mainPage) { + //foundEnabled[i]->setAddNewLine(i == 3); + mainPage->removeKnob(foundEnabled[i].get()); + mainPage->insertKnob(i,foundEnabled[i]); + } } _imp->enabledChan[i] = foundEnabled[i]; } + + } bool pluginDefaultPref[4]; @@ -3512,7 +3520,7 @@ Node::findOrCreateChannelEnabled(const boost::shared_ptr& mainPage) foundAll = true; } } - if (foundAll && !getApp()->isBackground()) { + if (!isWriter && foundAll && !getApp()->isBackground()) { _imp->enabledChan[3].lock()->setAddNewLine(false); boost::shared_ptr premultWarning = AppManager::createKnob(_imp->effect.get(), "", 1, false); premultWarning->setIconLabel("dialog-warning"); @@ -7603,6 +7611,24 @@ Node::onEffectKnobValueChanged(KnobI* what, } } } else if (_imp->effect->isWriter()) { + + KnobPtr sublabelKnob = getKnobByName(kNatronOfxParamStringSublabelName); + KnobOutputFile* isFile = dynamic_cast(what); + if (isFile && sublabelKnob && reason != eValueChangedReasonPluginEdited) { + Knob* isString = dynamic_cast*>(sublabelKnob.get()); + + std::string pattern = isFile->getValue(); + if (isString) { + + std::size_t foundSlash = pattern.find_last_of("/"); + if (foundSlash != std::string::npos) { + pattern = pattern.substr(foundSlash + 1); + } + + isString->setValue(pattern); + } + } + /* Check if the filename param has a %V in it, in which case make sure to hide the Views parameter */ @@ -9578,6 +9604,9 @@ Node::getChannelSelectorKnob(int inputNb) const void Node::checkForPremultWarningAndCheckboxes() { + if (isOutputNode()) { + return; + } boost::shared_ptr chans[4]; boost::shared_ptr premultWarn = _imp->premultWarning.lock(); if (!premultWarn) { diff --git a/Engine/Settings.cpp b/Engine/Settings.cpp index 9f532d3a32..e156677d36 100644 --- a/Engine/Settings.cpp +++ b/Engine/Settings.cpp @@ -130,7 +130,9 @@ Settings::initializeKnobsGeneral() _natronSettingsExist->setSecretByDefault(true); _generalTab->addKnob(_natronSettingsExist); - + boost::shared_ptr softwareSep = AppManager::createKnob(this, NATRON_APPLICATION_NAME); + _generalTab->addKnob(softwareSep); + _checkForUpdates = AppManager::createKnob(this, "Always check for updates on start-up"); _checkForUpdates->setName("checkForUpdates"); _checkForUpdates->setAnimationEnabled(false); @@ -156,14 +158,6 @@ Settings::initializeKnobsGeneral() _generalTab->addKnob(_testCrashReportButton); - - _notifyOnFileChange = AppManager::createKnob(this, "Warn when a file changes externally"); - _notifyOnFileChange->setName("warnOnExternalChange"); - _notifyOnFileChange->setAnimationEnabled(false); - _notifyOnFileChange->setHintToolTip("When checked, if a file read from a file parameter changes externally, a warning will be displayed " - "on the viewer. Turning this off will suspend the notification system."); - _generalTab->addKnob(_notifyOnFileChange); - _autoSaveDelay = AppManager::createKnob(this, "Auto-save trigger delay"); _autoSaveDelay->setName("autoSaveDelay"); _autoSaveDelay->setAnimationEnabled(false); @@ -172,10 +166,10 @@ Settings::initializeKnobsGeneral() _autoSaveDelay->setMaximum(60); _autoSaveDelay->setAddNewLine(false); _autoSaveDelay->setHintToolTip("The number of seconds after an event that " NATRON_APPLICATION_NAME " should wait before " - " auto-saving. Note that if a render is in progress, " NATRON_APPLICATION_NAME " will " - " wait until it is done to actually auto-save."); + " auto-saving. Note that if a render is in progress, " NATRON_APPLICATION_NAME " will " + " wait until it is done to actually auto-save."); _generalTab->addKnob(_autoSaveDelay); - + _autoSaveUnSavedProjects = AppManager::createKnob(this, "Enable Auto-save for unsaved projects"); @@ -186,30 +180,123 @@ Settings::initializeKnobsGeneral() "Disabling this will no longer save un-saved project."); _generalTab->addKnob(_autoSaveUnSavedProjects); - _linearPickers = AppManager::createKnob(this, "Linear color pickers"); - _linearPickers->setName("linearPickers"); - _linearPickers->setAnimationEnabled(false); - _linearPickers->setHintToolTip("When activated, all colors picked from the color parameters are linearized " - "before being fetched. Otherwise they are in the same colorspace " - "as the viewer they were picked from."); - _generalTab->addKnob(_linearPickers); - _convertNaNValues = AppManager::createKnob(this, "Convert NaN values"); - _convertNaNValues->setName("convertNaNs"); - _convertNaNValues->setAnimationEnabled(false); - _convertNaNValues->setHintToolTip("When activated, any pixel that is a Not-a-Number will be converted to 1 to avoid potential crashes from " - "downstream nodes. These values can be produced by faulty plug-ins when they use wrong arithmetic such as " - "division by zero. Disabling this option will keep the NaN(s) in the buffers: this may lead to an " - "undefined behavior."); - _generalTab->addKnob(_convertNaNValues); - + _hostName = AppManager::createKnob(this, "Appear to plug-ins as"); + _hostName->setName("pluginHostName"); + _hostName->setHintToolTip(NATRON_APPLICATION_NAME " will appear with the name of the selected application to the OpenFX plug-ins. " + "Changing it to the name of another application can help loading plugins which " + "restrict their usage to specific OpenFX host(s). " + "If a Host is not listed here, use the \"Custom\" entry to enter a custom host name. Changing this requires " + "a restart of the application and requires clearing " + "the OpenFX plugins cache from the Cache menu."); + _knownHostNames.clear(); + std::vector visibleHostEntries,hostEntriesHelp; + assert(_knownHostNames.size() == (int)eKnownHostNameNatron); + _knownHostNames.push_back(NATRON_ORGANIZATION_DOMAIN_TOPLEVEL "." NATRON_ORGANIZATION_DOMAIN_SUB "." NATRON_APPLICATION_NAME); + visibleHostEntries.push_back(NATRON_APPLICATION_NAME); + assert(_knownHostNames.size() == (int)eKnownHostNameNuke); + _knownHostNames.push_back("uk.co.thefoundry.nuke"); + visibleHostEntries.push_back("Nuke"); + assert(_knownHostNames.size() == (int)eKnownHostNameFusion); + _knownHostNames.push_back("com.eyeonline.Fusion"); + visibleHostEntries.push_back("Fusion"); + assert(_knownHostNames.size() == (int)eKnownHostNameCatalyst); + _knownHostNames.push_back("com.sony.Catalyst.Edit"); + visibleHostEntries.push_back("Sony Catalyst Edit"); + assert(_knownHostNames.size() == (int)eKnownHostNameVegas); + _knownHostNames.push_back("com.sonycreativesoftware.vegas"); + visibleHostEntries.push_back("Sony Vegas"); + assert(_knownHostNames.size() == (int)eKnownHostNameToxik); + _knownHostNames.push_back("Autodesk Toxik"); + visibleHostEntries.push_back("Toxik"); + assert(_knownHostNames.size() == (int)eKnownHostNameScratch); + _knownHostNames.push_back("Assimilator"); + visibleHostEntries.push_back("Scratch"); + assert(_knownHostNames.size() == (int)eKnownHostNameDustBuster); + _knownHostNames.push_back("Dustbuster"); + visibleHostEntries.push_back("DustBuster"); + assert(_knownHostNames.size() == (int)eKnownHostNameResolve); + _knownHostNames.push_back("DaVinciResolve"); + visibleHostEntries.push_back("Da Vinci Resolve"); + assert(_knownHostNames.size() == (int)eKnownHostNameResolveLite); + _knownHostNames.push_back("DaVinciResolveLite"); + visibleHostEntries.push_back("Da Vinci Resolve Lite"); + assert(_knownHostNames.size() == (int)eKnownHostNameMistika); + _knownHostNames.push_back("Mistika"); + visibleHostEntries.push_back("SGO Mistika"); + assert(_knownHostNames.size() == (int)eKnownHostNamePablo); + _knownHostNames.push_back("com.quantel.genq"); + visibleHostEntries.push_back("Quantel Pablo Rio"); + assert(_knownHostNames.size() == (int)eKnownHostNameMotionStudio); + _knownHostNames.push_back("com.idtvision.MotionStudio"); + visibleHostEntries.push_back("IDT Motion Studio"); + assert(_knownHostNames.size() == (int)eKnownHostNameShake); + _knownHostNames.push_back("com.apple.shake"); + visibleHostEntries.push_back("Shake"); + assert(_knownHostNames.size() == (int)eKnownHostNameBaselight); + _knownHostNames.push_back("Baselight"); + visibleHostEntries.push_back("Baselight"); + assert(_knownHostNames.size() == (int)eKnownHostNameFrameCycler); + _knownHostNames.push_back("IRIDAS Framecycler"); + visibleHostEntries.push_back("FrameCycler"); + assert(_knownHostNames.size() == (int)eKnownHostNameNucoda); + _knownHostNames.push_back("Nucoda"); + visibleHostEntries.push_back("Nucoda Film Master"); + assert(_knownHostNames.size() == (int)eKnownHostNameAvidDS); + _knownHostNames.push_back("DS OFX HOST"); + visibleHostEntries.push_back("Avid DS"); + assert(_knownHostNames.size() == (int)eKnownHostNameDX); + _knownHostNames.push_back("com.chinadigitalvideo.dx"); + visibleHostEntries.push_back("China Digital Video DX"); + assert(_knownHostNames.size() == (int)eKnownHostNameTitlerPro); + _knownHostNames.push_back("com.newblue.titlerpro"); + visibleHostEntries.push_back("NewBlueFX Titler Pro"); + assert(_knownHostNames.size() == (int)eKnownHostNameNewBlueOFXBridge); + _knownHostNames.push_back("com.newblue.ofxbridge"); + visibleHostEntries.push_back("NewBlueFX OFX Bridge"); + assert(_knownHostNames.size() == (int)eKnownHostNameRamen); + _knownHostNames.push_back("Ramen"); + visibleHostEntries.push_back("Ramen"); + assert(_knownHostNames.size() == (int)eKnownHostNameTuttleOfx); + _knownHostNames.push_back("TuttleOfx"); + visibleHostEntries.push_back("TuttleOFX"); + + + assert(visibleHostEntries.size() == _knownHostNames.size()); + hostEntriesHelp = _knownHostNames; + + visibleHostEntries.push_back(NATRON_CUSTOM_HOST_NAME_ENTRY); + hostEntriesHelp.push_back("Custom host name"); + + _hostName->populateChoices(visibleHostEntries,hostEntriesHelp); + _hostName->setAnimationEnabled(false); + _hostName->setAddNewLine(false); + _generalTab->addKnob(_hostName); + + _customHostName = AppManager::createKnob(this, "Custom Host name"); + _customHostName->setName("customHostName"); + _customHostName->setHintToolTip("This is the name of the OpenFX host (application) as it appears to the OpenFX plugins. " + "Changing it to the name of another application can help loading some plugins which " + "restrict their usage to specific OpenFX hosts. You shoud leave " + "this to its default value, unless a specific plugin refuses to load or run. " + "Changing this takes effect upon the next application launch, and requires clearing " + "the OpenFX plugins cache from the Cache menu. " + "The default host name is: \n" + NATRON_ORGANIZATION_DOMAIN_TOPLEVEL "." NATRON_ORGANIZATION_DOMAIN_SUB "." NATRON_APPLICATION_NAME); + _customHostName->setAnimationEnabled(false); + _customHostName->setSecretByDefault(true); + _generalTab->addKnob(_customHostName); + + boost::shared_ptr sepThreading = AppManager::createKnob(this, "Threading"); + _generalTab->addKnob(sepThreading); + _numberOfThreads = AppManager::createKnob(this, "Number of render threads (0=\"guess\")"); _numberOfThreads->setName("noRenderThreads"); _numberOfThreads->setAnimationEnabled(false); - + QString numberOfThreadsToolTip = QString::fromUtf8("Controls how many threads " NATRON_APPLICATION_NAME " should use to render. \n" - "-1: Disable multithreading totally (useful for debugging) \n" - "0: Guess the thread count from the number of cores. The ideal threads count for this hardware is %1.").arg( QThread::idealThreadCount() ); + "-1: Disable multithreading totally (useful for debugging) \n" + "0: Guess the thread count from the number of cores. The ideal threads count for this hardware is %1.").arg( QThread::idealThreadCount() ); _numberOfThreads->setHintToolTip( numberOfThreadsToolTip.toStdString() ); _numberOfThreads->disableSlider(); _numberOfThreads->setMinimum(-1); @@ -220,10 +307,10 @@ Settings::initializeKnobsGeneral() _numberOfParallelRenders = AppManager::createKnob(this, "Number of parallel renders (0=\"guess\")"); _numberOfParallelRenders->setHintToolTip("Controls the number of parallel frame that will be rendered at the same time by the renderer." "A value of 0 indicate that " NATRON_APPLICATION_NAME " should automatically determine " - "the best number of parallel renders to launch given your CPU activity. " - "Setting a value different than 0 should be done only if you know what you're doing and can lead " - "in some situations to worse performances. Overall to get the best performances you should have your " - "CPU at 100% activity without idle times. "); + "the best number of parallel renders to launch given your CPU activity. " + "Setting a value different than 0 should be done only if you know what you're doing and can lead " + "in some situations to worse performances. Overall to get the best performances you should have your " + "CPU at 100% activity without idle times. "); _numberOfParallelRenders->setName("nParallelRenders"); _numberOfParallelRenders->setMinimum(0); _numberOfParallelRenders->disableSlider(); @@ -243,7 +330,7 @@ Settings::initializeKnobsGeneral() "make sure to uncheck this option first otherwise it will crash " NATRON_APPLICATION_NAME); _useThreadPool->setAnimationEnabled(false); _generalTab->addKnob(_useThreadPool); - + _nThreadsPerEffect = AppManager::createKnob(this, "Max threads usable per effect (0=\"guess\")"); _nThreadsPerEffect->setName("nThreadsPerEffect"); _nThreadsPerEffect->setAnimationEnabled(false); @@ -256,14 +343,14 @@ Settings::initializeKnobsGeneral() _nThreadsPerEffect->setMinimum(0); _nThreadsPerEffect->disableSlider(); _generalTab->addKnob(_nThreadsPerEffect); - + _renderInSeparateProcess = AppManager::createKnob(this, "Render in a separate process"); _renderInSeparateProcess->setName("renderNewProcess"); _renderInSeparateProcess->setAnimationEnabled(false); _renderInSeparateProcess->setHintToolTip("If true, " NATRON_APPLICATION_NAME " will render frames to disk in " - "a separate process so that if the main application crashes, the render goes on."); + "a separate process so that if the main application crashes, the render goes on."); _generalTab->addKnob(_renderInSeparateProcess); - + _queueRenders = AppManager::createKnob(this, "Append new renders to queue"); _queueRenders->setHintToolTip("When checked, renders will be queued in the Progress Panel and will start only when all " "other prior tasks are done."); @@ -271,14 +358,25 @@ Settings::initializeKnobsGeneral() _queueRenders->setName("queueRenders"); _generalTab->addKnob(_queueRenders); - _autoPreviewEnabledForNewProjects = AppManager::createKnob(this, "Auto-preview enabled by default for new projects"); - _autoPreviewEnabledForNewProjects->setName("enableAutoPreviewNewProjects"); - _autoPreviewEnabledForNewProjects->setAnimationEnabled(false); - _autoPreviewEnabledForNewProjects->setHintToolTip("If checked, then when creating a new project, the Auto-preview option" - " is enabled."); - _generalTab->addKnob(_autoPreviewEnabledForNewProjects); + + boost::shared_ptr sepMisc = AppManager::createKnob(this, "Misc."); + _generalTab->addKnob(sepMisc); + + _notifyOnFileChange = AppManager::createKnob(this, "Warn when a file changes externally"); + _notifyOnFileChange->setName("warnOnExternalChange"); + _notifyOnFileChange->setAnimationEnabled(false); + _notifyOnFileChange->setHintToolTip("When checked, if a file read from a file parameter changes externally, a warning will be displayed " + "on the viewer. Turning this off will suspend the notification system."); + _generalTab->addKnob(_notifyOnFileChange); + _filedialogForWriters = AppManager::createKnob(this, "Prompt with file dialog when creating Write node"); + _filedialogForWriters->setName("writeUseDialog"); + _filedialogForWriters->setDefaultValue(true); + _filedialogForWriters->setAnimationEnabled(false); + _filedialogForWriters->setHintToolTip("When checked, opens-up a file dialog when creating a Write node"); + _generalTab->addKnob(_filedialogForWriters); + _firstReadSetProjectFormat = AppManager::createKnob(this, "First image read set project format"); _firstReadSetProjectFormat->setName("autoProjectFormat"); _firstReadSetProjectFormat->setAnimationEnabled(false); @@ -286,6 +384,28 @@ Settings::initializeKnobsGeneral() "image size."); _generalTab->addKnob(_firstReadSetProjectFormat); + + + _convertNaNValues = AppManager::createKnob(this, "Convert NaN values"); + _convertNaNValues->setName("convertNaNs"); + _convertNaNValues->setAnimationEnabled(false); + _convertNaNValues->setHintToolTip("When activated, any pixel that is a Not-a-Number will be converted to 1 to avoid potential crashes from " + "downstream nodes. These values can be produced by faulty plug-ins when they use wrong arithmetic such as " + "division by zero. Disabling this option will keep the NaN(s) in the buffers: this may lead to an " + "undefined behavior."); + _generalTab->addKnob(_convertNaNValues); + + + + _autoPreviewEnabledForNewProjects = AppManager::createKnob(this, "Auto-preview enabled by default for new projects"); + _autoPreviewEnabledForNewProjects->setName("enableAutoPreviewNewProjects"); + _autoPreviewEnabledForNewProjects->setAnimationEnabled(false); + _autoPreviewEnabledForNewProjects->setHintToolTip("If checked, then when creating a new project, the Auto-preview option" + " is enabled."); + _generalTab->addKnob(_autoPreviewEnabledForNewProjects); + + + _fixPathsOnProjectPathChanged = AppManager::createKnob(this, "Auto fix relative file-paths"); _fixPathsOnProjectPathChanged->setAnimationEnabled(false); _fixPathsOnProjectPathChanged->setHintToolTip("If checked, when a project-path changes (either the name or the value pointed to), " @@ -293,6 +413,44 @@ Settings::initializeKnobsGeneral() _fixPathsOnProjectPathChanged->setName("autoFixRelativePaths"); _generalTab->addKnob(_fixPathsOnProjectPathChanged); + _renderOnEditingFinished = AppManager::createKnob(this, "Refresh viewer only when editing is finished"); + _renderOnEditingFinished->setName("renderOnEditingFinished"); + _renderOnEditingFinished->setHintToolTip("When checked, the viewer triggers a new render only when mouse is released when editing parameters, curves " + " or the timeline. This setting doesn't apply to roto splines editing."); + _renderOnEditingFinished->setAnimationEnabled(false); + _generalTab->addKnob(_renderOnEditingFinished); + + _activateRGBSupport = AppManager::createKnob(this, "RGB components support"); + _activateRGBSupport->setHintToolTip("When checked " NATRON_APPLICATION_NAME " is able to process images with only RGB components " + "(support for images with RGBA and Alpha components is always enabled). " + "Un-checking this option may prevent plugins that do not well support RGB components from crashing " NATRON_APPLICATION_NAME ". " + "Changing this option requires a restart of the application."); + _activateRGBSupport->setAnimationEnabled(false); + _activateRGBSupport->setName("rgbSupport"); + _generalTab->addKnob(_activateRGBSupport); + + + _activateTransformConcatenationSupport = AppManager::createKnob(this, "Transforms concatenation support"); + _activateTransformConcatenationSupport->setHintToolTip("When checked " NATRON_APPLICATION_NAME " is able to concatenate transform effects " + "when they are chained in the compositing tree. This yields better results and faster " + "render times because the image is only filtered once instead of as many times as there are " + "transformations."); + _activateTransformConcatenationSupport->setAnimationEnabled(false); + _activateTransformConcatenationSupport->setName("transformCatSupport"); + _generalTab->addKnob(_activateTransformConcatenationSupport); + + + boost::shared_ptr sepUI = AppManager::createKnob(this, "User Interface"); + _generalTab->addKnob(sepUI); + + _linearPickers = AppManager::createKnob(this, "Linear color pickers"); + _linearPickers->setName("linearPickers"); + _linearPickers->setAnimationEnabled(false); + _linearPickers->setHintToolTip("When activated, all colors picked from the color parameters are linearized " + "before being fetched. Otherwise they are in the same colorspace " + "as the viewer they were picked from."); + _generalTab->addKnob(_linearPickers); + _maxPanelsOpened = AppManager::createKnob(this, "Maximum number of open settings panels (0=\"unlimited\")"); _maxPanelsOpened->setName("maxPanels"); _maxPanelsOpened->setHintToolTip("This property holds the maximum number of settings panels that can be " @@ -330,137 +488,9 @@ Settings::initializeKnobsGeneral() _loadProjectsWorkspace->setAnimationEnabled(false); _generalTab->addKnob(_loadProjectsWorkspace); - _renderOnEditingFinished = AppManager::createKnob(this, "Refresh viewer only when editing is finished"); - _renderOnEditingFinished->setName("renderOnEditingFinished"); - _renderOnEditingFinished->setHintToolTip("When checked, the viewer triggers a new render only when mouse is released when editing parameters, curves " - " or the timeline. This setting doesn't apply to roto splines editing."); - _renderOnEditingFinished->setAnimationEnabled(false); - _generalTab->addKnob(_renderOnEditingFinished); - - _activateRGBSupport = AppManager::createKnob(this, "RGB components support"); - _activateRGBSupport->setHintToolTip("When checked " NATRON_APPLICATION_NAME " is able to process images with only RGB components " - "(support for images with RGBA and Alpha components is always enabled). " - "Un-checking this option may prevent plugins that do not well support RGB components from crashing " NATRON_APPLICATION_NAME ". " - "Changing this option requires a restart of the application."); - _activateRGBSupport->setAnimationEnabled(false); - _activateRGBSupport->setName("rgbSupport"); - _generalTab->addKnob(_activateRGBSupport); - - - _activateTransformConcatenationSupport = AppManager::createKnob(this, "Transforms concatenation support"); - _activateTransformConcatenationSupport->setHintToolTip("When checked " NATRON_APPLICATION_NAME " is able to concatenate transform effects " - "when they are chained in the compositing tree. This yields better results and faster " - "render times because the image is only filtered once instead of as many times as there are " - "transformations."); - _activateTransformConcatenationSupport->setAnimationEnabled(false); - _activateTransformConcatenationSupport->setName("transformCatSupport"); - _generalTab->addKnob(_activateTransformConcatenationSupport); - - _hostName = AppManager::createKnob(this, "Appear to plug-ins as"); - _hostName->setName("pluginHostName"); - _hostName->setHintToolTip(NATRON_APPLICATION_NAME " will appear with the name of the selected application to the OpenFX plug-ins. " - "Changing it to the name of another application can help loading plugins which " - "restrict their usage to specific OpenFX host(s). " - "If a Host is not listed here, use the \"Custom\" entry to enter a custom host name. Changing this requires " - "a restart of the application and requires clearing " - "the OpenFX plugins cache from the Cache menu."); - _knownHostNames.clear(); - std::vector visibleHostEntries,hostEntriesHelp; - assert(_knownHostNames.size() == (int)eKnownHostNameNatron); - _knownHostNames.push_back(NATRON_ORGANIZATION_DOMAIN_TOPLEVEL "." NATRON_ORGANIZATION_DOMAIN_SUB "." NATRON_APPLICATION_NAME); - visibleHostEntries.push_back(NATRON_APPLICATION_NAME); - assert(_knownHostNames.size() == (int)eKnownHostNameNuke); - _knownHostNames.push_back("uk.co.thefoundry.nuke"); - visibleHostEntries.push_back("Nuke"); - assert(_knownHostNames.size() == (int)eKnownHostNameFusion); - _knownHostNames.push_back("com.eyeonline.Fusion"); - visibleHostEntries.push_back("Fusion"); - assert(_knownHostNames.size() == (int)eKnownHostNameCatalyst); - _knownHostNames.push_back("com.sony.Catalyst.Edit"); - visibleHostEntries.push_back("Sony Catalyst Edit"); - assert(_knownHostNames.size() == (int)eKnownHostNameVegas); - _knownHostNames.push_back("com.sonycreativesoftware.vegas"); - visibleHostEntries.push_back("Sony Vegas"); - assert(_knownHostNames.size() == (int)eKnownHostNameToxik); - _knownHostNames.push_back("Autodesk Toxik"); - visibleHostEntries.push_back("Toxik"); - assert(_knownHostNames.size() == (int)eKnownHostNameScratch); - _knownHostNames.push_back("Assimilator"); - visibleHostEntries.push_back("Scratch"); - assert(_knownHostNames.size() == (int)eKnownHostNameDustBuster); - _knownHostNames.push_back("Dustbuster"); - visibleHostEntries.push_back("DustBuster"); - assert(_knownHostNames.size() == (int)eKnownHostNameResolve); - _knownHostNames.push_back("DaVinciResolve"); - visibleHostEntries.push_back("Da Vinci Resolve"); - assert(_knownHostNames.size() == (int)eKnownHostNameResolveLite); - _knownHostNames.push_back("DaVinciResolveLite"); - visibleHostEntries.push_back("Da Vinci Resolve Lite"); - assert(_knownHostNames.size() == (int)eKnownHostNameMistika); - _knownHostNames.push_back("Mistika"); - visibleHostEntries.push_back("SGO Mistika"); - assert(_knownHostNames.size() == (int)eKnownHostNamePablo); - _knownHostNames.push_back("com.quantel.genq"); - visibleHostEntries.push_back("Quantel Pablo Rio"); - assert(_knownHostNames.size() == (int)eKnownHostNameMotionStudio); - _knownHostNames.push_back("com.idtvision.MotionStudio"); - visibleHostEntries.push_back("IDT Motion Studio"); - assert(_knownHostNames.size() == (int)eKnownHostNameShake); - _knownHostNames.push_back("com.apple.shake"); - visibleHostEntries.push_back("Shake"); - assert(_knownHostNames.size() == (int)eKnownHostNameBaselight); - _knownHostNames.push_back("Baselight"); - visibleHostEntries.push_back("Baselight"); - assert(_knownHostNames.size() == (int)eKnownHostNameFrameCycler); - _knownHostNames.push_back("IRIDAS Framecycler"); - visibleHostEntries.push_back("FrameCycler"); - assert(_knownHostNames.size() == (int)eKnownHostNameNucoda); - _knownHostNames.push_back("Nucoda"); - visibleHostEntries.push_back("Nucoda Film Master"); - assert(_knownHostNames.size() == (int)eKnownHostNameAvidDS); - _knownHostNames.push_back("DS OFX HOST"); - visibleHostEntries.push_back("Avid DS"); - assert(_knownHostNames.size() == (int)eKnownHostNameDX); - _knownHostNames.push_back("com.chinadigitalvideo.dx"); - visibleHostEntries.push_back("China Digital Video DX"); - assert(_knownHostNames.size() == (int)eKnownHostNameTitlerPro); - _knownHostNames.push_back("com.newblue.titlerpro"); - visibleHostEntries.push_back("NewBlueFX Titler Pro"); - assert(_knownHostNames.size() == (int)eKnownHostNameNewBlueOFXBridge); - _knownHostNames.push_back("com.newblue.ofxbridge"); - visibleHostEntries.push_back("NewBlueFX OFX Bridge"); - assert(_knownHostNames.size() == (int)eKnownHostNameRamen); - _knownHostNames.push_back("Ramen"); - visibleHostEntries.push_back("Ramen"); - assert(_knownHostNames.size() == (int)eKnownHostNameTuttleOfx); - _knownHostNames.push_back("TuttleOfx"); - visibleHostEntries.push_back("TuttleOFX"); - assert(visibleHostEntries.size() == _knownHostNames.size()); - hostEntriesHelp = _knownHostNames; - - visibleHostEntries.push_back(NATRON_CUSTOM_HOST_NAME_ENTRY); - hostEntriesHelp.push_back("Custom host name"); - - _hostName->populateChoices(visibleHostEntries,hostEntriesHelp); - _hostName->setAnimationEnabled(false); - _hostName->setAddNewLine(false); - _generalTab->addKnob(_hostName); - _customHostName = AppManager::createKnob(this, "Custom Host name"); - _customHostName->setName("customHostName"); - _customHostName->setHintToolTip("This is the name of the OpenFX host (application) as it appears to the OpenFX plugins. " - "Changing it to the name of another application can help loading some plugins which " - "restrict their usage to specific OpenFX hosts. You shoud leave " - "this to its default value, unless a specific plugin refuses to load or run. " - "Changing this takes effect upon the next application launch, and requires clearing " - "the OpenFX plugins cache from the Cache menu. " - "The default host name is: \n" - NATRON_ORGANIZATION_DOMAIN_TOPLEVEL "." NATRON_ORGANIZATION_DOMAIN_SUB "." NATRON_APPLICATION_NAME); - _customHostName->setAnimationEnabled(false); - _customHostName->setSecretByDefault(true); - _generalTab->addKnob(_customHostName); } void @@ -3587,6 +3617,12 @@ Settings::isRenderQueuingEnabled() const return _queueRenders->getValue(); } +bool +Settings::isFileDialogEnabledForNewWriters() const +{ + return _filedialogForWriters->getValue(); +} + NATRON_NAMESPACE_EXIT; NATRON_NAMESPACE_USING; diff --git a/Engine/Settings.h b/Engine/Settings.h index 72f76b386f..9bc3a1b7b9 100644 --- a/Engine/Settings.h +++ b/Engine/Settings.h @@ -275,6 +275,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void setAutoTurboModeEnabled(bool e); + bool isFileDialogEnabledForNewWriters() const; + void setOptionalInputsAutoHidden(bool hidden); bool areOptionalInputsAutoHidden() const; @@ -382,34 +384,42 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON boost::shared_ptr _generalTab; boost::shared_ptr _natronSettingsExist; + + // Natron boost::shared_ptr _checkForUpdates; boost::shared_ptr _enableCrashReports; boost::shared_ptr _testCrashReportButton; - boost::shared_ptr _notifyOnFileChange; boost::shared_ptr _autoSaveUnSavedProjects; boost::shared_ptr _autoSaveDelay; - boost::shared_ptr _linearPickers; - boost::shared_ptr _convertNaNValues; + boost::shared_ptr _hostName; + boost::shared_ptr _customHostName; + + // Threading boost::shared_ptr _numberOfThreads; boost::shared_ptr _numberOfParallelRenders; boost::shared_ptr _useThreadPool; boost::shared_ptr _nThreadsPerEffect; boost::shared_ptr _renderInSeparateProcess; boost::shared_ptr _queueRenders; - boost::shared_ptr _autoPreviewEnabledForNewProjects; + + // Misc + boost::shared_ptr _notifyOnFileChange; + boost::shared_ptr _filedialogForWriters; boost::shared_ptr _firstReadSetProjectFormat; + boost::shared_ptr _convertNaNValues; + boost::shared_ptr _autoPreviewEnabledForNewProjects; boost::shared_ptr _fixPathsOnProjectPathChanged; + boost::shared_ptr _renderOnEditingFinished; + boost::shared_ptr _activateRGBSupport; + boost::shared_ptr _activateTransformConcatenationSupport; + + // User Interface + boost::shared_ptr _linearPickers; boost::shared_ptr _maxPanelsOpened; boost::shared_ptr _useCursorPositionIncrements; boost::shared_ptr _defaultLayoutFile; boost::shared_ptr _loadProjectsWorkspace; - boost::shared_ptr _renderOnEditingFinished; - boost::shared_ptr _activateRGBSupport; - boost::shared_ptr _activateTransformConcatenationSupport; - boost::shared_ptr _hostName; - boost::shared_ptr _customHostName; - - + boost::shared_ptr _ocioConfigKnob; boost::shared_ptr _warnOcioConfigKnobChanged; diff --git a/Engine/WriteNode.cpp b/Engine/WriteNode.cpp index d5e61199cc..81fa44d0e8 100644 --- a/Engine/WriteNode.cpp +++ b/Engine/WriteNode.cpp @@ -846,7 +846,10 @@ WriteNode::onEffectCreated(bool mayCreateFileDialog, const std::listsaveImageFileDialog(); + bool useDialogForWriters = appPTR->getCurrentSettings()->isFileDialogEnabledForNewWriters(); + if (useDialogForWriters) { + pattern = getApp()->saveImageFileDialog(); + } //The user selected a file, if it fails to read do not create the node throwErrors = true; diff --git a/Gui/Gui20.cpp b/Gui/Gui20.cpp index a38fd6be4b..8c7146ac75 100644 --- a/Gui/Gui20.cpp +++ b/Gui/Gui20.cpp @@ -1311,25 +1311,37 @@ Gui::createWriter() for (std::map::const_iterator it = writersForFormat.begin(); it != writersForFormat.end(); ++it) { filters.push_back(it->first); } - std::string file = popSaveFileDialog( true, filters, _imp->_lastSaveSequenceOpenedDir.toStdString(), true ); - if ( !file.empty() ) { - + + + std::string file; +#ifdef NATRON_ENABLE_IO_META_NODES + bool useDialogForWriters = appPTR->getCurrentSettings()->isFileDialogEnabledForNewWriters(); + if (useDialogForWriters) { + file = popSaveFileDialog( true, filters, _imp->_lastSaveSequenceOpenedDir.toStdString(), true ); + if (file.empty()) { + return NodePtr(); + } + } +#endif + + if (!file.empty()) { std::string patternCpy = file; std::string path = SequenceParsing::removePath(patternCpy); _imp->_lastSaveSequenceOpenedDir = QString::fromUtf8(path.c_str()); - - NodeGraph* graph = 0; - if (_imp->_lastFocusedGraph) { - graph = _imp->_lastFocusedGraph; - } else { - graph = _imp->_nodeGraphArea; - } - boost::shared_ptr group = graph->getGroup(); - assert(group); - - ret = getApp()->createWriter(file, eCreateNodeReasonUserCreate, group); } + NodeGraph* graph = 0; + if (_imp->_lastFocusedGraph) { + graph = _imp->_lastFocusedGraph; + } else { + graph = _imp->_nodeGraphArea; + } + boost::shared_ptr group = graph->getGroup(); + assert(group); + + ret = getApp()->createWriter(file, eCreateNodeReasonUserCreate, group); + + return ret; } From c1e76343b3069c3465577e7329a95d9bb85395ce Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 25 Mar 2016 17:41:48 +0100 Subject: [PATCH 07/30] Fix #1258 --- Engine/Bezier.cpp | 26 +++++++-------- Engine/BezierCP.cpp | 78 ++++++++++++++++++++++----------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Engine/Bezier.cpp b/Engine/Bezier.cpp index 9ae4730b98..41ef48fde2 100644 --- a/Engine/Bezier.cpp +++ b/Engine/Bezier.cpp @@ -2072,13 +2072,13 @@ 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) { @@ -2086,17 +2086,17 @@ 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); } } } - _imp->setMustCopyGuiBezier(true); + // _imp->setMustCopyGuiBezier(true); Q_EMIT keyframeSet(time); } diff --git a/Engine/BezierCP.cpp b/Engine/BezierCP.cpp index 57f24bb019..3607089a62 100644 --- a/Engine/BezierCP.cpp +++ b/Engine/BezierCP.cpp @@ -132,18 +132,18 @@ BezierCP::setPositionAtTime(bool useGuiCurves, k.setInterpolation(eKeyframeTypeLinear); if (!useGuiCurves) { _imp->curveX->addKeyFrame(k); - } else { - _imp->guiCurveX->addKeyFrame(k); } + _imp->guiCurveX->addKeyFrame(k); + } { KeyFrame k(time,y); k.setInterpolation(eKeyframeTypeLinear); if (!useGuiCurves) { _imp->curveY->addKeyFrame(k); - } else { - _imp->guiCurveY->addKeyFrame(k); } + _imp->guiCurveY->addKeyFrame(k); + } } @@ -156,10 +156,10 @@ BezierCP::setStaticPosition(bool useGuiCurves, if (!useGuiCurves) { _imp->x = x; _imp->y = y; - } else { - _imp->guiX = x; - _imp->guiY = y; } + _imp->guiX = x; + _imp->guiY = y; + } void @@ -171,10 +171,10 @@ BezierCP::setLeftBezierStaticPosition(bool useGuiCurves, if (!useGuiCurves) { _imp->leftX = x; _imp->leftY = y; - } else { - _imp->guiLeftX = x; - _imp->guiLeftY = y; } + _imp->guiLeftX = x; + _imp->guiLeftY = y; + } void @@ -186,10 +186,10 @@ BezierCP::setRightBezierStaticPosition(bool useGuiCurves, if (!useGuiCurves) { _imp->rightX = x; _imp->rightY = y; - } else { - _imp->guiRightX = x; - _imp->guiRightY = y; } + _imp->guiRightX = x; + _imp->guiRightY = y; + } bool @@ -351,18 +351,18 @@ BezierCP::setRightBezierPointAtTime(bool useGuiCurves, k.setInterpolation(eKeyframeTypeLinear); if (!useGuiCurves) { _imp->curveRightBezierX->addKeyFrame(k); - } else { - _imp->guiCurveRightBezierX->addKeyFrame(k); } + _imp->guiCurveRightBezierX->addKeyFrame(k); + } { KeyFrame k(time,y); k.setInterpolation(eKeyframeTypeLinear); if (!useGuiCurves) { _imp->curveRightBezierY->addKeyFrame(k); - } else { - _imp->guiCurveRightBezierY->addKeyFrame(k); } + _imp->guiCurveRightBezierY->addKeyFrame(k); + } } @@ -380,15 +380,15 @@ BezierCP::removeAnimation(bool useGuiCurves,double currentTime) _imp->leftY = _imp->curveLeftBezierY->getValueAt(currentTime); _imp->rightX = _imp->curveRightBezierX->getValueAt(currentTime); _imp->rightY = _imp->curveRightBezierY->getValueAt(currentTime); - } else { - _imp->guiX = _imp->guiCurveX->getValueAt(currentTime); - _imp->guiY = _imp->guiCurveY->getValueAt(currentTime); - _imp->guiLeftX = _imp->guiCurveLeftBezierX->getValueAt(currentTime); - _imp->guiLeftY = _imp->guiCurveLeftBezierY->getValueAt(currentTime); - _imp->guiRightX = _imp->guiCurveRightBezierX->getValueAt(currentTime); - _imp->guiRightY = _imp->guiCurveRightBezierY->getValueAt(currentTime); - } + _imp->guiX = _imp->guiCurveX->getValueAt(currentTime); + _imp->guiY = _imp->guiCurveY->getValueAt(currentTime); + _imp->guiLeftX = _imp->guiCurveLeftBezierX->getValueAt(currentTime); + _imp->guiLeftY = _imp->guiCurveLeftBezierY->getValueAt(currentTime); + _imp->guiRightX = _imp->guiCurveRightBezierX->getValueAt(currentTime); + _imp->guiRightY = _imp->guiCurveRightBezierY->getValueAt(currentTime); + + } catch (const std::exception & e) { // } @@ -426,14 +426,14 @@ BezierCP::removeKeyframe(bool useGuiCurves,double time) _imp->leftY = _imp->curveLeftBezierY->getValueAt(time); _imp->rightX = _imp->curveRightBezierX->getValueAt(time); _imp->rightY = _imp->curveRightBezierY->getValueAt(time); - } else { - _imp->guiX = _imp->guiCurveX->getValueAt(time); - _imp->guiY = _imp->guiCurveY->getValueAt(time); - _imp->guiLeftX = _imp->guiCurveLeftBezierX->getValueAt(time); - _imp->guiLeftY = _imp->guiCurveLeftBezierY->getValueAt(time); - _imp->guiRightX = _imp->guiCurveRightBezierX->getValueAt(time); - _imp->guiRightY = _imp->guiCurveRightBezierY->getValueAt(time); } + _imp->guiX = _imp->guiCurveX->getValueAt(time); + _imp->guiY = _imp->guiCurveY->getValueAt(time); + _imp->guiLeftX = _imp->guiCurveLeftBezierX->getValueAt(time); + _imp->guiLeftY = _imp->guiCurveLeftBezierY->getValueAt(time); + _imp->guiRightX = _imp->guiCurveRightBezierX->getValueAt(time); + _imp->guiRightY = _imp->guiCurveRightBezierY->getValueAt(time); + } try { @@ -444,14 +444,14 @@ BezierCP::removeKeyframe(bool useGuiCurves,double time) _imp->curveRightBezierX->removeKeyFrameWithTime(time); _imp->curveLeftBezierY->removeKeyFrameWithTime(time); _imp->curveRightBezierY->removeKeyFrameWithTime(time); - } else { - _imp->guiCurveX->removeKeyFrameWithTime(time); - _imp->guiCurveY->removeKeyFrameWithTime(time); - _imp->guiCurveLeftBezierX->removeKeyFrameWithTime(time); - _imp->guiCurveRightBezierX->removeKeyFrameWithTime(time); - _imp->guiCurveLeftBezierY->removeKeyFrameWithTime(time); - _imp->guiCurveRightBezierY->removeKeyFrameWithTime(time); } + _imp->guiCurveX->removeKeyFrameWithTime(time); + _imp->guiCurveY->removeKeyFrameWithTime(time); + _imp->guiCurveLeftBezierX->removeKeyFrameWithTime(time); + _imp->guiCurveRightBezierX->removeKeyFrameWithTime(time); + _imp->guiCurveLeftBezierY->removeKeyFrameWithTime(time); + _imp->guiCurveRightBezierY->removeKeyFrameWithTime(time); + } catch (...) { } } From 246269c4f9685b0aa77d6fa5e24ee03eeb7f77d9 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 25 Mar 2016 18:26:39 +0100 Subject: [PATCH 08/30] Small fix with expressions --- Engine/Knob.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Engine/Knob.cpp b/Engine/Knob.cpp index 04d344159c..bc2468ec34 100644 --- a/Engine/Knob.cpp +++ b/Engine/Knob.cpp @@ -2070,7 +2070,13 @@ KnobHelperPrivate::parseListenersFromExpression(int dimension) } std::string declarations = declarePythonVariables(false, dimension); - script = declarations + "\n" + expressionCopy + "\n" + script; + std::stringstream ss; + ss << "frame=0\n"; + ss << "view=0\n"; + ss << declarations << '\n'; + ss << expressionCopy << '\n'; + ss << script; + script = ss.str(); ///This will register the listeners std::string error; bool ok = Python::interpretPythonScript(script, &error,NULL); @@ -5274,7 +5280,6 @@ AnimatingKnobStringHelper::stringFromInterpolatedValue(double interpolated, std::string* returnValue) const { assert(!view.isAll()); - assert(!view.isCurrent()); // not yet implemented Q_UNUSED(view); _animation->stringFromInterpolatedIndex(interpolated, returnValue); } From 060c2da364cd4ce14e35437fa6dd5b9d223a7cc4 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 25 Mar 2016 18:51:25 +0100 Subject: [PATCH 09/30] isIdentity before getRoD --- Engine/ParallelRenderArgs.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Engine/ParallelRenderArgs.cpp b/Engine/ParallelRenderArgs.cpp index fa2afaec6e..1de71e404e 100644 --- a/Engine/ParallelRenderArgs.cpp +++ b/Engine/ParallelRenderArgs.cpp @@ -396,22 +396,15 @@ StatusEnum EffectInstance::getInputsRoIsFunctor(bool useTransforms, fvRequest = &nodeRequest->frames[frameView]; - ///Get the RoD - StatusEnum stat = effect->getRegionOfDefinition_public(nodeRequest->nodeHash, time, nodeRequest->mappedScale, view, &fvRequest->globalData.rod, &fvRequest->globalData.isProjectFormat); - //If failed it should have failed earlier - if (stat == eStatusFailed && !fvRequest->globalData.rod.isNull()) { - return stat; - } - ///Check identity fvRequest->globalData.identityInputNb = -1; fvRequest->globalData.inputIdentityTime = 0.; fvRequest->globalData.identityView = view; - RectI pixelRod; - fvRequest->globalData.rod.toPixelEnclosing(mappedLevel, par, &pixelRod); + RectI identityRegionPixel; + canonicalRenderWindow.toPixelEnclosing(mappedLevel, par, &identityRegionPixel); if (view != 0 && viewInvariance == eViewInvarianceAllViewsInvariant) { fvRequest->globalData.isIdentity = true; @@ -419,12 +412,27 @@ StatusEnum EffectInstance::getInputsRoIsFunctor(bool useTransforms, fvRequest->globalData.inputIdentityTime = time; } else { try { - fvRequest->globalData.isIdentity = effect->isIdentity_public(true, nodeRequest->nodeHash, time, nodeRequest->mappedScale, pixelRod, view, &fvRequest->globalData.inputIdentityTime, &fvRequest->globalData.identityView, &fvRequest->globalData.identityInputNb); + fvRequest->globalData.isIdentity = effect->isIdentity_public(true, nodeRequest->nodeHash, time, nodeRequest->mappedScale, identityRegionPixel, view, &fvRequest->globalData.inputIdentityTime, &fvRequest->globalData.identityView, &fvRequest->globalData.identityInputNb); } catch (...) { return eStatusFailed; } } + /* + Do NOT call getRegionOfDefinition on the identity time, if the plug-in returns an identity time different from + this time, we expect that it handles getRegionOfDefinition itself correctly. + */ + double rodTime = time;//fvRequest->globalData.isIdentity ? fvRequest->globalData.inputIdentityTime : time; + ViewIdx rodView = view;//fvRequest->globalData.isIdentity ? fvRequest->globalData.identityView : view; + + ///Get the RoD + StatusEnum stat = effect->getRegionOfDefinition_public(nodeRequest->nodeHash, rodTime, nodeRequest->mappedScale, rodView, &fvRequest->globalData.rod, &fvRequest->globalData.isProjectFormat); + //If failed it should have failed earlier + if (stat == eStatusFailed && !fvRequest->globalData.rod.isNull()) { + return stat; + } + + ///Concatenate transforms if needed if (useTransforms) { From 6b719326b934b57aa945575e1cdf774003398766 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Mon, 28 Mar 2016 16:06:27 +0200 Subject: [PATCH 10/30] Expressions are now persistant: whenever they are no longer valid, an error icon is displayed next to the parameter's label. --- Engine/AppInstance.cpp | 55 +++++++ Engine/AppInstance.h | 4 + Engine/EffectInstance.cpp | 4 +- Engine/EffectInstance.h | 2 +- Engine/Knob.cpp | 285 +++++++++++++++++++++++++---------- Engine/Knob.h | 80 +++++----- Engine/KnobFile.cpp | 8 +- Engine/KnobFile.h | 8 +- Engine/KnobImpl.h | 130 ++++++++++------ Engine/KnobTypes.cpp | 4 +- Engine/KnobTypes.h | 4 +- Engine/Node.cpp | 39 ++++- Engine/Node.h | 17 ++- Engine/PyParameter.cpp | 2 +- Engine/Settings.cpp | 2 +- Gui/AddKnobDialog.cpp | 4 +- Gui/DockablePanelPrivate.cpp | 19 ++- Gui/KnobGui.cpp | 10 +- Gui/KnobGui.h | 1 + Gui/KnobGui20.cpp | 43 +++++- Gui/KnobGuiPrivate.cpp | 1 + Gui/KnobGuiPrivate.h | 1 + Gui/KnobUndoCommand.cpp | 6 +- Gui/MultiInstancePanel.cpp | 4 +- Gui/NodeGraph30.cpp | 5 +- Gui/NodeGraphUndoRedo.cpp | 2 +- Gui/NodeGui.cpp | 80 ++++++++-- Gui/NodeGui.h | 25 ++- 28 files changed, 615 insertions(+), 230 deletions(-) diff --git a/Engine/AppInstance.cpp b/Engine/AppInstance.cpp index fcfa4ad1d5..637df94d12 100644 --- a/Engine/AppInstance.cpp +++ b/Engine/AppInstance.cpp @@ -124,6 +124,9 @@ struct AppInstancePrivate mutable QMutex renderQueueMutex; std::list renderQueue, activeRenders; + mutable QMutex invalidExprKnobsMutex; + std::list invalidExprKnobs; + AppInstancePrivate(int appID, AppInstance* app) : _publicInterface(app) @@ -136,6 +139,9 @@ struct AppInstancePrivate , _creatingTree(0) , renderQueueMutex() , renderQueue() + , activeRenders() + , invalidExprKnobsMutex() + , invalidExprKnobs() { } @@ -1905,6 +1911,55 @@ AppInstance::newProject() return app; } +void +AppInstance::addInvalidExpressionKnob(const KnobPtr& knob) +{ + QMutexLocker k(&_imp->invalidExprKnobsMutex); + for (std::list::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::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 knobs; + { + QMutexLocker k(&_imp->invalidExprKnobsMutex); + for (std::list::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) { + KnobPtr k = it->lock(); + if (k) { + knobs.push_back(k); + } + } + } + std::list newInvalidKnobs; + for (std::list::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; diff --git a/Engine/AppInstance.h b/Engine/AppInstance.h index b2bcb30e9d..ad270f5ed9 100644 --- a/Engine/AppInstance.h +++ b/Engine/AppInstance.h @@ -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() {} diff --git a/Engine/EffectInstance.cpp b/Engine/EffectInstance.cpp index e2d83c613e..9ff9bb1679 100644 --- a/Engine/EffectInstance.cpp +++ b/Engine/EffectInstance.cpp @@ -2905,8 +2905,8 @@ EffectInstance::onAllKnobsSlaved(bool isSlave, } void -EffectInstance::onKnobSlaved(KnobI* slave, - KnobI* master, +EffectInstance::onKnobSlaved(const KnobPtr& slave, + const KnobPtr& master, int dimension, bool isSlave) { diff --git a/Engine/EffectInstance.h b/Engine/EffectInstance.h index e67ac697d3..542c225bde 100644 --- a/Engine/EffectInstance.h +++ b/Engine/EffectInstance.h @@ -1944,7 +1944,7 @@ friend class ClipPreferencesRunning_RAII; virtual void onSignificantEvaluateAboutToBeCalled(KnobI* knob) OVERRIDE FINAL; virtual void onAllKnobsSlaved(bool isSlave, KnobHolder* master) OVERRIDE FINAL; - virtual void onKnobSlaved(KnobI* slave, KnobI* master, + virtual void onKnobSlaved(const KnobPtr& slave, const KnobPtr& master, int dimension, bool isSlave) OVERRIDE FINAL; enum RenderingFunctorRetEnum diff --git a/Engine/Knob.cpp b/Engine/Knob.cpp index bc2468ec34..1f41b6e149 100644 --- a/Engine/Knob.cpp +++ b/Engine/Knob.cpp @@ -206,7 +206,7 @@ KnobI::getTopLevelPage() /***********************************KNOB HELPER******************************************/ ///for each dimension, the dimension of the master this dimension is linked to, and a pointer to the master -typedef std::vector< std::pair< int,KnobPtr > > MastersMap; +typedef std::vector< std::pair< int,KnobWPtr > > MastersMap; ///a curve for each dimension typedef std::vector< boost::shared_ptr > CurvesMap; @@ -215,15 +215,15 @@ struct Expr { std::string expression; //< the one modified by Natron std::string originalExpression; //< the one input by the user - + std::string exprInvalid; bool hasRet; ///The list of pair dpendencies for an expression - std::list< std::pair > dependencies; + std::list< std::pair > dependencies; //PyObject* code; - Expr() : expression(), originalExpression(), hasRet(false) /*, code(0)*/{} + Expr() : expression(), originalExpression(), exprInvalid(), hasRet(false) /*, code(0)*/{} }; @@ -470,12 +470,16 @@ KnobHelper::deleteKnob() knob->setKnobAsAliasOfThis(aliasKnob, false); } for (int i = 0; i < knob->getDimension(); ++i) { - knob->clearExpression(i,true); + knob->setExpressionInvalid(i, false, getName() + QObject::tr(": parameter does not exist").toStdString()); knob->unSlave(i, false); } } + if (getHolder() && getHolder()->getApp()) { + getHolder()->getApp()->recheckInvalidExpressions(); + } + for (int i = 0; i < getDimension(); ++i) { clearExpression(i, true); } @@ -2212,8 +2216,107 @@ KnobHelper::validateExpression(const std::string& expression,int dimension,bool return funcExecScript; } +bool +KnobHelper::checkInvalidExpressions() +{ + int ndims = getDimension(); + std::vector > exprToReapply(ndims); + { + QMutexLocker k(&_imp->expressionMutex); + for (int i = 0; i < ndims; ++i) { + if (!_imp->expressions[i].exprInvalid.empty()) { + exprToReapply[i] = std::make_pair(_imp->expressions[i].originalExpression, _imp->expressions[i].hasRet); + } + } + } + bool isInvalid = false; + for (int i = 0; i < ndims; ++i) { + if (!exprToReapply[i].first.empty()) { + setExpressionInternal(i, exprToReapply[i].first, exprToReapply[i].second, true, false); + } + std::string err; + if (!isExpressionValid(i, &err)) { + isInvalid = true; + } + } + return !isInvalid; +} + +bool +KnobHelper::isExpressionValid(int dimension, std::string* error) const +{ + int ndims = getDimension(); + if (dimension < 0 || dimension >= ndims) { + return false; + } + { + QMutexLocker k(&_imp->expressionMutex); + if (error) { + *error = _imp->expressions[dimension].exprInvalid; + } + return _imp->expressions[dimension].exprInvalid.empty(); + } +} + +void +KnobHelper::setExpressionInvalid(int dimension, bool valid, const std::string& error) +{ + int ndims = getDimension(); + if (dimension < 0 || dimension >= ndims) { + return; + } + bool wasValid; + { + QMutexLocker k(&_imp->expressionMutex); + wasValid = _imp->expressions[dimension].exprInvalid.empty(); + _imp->expressions[dimension].exprInvalid = error; + } + if (getHolder() && getHolder()->getApp()) { + if (wasValid && !valid) { + bool haveOtherExprInvalid = false; + { + QMutexLocker k(&_imp->expressionMutex); + for (int i = 0; i < ndims; ++i) { + if (i != dimension) { + if (!_imp->expressions[dimension].exprInvalid.empty()) { + haveOtherExprInvalid = true; + break; + } + } + } + } + if (!haveOtherExprInvalid) { + getHolder()->getApp()->addInvalidExpressionKnob(boost::const_pointer_cast(shared_from_this())); + } + if (_signalSlotHandler) { + _signalSlotHandler->s_expressionChanged(dimension); + } + } else if (!wasValid && valid) { + bool haveOtherExprInvalid = false; + { + QMutexLocker k(&_imp->expressionMutex); + for (int i = 0; i < ndims; ++i) { + if (i != dimension) { + if (!_imp->expressions[dimension].exprInvalid.empty()) { + haveOtherExprInvalid = true; + break; + } + } + } + } + if (!haveOtherExprInvalid) { + getHolder()->getApp()->removeInvalidExpressionKnob(this); + } + if (_signalSlotHandler) { + _signalSlotHandler->s_expressionChanged(dimension); + } + } + } + +} + void -KnobHelper::setExpressionInternal(int dimension,const std::string& expression,bool hasRetVariable,bool clearResults) +KnobHelper::setExpressionInternal(int dimension,const std::string& expression,bool hasRetVariable,bool clearResults, bool failIfInvalid) { #ifdef NATRON_RUN_WITHOUT_PYTHON return; @@ -2230,7 +2333,18 @@ KnobHelper::setExpressionInternal(int dimension,const std::string& expression,bo } std::string exprResult; - std::string exprCpy = validateExpression(expression, dimension, hasRetVariable,&exprResult); + std::string exprCpy; + + std::string exprInvalid; + try { + exprCpy = validateExpression(expression, dimension, hasRetVariable,&exprResult); + } catch (const std::exception &e) { + exprInvalid = e.what(); + exprCpy = expression; + if (failIfInvalid) { + throw e; + } + } //Set internal fields @@ -2239,19 +2353,31 @@ KnobHelper::setExpressionInternal(int dimension,const std::string& expression,bo _imp->expressions[dimension].hasRet = hasRetVariable; _imp->expressions[dimension].expression = exprCpy; _imp->expressions[dimension].originalExpression = expression; + _imp->expressions[dimension].exprInvalid = exprInvalid; ///This may throw an exception upon failure //Python::compilePyScript(exprCpy, &_imp->expressions[dimension].code); } - - //Parse listeners of the expression, to keep track of dependencies to indicate them to the user. if (getHolder()) { - { + + + + //Parse listeners of the expression, to keep track of dependencies to indicate them to the user. + + if (exprInvalid.empty()) { + EXPR_RECURSION_LEVEL(); _imp->parseListenersFromExpression(dimension); + + } else { + AppInstance* app = getHolder()->getApp(); + if (app) { + app->addInvalidExpressionKnob(shared_from_this()); + } } } + //Notify the expr. has changed expressionChanged(dimension); @@ -2285,7 +2411,7 @@ KnobHelper::replaceNodeNameInExpression(int dimension, QString estr = QString::fromUtf8(hasExpr.c_str()); estr.replace(QString::fromUtf8(oldName.c_str()), QString::fromUtf8(newName.c_str())); hasExpr = estr.toStdString(); - setExpression(dimension, hasExpr, hasRetVar); + setExpression(dimension, hasExpr, hasRetVar, false); } catch (...) { } @@ -2302,7 +2428,7 @@ KnobHelper::isExpressionUsingRetVariable(int dimension) const } bool -KnobHelper::getExpressionDependencies(int dimension, std::list >& dependencies) const +KnobHelper::getExpressionDependencies(int dimension, std::list >& dependencies) const { QMutexLocker k(&_imp->expressionMutex); if (!_imp->expressions[dimension].expression.empty()) { @@ -2322,20 +2448,23 @@ KnobHelper::clearExpression(int dimension,bool clearResults) hadExpression = !_imp->expressions[dimension].originalExpression.empty(); _imp->expressions[dimension].expression.clear(); _imp->expressions[dimension].originalExpression.clear(); + _imp->expressions[dimension].exprInvalid.clear(); //Py_XDECREF(_imp->expressions[dimension].code); //< new ref //_imp->expressions[dimension].code = 0; } + KnobPtr thisShared = shared_from_this(); { - std::list > dependencies; + std::list > dependencies; { QWriteLocker kk(&_imp->mastersMutex); dependencies = _imp->expressions[dimension].dependencies; _imp->expressions[dimension].dependencies.clear(); } - for (std::list >::iterator it = dependencies.begin(); + for (std::list >::iterator it = dependencies.begin(); it != dependencies.end(); ++it) { - KnobHelper* other = dynamic_cast(it->first); + KnobPtr otherKnob = it->first.lock(); + KnobHelper* other = dynamic_cast(otherKnob.get()); assert(other); if (!other) { continue; @@ -2371,7 +2500,7 @@ KnobHelper::clearExpression(int dimension,bool clearResults) } if (getHolder()) { - getHolder()->onKnobSlaved(this, other,dimension,false ); + getHolder()->onKnobSlaved(thisShared, otherKnob,dimension,false ); } @@ -2404,10 +2533,35 @@ KnobHelper::expressionChanged(int dimension) computeHasModifications(); } -PyObject* +static bool catchErrors(PyObject* mainModule, std::string* error) { + if (PyErr_Occurred()) { + + PyErr_Print(); + ///Gui session, do stdout, stderr redirection + if (PyObject_HasAttrString(mainModule, "catchErr")) { + PyObject* errCatcher = PyObject_GetAttrString(mainModule,"catchErr"); //get our catchOutErr created above, new ref + PyObject *errorObj = 0; + if (errCatcher) { + errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref + assert(errorObj); + *error = Python::PY3String_asString(errorObj); + PyObject* unicode = PyUnicode_FromString(""); + PyObject_SetAttrString(errCatcher, "value", unicode); + Py_DECREF(errorObj); + Py_DECREF(errCatcher); + } + + } + return false; + } + return true; +} + +bool KnobHelper::executeExpression(double time, ViewIdx view, - int dimension) const + int dimension, + PyObject** ret, std::string* error) const { std::string expr; @@ -2427,43 +2581,20 @@ KnobHelper::executeExpression(double time, PyObject* v = PyRun_String(script.c_str(), Py_file_input, globalDict, 0); Py_XDECREF(v); + *ret = 0; - - if (PyErr_Occurred()) { -#ifdef DEBUG - PyErr_Print(); - ///Gui session, do stdout, stderr redirection - if (PyObject_HasAttrString(mainModule, "catchErr")) { - std::string error; - PyObject* errCatcher = PyObject_GetAttrString(mainModule,"catchErr"); //get our catchOutErr created above, new ref - PyObject *errorObj = 0; - if (errCatcher) { - errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref - assert(errorObj); - error = Python::PY3String_asString(errorObj); - PyObject* unicode = PyUnicode_FromString(""); - PyObject_SetAttrString(errCatcher, "value", unicode); - Py_DECREF(errorObj); - Py_DECREF(errCatcher); - qDebug() << "Expression dump:\n========================================================="; - qDebug() << expr.c_str(); - qDebug() << error.c_str(); - } - - } - -#endif - throw std::runtime_error("Failed to execute expression"); + if (!catchErrors(mainModule, error)) { + return false; } - PyObject *ret = PyObject_GetAttrString(mainModule,"ret"); //get our ret variable created above - - if (!ret || PyErr_Occurred()) { -#ifdef DEBUG - PyErr_Print(); -#endif - throw std::runtime_error("return value must be assigned to the \"ret\" variable"); + *ret = PyObject_GetAttrString(mainModule,"ret"); //get our ret variable created above + if (!*ret) { + *error = "Missing ret variable"; + return false; } - return ret; + if (!catchErrors(mainModule, error)) { + return false; + } + return true; } @@ -2870,7 +3001,7 @@ KnobHelper::slaveTo(int dimension, } { QWriteLocker l(&_imp->mastersMutex); - if (_imp->masters[dimension].second) { + if (_imp->masters[dimension].second.lock()) { return false; } _imp->ignoreMasterPersistence = ignoreMasterPersistence; @@ -2935,8 +3066,8 @@ std::pair KnobHelper::getMaster(int dimension) const { assert(dimension >= 0 && dimension < (int)_imp->masters.size()); QReadLocker l(&_imp->mastersMutex); - - return _imp->masters[dimension]; + std::pair ret = std::make_pair(_imp->masters[dimension].first, _imp->masters[dimension].second.lock()); + return ret; } void @@ -2954,15 +3085,9 @@ KnobHelper::isSlave(int dimension) const assert(dimension >= 0); QReadLocker l(&_imp->mastersMutex); - return bool(_imp->masters[dimension].second); + return bool(_imp->masters[dimension].second.lock()); } -std::vector< std::pair > KnobHelper::getMasters_mt_safe() const -{ - QReadLocker l(&_imp->mastersMutex); - - return _imp->masters; -} void KnobHelper::checkAnimationLevel(ViewSpec view, @@ -3268,7 +3393,7 @@ KnobHelper::cloneExpressions(KnobI* other,int dimension) std::string expr = other->getExpression(i); bool hasRet = other->isExpressionUsingRetVariable(i); if (!expr.empty()) { - setExpression(i, expr,hasRet); + setExpression(i, expr,hasRet, false); cloneExpressionsResults(other,i); } } @@ -3290,7 +3415,7 @@ KnobHelper::cloneExpressionsAndCheckIfChanged(KnobI* other,int dimension) std::string expr = other->getExpression(i); bool hasRet = other->isExpressionUsingRetVariable(i); if (!expr.empty() && (expr != _imp->expressions[i].originalExpression || hasRet != _imp->expressions[i].hasRet)) { - setExpression(i, expr,hasRet); + setExpression(i, expr,hasRet, false); cloneExpressionsResults(other,i); ret = true; } @@ -3315,13 +3440,13 @@ KnobHelper::addListener(const bool isExpression, if (!listenerIsHelper) { return; } - + KnobPtr thisShared = shared_from_this(); if (listenerIsHelper->_signalSlotHandler && _signalSlotHandler) { //Notify the holder one of its knob is now slaved if (listenerIsHelper->getHolder()) { - listenerIsHelper->getHolder()->onKnobSlaved(listenerIsHelper, this,listenerDimension,true ); + listenerIsHelper->getHolder()->onKnobSlaved(listener, thisShared,listenerDimension,true ); } } @@ -3346,7 +3471,7 @@ KnobHelper::addListener(const bool isExpression, if (isExpression) { QMutexLocker k(&listenerIsHelper->_imp->expressionMutex); assert(listenerDimension >= 0 && listenerDimension < listenerIsHelper->_imp->dimension); - listenerIsHelper->_imp->expressions[listenerDimension].dependencies.push_back(std::make_pair(this,listenedToDimension)); + listenerIsHelper->_imp->expressions[listenerDimension].dependencies.push_back(std::make_pair(thisShared,listenedToDimension)); } @@ -3697,7 +3822,7 @@ KnobHelper::createDuplicateOnNode(EffectInstance* effect, std::string script = ss.str(); for (int i = 0; i < getDimension(); ++i) { clearExpression(i, true); - setExpression(i, script, false); + setExpression(i, script, false, false); } } catch (...) { @@ -3797,14 +3922,17 @@ KnobHelper::getAliasMaster() const void KnobHelper::getAllExpressionDependenciesRecursive(std::set& nodes) const { - std::set deps; + std::set deps; { QMutexLocker k(&_imp->expressionMutex); for (int i = 0; i < _imp->dimension; ++i) { - for (std::list< std::pair >::const_iterator it = _imp->expressions[i].dependencies.begin(); + for (std::list< std::pair >::const_iterator it = _imp->expressions[i].dependencies.begin(); it != _imp->expressions[i].dependencies.end(); ++it) { + KnobPtr knob = it->first.lock(); + if (knob) { + deps.insert(knob); + } - deps.insert(it->first); } } @@ -3812,16 +3940,17 @@ KnobHelper::getAllExpressionDependenciesRecursive(std::set& nodes) con { QReadLocker k(&_imp->mastersMutex); for (int i = 0; i < _imp->dimension; ++i) { - if (_imp->masters[i].second) { - if (std::find(deps.begin(), deps.end(), _imp->masters[i].second.get()) == deps.end()) { - deps.insert(_imp->masters[i].second.get()); + KnobPtr master = _imp->masters[i].second.lock(); + if (master) { + if (std::find(deps.begin(), deps.end(), master) == deps.end()) { + deps.insert(master); } } } } - std::list knobsToInspectRecursive; - for (std::set::iterator it = deps.begin(); it!=deps.end(); ++it) { + std::list knobsToInspectRecursive; + for (std::set::iterator it = deps.begin(); it!=deps.end(); ++it) { EffectInstance* effect = dynamic_cast((*it)->getHolder()); if (effect) { NodePtr node = effect->getNode(); @@ -3834,7 +3963,7 @@ KnobHelper::getAllExpressionDependenciesRecursive(std::set& nodes) con } - for (std::list::iterator it = knobsToInspectRecursive.begin(); it!=knobsToInspectRecursive.end(); ++it) { + for (std::list::iterator it = knobsToInspectRecursive.begin(); it!=knobsToInspectRecursive.end(); ++it) { (*it)->getAllExpressionDependenciesRecursive(nodes); } } @@ -5300,7 +5429,7 @@ AnimatingKnobStringHelper::keyframeRemoved_virtual(int /*dimension*/, std::string AnimatingKnobStringHelper::getStringAtTime(double time, ViewSpec view, - int dimension) const + int dimension) { std::string ret; // assert(!view.isAll()); diff --git a/Engine/Knob.h b/Engine/Knob.h index 961d69e013..c9e67d2625 100644 --- a/Engine/Knob.h +++ b/Engine/Knob.h @@ -491,12 +491,12 @@ class KnobI * @brief Evaluates the curve at the given dimension and at the given time. This returns the value of the curve directly. * If the knob is holding a string, it will return the index. **/ - virtual double getRawCurveValueAt(double time, ViewSpec view, int dimension) const = 0; + virtual double getRawCurveValueAt(double time, ViewSpec view, int dimension) = 0; /** * @brief Same as getRawCurveValueAt, but first check if an expression is present. The expression should return a PoD. **/ - virtual double getValueAtWithExpression(double time, ViewSpec view, int dimension) const = 0; + virtual double getValueAtWithExpression(double time, ViewSpec view, int dimension) = 0; protected: @@ -579,16 +579,24 @@ class KnobI * just store it. This flag is used for serialisation, you should always pass false **/ protected: - virtual void setExpressionInternal(int dimension,const std::string& expression,bool hasRetVariable,bool clearResults) = 0; + virtual void setExpressionInternal(int dimension,const std::string& expression,bool hasRetVariable,bool clearResults, bool failIfInvalid) = 0; public: void restoreExpression(int dimension,const std::string& expression,bool hasRetVariable) { - setExpressionInternal(dimension, expression, hasRetVariable, false); + setExpressionInternal(dimension, expression, hasRetVariable, false, false); } - void setExpression(int dimension,const std::string& expression,bool hasRetVariable) { - setExpressionInternal(dimension, expression, hasRetVariable, true); + void setExpression(int dimension,const std::string& expression,bool hasRetVariable, bool failIfInvalid) { + setExpressionInternal(dimension, expression, hasRetVariable, true, failIfInvalid); } + /** + * @brief Tries to re-apply invalid expressions, returns true if they are all valid + **/ + virtual bool checkInvalidExpressions() = 0; + virtual bool isExpressionValid(int dimension, std::string* error) const = 0; + virtual void setExpressionInvalid(int dimension, bool valid, const std::string& error) = 0; + + /** * @brief For each dimension, try to find in the expression, if set, the node name "oldName" and replace * it by "newName" @@ -630,7 +638,7 @@ class KnobI * @brief Returns in dependencies a list of all the knobs used in the expression at the given dimension * @returns True on sucess, false if no expression is set. **/ - virtual bool getExpressionDependencies(int dimension, std::list >& dependencies) const = 0; + virtual bool getExpressionDependencies(int dimension, std::list >& dependencies) const = 0; /** @@ -650,12 +658,12 @@ class KnobI /** * @brief Compute the derivative at time as a double **/ - virtual double getDerivativeAtTime(double time, ViewSpec view, int dimension = 0) const = 0; + virtual double getDerivativeAtTime(double time, ViewSpec view, int dimension = 0) = 0; /** * @brief Compute the integral of dimension from time1 to time2 as a double **/ - virtual double getIntegrateFromTimeToTime(double time1, double time2, ViewSpec view, int dimension = 0) const = 0; + virtual double getIntegrateFromTimeToTime(double time1, double time2, ViewSpec view, int dimension = 0) = 0; /** * @brief Places in time the keyframe time at the given index. @@ -1072,12 +1080,6 @@ class KnobI **/ virtual bool isSlave(int dimension) const = 0; - /** - * @brief Same as getMaster but for all dimensions. - **/ - virtual std::vector > getMasters_mt_safe() const = 0; - - /** * @brief Get the current animation level. **/ @@ -1267,7 +1269,16 @@ class KnobHelper virtual boost::shared_ptr getCurve(ViewSpec view, int dimension,bool byPassMaster = false) const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual bool isAnimated(int dimension, ViewSpec view = ViewSpec::current()) const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual bool hasAnimation() const OVERRIDE FINAL WARN_UNUSED_RETURN; - virtual void setExpressionInternal(int dimension,const std::string& expression,bool hasRetVariable,bool clearResults) OVERRIDE FINAL; + virtual bool checkInvalidExpressions() OVERRIDE FINAL; + virtual bool isExpressionValid(int dimension, std::string* error) const OVERRIDE FINAL WARN_UNUSED_RETURN; + virtual void setExpressionInvalid(int dimension, bool valid, const std::string& error) OVERRIDE FINAL; + +protected: + + +public: + + virtual void setExpressionInternal(int dimension,const std::string& expression,bool hasRetVariable,bool clearResults, bool failIfInvalid) OVERRIDE FINAL; virtual void replaceNodeNameInExpression(int dimension, const std::string& oldName, const std::string& newName) OVERRIDE FINAL; @@ -1285,7 +1296,7 @@ class KnobHelper public: virtual bool isExpressionUsingRetVariable(int dimension = 0) const OVERRIDE FINAL WARN_UNUSED_RETURN; - virtual bool getExpressionDependencies(int dimension, std::list >& dependencies) const OVERRIDE FINAL; + virtual bool getExpressionDependencies(int dimension, std::list >& dependencies) const OVERRIDE FINAL; virtual std::string getExpression(int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual const std::vector< boost::shared_ptr > & getCurves() const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual void setAnimationEnabled(bool val) OVERRIDE FINAL; @@ -1388,13 +1399,12 @@ class KnobHelper void resetMaster(int dimension); ///The return value must be Py_DECRREF - PyObject* executeExpression(double time, ViewIdx view, int dimension) const; + bool executeExpression(double time, ViewIdx view, int dimension, PyObject** ret, std::string* error) const; public: virtual std::pair getMaster(int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual bool isSlave(int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN; - virtual std::vector > getMasters_mt_safe() const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual AnimationLevelEnum getAnimationLevel(int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN; virtual bool isTypeCompatible(const KnobPtr & other) const OVERRIDE WARN_UNUSED_RETURN = 0; @@ -1567,7 +1577,7 @@ class Knob * @brief Get the current value of the knob for the given dimension. * If it is animated, it will return the value at the current time. **/ - T getValue(int dimension = 0, ViewSpec view = ViewSpec::current(), bool clampToMinMax = true) const WARN_UNUSED_RETURN; + T getValue(int dimension = 0, ViewSpec view = ViewSpec::current(), bool clampToMinMax = true) WARN_UNUSED_RETURN; /** @@ -1577,10 +1587,10 @@ class Knob * This function is overloaded by the KnobString which can have its custom interpolation * but this should be the only knob which should ever need to overload it. **/ - T getValueAtTime(double time, int dimension = 0, ViewSpec view = ViewSpec::current(), bool clampToMinMax = true,bool byPassMaster = false) const WARN_UNUSED_RETURN; + T getValueAtTime(double time, int dimension = 0, ViewSpec view = ViewSpec::current(), bool clampToMinMax = true,bool byPassMaster = false) WARN_UNUSED_RETURN; - virtual double getRawCurveValueAt(double time, ViewSpec view, int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN; - virtual double getValueAtWithExpression(double time, ViewSpec view, int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN; + virtual double getRawCurveValueAt(double time, ViewSpec view, int dimension) OVERRIDE FINAL WARN_UNUSED_RETURN; + virtual double getValueAtWithExpression(double time, ViewSpec view, int dimension) OVERRIDE FINAL WARN_UNUSED_RETURN; private: @@ -1770,9 +1780,9 @@ class Knob virtual void onTimeChanged(bool isPlayback, double time) OVERRIDE FINAL; ///Cannot be overloaded by KnobHelper as it requires the value member - virtual double getDerivativeAtTime(double time, ViewSpec view, int dimension = 0) const OVERRIDE FINAL WARN_UNUSED_RETURN; - virtual double getIntegrateFromTimeToTime(double time1, double time2, ViewSpec view, int dimension = 0) const OVERRIDE FINAL WARN_UNUSED_RETURN; - double getIntegrateFromTimeToTimeSimpson(double time1, double time2, ViewSpec view, int dimension = 0) const; + virtual double getDerivativeAtTime(double time, ViewSpec view, int dimension = 0) OVERRIDE FINAL WARN_UNUSED_RETURN; + virtual double getIntegrateFromTimeToTime(double time1, double time2, ViewSpec view, int dimension = 0) OVERRIDE FINAL WARN_UNUSED_RETURN; + double getIntegrateFromTimeToTimeSimpson(double time1, double time2, ViewSpec view, int dimension = 0) ; ///Cannot be overloaded by KnobHelper as it requires setValue virtual void resetToDefaultValue(int dimension) OVERRIDE FINAL; @@ -1811,10 +1821,10 @@ class Knob map = _exprRes[dim]; } - T getValueFromMasterAt(double time, ViewSpec view, int dimension, KnobI* master) const; - T getValueFromMaster(ViewSpec view, int dimension, KnobI* master, bool clamp) const; + T getValueFromMasterAt(double time, ViewSpec view, int dimension, KnobI* master) ; + T getValueFromMaster(ViewSpec view, int dimension, KnobI* master, bool clamp) ; - bool getValueFromCurve(double time, ViewSpec view, int dimension, bool useGuiCurve, bool byPassMaster, bool clamp, T* ret) const; + bool getValueFromCurve(double time, ViewSpec view, int dimension, bool useGuiCurve, bool byPassMaster, bool clamp, T* ret) ; protected: @@ -1855,17 +1865,17 @@ class Knob private: - T evaluateExpression(double time, ViewIdx view, int dimension) const; + bool evaluateExpression(double time, ViewIdx view, int dimension, T* ret, std::string* error); /* * @brief Same as evaluateExpression but expects it to return a PoD */ - double evaluateExpression_pod(double time, ViewIdx view, int dimension) const; + bool evaluateExpression_pod(double time, ViewIdx view, int dimension, double* value, std::string* error); - bool getValueFromExpression(double time, ViewIdx view, int dimension,bool clamp,T* ret) const; + bool getValueFromExpression(double time, ViewIdx view, int dimension,bool clamp,T* ret); - bool getValueFromExpression_pod(double time, ViewIdx view, int dimension,bool clamp,double* ret) const; + bool getValueFromExpression_pod(double time, ViewIdx view, int dimension,bool clamp,double* ret); ////////////////////////////////////////////////////////////////////// /////////////////////////////////// End implementation of KnobI @@ -1956,7 +1966,7 @@ class AnimatingKnobStringHelper void stringFromInterpolatedValue(double interpolated, ViewSpec view, std::string* returnValue) const; - std::string getStringAtTime(double time, ViewSpec view, int dimension) const; + std::string getStringAtTime(double time, ViewSpec view, int dimension) ; protected: @@ -2394,7 +2404,7 @@ class KnobHolder : public QObject /** * @brief Same as onAllKnobsSlaved but called when only 1 knob is slaved **/ - virtual void onKnobSlaved(KnobI* /*slave*/,KnobI* /*master*/, + virtual void onKnobSlaved(const KnobPtr& /*slave*/,const KnobPtr& /*master*/, int /*dimension*/, bool /*isSlave*/) { diff --git a/Engine/KnobFile.cpp b/Engine/KnobFile.cpp index 13faaa92ca..efa56f55de 100644 --- a/Engine/KnobFile.cpp +++ b/Engine/KnobFile.cpp @@ -84,7 +84,7 @@ KnobFile::typeName() const std::string -KnobFile::getFileName(int time, ViewSpec view) const +KnobFile::getFileName(int time, ViewSpec view) { if (!_isInputImage) { return getValue(0, view); @@ -133,7 +133,7 @@ KnobOutputFile::typeName() const } QString -KnobOutputFile::generateFileNameAtTime(SequenceTime time, ViewSpec view) const +KnobOutputFile::generateFileNameAtTime(SequenceTime time, ViewSpec view) { std::vector views; if (getHolder() && getHolder()->getApp()) { @@ -202,7 +202,7 @@ KnobPath::getIsStringList() const } void -KnobPath::getVariables(std::list >* paths) const +KnobPath::getVariables(std::list >* paths) { if (!_isMultiPath) { return; @@ -250,7 +250,7 @@ KnobPath::getVariables(std::list >* paths) co void -KnobPath::getPaths(std::list *paths) const +KnobPath::getPaths(std::list *paths) { std::string raw = getValue().c_str(); diff --git a/Engine/KnobFile.h b/Engine/KnobFile.h index 330ed457c8..5e8112ecb6 100644 --- a/Engine/KnobFile.h +++ b/Engine/KnobFile.h @@ -91,7 +91,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON * @brief getRandomFrameName * @param f The index of the frame. */ - std::string getFileName(int time, ViewSpec view) const; + std::string getFileName(int time, ViewSpec view) ; Q_SIGNALS: @@ -161,7 +161,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON return _sequenceDialog; } - QString generateFileNameAtTime(SequenceTime time, ViewSpec view) const; + QString generateFileNameAtTime(SequenceTime time, ViewSpec view) ; Q_SIGNALS: @@ -215,10 +215,10 @@ class KnobPath bool isMultiPath() const; - void getPaths(std::list* paths) const; + void getPaths(std::list* paths) ; ///Doesn't work if isMultiPath() == false - void getVariables(std::list >* paths) const; + void getVariables(std::list >* paths) ; static std::string encodeToMultiPathFormat(const std::list >& paths); diff --git a/Engine/KnobImpl.h b/Engine/KnobImpl.h index d00459f255..89a72c96dc 100644 --- a/Engine/KnobImpl.h +++ b/Engine/KnobImpl.h @@ -388,55 +388,57 @@ inline unsigned int hashFunction(unsigned int a) } template -T +bool Knob::evaluateExpression(double time, ViewIdx view, - int dimension) const + int dimension, + T* value, + std::string* error) { + PythonGILLocker pgl; PyObject *ret; ///Reset the random state to reproduce the sequence randomSeed(time, hashFunction(dimension)); - try { - ret = executeExpression(time, view, dimension); - } catch (...) { - return T(); + bool exprOk = executeExpression(time, view, dimension, &ret, error); + if (!exprOk) { + return false; } - - T val = pyObjectToType(ret); + *value = pyObjectToType(ret); Py_DECREF(ret); //< new ref - return val; + return true; } template -double +bool Knob::evaluateExpression_pod(double time, ViewIdx view, - int dimension) const + int dimension, + double* value, + std::string* error) { PythonGILLocker pgl; PyObject *ret; ///Reset the random state to reproduce the sequence randomSeed(time, hashFunction(dimension)); - try { - ret = executeExpression(time, view, dimension); - } catch (...) { - return 0.; + bool exprOk = executeExpression(time, view, dimension, &ret, error); + if (!exprOk) { + return false; } if (PyFloat_Check(ret)) { - return (double)PyFloat_AsDouble(ret); + *value = (double)PyFloat_AsDouble(ret); } else if (PyLong_Check(ret)) { - return (int)PyInt_AsLong(ret); + *value = (int)PyInt_AsLong(ret); } else if (PyObject_IsTrue(ret) == 1) { - return 1; + *value = 1; } else { //Strings should always fall here - return 0.; + *value = 0.; } - + return true; } template @@ -445,17 +447,16 @@ Knob::getValueFromExpression(double time, ViewIdx view, int dimension, bool clamp, - T* ret) const + T* ret) { ///Prevent recursive call of the expression - - if (getExpressionRecursionLevel() > 0) { return false; } + ///Check first if a value was already computed: { @@ -467,10 +468,19 @@ Knob::getValueFromExpression(double time, } } - + bool exprWasValid = isExpressionValid(dimension, 0); { EXPR_RECURSION_LEVEL(); - *ret = evaluateExpression(time, view, dimension); + std::string error; + bool exprOk = evaluateExpression(time, view, dimension, ret, &error); + if (!exprOk) { + setExpressionInvalid(dimension, false, error); + return false; + } else { + if (!exprWasValid) { + setExpressionInvalid(dimension, true, error); + } + } } if (clamp) { @@ -489,7 +499,7 @@ Knob::getValueFromExpression_pod(double time, ViewIdx view, int dimension, bool /*clamp*/, - double* ret) const + double* ret) { ///Prevent recursive call of the expression @@ -498,9 +508,19 @@ Knob::getValueFromExpression_pod(double time, return false; } + bool exprWasValid = isExpressionValid(dimension, 0); { EXPR_RECURSION_LEVEL(); - *ret = evaluateExpression_pod(time, view, dimension); + std::string error; + bool exprOk = evaluateExpression_pod(time, view, dimension, ret, &error); + if (!exprOk) { + setExpressionInvalid(dimension, false, error); + return false; + } else { + if (!exprWasValid) { + setExpressionInvalid(dimension, true, error); + } + } } return true; @@ -513,7 +533,7 @@ Knob::getValueFromExpression_pod(double time, ViewIdx view, int dimension, bool clamp, - double* ret) const + double* ret) { ///Prevent recursive call of the expression @@ -534,9 +554,19 @@ Knob::getValueFromExpression_pod(double time, } + bool exprWasValid = isExpressionValid(dimension, 0); { EXPR_RECURSION_LEVEL(); - *ret = evaluateExpression_pod(time, view, dimension); + std::string error; + bool exprOk = evaluateExpression_pod(time, view, dimension, ret, &error); + if (!exprOk) { + setExpressionInvalid(dimension, false, error); + return false; + } else { + if (!exprWasValid) { + setExpressionInvalid(dimension, true, error); + } + } } if (clamp) { @@ -554,7 +584,7 @@ std::string Knob::getValueFromMasterAt(double time, ViewSpec view, int dimension, - KnobI* master) const + KnobI* master) { Knob* isString = dynamic_cast* >(master); assert(isString); //< other data types aren't supported @@ -570,7 +600,7 @@ std::string Knob::getValueFromMaster(ViewSpec view, int dimension, KnobI* master, - bool /*clamp*/) const + bool /*clamp*/) { Knob* isString = dynamic_cast* >(master); assert(isString); //< other data types aren't supported @@ -586,7 +616,7 @@ T Knob::getValueFromMasterAt(double time, ViewSpec view, int dimension, - KnobI* master) const + KnobI* master) { Knob* isInt = dynamic_cast* >(master); Knob* isBool = dynamic_cast* >(master); @@ -607,7 +637,7 @@ T Knob::getValueFromMaster(ViewSpec view, int dimension, KnobI* master, - bool clamp) const + bool clamp) { Knob* isInt = dynamic_cast* >(master); Knob* isBool = dynamic_cast* >(master); @@ -630,7 +660,7 @@ template T Knob::getValue(int dimension, ViewSpec view, - bool clamp) const + bool clamp) { assert(!view.isAll()); bool useGuiValues = QThread::currentThread() == qApp->thread(); @@ -683,7 +713,7 @@ Knob::getValueFromCurve(double time, bool useGuiCurve, bool byPassMaster, bool clamp, - T* ret) const + T* ret) { boost::shared_ptr curve; @@ -709,10 +739,10 @@ Knob::getValueFromCurve(double time, bool useGuiCurve, bool byPassMaster, bool /*clamp*/, - std::string* ret) const + std::string* ret) { - const AnimatingKnobStringHelper* isStringAnimated = dynamic_cast(this); + AnimatingKnobStringHelper* isStringAnimated = dynamic_cast(this); if (isStringAnimated) { *ret = isStringAnimated->getStringAtTime(time,view, dimension); ///ret is not empty if the animated string knob has a custom interpolation @@ -745,7 +775,7 @@ Knob::getValueAtTime(double time, int dimension, ViewSpec view, bool clamp, - bool byPassMaster) const + bool byPassMaster) { assert(!view.isAll()); if (dimension >= (int)_values.size() || dimension < 0) { @@ -792,7 +822,7 @@ template <> double Knob::getRawCurveValueAt(double time, ViewSpec view, - int dimension) const + int dimension) { boost::shared_ptr curve = getCurve(view, dimension,true); if (curve && curve->getKeyFramesCount() > 0) { @@ -806,7 +836,7 @@ template double Knob::getRawCurveValueAt(double time, ViewSpec view, - int dimension) const + int dimension) { boost::shared_ptr curve = getCurve(view, dimension,true); if (curve && curve->getKeyFramesCount() > 0) { @@ -822,10 +852,12 @@ template double Knob::getValueAtWithExpression(double time, ViewSpec view, - int dimension) const + int dimension) { + bool exprValid = isExpressionValid(dimension, 0); + std::string expr = getExpression(dimension); - if (!expr.empty()) { + if (!expr.empty() && exprValid) { double ret; if (getValueFromExpression_pod(time, /*view*/ ViewIdx(0), dimension,false, &ret)) { return ret; @@ -1595,7 +1627,7 @@ Knob::unSlave(int dimension, } } if (getHolder() && _signalSlotHandler) { - getHolder()->onKnobSlaved( this, master.second.get(),dimension,false ); + getHolder()->onKnobSlaved( shared_from_this(), master.second,dimension,false ); } if (masterHelper) { masterHelper->removeListener(this, dimension); @@ -1965,7 +1997,7 @@ template double Knob::getDerivativeAtTime(double time, ViewSpec view, - int dimension) const + int dimension) { if ( ( dimension > getDimension() ) || (dimension < 0) ) { throw std::invalid_argument("Knob::getDerivativeAtTime(): Dimension out of range"); @@ -1997,7 +2029,7 @@ template<> double Knob::getDerivativeAtTime(double /*time*/, ViewSpec /*view*/, - int /*dimension*/) const + int /*dimension*/) { throw std::invalid_argument("Knob::getDerivativeAtTime() not available"); } @@ -2009,7 +2041,7 @@ double Knob::getIntegrateFromTimeToTimeSimpson(double time1, double time2, ViewSpec view, - int dimension) const + int dimension) { double fa = getValueAtTime(time1, dimension, view); double fm = getValueAtTime((time1+time2)/2, dimension, view); @@ -2022,7 +2054,7 @@ double Knob::getIntegrateFromTimeToTime(double time1, double time2, ViewSpec view, - int dimension) const + int dimension) { if ( ( dimension > getDimension() ) || (dimension < 0) ) { throw std::invalid_argument("Knob::getIntegrateFromTimeToTime(): Dimension out of range"); @@ -2082,7 +2114,7 @@ double Knob::getIntegrateFromTimeToTimeSimpson(double /*time1*/, double /*time2*/, ViewSpec /*view*/, - int /*dimension*/) const + int /*dimension*/) { return 0; // dummy value } @@ -2092,7 +2124,7 @@ double Knob::getIntegrateFromTimeToTime(double /*time1*/, double /*time2*/, ViewSpec /*view*/, - int /*dimension*/) const + int /*dimension*/) { throw std::invalid_argument("Knob::getIntegrateFromTimeToTime() not available"); } diff --git a/Engine/KnobTypes.cpp b/Engine/KnobTypes.cpp index 1abb7f84e5..57ede30fce 100644 --- a/Engine/KnobTypes.cpp +++ b/Engine/KnobTypes.cpp @@ -729,7 +729,7 @@ KnobChoice::getEntriesHelp_mt_safe() const } std::string -KnobChoice::getActiveEntryText_mt_safe() const +KnobChoice::getActiveEntryText_mt_safe() { int activeIndex = getValue(); @@ -1074,7 +1074,7 @@ KnobString::typeName() const } bool -KnobString::hasContentWithoutHtmlTags() const +KnobString::hasContentWithoutHtmlTags() { std::string str = getValue(); if (str.empty()) { diff --git a/Engine/KnobTypes.h b/Engine/KnobTypes.h index bd00026c77..b757b1b585 100644 --- a/Engine/KnobTypes.h +++ b/Engine/KnobTypes.h @@ -426,7 +426,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON std::vector getEntries_mt_safe() const; const std::string& getEntry(int v) const; std::vector getEntriesHelp_mt_safe() const; - std::string getActiveEntryText_mt_safe() const; + std::string getActiveEntryText_mt_safe() ; int getNumEntries() const; @@ -696,7 +696,7 @@ class KnobString * @brief Relevant for multi-lines with rich text enables. It tells if * the string has content without the html tags **/ - bool hasContentWithoutHtmlTags() const; + bool hasContentWithoutHtmlTags() ; private: diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 4ac551707a..fa2fd6e748 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -4772,6 +4772,8 @@ Node::connectInput(const NodePtr & input, input->connectOutput(useGuiInputs,shared_from_this()); } + getApp()->recheckInvalidExpressions(); + ///Get notified when the input name has changed QObject::connect( input.get(), SIGNAL(labelChanged(QString)), this, SLOT(onInputLabelChanged(QString)) ); @@ -5301,9 +5303,10 @@ Node::deactivate(const std::list< NodePtr > & outputsToDisconnect, clearPersistentMessage(false); boost::shared_ptr parentCol = getGroup(); - NodeGroup* isParentGroup = dynamic_cast(parentCol.get()); - ///For all knobs that have listeners, kill expressions + + ///For all knobs that have listeners, invalidate expressions + NodeGroup* isParentGroup = dynamic_cast(parentCol.get()); const KnobsVec & knobs = getKnobs(); for (U32 i = 0; i < knobs.size(); ++i) { KnobI::ListenerDimsMap listeners; @@ -5342,12 +5345,18 @@ Node::deactivate(const std::list< NodePtr > & outputsToDisconnect, std::string hasExpr = listener->getExpression(dim); if (!hasExpr.empty()) { - listener->clearExpression(dim,true); + std::stringstream ss; + ss << tr("Missing node ").toStdString(); + ss << getFullyQualifiedName(); + ss << ' '; + ss << tr("in expression.").toStdString(); + listener->setExpressionInvalid(dim, false, ss.str()); } } isEffect->endChanges(true); } } + ///if the node has 1 non-optional input, attempt to connect the outputs to the input of the current node ///this node is the node the outputs should attempt to connect to @@ -5504,6 +5513,8 @@ Node::deactivate(const std::list< NodePtr > & outputsToDisconnect, _imp->runOnNodeDeleteCB(); } + deleteNodeVariableToPython(getFullyQualifiedName()); + } // deactivate void @@ -5596,6 +5607,9 @@ Node::activate(const std::list< NodePtr > & outputsToRestore, } _imp->runOnNodeCreatedCB(true); + + getApp()->recheckInvalidExpressions(); + declareAllPythonAttributes(); } // activate void @@ -5646,6 +5660,8 @@ Node::destroyNodeInternal(bool fromDest, bool autoReconnect) ///This will not remove from the disk cache if the project is closing removeAllImagesFromCache(false); + getApp()->recheckInvalidExpressions(); + ///Remove the Python node deleteNodeVariableToPython(getFullyQualifiedName()); @@ -6541,7 +6557,7 @@ Node::onAllKnobsSlaved(bool isSlave, } void -Node::onKnobSlaved(KnobI* slave,KnobI* master, +Node::onKnobSlaved(const KnobPtr& slave,const KnobPtr& master, int dimension, bool isSlave) { @@ -7007,7 +7023,7 @@ Node::duringInputChangedAction() const } void -Node::computeFrameRangeForReader(const KnobI* fileKnob) +Node::computeFrameRangeForReader(KnobI* fileKnob) { /* We compute the original frame range of the sequence for the plug-in @@ -7034,7 +7050,7 @@ Node::computeFrameRangeForReader(const KnobI* fileKnob) KnobInt* originalFrameRange = dynamic_cast(knob.get()); if (originalFrameRange && originalFrameRange->getDimension() == 2) { - const KnobFile* isFile = dynamic_cast(fileKnob); + KnobFile* isFile = dynamic_cast(fileKnob); assert(isFile); if (!isFile) { throw std::logic_error("Node::computeFrameRangeForReader"); @@ -9311,7 +9327,16 @@ Node::removeParameterFromPython(const std::string& parameterName) } } - +void +Node::declareAllPythonAttributes() +{ + declareNodeVariableToPython(getFullyQualifiedName()); + declarePythonFields(); + if (_imp->rotoContext) { + declareRotoPythonField(); + } +#pragma message WARN("Also declare tracker ctx to python in 2.1") +} std::string Node::getKnobChangedCallback() const diff --git a/Engine/Node.h b/Engine/Node.h index e5239f1257..0b6ebcea4d 100644 --- a/Engine/Node.h +++ b/Engine/Node.h @@ -813,7 +813,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void onAllKnobsSlaved(bool isSlave,KnobHolder* master); - void onKnobSlaved(KnobI* slave,KnobI* master,int dimension,bool isSlave); + void onKnobSlaved(const KnobPtr& slave,const KnobPtr& master,int dimension,bool isSlave); NodePtr getMasterNode() const; @@ -915,8 +915,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON struct KnobLink { ///The knob being slaved - KnobI* slave; - KnobI* master; + KnobWPtr slave; + KnobWPtr master; ///The master node to which the knob is slaved to NodeWPtr masterNode; @@ -1013,7 +1013,14 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON * @brief Declares to Python all parameters as attribute of the variable representing this node. **/ void declarePythonFields(); - + +private: + /** + * @brief Declares to Python all parameters, roto, tracking attributes + * This is called in activate() whenever the node was deleted + **/ + void declareAllPythonAttributes(); +public: /** * @brief Set the node name. * Throws a run-time error with the message in case of error @@ -1051,7 +1058,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON std::string getAfterNodeCreatedCallback() const; std::string getBeforeNodeRemovalCallback() const; - void computeFrameRangeForReader(const KnobI* fileKnob); + void computeFrameRangeForReader(KnobI* fileKnob); bool getOverlayColor(double* r,double* g,double* b) const; diff --git a/Engine/PyParameter.cpp b/Engine/PyParameter.cpp index 4202e20ea9..649c200b0d 100644 --- a/Engine/PyParameter.cpp +++ b/Engine/PyParameter.cpp @@ -418,7 +418,7 @@ bool AnimatedParam::setExpression(const std::string& expr,bool hasRetVariable,int dimension) { try { - _knob.lock()->setExpression(dimension,expr,hasRetVariable); + _knob.lock()->setExpression(dimension,expr,hasRetVariable, true); } catch (...) { return false; } diff --git a/Engine/Settings.cpp b/Engine/Settings.cpp index e156677d36..b87053a5d5 100644 --- a/Engine/Settings.cpp +++ b/Engine/Settings.cpp @@ -142,7 +142,7 @@ Settings::initializeKnobsGeneral() _enableCrashReports = AppManager::createKnob(this, "Enable crash reporting"); _enableCrashReports->setName("enableCrashReports"); _enableCrashReports->setAnimationEnabled(false); - _enableCrashReports->setHintToolTip("When checked, if " NATRON_APPLICATION_NAME "crashes a window will pop-up asking you " + _enableCrashReports->setHintToolTip("When checked, if " NATRON_APPLICATION_NAME " crashes a window will pop-up asking you " "whether you want to upload the crash dump to the developers or not. " "This can help them track down the bug.\n" "If you need to turn the crash reporting system off, uncheck this.\n" diff --git a/Gui/AddKnobDialog.cpp b/Gui/AddKnobDialog.cpp index f49e3ce686..6fccb391f7 100644 --- a/Gui/AddKnobDialog.cpp +++ b/Gui/AddKnobDialog.cpp @@ -1809,7 +1809,7 @@ AddKnobDialog::onOkClicked() try { for (std::size_t i = 0 ; i < expressions.size(); ++i) { if (!expressions[i].first.empty()) { - _imp->knob->setExpression(i, expressions[i].first, expressions[i].second); + _imp->knob->setExpression(i, expressions[i].first, expressions[i].second, false); } } } catch (...) { @@ -1933,7 +1933,7 @@ AddKnobDialog::onOkClicked() } else { expr = it->second[i].first; } - it->first->setExpression(i, expr, it->second[i].second); + it->first->setExpression(i, expr, it->second[i].second, false); } catch (...) { } diff --git a/Gui/DockablePanelPrivate.cpp b/Gui/DockablePanelPrivate.cpp index 4c5a726dab..9823825400 100644 --- a/Gui/DockablePanelPrivate.cpp +++ b/Gui/DockablePanelPrivate.cpp @@ -605,7 +605,7 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, ///Create the label if needed KnobClickableLabel* label = 0; - + Label* exprLabelWarn = 0; std::string descriptionLabel; KnobString* isStringKnob = dynamic_cast(knob.get()); bool isLabelKnob = isStringKnob && isStringKnob->isLabel(); @@ -629,17 +629,25 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, } label = new KnobClickableLabel(QString(), ret, page->second.tab); + exprLabelWarn = new Label(page->second.tab); + exprLabelWarn->setToolTip(QObject::tr("Expression invalid, value returned is the underlying curve.")); + exprLabelWarn->setVisible(false); + QFontMetrics fm(label->font(),0); + int pixSize = fm.height(); + QPixmap stdErrorPix; + stdErrorPix = getStandardIcon(QMessageBox::Critical, pixSize, label); + exprLabelWarn->setPixmap(stdErrorPix); + bool pixmapSet = false; if (!labelIconFilePath.empty()) { QPixmap pix; - QFontMetrics fm(label->font(),0); - int pixSize = fm.height(); + if (labelIconFilePath == "dialog-warning") { pix = getStandardIcon(QMessageBox::Warning, pixSize, label); } else if (labelIconFilePath == "dialog-question") { pix = getStandardIcon(QMessageBox::Question, pixSize, label); } else if (labelIconFilePath == "dialog-error") { - pix = getStandardIcon(QMessageBox::Critical, pixSize, label); + pix = stdErrorPix; } else if (labelIconFilePath == "dialog-information") { pix = getStandardIcon(QMessageBox::Information, pixSize, label); } else { @@ -665,6 +673,7 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, if (makeNewLine) { + labelLayout->addWidget(exprLabelWarn); labelLayout->addWidget(label); } @@ -724,7 +733,7 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, } ///fill the fieldLayout with the widgets - ret->createGUI(layout,fieldContainer, labelContainer, label,fieldLayout,makeNewLine,knobsOnSameLine); + ret->createGUI(layout,fieldContainer, labelContainer, label, exprLabelWarn, fieldLayout,makeNewLine,knobsOnSameLine); ret->setEnabledSlot(); diff --git a/Gui/KnobGui.cpp b/Gui/KnobGui.cpp index dd8c4b962a..a1031ea22c 100644 --- a/Gui/KnobGui.cpp +++ b/Gui/KnobGui.cpp @@ -170,6 +170,7 @@ KnobGui::createGUI(QGridLayout* containerLayout, QWidget* fieldContainer, QWidget* labelContainer, KnobClickableLabel* label, + Label* expressinoLabelWarning, QHBoxLayout* layout, bool isOnNewLine, const std::vector< boost::shared_ptr< KnobI > > & knobsOnSameLine) @@ -185,11 +186,13 @@ KnobGui::createGUI(QGridLayout* containerLayout, _imp->field = fieldContainer; _imp->labelContainer = labelContainer; _imp->descriptionLabel = label; + _imp->expressionWarningLabel = expressinoLabelWarning; _imp->isOnNewLine = isOnNewLine; if (!isOnNewLine) { //layout->addStretch(); layout->addSpacing(TO_DPIX(15)); if (label) { + layout->addWidget(_imp->expressionWarningLabel); layout->addWidget(label); } } @@ -213,12 +216,15 @@ KnobGui::createGUI(QGridLayout* containerLayout, _imp->widgetCreated = true; for (int i = 0; i < knob->getDimension(); ++i) { - updateGuiInternal(i); + + onExprChanged(i); + + /*updateGuiInternal(i); std::string exp = knob->getExpression(i); reflectExpressionState(i,!exp.empty()); if (exp.empty()) { onAnimationLevelChanged(ViewSpec::all(), i); - } + }*/ } } diff --git a/Gui/KnobGui.h b/Gui/KnobGui.h index e3bb272e45..87b8b5792c 100644 --- a/Gui/KnobGui.h +++ b/Gui/KnobGui.h @@ -117,6 +117,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON QWidget* fieldContainer, QWidget* labelContainer, KnobClickableLabel* label, + Label* expressinoLabelWarning, QHBoxLayout* layout, bool isOnNewLine, const std::vector< boost::shared_ptr< KnobI > > & knobsOnSameLine); diff --git a/Gui/KnobGui20.cpp b/Gui/KnobGui20.cpp index 1414381f5c..b38dcf146b 100644 --- a/Gui/KnobGui20.cpp +++ b/Gui/KnobGui20.cpp @@ -316,7 +316,7 @@ KnobGui::linkTo(int dimension) thisKnob->beginChanges(); for (int i = 0; i < thisKnob->getDimension(); ++i) { if (i == dimension || dimension == -1) { - thisKnob->setExpression(i, expr.str(), false); + thisKnob->setExpression(i, expr.str(), false, false); } } thisKnob->endChanges(); @@ -711,14 +711,47 @@ KnobGui::onExprChanged(int dimension) reflectExpressionState(dimension,!exp.empty()); if (exp.empty()) { reflectAnimationLevel(dimension, knob->getAnimationLevel(dimension)); + } else { + + NodeSettingsPanel* isNodeSettings = dynamic_cast(_imp->container); + if (isNodeSettings) { + NodeGuiPtr node = isNodeSettings->getNode(); + if (node) { + node->onKnobExpressionChanged(this); + } + } + + if (_imp->expressionWarningLabel) { + bool invalid = false; + QString fullErrTooltip; + int dims = knob->getDimension(); + for (int i = 0; i < dims; ++i) { + std::string err; + if (!knob->isExpressionValid(i, &err)) { + invalid = true; + } + if (dims > 1 && invalid) { + fullErrTooltip += QString::fromUtf8("

"); + fullErrTooltip += QString::fromUtf8(knob->getDimensionName(i).c_str()); + fullErrTooltip += QString::fromUtf8("

"); + } + if (!err.empty()) { + fullErrTooltip += QString::fromUtf8(err.c_str()); + } + } + if (invalid) { + _imp->expressionWarningLabel->show(); + _imp->expressionWarningLabel->setToolTip(fullErrTooltip); + } else { + _imp->expressionWarningLabel->hide(); + } + } + onHelpChanged(); + Q_EMIT expressionChanged(); } - - onHelpChanged(); - updateGUI(dimension); - Q_EMIT expressionChanged(); } void diff --git a/Gui/KnobGuiPrivate.cpp b/Gui/KnobGuiPrivate.cpp index 24ff48ce85..b2801c6dc8 100644 --- a/Gui/KnobGuiPrivate.cpp +++ b/Gui/KnobGuiPrivate.cpp @@ -41,6 +41,7 @@ KnobGuiPrivate::KnobGuiPrivate(DockablePanel* container) , field(NULL) , labelContainer(NULL) , descriptionLabel(NULL) +, expressionWarningLabel(NULL) , isOnNewLine(false) , customInteract(NULL) , guiCurves() diff --git a/Gui/KnobGuiPrivate.h b/Gui/KnobGuiPrivate.h index 40dde44ea0..e0cd441753 100644 --- a/Gui/KnobGuiPrivate.h +++ b/Gui/KnobGuiPrivate.h @@ -117,6 +117,7 @@ struct KnobGuiPrivate QWidget* field; QWidget* labelContainer; KnobClickableLabel* descriptionLabel; + Label* expressionWarningLabel; bool isOnNewLine; CustomParamInteract* customInteract; diff --git a/Gui/KnobUndoCommand.cpp b/Gui/KnobUndoCommand.cpp index f8f2fda1a3..221d94824b 100644 --- a/Gui/KnobUndoCommand.cpp +++ b/Gui/KnobUndoCommand.cpp @@ -683,7 +683,7 @@ SetExpressionCommand::undo() { for (int i = 0; i < _knob->getDimension(); ++i) { try { - _knob->setExpression(i, _oldExprs[i], _hadRetVar[i]); + _knob->setExpression(i, _oldExprs[i], _hadRetVar[i], false); } catch (...) { Dialogs::errorDialog(QObject::tr("Expression").toStdString(), QObject::tr("The expression is invalid").toStdString()); break; @@ -700,7 +700,7 @@ SetExpressionCommand::redo() if (_dimension == -1) { for (int i = 0; i < _knob->getDimension(); ++i) { try { - _knob->setExpression(i, _newExpr, _hasRetVar); + _knob->setExpression(i, _newExpr, _hasRetVar, false); } catch (...) { Dialogs::errorDialog(QObject::tr("Expression").toStdString(), QObject::tr("The expression is invalid").toStdString()); break; @@ -708,7 +708,7 @@ SetExpressionCommand::redo() } } else { try { - _knob->setExpression(_dimension, _newExpr, _hasRetVar); + _knob->setExpression(_dimension, _newExpr, _hasRetVar, false); } catch (...) { Dialogs::errorDialog(QObject::tr("Expression").toStdString(), QObject::tr("The expression is invalid").toStdString()); } diff --git a/Gui/MultiInstancePanel.cpp b/Gui/MultiInstancePanel.cpp index f8836604b8..d9bd94602d 100644 --- a/Gui/MultiInstancePanel.cpp +++ b/Gui/MultiInstancePanel.cpp @@ -2371,8 +2371,8 @@ TrackerPanelPrivate::createCornerPinFromSelection(const std::list & selec std::stringstream ss; ss << "thisGroup." << effect->getNode()->getFullyQualifiedName() << "." << centers[i]->getName() << ".get()[dimension]"; std::string expr = ss.str(); - dynamic_cast(toPoints[i].get())->setExpression(0, expr, false); - dynamic_cast(toPoints[i].get())->setExpression(1, expr, false); + dynamic_cast(toPoints[i].get())->setExpression(0, expr, false, false); + dynamic_cast(toPoints[i].get())->setExpression(1, expr, false, false); } } } diff --git a/Gui/NodeGraph30.cpp b/Gui/NodeGraph30.cpp index 68c56b45a9..b3a2836614 100644 --- a/Gui/NodeGraph30.cpp +++ b/Gui/NodeGraph30.cpp @@ -334,9 +334,8 @@ NodeGraph::deleteSelection() "parameters from which other parameters " "of the project rely on through expressions " "or links. Deleting this node will " - "remove these expressions. " - ". Undoing the action will not recover " - "them. \nContinue anyway ?") + "may break these expressions." + "\nContinue anyway ?") .toStdString(), false ); if (reply == eStandardButtonNo) { return; diff --git a/Gui/NodeGraphUndoRedo.cpp b/Gui/NodeGraphUndoRedo.cpp index f07dc5f8ea..14e15bb72b 100644 --- a/Gui/NodeGraphUndoRedo.cpp +++ b/Gui/NodeGraphUndoRedo.cpp @@ -197,7 +197,7 @@ AddMultipleNodesCommand::redo() _graph->setSelection(nodes); } - + _graph->getGui()->getApp()->recheckInvalidExpressions(); _graph->getGui()->getApp()->triggerAutoSave(); for (std::list::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { diff --git a/Gui/NodeGui.cpp b/Gui/NodeGui.cpp index 133c823bae..1d3152ee38 100644 --- a/Gui/NodeGui.cpp +++ b/Gui/NodeGui.cpp @@ -2373,6 +2373,47 @@ static QString makeLinkString(Node* masterNode,KnobI* master,Node* slaveNode,Kno return tt; } +void +NodeGui::onKnobExpressionChanged(const KnobGui* knob) +{ + KnobPtr internalKnob = knob->getKnob(); + + for (KnobGuiLinks::iterator it = _knobsLinks.begin(); it != _knobsLinks.end(); ++it) { + + int totalLinks = 0; + int totalInvalid = 0; + + bool isCurrentLink = false; + + for (std::list::iterator it2 = it->second.knobs.begin(); it2 != it->second.knobs.end(); ++it2) { + KnobPtr slave = it2->slave.lock(); + if (slave == internalKnob) { + isCurrentLink = true; + } + int ndims = slave->getDimension(); + int invalid = 0; + for (int i = 0; i < ndims; ++i) { + if (!slave->getExpression(i).empty() && !slave->isExpressionValid(i, 0)) { + ++invalid; + } + } + totalLinks += it2->dimensions.size(); + totalInvalid += invalid; + + it2->linkInValid = invalid; + + } + if (isCurrentLink) { + if (totalLinks > 0) { + it->second.arrow->setVisible(totalLinks > totalInvalid); + } + break; + } + } + + +} + void NodeGui::onKnobsLinksChanged() { @@ -2410,26 +2451,30 @@ NodeGui::onKnobsLinksChanged() KnobGuiLinks::iterator foundGuiLink = masterNode ? _knobsLinks.find(it->masterNode) : _knobsLinks.end(); if (foundGuiLink != _knobsLinks.end()) { - - //We already have a link to the master node - bool found = false; + std::list::iterator found = foundGuiLink->second.knobs.end(); - for (std::list >::iterator it2 = foundGuiLink->second.knobs.begin(); it2 != foundGuiLink->second.knobs.end(); ++it2) { - if (it2->first == it->slave && it2->second == it->master) { - found = true; + for (std::list::iterator it2 = foundGuiLink->second.knobs.begin(); it2 != foundGuiLink->second.knobs.end(); ++it2) { + if (it2->slave.lock() == it->slave.lock() && it2->master.lock() == it->master.lock()) { + found = it2; break; } } - if (!found) { + if (found == foundGuiLink->second.knobs.end()) { ///There's no link for this knob, add info to the tooltip of the link arrow - - foundGuiLink->second.knobs.push_back(std::make_pair(it->slave,it->master)); + LinkedKnob k; + k.slave = it->slave; + k.master = it->master; + k.dimensions.insert(it->dimension); + k.linkInValid = 0; + foundGuiLink->second.knobs.push_back(k); QString fullTooltip; - for (std::list >::iterator it2 = foundGuiLink->second.knobs.begin(); it2 != foundGuiLink->second.knobs.end(); ++it2) { - QString tt = makeLinkString(masterNode.get(),it2->second,node.get(),it2->first); + for (std::list::iterator it2 = foundGuiLink->second.knobs.begin(); it2 != foundGuiLink->second.knobs.end(); ++it2) { + QString tt = makeLinkString(masterNode.get(),it2->master.lock().get(),node.get(),it2->slave.lock().get()); fullTooltip.append(tt); } + } else { + found->dimensions.insert(it->dimension); } } else { @@ -2438,20 +2483,25 @@ NodeGui::onKnobsLinksChanged() boost::shared_ptr master_i = masterNode->getNodeGui(); NodeGuiPtr master = boost::dynamic_pointer_cast(master_i); assert(master); + LinkArrow* arrow = new LinkArrow( master,thisShared,parentItem() ); arrow->setWidth(2); arrow->setColor( QColor(143,201,103) ); arrow->setArrowHeadColor( QColor(200,255,200) ); - QString tt = makeLinkString(masterNode.get(),it->master,node.get(),it->slave); + QString tt = makeLinkString(masterNode.get(),it->master.lock().get(),node.get(),it->slave.lock().get()); arrow->setToolTip(tt); if ( !getDagGui()->areKnobLinksVisible() ) { arrow->setVisible(false); } - LinkedDim guilink; - guilink.knobs.push_back(std::make_pair(it->slave,it->master)); + LinkedDim& guilink = _knobsLinks[it->masterNode]; guilink.arrow = arrow; - _knobsLinks.insert(std::make_pair(it->masterNode,guilink)); + LinkedKnob k; + k.slave = it->slave; + k.master = it->master; + k.dimensions.insert(it->dimension); + k.linkInValid = 0; + guilink.knobs.push_back(k); } } diff --git a/Gui/NodeGui.h b/Gui/NodeGui.h index f67fafe5cf..ee8b4044d2 100644 --- a/Gui/NodeGui.h +++ b/Gui/NodeGui.h @@ -401,6 +401,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual void onIdentityStateChanged(int inputNb) OVERRIDE FINAL; void copyPreviewImageBuffer(const std::vector& data, int width, int height); + + void onKnobExpressionChanged(const KnobGui* knob); protected: @@ -633,9 +635,30 @@ public Q_SLOTS: boost::weak_ptr _masterNodeGui; ///For each knob that has a link to another parameter, display an arrow + struct LinkedKnob { + + KnobWPtr master; + KnobWPtr slave; + + // Is this link valid (counter for all dimensions) + int linkInValid; + + // The dimensions of the slave linked to the master + std::set dimensions; + + LinkedKnob() + : master() + , slave() + , linkInValid(false) + , dimensions() + { + + } + + }; struct LinkedDim { - std::list > knobs; + std::list knobs; LinkArrow* arrow; }; From 02a91cbd6fd9394fd898733548764ce39634bfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 28 Mar 2016 16:45:43 +0200 Subject: [PATCH 11/30] add missing includes --- Gui/NodeGui.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gui/NodeGui.h b/Gui/NodeGui.h index ee8b4044d2..d950f8886e 100644 --- a/Gui/NodeGui.h +++ b/Gui/NodeGui.h @@ -28,6 +28,11 @@ #include "Global/Macros.h" #include +#include +#include +#include +#include + #if !defined(Q_MOC_RUN) && !defined(SBK_RUN) #include #include From 90d644baadc125425cd13bbe2ffa0fc14f04bbe8 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Thu, 31 Mar 2016 19:25:31 +0200 Subject: [PATCH 12/30] Layers are now persistant in menus + user can add project wide layers. (accessible to python too) --- .../PythonReference/NatronEngine/App.rst | 12 +- Engine/AppManager.cpp | 18 +- Engine/AppManager.h | 2 + Engine/EffectInstance.cpp | 11 +- Engine/EngineFwd.h | 2 + Engine/FileSystemModel.cpp | 2 +- Engine/Knob.cpp | 14 +- Engine/KnobFactory.cpp | 1 + Engine/KnobFile.cpp | 163 ++-- Engine/KnobFile.h | 54 +- Engine/KnobSerialization.cpp | 2 + Engine/KnobTypes.cpp | 538 +++++++++++-- Engine/KnobTypes.h | 183 ++++- Engine/NatronEngine/app_wrapper.cpp | 50 ++ .../natronengine_module_wrapper.cpp | 44 +- Engine/NatronEngine/natronengine_python.h | 44 +- Engine/Node.cpp | 558 ++++++------- Engine/Node.h | 6 +- Engine/OfxParamInstance.cpp | 109 ++- Engine/OfxParamInstance.h | 3 + Engine/Project.cpp | 366 +++++---- Engine/Project.h | 13 +- Engine/ProjectPrivate.cpp | 37 +- Engine/ProjectPrivate.h | 9 +- Engine/PyAppInstance.cpp | 6 + Engine/PyAppInstance.h | 2 + Engine/PyNode.h | 4 + Engine/Settings.cpp | 3 +- Engine/ViewerInstance.cpp | 6 +- Engine/ViewerInstancePrivate.h | 6 +- Global/Macros.h | 5 - Gui/ComboBox.cpp | 19 +- Gui/ComboBox.h | 5 + Gui/DockablePanelPrivate.cpp | 13 +- Gui/Gui.pro | 2 + Gui/GuiFwd.h | 2 + Gui/KnobGui.cpp | 6 +- Gui/KnobGui.h | 12 +- Gui/KnobGui20.cpp | 46 +- Gui/KnobGuiChoice.cpp | 87 +- Gui/KnobGuiChoice.h | 5 +- Gui/KnobGuiFactory.cpp | 2 +- Gui/KnobGuiFile.cpp | 547 +++---------- Gui/KnobGuiFile.h | 54 +- Gui/KnobGuiPrivate.cpp | 2 +- Gui/KnobGuiPrivate.h | 6 +- Gui/KnobGuiTable.cpp | 759 ++++++++++++++++++ Gui/KnobGuiTable.h | 152 ++++ Gui/NatronGui/natrongui_module_wrapper.cpp | 4 +- Gui/NatronGui/natrongui_python.h | 4 +- Gui/NewLayerDialog.cpp | 74 +- Gui/NewLayerDialog.h | 2 +- Gui/NodeGraph.cpp | 4 +- Gui/NodeGraphPrivate10.cpp | 1 - Gui/NodeGui.cpp | 3 +- Gui/ProjectGui.cpp | 3 + Gui/ProjectGuiSerialization.cpp | 2 + Gui/ProjectGuiSerialization.h | 8 +- Gui/Resources/PyPlugs/ZMask.py | 82 +- Gui/ViewerTab.h | 7 + Gui/ViewerTab40.cpp | 85 +- Gui/ViewerTabPrivate.h | 2 + global.pri | 2 +- 63 files changed, 2870 insertions(+), 1405 deletions(-) create mode 100644 Gui/KnobGuiTable.cpp create mode 100644 Gui/KnobGuiTable.h diff --git a/Documentation/source/PythonReference/NatronEngine/App.rst b/Documentation/source/PythonReference/NatronEngine/App.rst index e4286b2245..9c46bcdf22 100644 --- a/Documentation/source/PythonReference/NatronEngine/App.rst +++ b/Documentation/source/PythonReference/NatronEngine/App.rst @@ -16,7 +16,7 @@ See :ref:`detailed` description... Functions ^^^^^^^^^ - +* def :meth:`addProjectLayer` (layer) * def :meth:`addFormat` (formatSpec) * def :meth:`createNode` (pluginID[, majorVersion=-1[, group=None]]) * def :meth:`createReader` (filename[, group=None]) @@ -132,6 +132,16 @@ You can get a specific :doc:`parameter` of the project settings with the Member functions description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. method:: NatronEngine.App.addProjectLayer(layer) + + :param layer: :class:`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` diff --git a/Engine/AppManager.cpp b/Engine/AppManager.cpp index b345d3cecb..b7f58f84fc 100644 --- a/Engine/AppManager.cpp +++ b/Engine/AppManager.cpp @@ -3152,9 +3152,7 @@ Python::compilePyScript(const std::string& script,PyObject** code) } #endif - -std::string -Python::makeNameScriptFriendly(const std::string& str) +static std::string makeNameScriptFriendlyInternal(const std::string& str, bool allowDots) { if (str == "from") { return "pFrom"; @@ -3179,13 +3177,25 @@ Python::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 +Python::makeNameScriptFriendlyWithDots(const std::string& str) +{ + return makeNameScriptFriendlyInternal(str, true); +} + +std::string +Python::makeNameScriptFriendly(const std::string& str) +{ + return makeNameScriptFriendlyInternal(str, false); +} + PythonGILLocker::PythonGILLocker() // : state(PyGILState_UNLOCKED) { diff --git a/Engine/AppManager.h b/Engine/AppManager.h index 16cb5d4b85..dc9c96a343 100644 --- a/Engine/AppManager.h +++ b/Engine/AppManager.h @@ -687,6 +687,8 @@ 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 makeNameScriptFriendlyWithDots(const std::string& str); std::string makeNameScriptFriendly(const std::string& str); diff --git a/Engine/EffectInstance.cpp b/Engine/EffectInstance.cpp index 9ff9bb1679..50f150d42d 100644 --- a/Engine/EffectInstance.cpp +++ b/Engine/EffectInstance.cpp @@ -411,7 +411,9 @@ EffectInstance::aborted() const const boost::shared_ptr & args = tls->frameArgs.back(); isRenderUserInteraction = args->isRenderResponseToUserInteraction; abortInfo = args->abortInfo; - treeRoot = args->treeRoot->getEffectInstance(); + if (args->treeRoot) { + treeRoot = args->treeRoot->getEffectInstance(); + } #ifdef QT_CUSTOM_THREADPOOL if (isAbortableThread) { @@ -3683,6 +3685,11 @@ EffectInstance::getComponentsAvailableRecursive(bool useLayerChoice, if (!processAll) { std::list userComps; node->getUserCreatedComponents(&userComps); + + ///Add to the user comps the project components + std::vector projectLayers = getApp()->getProject()->getProjectDefaultLayers(); + userComps.insert(userComps.end(), projectLayers.begin(), projectLayers.end()); + ///Foreach user component, add it as an available component, but use this node only if it is also ///in the "needed components" list for (std::list::iterator it = userComps.begin(); it != userComps.end(); ++it) { @@ -3851,7 +3858,7 @@ EffectInstance::getComponentsNeededAndProduced_public(bool useLayerChoice, *passThroughView = view; int idx = getNode()->getPreferredInput(); *passThroughInput = getNode()->getInput(idx); - + *processAllRequested = false; if (!useThisNodeComponentsNeeded) { return; } diff --git a/Engine/EngineFwd.h b/Engine/EngineFwd.h index a3c5075b98..4e4dc77420 100644 --- a/Engine/EngineFwd.h +++ b/Engine/EngineFwd.h @@ -151,6 +151,7 @@ class KnobHelper; class KnobHolder; class KnobI; class KnobInt; +class KnobLayers; class KnobOutputFile; class KnobPage; class KnobParametric; @@ -158,6 +159,7 @@ class KnobPath; class KnobSeparator; class KnobSerialization; class KnobString; +class KnobTable; class LibraryBinary; class Node; class NodeCollection; diff --git a/Engine/FileSystemModel.cpp b/Engine/FileSystemModel.cpp index cb473e39e5..896498584f 100644 --- a/Engine/FileSystemModel.cpp +++ b/Engine/FileSystemModel.cpp @@ -438,7 +438,7 @@ FileSystemItem::matchPath(const QStringList& path, int startIndex) const const boost::shared_ptr& child = _imp->children[i]; - if ( child->fileName() == pathBit ) { + if ( child && child->fileName() == pathBit ) { if ( startIndex == path.size() -1 ) { return child; diff --git a/Engine/Knob.cpp b/Engine/Knob.cpp index 1f41b6e149..3eedd6cb21 100644 --- a/Engine/Knob.cpp +++ b/Engine/Knob.cpp @@ -1528,17 +1528,16 @@ KnobHelper::evaluateValueChangeInternal(int dimension, /// For eValueChangedReasonTimeChanged we never call the instanceChangedAction and evaluate otherwise it would just throttle /// the application responsiveness + onInternalValueChanged(dimension, time, view); + if ((originalReason != eValueChangedReasonTimeChanged || evaluateValueChangeOnTimeChange()) && _imp->holder) { - if (!app || !app->getProject()->isLoadingProject()) { _imp->holder->beginChanges(); _imp->holder->appendValueChange(shared_from_this(), dimension, refreshWidget, time, view, originalReason, reason); _imp->holder->endChanges(); - - } + } - onInternalValueChanged(dimension, time, view); if (!_imp->holder && _signalSlotHandler) { computeHasModifications(); @@ -3884,7 +3883,7 @@ KnobHelper::setKnobAsAliasOfThis(const KnobPtr& master, bool doAlias) assert(thisChoice); if (thisChoice) { isChoice->populateChoices(thisChoice->getEntries_mt_safe(), - thisChoice->getEntriesHelp_mt_safe()); + thisChoice->getEntriesHelp_mt_safe(), 0, 0, false); } } } @@ -3899,8 +3898,9 @@ KnobHelper::setKnobAsAliasOfThis(const KnobPtr& master, bool doAlias) assert(ok); Q_UNUSED(ok); } - handleSignalSlotsForAliasLink(master,doAlias); } + handleSignalSlotsForAliasLink(master,doAlias); + endChanges(); QWriteLocker k(&_imp->mastersMutex); @@ -4766,7 +4766,7 @@ KnobHolder::endChanges(bool discardRendering) // Call instanceChanged on each knob for (KnobChanges::iterator it = knobChanged.begin(); it!=knobChanged.end(); ++it) { - if (it->knob && !it->valueChangeBlocked) { + if (it->knob && !it->valueChangeBlocked && !isLoadingProject) { if (!it->originatedFromMainThread && !canHandleEvaluateOnChangeInOtherThread()) { Q_EMIT doValueChangeOnMainThread(it->knob.get(), it->originalReason, it->time, it->view, it->originatedFromMainThread); } else { diff --git a/Engine/KnobFactory.cpp b/Engine/KnobFactory.cpp index 9c3b5814ec..ca73229236 100644 --- a/Engine/KnobFactory.cpp +++ b/Engine/KnobFactory.cpp @@ -93,6 +93,7 @@ KnobFactory::loadBultinKnobs() _loadedKnobs.insert( knobFactoryEntry() ); _loadedKnobs.insert( knobFactoryEntry() ); _loadedKnobs.insert( knobFactoryEntry() ); + _loadedKnobs.insert( knobFactoryEntry() ); } boost::shared_ptr KnobFactory::createKnob(const std::string &id, diff --git a/Engine/KnobFile.cpp b/Engine/KnobFile.cpp index efa56f55de..ad45342a9a 100644 --- a/Engine/KnobFile.cpp +++ b/Engine/KnobFile.cpp @@ -151,7 +151,7 @@ KnobPath::KnobPath(KnobHolder* holder, const std::string &description, int dimension, bool declaredByPlugin) -: Knob(holder,description,dimension,declaredByPlugin) +: KnobTable(holder,description,dimension,declaredByPlugin) , _isMultiPath(false) , _isStringList(false) { @@ -164,12 +164,6 @@ KnobPath::typeNameStatic() return _typeNameStr; } -bool -KnobPath::canAnimate() const -{ - return false; -} - const std::string & KnobPath::typeName() const { @@ -201,100 +195,9 @@ KnobPath::getIsStringList() const return _isStringList; } -void -KnobPath::getVariables(std::list >* paths) -{ - if (!_isMultiPath) { - return; - } - - std::string startNameTag(NATRON_ENV_VAR_NAME_START_TAG); - std::string endNameTag(NATRON_ENV_VAR_NAME_END_TAG); - std::string startValueTag(NATRON_ENV_VAR_VALUE_START_TAG); - std::string endValueTag(NATRON_ENV_VAR_VALUE_END_TAG); - - std::string raw = getValue().c_str(); - size_t i = raw.find(startNameTag); - while (i != std::string::npos) { - i += startNameTag.size(); - assert(i < raw.size()); - size_t endNamePos = raw.find(endNameTag,i); - assert(endNamePos != std::string::npos && endNamePos < raw.size()); - if (endNamePos == std::string::npos || endNamePos >= raw.size()) { - throw std::logic_error("KnobPath::getVariables()"); - } - std::string name,value; - while (i < endNamePos) { - name.push_back(raw[i]); - ++i; - } - - i = raw.find(startValueTag,i); - i += startValueTag.size(); - assert(i != std::string::npos && i < raw.size()); - - size_t endValuePos = raw.find(endValueTag,i); - assert(endValuePos != std::string::npos && endValuePos < raw.size()); - - while (endValuePos != std::string::npos && endValuePos < raw.size() && i < endValuePos) { - value.push_back(raw.at(i)); - ++i; - } - - // In order to use XML tags, the text inside the tags has to be unescaped. - paths->push_back(std::make_pair(name,Project::unescapeXML(value).c_str())); - - i = raw.find(startNameTag,i); - } -} - - -void -KnobPath::getPaths(std::list *paths) -{ - std::string raw = getValue().c_str(); - - if (_isMultiPath) { - std::list > ret; - getVariables(&ret); - for (std::list >::iterator it = ret.begin(); it != ret.end(); ++it) { - paths->push_back(it->second); - } - } else { - paths->push_back(raw); - } - -} std::string -KnobPath::encodeToMultiPathFormat(const std::list >& paths) -{ - std::string path; - - - for (std::list >::const_iterator it = paths.begin(); it != paths.end(); ++it) { - // In order to use XML tags, the text inside the tags has to be escaped. - path += NATRON_ENV_VAR_NAME_START_TAG; - path += Project::escapeXML(it->first); - path += NATRON_ENV_VAR_NAME_END_TAG; - path += NATRON_ENV_VAR_VALUE_START_TAG; - path += Project::escapeXML(it->second); - path += NATRON_ENV_VAR_VALUE_END_TAG; - } - return path; -} - -void -KnobPath::setPaths(const std::list >& paths) -{ - if (!_isMultiPath) { - return; - } - setValue(encodeToMultiPathFormat(paths)); -} - -std::string -KnobPath::generateUniquePathID(const std::list >& paths) +KnobPath::generateUniquePathID(const std::list >& paths) { std::string baseName("Path"); int idx = 0; @@ -308,8 +211,8 @@ KnobPath::generateUniquePathID(const std::list >::const_iterator it = paths.begin(); it != paths.end(); ++it) { - if (it->first == name) { + for (std::list >::const_iterator it = paths.begin(); it != paths.end(); ++it) { + if ((*it)[0] == name) { found = true; break; } @@ -319,17 +222,52 @@ KnobPath::generateUniquePathID(const std::list* paths) +{ + std::list > table; + getTable(&table); + for (std::list >::iterator it = table.begin(); it!=table.end(); ++it) { + assert(it->size() == 2); + paths->push_back((*it)[1]); + } +} + void KnobPath::prependPath(const std::string& path) { if (!_isMultiPath) { setValue(path); } else { - std::list > paths; - getVariables(&paths); + std::list > paths; + getTable(&paths); std::string name = generateUniquePathID(paths); - paths.push_front(std::make_pair(name, path)); - setPaths(paths); + std::vector row(2); + row[0] = name; + row[1] = path; + paths.push_front(row); + setTable(paths); } } @@ -339,16 +277,19 @@ KnobPath::appendPath(const std::string& path) if (!_isMultiPath) { setValue(path); } else { - std::list > paths; - getVariables(&paths); - for (std::list >::iterator it = paths.begin(); it!=paths.end(); ++it) { - if (it->second == path) { + std::list > paths; + getTable(&paths); + for (std::list >::iterator it = paths.begin(); it!=paths.end(); ++it) { + if ((*it)[1] == path) { return; } } std::string name = generateUniquePathID(paths); - paths.push_back(std::make_pair(name, path)); - setPaths(paths); + std::vector row(2); + row[0] = name; + row[1] = path; + paths.push_back(row); + setTable(paths); } } diff --git a/Engine/KnobFile.h b/Engine/KnobFile.h index 5e8112ecb6..470d556140 100644 --- a/Engine/KnobFile.h +++ b/Engine/KnobFile.h @@ -185,14 +185,11 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON /** - * @brief A Path knob could also be called Environment_variable_Knob. - * The string is encoded the following way: + * @brief The string value is encoded the following way: * LalaMyValue - * Split all the ';' characters to get all different variables - * then for each variable split the ':' to get the name and the value of the variable. **/ class KnobPath - : public Knob + : public KnobTable { public: @@ -215,29 +212,46 @@ class KnobPath bool isMultiPath() const; - void getPaths(std::list* paths) ; - - ///Doesn't work if isMultiPath() == false - void getVariables(std::list >* paths) ; - - static std::string encodeToMultiPathFormat(const std::list >& paths); - - void setPaths(const std::list >& paths); - - void prependPath(const std::string& path) ; - void appendPath(const std::string& path) ; - /* @brief same as setMultiPath except that there will be only variable names, no values */ void setAsStringList(bool b); bool getIsStringList() const; -private: + void getPaths(std::list* paths) ; + void prependPath(const std::string& path) ; + void appendPath(const std::string& path) ; + - static std::string generateUniquePathID(const std::list >& paths); + 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; + } - virtual bool canAnimate() const OVERRIDE FINAL; +private: + + static std::string generateUniquePathID(const std::list >& paths); virtual const std::string & typeName() const OVERRIDE FINAL; private: diff --git a/Engine/KnobSerialization.cpp b/Engine/KnobSerialization.cpp index 43e4be69e9..9d44f6e427 100644 --- a/Engine/KnobSerialization.cpp +++ b/Engine/KnobSerialization.cpp @@ -105,6 +105,8 @@ KnobPtr KnobSerialization::createKnob(const std::string & typeName, ret.reset( new KnobColor(NULL,"",dimension,false) ); } else if ( typeName == KnobPath::typeNameStatic() ) { ret.reset( new KnobPath(NULL,"",dimension,false) ); + } else if ( typeName == KnobLayers::typeNameStatic() ) { + ret.reset( new KnobLayers(NULL,"",dimension,false) ); } else if ( typeName == KnobFile::typeNameStatic() ) { ret.reset( new KnobFile(NULL,"",dimension,false) ); } else if ( typeName == KnobOutputFile::typeNameStatic() ) { diff --git a/Engine/KnobTypes.cpp b/Engine/KnobTypes.cpp index 57ede30fce..930d5b0d9f 100644 --- a/Engine/KnobTypes.cpp +++ b/Engine/KnobTypes.cpp @@ -49,6 +49,7 @@ GCC_DIAG_UNUSED_LOCAL_TYPEDEFS_ON #include "Engine/KnobFile.h" #include "Engine/KnobSerialization.h" #include "Engine/Node.h" +#include "Engine/Project.h" #include "Engine/RotoContext.h" #include "Engine/TimeLine.h" #include "Engine/Transform.h" @@ -567,6 +568,7 @@ KnobChoice::KnobChoice(KnobHolder* holder, bool declaredByPlugin) : Knob(holder, label, dimension, declaredByPlugin) , _entriesMutex() +, _currentEntryLabel() , _addNewChoice(false) , _isCascading(false) { @@ -607,6 +609,49 @@ KnobChoice::typeName() const return typeNameStatic(); } +void +KnobChoice::cloneExtraData(KnobI* other,int /*dimension*/) +{ + KnobChoice* isChoice = dynamic_cast(other); + if (!isChoice) { + return; + } + + QMutexLocker k(&_entriesMutex); + _currentEntryLabel = isChoice->getActiveEntryText_mt_safe(); +} + +bool +KnobChoice::cloneExtraDataAndCheckIfChanged(KnobI* other,int /*dimension*/) +{ + KnobChoice* isChoice = dynamic_cast(other); + if (!isChoice) { + return false; + } + + QMutexLocker k(&_entriesMutex); + std::string otherEntry = isChoice->getActiveEntryText_mt_safe(); + if (_currentEntryLabel != otherEntry) { + _currentEntryLabel = otherEntry; + return true; + } + return false; +} + +void +KnobChoice::cloneExtraData(KnobI* other, double /*offset*/, const RangeD* /*range*/,int /*dimension*/) +{ + KnobChoice* isChoice = dynamic_cast(other); + if (!isChoice) { + return; + } + + QMutexLocker k(&_entriesMutex); + _currentEntryLabel = isChoice->getActiveEntryText_mt_safe(); + +} + + #ifdef DEBUG #pragma message WARN("When enabling multi-view knobs, make this multi-view too") #endif @@ -616,52 +661,155 @@ KnobChoice::onInternalValueChanged(int /*dimension*/, double time, ViewSpec /*vi int index = getValueAtTime(time, 0); QMutexLocker k(&_entriesMutex); - if (index >= 0 && index < (int)_entries.size()) { - _lastValidEntry = _entries[index]; + if (index >= 0 && index < (int)_mergedEntries.size()) { + _currentEntryLabel = _mergedEntries[index]; + } +} + +static bool caseInsensitiveCompare(const std::string& a, const std::string& b) +{ + if (a.size() != b.size()) { + return false; + } + std::locale loc; + for (std::size_t i = 0; i < a.size(); ++i) { + char aLow = std::tolower(a[i],loc); + char bLow = std::tolower(b[i],loc); + if (aLow != bLow) { + return false; + } } + return true; +} + +static bool stringEqualFunctor(const std::string& a, const std::string& b, KnobChoiceMergeEntriesData* /*data*/) +{ + return a == b; } void -KnobChoice::findAndSetOldChoice(const std::vector& newEntries) +KnobChoice::findAndSetOldChoice(MergeMenuEqualityFunctor mergingFunctor, + KnobChoiceMergeEntriesData* mergingData) { std::string curEntry; { QMutexLocker k(&_entriesMutex); - curEntry = _lastValidEntry; + curEntry = _currentEntryLabel; } if (!curEntry.empty()) { - for (std::size_t i = 0; i < newEntries.size(); ++i) { - if (newEntries[i] == curEntry) { - blockValueChanges(); - setValue((int)i); - unblockValueChanges(); + + if (mergingFunctor) { + assert(mergingData); + mergingData->clear(); + } else { + mergingFunctor = stringEqualFunctor; + } + int found = -1; + for (std::size_t i = 0; i < _mergedEntries.size(); ++i) { + if (mergingFunctor(_mergedEntries[i],curEntry, mergingData)) { + found = i; break; } } + if (found != -1) { + blockValueChanges(); + setValue(found); + unblockValueChanges(); + } else { + /*// We are in invalid state + blockValueChanges(); + setValue(-1); + unblockValueChanges();*/ + } } } -/*Must be called right away after the constructor.*/ -void + + +bool KnobChoice::populateChoices(const std::vector &entries, - const std::vector &entriesHelp) + const std::vector &entriesHelp, + MergeMenuEqualityFunctor mergingFunctor, + KnobChoiceMergeEntriesData* mergingData, + bool restoreOldChoice) { assert( entriesHelp.empty() || entriesHelp.size() == entries.size() ); + bool hasChanged; { QMutexLocker l(&_entriesMutex); - _entriesHelp = entriesHelp; - _entries = entries; + + _newEntries = entries; + if (!entriesHelp.empty()) { + _newEntriesHelp = entriesHelp; + } else { + _newEntriesHelp.resize(entries.size()); + } + if (mergingFunctor) { + assert(mergingData); + for (std::size_t i = 0; i < entries.size(); ++i) { + + mergingData->clear(); + bool found = false; + for (std::size_t j = 0; j < _mergedEntries.size(); ++j) { + if (mergingFunctor(_mergedEntries[j],entries[i], mergingData)) { + found = true; + break; + } + } + if (!found) { + hasChanged = true; + if (i < (int)_newEntriesHelp.size()) { + _mergedEntriesHelp.push_back(_newEntriesHelp[i]); + } + _mergedEntries.push_back(entries[i]); + } + } + + } else { + _mergedEntries = _newEntries; + _mergedEntriesHelp = _newEntriesHelp; + hasChanged = true; + } } /* - Try to restore the last choice. - This has been commented-out because it will loose the user choice in case of alias knobs + Try to restore the last choice. */ - //findAndSetOldChoice(entries); - - if (_signalSlotHandler) { - _signalSlotHandler->s_helpChanged(); + if (hasChanged) { + if (restoreOldChoice) { + findAndSetOldChoice(mergingFunctor, mergingData); + } + + if (_signalSlotHandler) { + _signalSlotHandler->s_helpChanged(); + } + Q_EMIT populated(); } + return hasChanged; +} + + +void +KnobChoice::refreshMenu() +{ + KnobHolder* holder = getHolder(); + if (holder) { + // In OpenFX we reset the menu with a button + KnobPtr hasRefreshButton = holder->getKnobByName(getName() + "RefreshButton"); + if (hasRefreshButton) { + KnobButton* button = dynamic_cast(hasRefreshButton.get()); + button->trigger(); + return; + } + } + std::vector entries; + { + QMutexLocker l(&_entriesMutex); + + _mergedEntries = _newEntries; + _mergedEntriesHelp = _newEntriesHelp; + } + findAndSetOldChoice(); Q_EMIT populated(); } @@ -670,9 +818,13 @@ KnobChoice::resetChoices() { { QMutexLocker l(&_entriesMutex); - _entries.clear(); - _entriesHelp.clear(); + _newEntries.clear(); + _newEntriesHelp.clear(); + _mergedEntries.clear(); + _mergedEntriesHelp.clear(); + } + findAndSetOldChoice(); if (_signalSlotHandler) { _signalSlotHandler->s_helpChanged(); } @@ -682,60 +834,83 @@ KnobChoice::resetChoices() void KnobChoice::appendChoice(const std::string& entry, const std::string& help) { - std::vector curEntries,newEntries; { QMutexLocker l(&_entriesMutex); - _entriesHelp.push_back(help); - _entries.push_back(entry); - newEntries = _entries; + + _mergedEntriesHelp.push_back(help); + _mergedEntries.push_back(entry); + _newEntries.push_back(entry); + _newEntriesHelp.push_back(help); + } - //findAndSetOldChoice(newEntries); - + findAndSetOldChoice(); if (_signalSlotHandler) { _signalSlotHandler->s_helpChanged(); } Q_EMIT entryAppended(QString::fromUtf8(entry.c_str()), QString::fromUtf8(help.c_str())); + } std::vector KnobChoice::getEntries_mt_safe() const { QMutexLocker l(&_entriesMutex); - return _entries; + return _mergedEntries; +} + +bool +KnobChoice::isActiveEntryPresentInEntries() const +{ + + QMutexLocker k(&_entriesMutex); + if (_currentEntryLabel.empty()) { + return true; + } + for (std::size_t i = 0; i < _newEntries.size(); ++i) { + if (_newEntries[i] == _currentEntryLabel) { + return true; + } + } + return false; } const std::string& KnobChoice::getEntry(int v) const { - if (v < 0 || (int)_entries.size() <= v) { + assert(v != -1); // use getActiveEntryText_mt_safe() otherwise + if ((int)_mergedEntries.size() <= v) { throw std::runtime_error(std::string("KnobChoice::getEntry: index out of range")); } - return _entries[v]; + return _mergedEntries[v]; } int KnobChoice::getNumEntries() const { QMutexLocker l(&_entriesMutex); - return (int)_entries.size(); + return (int)_mergedEntries.size(); } std::vector KnobChoice::getEntriesHelp_mt_safe() const { QMutexLocker l(&_entriesMutex); - return _entriesHelp; + return _mergedEntriesHelp; } std::string KnobChoice::getActiveEntryText_mt_safe() { - int activeIndex = getValue(); + QMutexLocker l(&_entriesMutex); - if ( activeIndex < (int)_entries.size()) { - return _entries[activeIndex]; + if (!_currentEntryLabel.empty()) { + return _currentEntryLabel; + } + int activeIndex = getValue(); + if ( activeIndex < (int)_mergedEntries.size()) { + return _mergedEntries[activeIndex]; } return std::string(); @@ -778,10 +953,10 @@ KnobChoice::getHintToolTipFull() const int gothelp = 0; - if ( !_entriesHelp.empty() ) { - assert( _entriesHelp.size() == _entries.size() ); - for (U32 i = 0; i < _entries.size(); ++i) { - if ( !_entriesHelp.empty() && !_entriesHelp[i].empty() ) { + if ( !_mergedEntriesHelp.empty() ) { + assert( _mergedEntriesHelp.size() == _mergedEntries.size() ); + for (U32 i = 0; i < _mergedEntries.size(); ++i) { + if ( !_mergedEntriesHelp.empty() && !_mergedEntriesHelp[i].empty() ) { ++gothelp; } } @@ -801,16 +976,16 @@ KnobChoice::getHintToolTipFull() const } // param may have no hint but still have per-option help if (gothelp) { - for (U32 i = 0; i < _entriesHelp.size(); ++i) { - if ( !_entriesHelp[i].empty() ) { // no help line is needed if help is unavailable for this option - std::string entry = trim(_entries[i]); + for (U32 i = 0; i < _mergedEntriesHelp.size(); ++i) { + if ( !_mergedEntriesHelp[i].empty() ) { // no help line is needed if help is unavailable for this option + std::string entry = trim(_mergedEntries[i]); whitespacify(entry); - std::string help = trim(_entriesHelp[i]); + std::string help = trim(_mergedEntriesHelp[i]); whitespacify(help); ss << entry; ss << ": "; ss << help; - if (i < _entriesHelp.size() - 1) { + if (i < _mergedEntriesHelp.size() - 1) { ss << '\n'; } } @@ -820,46 +995,35 @@ KnobChoice::getHintToolTipFull() const return ss.str(); } -static bool caseInsensitiveCompare(const std::string& a,const std::string& b) -{ - if (a.size() != b.size()) { - return false; - } - std::locale loc; - for (std::size_t i = 0; i < a.size(); ++i) { - char aLow = std::tolower(a[i],loc); - char bLow = std::tolower(b[i],loc); - if (aLow != bLow) { - return false; - } - } - return true; -} KnobHelper::ValueChangedReturnCodeEnum KnobChoice::setValueFromLabel(const std::string & value, int dimension, bool turnOffAutoKeying) { - for (std::size_t i = 0; i < _entries.size(); ++i) { - if (caseInsensitiveCompare(_entries[i], value)) { + for (std::size_t i = 0; i < _mergedEntries.size(); ++i) { + if (caseInsensitiveCompare(_mergedEntries[i], value)) { return setValue(i, ViewIdx(0), dimension, turnOffAutoKeying); } } - return KnobHelper::eValueChangedReturnCodeNothingChanged; - //throw std::runtime_error(std::string("KnobChoice::setValueFromLabel: unknown label ") + value); + /*{ + QMutexLocker k(&_entriesMutex); + _currentEntryLabel = value; + } + return setValue(-1, ViewIdx(0), dimension, turnOffAutoKeying);*/ + throw std::runtime_error(std::string("KnobChoice::setValueFromLabel: unknown label ") + value); } void KnobChoice::setDefaultValueFromLabel(const std::string & value, int dimension) { - for (std::size_t i = 0; i < _entries.size(); ++i) { - if (caseInsensitiveCompare(_entries[i], value)) { + for (std::size_t i = 0; i < _mergedEntries.size(); ++i) { + if (caseInsensitiveCompare(_mergedEntries[i], value)) { return setDefaultValue(i, dimension); } } - //throw std::runtime_error(std::string("KnobChoice::setDefaultValueFromLabel: unknown label ") + value); + throw std::runtime_error(std::string("KnobChoice::setDefaultValueFromLabel: unknown label ") + value); } void @@ -867,7 +1031,7 @@ KnobChoice::choiceRestoration(KnobChoice* knob,const ChoiceExtraData* data) { assert(knob && data); - + ///Clone first and then handle restoration of the static value clone(knob); setSecret( knob->getIsSecret() ); @@ -877,18 +1041,27 @@ KnobChoice::choiceRestoration(KnobChoice* knob,const ChoiceExtraData* data) } } + { + QMutexLocker k(&_entriesMutex); + _currentEntryLabel = data->_choiceString; + } + int serializedIndex = knob->getValue(); - if ( ( serializedIndex < (int)_entries.size() ) && (_entries[serializedIndex] == data->_choiceString) ) { + if ((serializedIndex < (int)_mergedEntries.size()) && (_mergedEntries[serializedIndex] == data->_choiceString)) { // we're lucky, entry hasn't changed setValue(serializedIndex); } else { // try to find the same label at some other index - for (std::size_t i = 0; i < _entries.size(); ++i) { - if (caseInsensitiveCompare(_entries[i], data->_choiceString)) { + for (std::size_t i = 0; i < _mergedEntries.size(); ++i) { + if (caseInsensitiveCompare(_mergedEntries[i], data->_choiceString)) { setValue(i); return; } } + + + // setValue(-1); + } } @@ -901,7 +1074,7 @@ KnobChoice::onOriginalKnobPopulated() if (!isChoice) { return; } - populateChoices(isChoice->_entries,isChoice->_entriesHelp); + populateChoices(isChoice->_mergedEntries,isChoice->_mergedEntriesHelp, 0, 0, false); } void @@ -1795,6 +1968,227 @@ KnobParametric::hasModificationsVirtual(int dimension) const return false; } + + +KnobTable::KnobTable(KnobHolder* holder, + const std::string &description, + int dimension, + bool declaredByPlugin) +: Knob(holder,description,dimension,declaredByPlugin) +{ + +} + +KnobTable::~KnobTable() +{ + +} + +void +KnobTable::getTableSingleCol(std::list* table) +{ + std::list > tmp; + getTable(&tmp); + for (std::list >::iterator it = tmp.begin(); it!=tmp.end(); ++it) { + table->push_back((*it)[0]); + } +} + +void +KnobTable::getTable(std::list >* table) +{ + + decodeFromKnobTableFormat(getValue(), table); +} + +void +KnobTable::decodeFromKnobTableFormat(const std::string& value, std::list >* table) +{ + QString raw = QString::fromUtf8(value.c_str()); + if (raw.isEmpty()) { + return; + } + const int colsCount = getColumnsCount(); + assert(colsCount > 0); + + + + QString startTag = QString::fromUtf8("<%1>"); + QString endTag = QString::fromUtf8(""); + + int lastFoundIndex = 0; + + for (;;) { + + int colIndex = 0; + std::vector row; + bool mustStop = false; + while (colIndex < colsCount) { + + QString colLabel = QString::fromUtf8(getColumnLabel(colIndex).c_str()); + const QString startToFind = startTag.arg(colLabel); + const QString endToFind = endTag.arg(colLabel); + + lastFoundIndex = raw.indexOf(startToFind, lastFoundIndex); + if (lastFoundIndex == -1) { + mustStop = true; + break; + } + + lastFoundIndex += startToFind.size(); + assert(lastFoundIndex < raw.size()); + + int endNamePos = raw.indexOf(endToFind,lastFoundIndex); + assert(endNamePos != -1 && endNamePos < raw.size()); + + if (endNamePos == -1 || endNamePos >= raw.size()) { + throw std::logic_error("KnobTable: mal-formed table"); + } + + std::string value; + while (lastFoundIndex < endNamePos) { + value.push_back(raw[lastFoundIndex].toAscii()); + ++lastFoundIndex; + } + + // In order to use XML tags, the text inside the tags has to be unescaped. + value = Project::unescapeXML(value); + + row.push_back(value); + + ++colIndex; + } + + if (mustStop) { + break; + } + + if ((int)row.size() == colsCount) { + table->push_back(row); + } else { + throw std::logic_error("KnobTable: mal-formed table"); + } + + + } +} + +std::string +KnobTable::encodeToKnobTableFormatSingleCol(const std::list& table) +{ + std::list > tmp; + for (std::list::const_iterator it = table.begin(); it!=table.end(); ++it) { + std::vector vec; + vec.push_back(*it); + tmp.push_back(vec); + } + return encodeToKnobTableFormat(tmp); +} + + + +std::string +KnobTable::encodeToKnobTableFormat(const std::list >& table) +{ + std::stringstream ss; + + + for (std::list >::const_iterator it = table.begin(); it != table.end(); ++it) { + // In order to use XML tags, the text inside the tags has to be escaped. + for (std::size_t c = 0; c < it->size(); ++c) { + + std::string label = getColumnLabel(c); + ss << "<" << label << ">"; + ss << Project::escapeXML((*it)[c]); + ss << ""; + } + } + return ss.str(); + +} + +void +KnobTable::setTableSingleCol(const std::list& table) +{ + std::list > tmp; + for (std::list::const_iterator it = table.begin(); it!=table.end(); ++it) { + std::vector vec; + vec.push_back(*it); + tmp.push_back(vec); + } + setTable(tmp); +} + +void +KnobTable::setTable(const std::list >& table) +{ + setValue(encodeToKnobTableFormat(table)); +} + +void +KnobTable::appendRowSingleCol(const std::string& row) +{ + std::vector tmp; + tmp.push_back(row); + appendRow(tmp); +} + +void +KnobTable::appendRow(const std::vector& row) +{ + std::list > table; + getTable(&table); + table.push_back(row); + setTable(table); +} + +void +KnobTable::insertRowSingleCol(int index, const std::string& row) +{ + std::vector tmp; + tmp.push_back(row); + insertRow(index, tmp); +} + +void +KnobTable::insertRow(int index, const std::vector& row) +{ + std::list > table; + getTable(&table); + if (index < 0 || index >= (int)table.size()) { + table.push_back(row); + } else { + std::list >::iterator pos = table.begin(); + std::advance(pos, index); + table.insert(pos, row); + } + + setTable(table); +} + +void +KnobTable::removeRow(int index) +{ + std::list > table; + getTable(&table); + if (index < 0 || index >= (int)table.size()) { + return; + } + std::list >::iterator pos = table.begin(); + std::advance(pos, index); + table.erase(pos); + setTable(table); +} + + +const std::string KnobLayers::_typeNameStr("Layers"); + +const std::string& +KnobLayers::typeNameStatic() +{ + return _typeNameStr; +} + NATRON_NAMESPACE_EXIT; NATRON_NAMESPACE_USING; diff --git a/Engine/KnobTypes.h b/Engine/KnobTypes.h index b757b1b585..f528336f65 100644 --- a/Engine/KnobTypes.h +++ b/Engine/KnobTypes.h @@ -391,6 +391,21 @@ class KnobButton }; /******************************KnobChoice**************************************/ +class KnobChoiceMergeEntriesData +{ +public: + + KnobChoiceMergeEntriesData() + { + + } + + virtual void clear() = 0; + + virtual ~KnobChoiceMergeEntriesData() { + + } +}; class KnobChoice : public QObject,public Knob @@ -400,6 +415,13 @@ GCC_DIAG_SUGGEST_OVERRIDE_OFF GCC_DIAG_SUGGEST_OVERRIDE_ON public: + + // Used in populateChoices() to add new entries in the menu. If not passed the entries will be completly replaced. + // It should return wether a equals b. The userData are the one passed to populateChoice and can be used to store temporary + // potentially costly operations. + // The clear() function will be called right before attempting to compare the first member of the entries to merge to b. + // Then throughout the cycling of the internal entries, b will remain at the same value and temporary data can be used. + typedef bool (*MergeMenuEqualityFunctor)(const std::string& a, const std::string& b, KnobChoiceMergeEntriesData* userData); static KnobHelper * BuildKnob(KnobHolder* holder, const std::string &label, @@ -416,13 +438,29 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual ~KnobChoice(); - /*Must be called right away after the constructor.*/ - void populateChoices( const std::vector &entries, const std::vector &entriesHelp = std::vector() ); + /** + * @brief Fills-up the menu with the given entries and optionnally their tooltip. + * @param entriesHelp Can either be empty, meaning no-tooltip or must be of the size of the entries. + * @param mergingFunctor If not set, the internal menu will be completely reset and replaced with the given entries. + * Otherwise the internal menu entries will be merged with the given entries according to this equality functor. + * @param mergingData Can be passed when mergingFunctor is not null to speed up the comparisons. + * + * @returns true if something changed, false otherwise. + **/ + bool populateChoices(const std::vector &entries, + const std::vector &entriesHelp = std::vector(), + MergeMenuEqualityFunctor mergingFunctor = 0, + KnobChoiceMergeEntriesData* mergingData = 0, + bool restoreOldChoice = true); void resetChoices(); void appendChoice(const std::string& entry, const std::string& help = std::string()); + void refreshMenu(); + + bool isActiveEntryPresentInEntries() const; + std::vector getEntries_mt_safe() const; const std::string& getEntry(int v) const; std::vector getEntriesHelp_mt_safe() const; @@ -482,21 +520,26 @@ public Q_SLOTS: private: - - void findAndSetOldChoice(const std::vector& newEntries); + void findAndSetOldChoice(MergeMenuEqualityFunctor mergingFunctor = 0, + KnobChoiceMergeEntriesData* mergingData = 0); virtual bool canAnimate() const OVERRIDE FINAL; virtual const std::string & typeName() const OVERRIDE FINAL; virtual void handleSignalSlotsForAliasLink(const KnobPtr& alias,bool connect) OVERRIDE FINAL; virtual void onInternalValueChanged(int dimension, double time, ViewSpec view) OVERRIDE FINAL; + virtual void cloneExtraData(KnobI* other,int dimension = -1) OVERRIDE FINAL; + virtual bool cloneExtraDataAndCheckIfChanged(KnobI* other,int dimension = -1) OVERRIDE FINAL; + virtual void cloneExtraData(KnobI* other, double offset, const RangeD* range,int dimension = -1) OVERRIDE FINAL; private: mutable QMutex _entriesMutex; - std::vector _entries; - std::vector _entriesHelp; + std::vector _newEntries,_mergedEntries; + + + std::vector _newEntriesHelp,_mergedEntriesHelp; - std::string _lastValidEntry; // protected by _entriesMutex + std::string _currentEntryLabel; // protected by _entriesMutex bool _addNewChoice; static const std::string _typeNameStr; bool _isCascading; @@ -923,6 +966,132 @@ public Q_SLOTS: static const std::string _typeNameStr; }; +/** + * @brief A Table containing strings. The number of columns is static. + **/ +class KnobTable +: public Knob +{ + +public: + + + KnobTable(KnobHolder* holder, + const std::string &description, + int dimension, + bool declaredByPlugin); + + virtual ~KnobTable(); + + void getTable(std::list >* table); + void getTableSingleCol(std::list* table); + + void decodeFromKnobTableFormat(const std::string& value, std::list >* table); + std::string encodeToKnobTableFormat(const std::list >& table); + std::string encodeToKnobTableFormatSingleCol(const std::list& table); + + void setTable(const std::list >& table); + void setTableSingleCol(const std::list& table); + void appendRow(const std::vector& row); + void appendRowSingleCol(const std::string& row); + void insertRow(int index, const std::vector& row); + void insertRowSingleCol(int index, const std::string& row); + void removeRow(int index); + + virtual int getColumnsCount() const = 0; + + virtual std::string getColumnLabel(int col) const = 0; + + virtual bool isCellEnabled(int row, int col, const QStringList& values) const = 0; + + virtual bool isCellBracketDecorated(int /*row*/, int /*col*/) const { + return false; + } + + virtual bool isColumnEditable(int /*col*/) { + return true; + } + + virtual bool useEditButton() const + { + return true; + } + +private: + + + virtual bool canAnimate() const OVERRIDE FINAL { + return false; + } + +}; + +class KnobLayers +: public KnobTable +{ + +public: + + static KnobHelper * BuildKnob(KnobHolder* holder, + const std::string &label, + int dimension, + bool declaredByPlugin = true) + { + return new KnobLayers(holder, label, dimension, declaredByPlugin); + } + + KnobLayers(KnobHolder* holder, + const std::string &description, + int dimension, + bool declaredByPlugin) + : KnobTable(holder, description, dimension, declaredByPlugin) + { + + } + + virtual ~KnobLayers() + { + + } + + virtual int getColumnsCount() const OVERRIDE FINAL + { + return 2; + } + + virtual std::string getColumnLabel(int col) const OVERRIDE FINAL + { + if (col == 0) { + return "Name"; + } else if (col == 1) { + return "Channels"; + } else { + return ""; + } + } + + virtual bool isCellEnabled(int /*row*/, int /*col*/, const QStringList& /*values*/) const OVERRIDE FINAL WARN_UNUSED_RETURN { + return true; + } + + virtual bool isColumnEditable(int col) OVERRIDE FINAL WARN_UNUSED_RETURN { + if (col == 1) { + return false; + } + return true; + } + + static const std::string & typeNameStatic() WARN_UNUSED_RETURN; + +private: + + virtual const std::string & typeName() const OVERRIDE FINAL + { + return typeNameStatic(); + } + static const std::string _typeNameStr; +}; + NATRON_NAMESPACE_EXIT; #endif // NATRON_ENGINE_KNOBTYPES_H diff --git a/Engine/NatronEngine/app_wrapper.cpp b/Engine/NatronEngine/app_wrapper.cpp index 3eca2bef33..bef4dea91f 100644 --- a/Engine/NatronEngine/app_wrapper.cpp +++ b/Engine/NatronEngine/app_wrapper.cpp @@ -83,6 +83,55 @@ static PyObject* Sbk_AppFunc_addFormat(PyObject* self, PyObject* pyArg) return 0; } +static PyObject* Sbk_AppFunc_addProjectLayer(PyObject* self, PyObject* pyArg) +{ + AppWrapper* cppSelf = 0; + SBK_UNUSED(cppSelf) + if (!Shiboken::Object::isValid(self)) + return 0; + cppSelf = (AppWrapper*)((::App*)Shiboken::Conversions::cppPointer(SbkNatronEngineTypes[SBK_APP_IDX], (SbkObject*)self)); + int overloadId = -1; + PythonToCppFunc pythonToCpp; + SBK_UNUSED(pythonToCpp) + + // Overloaded function decisor + // 0: addProjectLayer(ImageLayer) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppReferenceConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], (pyArg)))) { + overloadId = 0; // addProjectLayer(ImageLayer) + } + + // Function signature not found. + if (overloadId == -1) goto Sbk_AppFunc_addProjectLayer_TypeError; + + // Call function/method + { + if (!Shiboken::Object::isValid(pyArg)) + return 0; + ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer* cppArg0 = &cppArg0_local; + if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp)) + pythonToCpp(pyArg, &cppArg0_local); + else + pythonToCpp(pyArg, &cppArg0); + + + if (!PyErr_Occurred()) { + // addProjectLayer(ImageLayer) + cppSelf->addProjectLayer(*cppArg0); + } + } + + if (PyErr_Occurred()) { + return 0; + } + Py_RETURN_NONE; + + Sbk_AppFunc_addProjectLayer_TypeError: + const char* overloads[] = {"NatronEngine.ImageLayer", 0}; + Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.addProjectLayer", overloads); + return 0; +} + static PyObject* Sbk_AppFunc_closeProject(PyObject* self) { AppWrapper* cppSelf = 0; @@ -1014,6 +1063,7 @@ static PyObject* Sbk_AppFunc_writeToScriptEditor(PyObject* self, PyObject* pyArg static PyMethodDef Sbk_App_methods[] = { {"addFormat", (PyCFunction)Sbk_AppFunc_addFormat, METH_O}, + {"addProjectLayer", (PyCFunction)Sbk_AppFunc_addProjectLayer, METH_O}, {"closeProject", (PyCFunction)Sbk_AppFunc_closeProject, METH_NOARGS}, {"createNode", (PyCFunction)Sbk_AppFunc_createNode, METH_VARARGS|METH_KEYWORDS}, {"createReader", (PyCFunction)Sbk_AppFunc_createReader, METH_VARARGS|METH_KEYWORDS}, diff --git a/Engine/NatronEngine/natronengine_module_wrapper.cpp b/Engine/NatronEngine/natronengine_module_wrapper.cpp index 291fcc53bf..942001f608 100644 --- a/Engine/NatronEngine/natronengine_module_wrapper.cpp +++ b/Engine/NatronEngine/natronengine_module_wrapper.cpp @@ -47,13 +47,8 @@ void init_ImageLayer(PyObject* module); void init_UserParamHolder(PyObject* module); void init_Effect(PyObject* module); void init_Param(PyObject* module); +void init_SeparatorParam(PyObject* module); void init_AnimatedParam(PyObject* module); -void init_BooleanParam(PyObject* module); -void init_StringParamBase(PyObject* module); -void init_StringParam(PyObject* module); -void init_FileParam(PyObject* module); -void init_OutputFileParam(PyObject* module); -void init_PathParam(PyObject* module); void init_IntParam(PyObject* module); void init_Int2DParam(PyObject* module); void init_Int3DParam(PyObject* module); @@ -62,18 +57,23 @@ void init_Double2DParam(PyObject* module); void init_Double3DParam(PyObject* module); void init_ColorParam(PyObject* module); void init_ChoiceParam(PyObject* module); -void init_ButtonParam(PyObject* module); -void init_SeparatorParam(PyObject* module); +void init_BooleanParam(PyObject* module); +void init_StringParamBase(PyObject* module); +void init_StringParam(PyObject* module); +void init_FileParam(PyObject* module); +void init_OutputFileParam(PyObject* module); +void init_PathParam(PyObject* module); void init_GroupParam(PyObject* module); -void init_PageParam(PyObject* module); void init_ParametricParam(PyObject* module); +void init_PageParam(PyObject* module); +void init_ButtonParam(PyObject* module); +void init_RectI(PyObject* module); +void init_RectD(PyObject* module); void init_Int2DTuple(PyObject* module); void init_Int3DTuple(PyObject* module); void init_Double2DTuple(PyObject* module); void init_Double3DTuple(PyObject* module); void init_ColorTuple(PyObject* module); -void init_RectI(PyObject* module); -void init_RectD(PyObject* module); void init_NATRON_NAMESPACE(PyObject* module); // Required modules' type and converter arrays. @@ -618,13 +618,8 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) init_UserParamHolder(module); init_Effect(module); init_Param(module); + init_SeparatorParam(module); init_AnimatedParam(module); - init_BooleanParam(module); - init_StringParamBase(module); - init_StringParam(module); - init_FileParam(module); - init_OutputFileParam(module); - init_PathParam(module); init_IntParam(module); init_Int2DParam(module); init_Int3DParam(module); @@ -633,18 +628,23 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) init_Double3DParam(module); init_ColorParam(module); init_ChoiceParam(module); - init_ButtonParam(module); - init_SeparatorParam(module); + init_BooleanParam(module); + init_StringParamBase(module); + init_StringParam(module); + init_FileParam(module); + init_OutputFileParam(module); + init_PathParam(module); init_GroupParam(module); - init_PageParam(module); init_ParametricParam(module); + init_PageParam(module); + init_ButtonParam(module); + init_RectI(module); + init_RectD(module); init_Int2DTuple(module); init_Int3DTuple(module); init_Double2DTuple(module); init_Double3DTuple(module); init_ColorTuple(module); - init_RectI(module); - init_RectD(module); init_NATRON_NAMESPACE(module); // Register converter for type 'NatronEngine.std::size_t'. diff --git a/Engine/NatronEngine/natronengine_python.h b/Engine/NatronEngine/natronengine_python.h index 45d0577bfd..0484f58b1c 100644 --- a/Engine/NatronEngine/natronengine_python.h +++ b/Engine/NatronEngine/natronengine_python.h @@ -71,25 +71,17 @@ CLANG_DIAG_ON(uninitialized) #define SBK_NATRON_NAMESPACE_PLAYBACKMODEENUM_IDX 36 #define SBK_NATRON_NAMESPACE_PIXMAPENUM_IDX 35 #define SBK_NATRON_NAMESPACE_VIEWERCOLORSPACEENUM_IDX 40 -#define SBK_RECTD_IDX 49 -#define SBK_RECTI_IDX 50 #define SBK_COLORTUPLE_IDX 9 #define SBK_DOUBLE3DTUPLE_IDX 13 #define SBK_DOUBLE2DTUPLE_IDX 11 #define SBK_INT3DTUPLE_IDX 23 #define SBK_INT2DTUPLE_IDX 21 +#define SBK_RECTD_IDX 49 +#define SBK_RECTI_IDX 50 #define SBK_PARAM_IDX 44 -#define SBK_PARAMETRICPARAM_IDX 45 -#define SBK_PAGEPARAM_IDX 43 -#define SBK_GROUPPARAM_IDX 18 -#define SBK_SEPARATORPARAM_IDX 52 #define SBK_BUTTONPARAM_IDX 6 +#define SBK_PARAMETRICPARAM_IDX 45 #define SBK_ANIMATEDPARAM_IDX 0 -#define SBK_CHOICEPARAM_IDX 7 -#define SBK_COLORPARAM_IDX 8 -#define SBK_DOUBLEPARAM_IDX 14 -#define SBK_DOUBLE2DPARAM_IDX 10 -#define SBK_DOUBLE3DPARAM_IDX 12 #define SBK_INTPARAM_IDX 24 #define SBK_INT2DPARAM_IDX 20 #define SBK_INT3DPARAM_IDX 22 @@ -100,6 +92,14 @@ CLANG_DIAG_ON(uninitialized) #define SBK_STRINGPARAM_IDX 53 #define SBK_STRINGPARAM_TYPEENUM_IDX 54 #define SBK_BOOLEANPARAM_IDX 5 +#define SBK_CHOICEPARAM_IDX 7 +#define SBK_COLORPARAM_IDX 8 +#define SBK_DOUBLEPARAM_IDX 14 +#define SBK_DOUBLE2DPARAM_IDX 10 +#define SBK_DOUBLE3DPARAM_IDX 12 +#define SBK_PAGEPARAM_IDX 43 +#define SBK_GROUPPARAM_IDX 18 +#define SBK_SEPARATORPARAM_IDX 52 #define SBK_USERPARAMHOLDER_IDX 56 #define SBK_IMAGELAYER_IDX 19 #define SBK_ROTO_IDX 51 @@ -158,25 +158,17 @@ template<> inline PyTypeObject* SbkType inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_NATRON_NAMESPACE_PLAYBACKMODEENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_NATRON_NAMESPACE_PIXMAPENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_NATRON_NAMESPACE_VIEWERCOLORSPACEENUM_IDX]; } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTD_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTI_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_COLORTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE3DTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE2DTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT3DTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT2DTUPLE_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTD_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTI_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PARAMETRICPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PAGEPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_GROUPPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_SEPARATORPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_BUTTONPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PARAMETRICPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_ANIMATEDPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_CHOICEPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_COLORPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLEPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE2DPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE3DPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INTPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT2DPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT3DPARAM_IDX]); } @@ -187,6 +179,14 @@ template<> inline PyTypeObject* SbkType() { return template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_STRINGPARAM_TYPEENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_STRINGPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_BOOLEANPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_CHOICEPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_COLORPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLEPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE2DPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE3DPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PAGEPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_GROUPPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_SEPARATORPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_USERPARAMHOLDER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_IMAGELAYER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_ROTO_IDX]); } diff --git a/Engine/Node.cpp b/Engine/Node.cpp index fa2fd6e748..c4c7717ce9 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -109,7 +109,6 @@ namespace { // protect local classes in anonymous namespace public: boost::weak_ptr layer; - boost::weak_ptr layerName; bool hasAllChoice; // if true, the layer has a "all" entry mutable QMutex compsMutex; @@ -119,7 +118,6 @@ namespace { // protect local classes in anonymous namespace ChannelSelector() : layer() - , layerName() , hasAllChoice(false) , compsMutex() , compsAvailable() @@ -134,7 +132,6 @@ namespace { // protect local classes in anonymous namespace void operator=(const ChannelSelector& other) { layer = other.layer; hasAllChoice = other.hasAllChoice; - layerName = other.layerName; QMutexLocker k(&compsMutex); compsAvailable = other.compsAvailable; } @@ -146,7 +143,6 @@ namespace { // protect local classes in anonymous namespace boost::weak_ptr enabled; boost::weak_ptr channel; - boost::weak_ptr channelName; mutable QMutex compsMutex; //Stores the components available at build time of the choice menu @@ -156,7 +152,6 @@ namespace { // protect local classes in anonymous namespace MaskSelector() : enabled() , channel() - , channelName() , compsMutex() , compsAvailable() { @@ -170,7 +165,6 @@ namespace { // protect local classes in anonymous namespace void operator=(const MaskSelector& other) { enabled = other.enabled; channel = other.channel; - channelName = other.channelName; QMutexLocker k(&compsMutex); compsAvailable = other.compsAvailable; } @@ -365,7 +359,7 @@ struct Node::Implementation void runInputChangedCallback(int index,const std::string& script); - void createChannelSelector(int inputNb,const std::string & inputName, bool isOutput,const boost::shared_ptr& page); + void createChannelSelector(int inputNb,const std::string & inputName, bool isOutput,const boost::shared_ptr& page, KnobPtr* lastKnobBeforeAdvancedOption); void onLayerChanged(int inputNb,const ChannelSelector& selector); @@ -3304,7 +3298,8 @@ void Node::createMaskSelectors(const std::vector >& hasMaskChannelSelector, const std::vector& inputLabels, const boost::shared_ptr& mainPage, - bool addNewLineOnLastMask) + bool addNewLineOnLastMask, + KnobPtr* lastKnobCreated) { assert(hasMaskChannelSelector.size() == inputLabels.size()); @@ -3343,6 +3338,14 @@ Node::createMaskSelectors(const std::vector >& hasMaskChann std::vector choices; choices.push_back("None"); + + const ImageComponents& rgba = ImageComponents::getRGBAComponents(); + const std::string& rgbaCompname = rgba.getComponentsGlobalName(); + const std::vector& rgbaChannels = rgba.getComponentsNames(); + for (std::size_t i = 0; i < rgbaChannels.size(); ++i) { + std::string option = rgbaCompname + '.' + rgbaChannels[i]; + choices.push_back(option); + } /*const ImageComponents& rgba = ImageComponents::getRGBAComponents(); const std::vector& channels = rgba.getComponentsNames(); const std::string& layerName = rgba.getComponentsGlobalName(); @@ -3363,27 +3366,19 @@ Node::createMaskSelectors(const std::vector >& hasMaskChann channel->setName(channelMaskName); } sel.channel = channel; - channel->setAddNewLine(false); if (mainPage) { mainPage->addKnob(channel); } - - boost::shared_ptr channelName = AppManager::createKnob(_imp->effect.get(), "",1,false); - channelName->setSecretByDefault(true); - channelName->setEvaluateOnChange(false); - channelName->setDefaultValue(choices[choices.size() - 1]); - if (mainPage) { - mainPage->addKnob(channelName); - } - sel.channelName = channelName; - + //Make sure the first default param in the vector is MaskInvert if (!addNewLineOnLastMask) { //If there is a MaskInvert parameter, make it on the same line as the Mask channel parameter - channelName->setAddNewLine(false); + channel->setAddNewLine(false); + } + if (!*lastKnobCreated) { + *lastKnobCreated = channel; } - _imp->maskSelectors[i] = sel; @@ -3542,26 +3537,19 @@ Node::findOrCreateChannelEnabled(const boost::shared_ptr& mainPage) void Node::createChannelSelectors(const std::vector >& hasMaskChannelSelector, const std::vector& inputLabels, - const boost::shared_ptr& mainPage) + const boost::shared_ptr& mainPage, + KnobPtr* lastKnobBeforeAdvancedOption) { - KnobsVec mainPageChildren = mainPage->getChildren(); - bool skipSeparator = !mainPageChildren.empty() && dynamic_cast(mainPageChildren.back().get()); - - if (!skipSeparator) { - boost::shared_ptr sep = AppManager::createKnob(_imp->effect.get(), "", 1, false); - sep->setName("advancedSep"); - mainPage->addKnob(sep); - } - + ///Create input layer selectors for (std::size_t i = 0; i < inputLabels.size(); ++i) { if (!hasMaskChannelSelector[i].first) { - _imp->createChannelSelector(i,inputLabels[i], false, mainPage); + _imp->createChannelSelector(i,inputLabels[i], false, mainPage, lastKnobBeforeAdvancedOption); } } ///Create output layer selectors - _imp->createChannelSelector(-1, "Output", true, mainPage); + _imp->createChannelSelector(-1, "Output", true, mainPage, lastKnobBeforeAdvancedOption); } void @@ -3622,8 +3610,9 @@ Node::initializeDefaultKnobs(int renderScaleSupportPref,bool loadingSerializatio assert(mainPage); // Create the Output Layer choice if needed plus input layers selectors + KnobPtr lastKnobBeforeAdvancedOption; if (_imp->effect->getCreateChannelSelectorKnob()) { - createChannelSelectors(hasMaskChannelSelector, inputLabels, mainPage); + createChannelSelectors(hasMaskChannelSelector, inputLabels, mainPage, &lastKnobBeforeAdvancedOption); } @@ -3646,7 +3635,7 @@ Node::initializeDefaultKnobs(int renderScaleSupportPref,bool loadingSerializatio assert(foundPluginDefaultKnobsToReorder.size() > 0 && foundPluginDefaultKnobsToReorder[0].first == kOfxMaskInvertParamName); - createMaskSelectors(hasMaskChannelSelector, inputLabels, mainPage, !foundPluginDefaultKnobsToReorder[0].second.get()); + createMaskSelectors(hasMaskChannelSelector, inputLabels, mainPage, !foundPluginDefaultKnobsToReorder[0].second.get(), &lastKnobBeforeAdvancedOption); //Create the host mix if needed @@ -3667,6 +3656,28 @@ Node::initializeDefaultKnobs(int renderScaleSupportPref,bool loadingSerializatio } } + if (lastKnobBeforeAdvancedOption) { + KnobsVec mainPageChildren = mainPage->getChildren(); + int i = 0; + for (KnobsVec::iterator it = mainPageChildren.begin(); it != mainPageChildren.end(); ++it, ++i) { + if (*it == lastKnobBeforeAdvancedOption) { + if (i > 0) { + KnobsVec::iterator prev = it; + --prev; + if (!dynamic_cast(prev->get())) { + boost::shared_ptr sep = AppManager::createKnob(_imp->effect.get(), "", 1, false); + sep->setName("advancedSep"); + mainPage->insertKnob(i - 1, sep); + } + } + + break; + } + } + + } + + createNodePage(settingsPage,renderScaleSupportPref); createInfoPage(); @@ -3728,7 +3739,8 @@ Node::initializeKnobs(int renderScaleSupportPref,bool loadingSerialization) void Node::Implementation::createChannelSelector(int inputNb,const std::string & inputName,bool isOutput, - const boost::shared_ptr& page) + const boost::shared_ptr& page, + KnobPtr* lastKnobBeforeAdvancedOption) { ChannelSelector sel; @@ -3758,14 +3770,9 @@ Node::Implementation::createChannelSelector(int inputNb,const std::string & inpu std::map defaultLayers; { - int i = 0; - while (ImageComponents::defaultComponents[i][0] != 0) { - std::string layer = ImageComponents::defaultComponents[i][0]; - if (layer != kNatronAlphaComponentsName && layer != kNatronRGBAComponentsName && layer != kNatronRGBComponentsName) { - //Do not add the color plane, because it is handled in a separate case to make sure it is always the first choice - defaultLayers[layer] = -1; - } - ++i; + std::vector projectLayers = _publicInterface->getApp()->getProject()->getProjectDefaultLayerNames(); + for (std::size_t i = 0; i < projectLayers.size(); ++i) { + defaultLayers[projectLayers[i]] = -1; } } baseLayers.push_back(kNatronRGBAPlaneUserName); @@ -3788,14 +3795,9 @@ Node::Implementation::createChannelSelector(int inputNb,const std::string & inpu } layer->setDefaultValue(defVal); - boost::shared_ptr layerName = AppManager::createKnob(effect.get(), inputName + "_layer_name", 1, false); - layerName->setSecretByDefault(true); - layerName->setAnimationEnabled(false); - layerName->setEvaluateOnChange(false); - layerName->setDefaultValue(baseLayers[defVal]); - //layerName->setAddNewLine(!sel.useRGBASelectors); - page->addKnob(layerName); - sel.layerName = layerName; + if (!*lastKnobBeforeAdvancedOption) { + *lastKnobBeforeAdvancedOption = layer; + } channelsSelectors[inputNb] = sel; @@ -7741,15 +7743,8 @@ Node::Implementation::getSelectedLayerInternal(int inputNb,const ChannelSelector boost::shared_ptr layerKnob = selector.layer.lock(); assert(layerKnob); - int index = layerKnob->getValue(); - std::vector entries = layerKnob->getEntries_mt_safe(); - if (entries.empty()) { - return false; - } - if (index < 0 || index >= (int)entries.size()) { - return false; - } - const std::string& layer = entries[index]; + std::string layer = layerKnob->getActiveEntryText_mt_safe(); + if (layer == "All") { return false; } @@ -7779,17 +7774,16 @@ Node::Implementation::getSelectedLayerInternal(int inputNb,const ChannelSelector } } } + + if (comp->getNumComponents() == 0) { - if (mappedLayerName == kNatronRGBAComponentsName) { - *comp = ImageComponents::getRGBAComponents(); - } else if (mappedLayerName == kNatronDisparityLeftPlaneName) { - *comp = ImageComponents::getDisparityLeftComponents(); - } else if (mappedLayerName == kNatronDisparityRightPlaneName) { - *comp = ImageComponents::getDisparityRightComponents(); - } else if (mappedLayerName == kNatronBackwardMotionVectorsPlaneName) { - *comp = ImageComponents::getBackwardMotionComponents(); - } else if (mappedLayerName == kNatronForwardMotionVectorsPlaneName) { - *comp = ImageComponents::getForwardMotionComponents(); + + std::vector projectLayers = _publicInterface->getApp()->getProject()->getProjectDefaultLayers(); + for (std::size_t i = 0; i < projectLayers.size(); ++i) { + if (projectLayers[i].getLayerName() == mappedLayerName) { + *comp = projectLayers[i]; + break; + } } } return true; @@ -7802,13 +7796,10 @@ Node::Implementation::onLayerChanged(int inputNb,const ChannelSelector& selector { boost::shared_ptr layerKnob = selector.layer.lock(); - std::vector entries = layerKnob->getEntries_mt_safe(); - int curLayer_i = layerKnob->getValue(); - assert(curLayer_i >= 0 && curLayer_i < (int)entries.size()); - selector.layerName.lock()->setValue(entries[curLayer_i]); + std::string curLayer = layerKnob->getActiveEntryText_mt_safe(); if (inputNb == -1) { - bool outputIsAll = entries[curLayer_i] == "All"; + bool outputIsAll = curLayer == "All"; ///Disable all input selectors as it doesn't make sense to edit them whilst output is All for (std::map::iterator it = channelsSelectors.begin(); it != channelsSelectors.end(); ++it) { @@ -7925,15 +7916,6 @@ Node::Implementation::onMaskSelectorChanged(int inputNb,const MaskSelector& sele } } - std::vector entries = channel->getEntries_mt_safe(); - int curChan_i = channel->getValue(); - if (curChan_i < 0 || curChan_i >= (int)entries.size()) { - _publicInterface->refreshChannelSelectors(); - return; - } - selector.channelName.lock()->setValue(entries[curChan_i]); - - if (!isRefreshingInputRelatedData) { ///Clip preferences have changed RenderScale s(1.); @@ -8724,7 +8706,7 @@ bool Node::refreshLayersChoiceSecretness(int inputNb) { std::map::iterator foundChan = _imp->channelsSelectors.find(inputNb); - NodePtr inp = getInput(inputNb); + NodePtr inp = getInputInternal(false/*useGuiInput*/, false/*useGroupRedirections*/, inputNb); if ( foundChan != _imp->channelsSelectors.end() ) { std::map::iterator foundOuptut = _imp->channelsSelectors.find(-1); bool outputIsAll = false; @@ -8804,12 +8786,16 @@ Node::refreshAllInputRelatedData(bool /*canChangeValues*/,const std::vectorgetProject()->isLoadingProject(); ///if all non optional clips are connected, call getClipPrefs ///The clip preferences action is never called until all non optional clips have been attached to the plugin. - if (!hasMandatoryInputDisconnected()) { + /// EDIT: we allow calling getClipPreferences even if some non optional clip is not connected so that layer menus get properly created + const bool canCallRefreshMetaData = true; // = !hasMandatoryInputDisconnected(); + + if (canCallRefreshMetaData) { - if (getApp()->getProject()->isLoadingProject()) { + if (loadingProject) { //Nb: we clear the action cache because when creating the node many calls to getRoD and stuff might have returned //empty rectangles, but since we force the hash to remain what was in the project file, we might then get wrong RoDs returned _imp->effect->clearActionsCache(); @@ -8841,7 +8827,7 @@ Node::refreshAllInputRelatedData(bool /*canChangeValues*/,const std::vectorgetProject()->isLoadingProject()) { + if (loadingProject) { //When loading the project, refresh the hash of the nodes in a recursive manner in the proper order //for the disk cache to work hasChanged |= computeHashInternal(); @@ -9222,14 +9208,20 @@ Node::deleteNodeVariableToPython(const std::string& nodeName) return; } QString appID = QString::fromUtf8(getApp()->getAppIDString().c_str()); - QString str = QString(QString::fromUtf8("del ") + appID + QString::fromUtf8(".%1")).arg(QString::fromUtf8(nodeName.c_str())); - std::string script = str.toStdString(); - std::string err; - if (!appPTR->isBackground()) { - getApp()->printAutoDeclaredVariable(script); - } - if (!Python::interpretPythonScript(script, &err, 0)) { - qDebug() << err.c_str(); + std::string nodeFullName = appID.toStdString() + "." + nodeName; + bool alreadyDefined = false; + PyObject* nodeObj = Python::getAttrRecursive(nodeFullName, appPTR->getMainModule(), &alreadyDefined); + assert(nodeObj); + Q_UNUSED(nodeObj); + if (alreadyDefined) { + std::string script = "del " + nodeFullName; + std::string err; + if (!appPTR->isBackground()) { + getApp()->printAutoDeclaredVariable(script); + } + if (!Python::interpretPythonScript(script, &err, 0)) { + qDebug() << err.c_str(); + } } } @@ -9690,6 +9682,151 @@ Node::checkForPremultWarningAndCheckboxes() } + +static void parseLayerString(const std::string& encoded, bool* isColor) +{ + if (encoded == kNatronRGBAPlaneUserName || + encoded == kNatronRGBPlaneUserName || + encoded == kNatronAlphaPlaneUserName) { + *isColor = true; + } else { + *isColor = false; + } +} + +static void parseMaskChannelString(const std::string& encodedChannel, + std::string* nodeName, + std::string* layerName, + std::string* channelName, + bool *isColor) +{ + std::size_t foundLastDot = encodedChannel.find_last_of("."); + if (foundLastDot != std::string::npos) { + *layerName = encodedChannel.substr(0, foundLastDot); + std::size_t foundPrevDot = layerName->find_first_of("."); + if (foundPrevDot != std::string::npos) { + //Remove the node name + *layerName = layerName->substr(foundPrevDot + 1); + *nodeName = layerName->substr(0, foundPrevDot); + } else { + *nodeName = *layerName; + layerName->clear(); + } + *isColor = *layerName == kNatronRGBAComponentsName || *layerName == kNatronRGBComponentsName || *layerName == kNatronAlphaComponentsName; + *channelName = encodedChannel.substr(foundLastDot + 1); + } +} + +class MergeMaskChannelData : public KnobChoiceMergeEntriesData +{ +public: + + std::string bNode, bLayer, bChannel; + bool isColor; + bool dataSet; + + MergeMaskChannelData() + : KnobChoiceMergeEntriesData() + , isColor(false) + , dataSet(false) + { + + } + + virtual void clear() + { + dataSet = false; + } + + virtual ~MergeMaskChannelData() + { + + } +}; + +static bool maskChannelEqualityFunctorInternal(const std::string& aLayer, + const std::string& aChannel, + const std::string& bLayer, + const std::string& bChannel, + bool aIsColor, + bool bIsColor) +{ + if (aChannel.empty() && bChannel.empty()) { + // None choice + return aLayer == bLayer; + } else if (aChannel != bChannel) { + return false; + } else { + // Same channel, check layer + if (aLayer == bLayer) { + return true; + } else if (aIsColor && bIsColor) { + return true; + } + } + return false; +} + +static bool maskChannelEqualityFunctor(const std::string& a, const std::string& b, KnobChoiceMergeEntriesData* data) +{ + MergeMaskChannelData* mergeData = dynamic_cast(data); + assert(mergeData); + std::string aNode,aLayer,aChannel; + bool aIsColor; + parseMaskChannelString(a,&aNode,&aLayer,&aChannel,&aIsColor); + if (!mergeData->dataSet) { + parseMaskChannelString(b,&mergeData->bNode,&mergeData->bLayer,&mergeData->bChannel,&mergeData->isColor); + mergeData->dataSet = true; + } + return maskChannelEqualityFunctorInternal(aLayer, aChannel, mergeData->bLayer, mergeData->bChannel, aIsColor, mergeData->isColor); +} + + +class MergeLayerData : public KnobChoiceMergeEntriesData +{ +public: + + bool isColor; + bool dataSet; + + MergeLayerData() + : KnobChoiceMergeEntriesData() + , isColor(false) + , dataSet(false) + { + + } + + virtual void clear() + { + dataSet = false; + } + + virtual ~MergeLayerData() + { + + } +}; + + +static bool layerEqualityFunctor(const std::string& a, const std::string& b, KnobChoiceMergeEntriesData* data) +{ + MergeLayerData* mergeData = dynamic_cast(data); + assert(mergeData); + bool aIsColor; + parseLayerString(a, &aIsColor); + if (!mergeData->dataSet) { + parseLayerString(b, &mergeData->isColor); + mergeData->dataSet = true; + } + if (aIsColor && mergeData->isColor) { + return true; + } else if (a == b) { + return true; + } + return false; +} + bool Node::refreshChannelSelectors() { @@ -9711,12 +9848,8 @@ Node::refreshChannelSelectors() } boost::shared_ptr layerKnob = it->second.layer.lock(); - const std::vector currentLayerEntries = layerKnob->getEntries_mt_safe(); - const std::string curLayer_internalName = it->second.layerName.lock()->getValue(); - const std::string curLayer = ImageComponents::mapUserFriendlyPlaneNameToNatronInternalPlaneName(curLayer_internalName); - - bool isCurLayerColorComp = curLayer == kNatronAlphaComponentsName || curLayer == kNatronRGBAComponentsName || curLayer == kNatronRGBComponentsName; - + + // The Output Layer menu has a All choice, input layers menus have a None choice. std::vector choices; if (it->second.hasAllChoice) { choices.push_back("All"); @@ -9725,31 +9858,25 @@ Node::refreshChannelSelectors() } int gotColor = -1; - ImageComponents colorComp,selectedComp; + ImageComponents colorComp; - /* - These are default layers that we always display in the layer selector. - If one of them is found in the clip preferences, we set the default value to it. - */ + // + // These are default layers that we always display in the layer selector. + // If one of them is found in the clip preferences, we set the default value to it. + // std::map defaultLayers; { - int i = 0; - while (ImageComponents::defaultComponents[i][0] != 0) { - std::string layer = ImageComponents::defaultComponents[i][0]; - if (layer != kNatronAlphaComponentsName && layer != kNatronRGBAComponentsName && layer != kNatronRGBComponentsName) { - //Do not add the color plane, because it is handled in a separate case to make sure it is always the first choice - defaultLayers[layer] = -1; - } - ++i; + std::vector projectLayers = getApp()->getProject()->getProjectDefaultLayerNames(); + for (std::size_t i = 0; i < projectLayers.size(); ++i) { + defaultLayers[projectLayers[i]] = -1; } } + - int foundCurLayerChoice = -1; - if (curLayer == "All" || curLayer == "None") { - foundCurLayerChoice = 0; - } - + // We may not have an input if (node) { + + // Get the components available on the node EffectInstance::ComponentsAvailableMap compsAvailable; node->getEffectInstance()->getComponentsAvailable(it->first != -1, true, time, &compsAvailable); { @@ -9757,6 +9884,8 @@ Node::refreshChannelSelectors() it->second.compsAvailable = compsAvailable; } for (EffectInstance::ComponentsAvailableMap::iterator it2 = compsAvailable.begin(); it2!= compsAvailable.end(); ++it2) { + + // Insert the color plane second in the menu if (it2->first.isColorPlane()) { int numComp = it2->first.getNumComponents(); colorComp = it2->first; @@ -9779,13 +9908,8 @@ Node::refreshChannelSelectors() } choices.insert(pos,colorCompName); - if (foundCurLayerChoice == -1 && isCurLayerColorComp) { - selectedComp = it2->first; - foundCurLayerChoice = 1; - } - - - ///Increment all default indexes + + // Increment all default indexes since we inserted color in the list for (std::map::iterator it = defaultLayers.begin() ;it!=defaultLayers.end(); ++it) { if (it->second != -1) { ++it->second; @@ -9802,15 +9926,11 @@ Node::refreshChannelSelectors() choices.push_back(choiceName); - if (foundCurLayerChoice == -1 && it2->first.getLayerName() == curLayer) { - selectedComp = it2->first; - foundCurLayerChoice = choices.size()-1; - } - } } } // if (node) { + // If we did not find the color plane, insert it since it is the unique mandatory plane. if (gotColor == -1) { assert(choices.size() > 0); std::vector::iterator pos = choices.begin(); @@ -9826,76 +9946,29 @@ Node::refreshChannelSelectors() choices.insert(pos,kNatronRGBAPlaneUserName); } + + // Insert default layers for (std::map::iterator itl = defaultLayers.begin(); itl != defaultLayers.end(); ++itl) { if (itl->second == -1) { std::string choiceName = ImageComponents::mapNatronInternalPlaneNameToUserFriendlyPlaneName(itl->first); choices.push_back(choiceName); - - if (foundCurLayerChoice == -1 && itl->first == curLayer) { - selectedComp = ImageComponents::getDefaultComponent(itl->first); - foundCurLayerChoice = choices.size()-1; - } - } } - if (choices.size() != currentLayerEntries.size()) { - hasChanged = true; - } else { - for (std::size_t i = 0; i < currentLayerEntries.size(); ++i) { - if (currentLayerEntries[i] != choices[i]) { - hasChanged = true; - break; - } - } - } - - layerKnob->populateChoices(choices); - if (hasChanged) { - s_outputLayerChanged(); - } + const std::vector currentLayerEntries = layerKnob->getEntries_mt_safe(); + const std::string curLayer_FriendlyName = layerKnob->getActiveEntryText_mt_safe(); + const std::string curLayer = ImageComponents::mapUserFriendlyPlaneNameToNatronInternalPlaneName(curLayer_FriendlyName); - if (!curLayer.empty() && foundCurLayerChoice != -1) { - //We already had a choice and it was found in the current layers - assert(foundCurLayerChoice >= 0 && foundCurLayerChoice < (int)choices.size()); - layerKnob->blockValueChanges(); - _imp->effect->beginChanges(); - layerKnob->setValue(foundCurLayerChoice); - _imp->effect->endChanges(true); - layerKnob->unblockValueChanges(); - if (it->first == -1 && _imp->enabledChan[0].lock()) { - refreshEnabledKnobsLabel(selectedComp); - } - - } else { - //fallback - bool foundLayer = false; - if (!curLayer_internalName.empty()) { - //check if the layer is in the available options: since we had default layers that may not be produced, it may be in the list - //but not in the components presents - for (std::size_t i = 0; i < currentLayerEntries.size(); ++i) { - if (currentLayerEntries[i] == curLayer_internalName) { - layerKnob->setValue(i); - it->second.layerName.lock()->setValue(choices[i]); - foundLayer = true; - break; - } - } - + { + MergeLayerData tmpData; + bool menuChanged = layerKnob->populateChoices(choices, std::vector(), layerEqualityFunctor,&tmpData); + if (menuChanged) { + hasChanged = true; + s_outputLayerChanged(); } - if (!foundLayer) { - if (it->second.hasAllChoice && - _imp->effect->isPassThroughForNonRenderedPlanes() == EffectInstance::ePassThroughRenderAllRequestedPlanes) { - layerKnob->setValue(0); - it->second.layerName.lock()->setValue(choices[0]); - } else { - assert(gotColor != -1 && gotColor >= 0 && gotColor < (int)choices.size()); - layerKnob->setValue(gotColor); - it->second.layerName.lock()->setValue(choices[gotColor]); - } - } // !foundLayer } + } // for (std::map::iterator it = _imp->channelsSelectors.begin(); it != _imp->channelsSelectors.end(); ++it) { NodePtr prefInputNode; @@ -9913,33 +9986,10 @@ Node::refreshChannelSelectors() } else { node = getInput(it->first); } - - boost::shared_ptr channelKnob = it->second.channel.lock(); - boost::shared_ptr channelNameKnob = it->second.channelName.lock(); - const std::vector currentLayerEntries = channelKnob->getEntries_mt_safe(); - const std::string curLayer = channelNameKnob->getValue(); - std::string curLayerName = curLayer,curChannelName; - { - std::size_t foundLastDot = curLayer.find_last_of("."); - if (foundLastDot != std::string::npos) { - curLayerName = curLayer.substr(0, foundLastDot); - std::size_t foundPrevDot = curLayerName.find_first_of("."); - if (foundPrevDot != std::string::npos) { - //Remove the node name - curLayerName = curLayerName.substr(foundPrevDot + 1); - } - curChannelName = curLayer.substr(foundLastDot + 1); - } - } - - bool isCurLayerColor = curLayerName == kNatronRGBAComponentsName || - curLayerName == kNatronRGBComponentsName || - curLayerName == kNatronAlphaComponentsName; - + std::vector choices; choices.push_back("None"); - int alphaIndex = 0; //Get the mask input components EffectInstance::ComponentsAvailableMap compsAvailable; @@ -9992,21 +10042,11 @@ Node::refreshChannelSelectors() QMutexLocker k(&it->second.compsMutex); it->second.compsAvailable = compsOrdered; } - int foundLastLayerChoice = -1; - if (curLayer == "None") { - foundLastLayerChoice = 0; - } + for (std::vector >::iterator it2 = compsOrdered.begin(); it2!= compsOrdered.end(); ++it2) { const std::vector& channels = it2->first.getComponentsNames(); const std::string& layerName = it2->first.isColorPlane() ? it2->first.getComponentsGlobalName() : it2->first.getLayerName(); - bool isLastLayer = false; - bool isColorPlane = it2->first.isColorPlane(); - - if (foundLastLayerChoice == -1 && (layerName == curLayerName || (isCurLayerColor && isColorPlane))) { - isLastLayer = true; - } - NodePtr providerNode = it2->second.lock(); std::string nodeName; @@ -10015,74 +10055,34 @@ Node::refreshChannelSelectors() } for (std::size_t i = 0; i < channels.size(); ++i) { + std::string option; + option += nodeName; if (!nodeName.empty()) { - option += nodeName; option += '.'; } + option += layerName; if (!layerName.empty()) { - option += layerName; option += '.'; } option += channels[i]; choices.push_back(option); - if (isLastLayer && channels[i] == curChannelName) { - foundLastLayerChoice = choices.size() - 1; - } } - if (it2->first.isColorPlane()) { - if (channels.size() == 1 || channels.size() == 4) { - alphaIndex = choices.size() - 1; - } else { - alphaIndex = 0; - } - } + + } + boost::shared_ptr channelKnob = it->second.channel.lock(); + const std::vector currentLayerEntries = channelKnob->getEntries_mt_safe(); + const std::string curChannelEncoded = channelKnob->getActiveEntryText_mt_safe(); - /*if (!gotColor) { - const ImageComponents& rgba = ImageComponents::getRGBAComponents(); - const std::vector& channels = rgba.getComponentsNames(); - const std::string& layerName = rgba.getComponentsGlobalName(); - for (std::size_t i = 0; i < channels.size(); ++i) { - choices.push_back(layerName + "." + channels[i]); - } - alphaIndex = choices.size() - 1; - }*/ - - if (choices.size() != currentLayerEntries.size()) { - hasChanged = true; - } else { - for (std::size_t i = 0; i < currentLayerEntries.size(); ++i) { - if (currentLayerEntries[i] != choices[i]) { - hasChanged = true; - break; - } - } + // This will merge previous channels with new channels available while retaining previously existing channels. + { + MergeMaskChannelData tmpData; + hasChanged |= channelKnob->populateChoices(choices, std::vector(), maskChannelEqualityFunctor, &tmpData); } - channelKnob->populateChoices(choices); - - /*if (setValues) { - assert(alphaIndex != -1 && alphaIndex >= 0 && alphaIndex < (int)choices.size()); - channelKnob->setValue(alphaIndex,0); - channelNameKnob->setValue(choices[alphaIndex], 0); - } else {*/ - if (foundLastLayerChoice != -1 && foundLastLayerChoice != 0) { - channelKnob->blockValueChanges(); - _imp->effect->beginChanges(); - channelKnob->setValue(foundLastLayerChoice); - channelKnob->unblockValueChanges(); - channelNameKnob->setValue(choices[foundLastLayerChoice]); - _imp->effect->endChanges(); - - } else { - assert(alphaIndex != -1 && alphaIndex >= 0 && alphaIndex < (int)choices.size()); - channelKnob->setValue(alphaIndex); - channelNameKnob->setValue(choices[alphaIndex]); - } - //} } //Notify the effect channels have changed (the viewer needs this) diff --git a/Engine/Node.h b/Engine/Node.h index 0b6ebcea4d..6800621bc4 100644 --- a/Engine/Node.h +++ b/Engine/Node.h @@ -958,7 +958,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void createMaskSelectors(const std::vector >& hasMaskChannelSelector, const std::vector& inputLabels, const boost::shared_ptr& mainPage, - bool addNewLineOnLastMask); + bool addNewLineOnLastMask, + KnobPtr* lastKnobCreated); boost::shared_ptr getOrCreateMainPage(); @@ -968,7 +969,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void createChannelSelectors(const std::vector >& hasMaskChannelSelector, const std::vector& inputLabels, - const boost::shared_ptr& mainPage); + const boost::shared_ptr& mainPage, + KnobPtr* lastKnobBeforeAdvancedOption); public: diff --git a/Engine/OfxParamInstance.cpp b/Engine/OfxParamInstance.cpp index c280f4e004..4130833b2c 100644 --- a/Engine/OfxParamInstance.cpp +++ b/Engine/OfxParamInstance.cpp @@ -309,6 +309,66 @@ OfxParamToKnob::onKnobAnimationLevelChanged(ViewSpec /*view*/, int /*dimension*/ param->getProperties().setIntProperty(kOfxParamPropIsAutoKeying, l == eAnimationLevelInterpolatedValue); } +void +OfxParamToKnob::onChoiceMenuReset() +{ + onChoiceMenuPopulated(); +} + +static void setStringPropertyN(const std::vector& entries, + OFX::Host::Param::Instance* param, + const std::string& property) +{ + try { + OFX::Host::Property::PropertyTemplate *prop = 0; + if (param->getProperties().fetchTypedProperty(property, prop)) { + prop->reset(); + for (std::size_t i = 0; i < entries.size(); ++i) { + prop->setValue(entries[i], i); + } + + } + } catch(...) { + + } +} + +void +OfxParamToKnob::onChoiceMenuPopulated() +{ + DYNAMIC_PROPERTY_CHECK(); + + OFX::Host::Param::Instance* param = getOfxParam(); + assert(param); + KnobPtr knob = getKnob(); + if (!knob) { + return; + } + KnobChoice* isChoice = dynamic_cast(knob.get()); + if (!isChoice) { + return; + } + std::vector entries = isChoice->getEntries_mt_safe(); + std::vector entriesHelp = isChoice->getEntriesHelp_mt_safe(); + setStringPropertyN(entries, param, kOfxParamPropChoiceOption); + setStringPropertyN(entriesHelp, param, kOfxParamPropChoiceLabelOption); + +} + +void +OfxParamToKnob::onChoiceMenuEntryAppended(const QString& entry, const QString& help) +{ + DYNAMIC_PROPERTY_CHECK(); + + OFX::Host::Param::Instance* param = getOfxParam(); + assert(param); + int nProps = param->getProperties().getDimension(kOfxParamPropChoiceOption); + int nLabelProps = param->getProperties().getDimension(kOfxParamPropChoiceLabelOption); + assert(nProps == nLabelProps); + param->getProperties().setStringProperty(kOfxParamPropChoiceOption, entry.toStdString(),nProps); + param->getProperties().setStringProperty(kOfxParamPropChoiceLabelOption, help.toStdString(),nLabelProps); +} + void OfxParamToKnob::onEvaluateOnChangeChanged(bool evaluate) { @@ -997,7 +1057,7 @@ OfxChoiceInstance::OfxChoiceInstance(const boost::shared_ptr& boost::shared_ptr choice = checkIfKnobExistsWithNameOrCreate(descriptor.getName(), this, 1); _knob = choice; - + int dim = getProperties().getDimension(kOfxParamPropChoiceOption); int labelOptionDim = getProperties().getDimension(kOfxParamPropChoiceLabelOption); @@ -1032,6 +1092,10 @@ OfxChoiceInstance::OfxChoiceInstance(const boost::shared_ptr& if (canAddOptions) { choice->setHostCanAddOptions(true); } + QObject::connect(choice.get(), SIGNAL(populated()), this, SLOT(onChoiceMenuPopulated())); + QObject::connect(choice.get(), SIGNAL(entryAppended(QString,QString)), this, SLOT(onChoiceMenuEntryAppended(QString,QString))); + QObject::connect(choice.get(), SIGNAL(entriesReset()), this, SLOT(onChoiceMenuReset())); + } OfxStatus @@ -1121,25 +1185,44 @@ OfxChoiceInstance::setEvaluateOnChange() void OfxChoiceInstance::setOption(int num) { + + DYNAMIC_PROPERTY_CHECK(); + + /* + This function can serve 3 type of behaviours depending on num: + - 0: meaning resetOptions + - num == nDim - 1: meaning appendOption + - num == nDim: meaning setOptions + */ int dim = getProperties().getDimension(kOfxParamPropChoiceOption); boost::shared_ptr knob = _knob.lock(); if (dim == 0) { knob->resetChoices(); return; } - //Only 2 kind of behaviours are supported: either resetOptions (dim == 0) or - //appendOption, hence num == dim -1 - assert(num == dim - 1); - if (num != (dim -1)) { - return; - } - std::string entry = getProperties().getStringProperty(kOfxParamPropChoiceOption,num); - std::string help; - int labelOptionDim = getProperties().getDimension(kOfxParamPropChoiceLabelOption); - if (num < labelOptionDim) { - help = getProperties().getStringProperty(kOfxParamPropChoiceLabelOption,num); + + assert(num == dim - 1 || num == dim); + + if (num == (dim -1)) { + std::string entry = getProperties().getStringProperty(kOfxParamPropChoiceOption,num); + std::string help; + int labelOptionDim = getProperties().getDimension(kOfxParamPropChoiceLabelOption); + if (num < labelOptionDim) { + help = getProperties().getStringProperty(kOfxParamPropChoiceLabelOption,num); + } + knob->appendChoice(entry,help); + } else if (num == dim) { + int labelOptionDim = getProperties().getDimension(kOfxParamPropChoiceLabelOption); + assert(labelOptionDim == 0 || labelOptionDim == dim); + std::vector entries(dim), helps(labelOptionDim); + for (std::size_t i = 0; i < entries.size(); ++i) { + entries[i] = getProperties().getStringProperty(kOfxParamPropChoiceOption,i); + if ((int)i < labelOptionDim) { + helps[i] = getProperties().getStringProperty(kOfxParamPropChoiceLabelOption,i); + } + } + knob->populateChoices(entries, helps); } - knob->appendChoice(entry,help); } KnobPtr diff --git a/Engine/OfxParamInstance.h b/Engine/OfxParamInstance.h index 1b715f52b8..64728718f2 100644 --- a/Engine/OfxParamInstance.h +++ b/Engine/OfxParamInstance.h @@ -177,6 +177,9 @@ public Q_SLOTS: void onDisplayMinMaxChanged(double min, double max, int index); void onMinMaxChanged(double min, double max, int index); void onKnobAnimationLevelChanged(ViewSpec view, int dimension); + void onChoiceMenuReset(); + void onChoiceMenuPopulated(); + void onChoiceMenuEntryAppended(const QString& entry, const QString& help); protected: diff --git a/Engine/Project.cpp b/Engine/Project.cpp index 7e149456ed..488d05503d 100644 --- a/Engine/Project.cpp +++ b/Engine/Project.cpp @@ -750,64 +750,16 @@ Project::initializeKnobs() _imp->addFormatKnob->setName("newFormat"); page->addKnob(_imp->addFormatKnob); - boost::shared_ptr viewsPage = AppManager::createKnob(this, "Views"); - - _imp->viewsList = AppManager::createKnob(this, "Views List"); - _imp->viewsList->setName("viewsList"); - _imp->viewsList->setHintToolTip("The list of the views in the project"); - _imp->viewsList->setAnimationEnabled(false); - _imp->viewsList->setEvaluateOnChange(false); - _imp->viewsList->setAsStringList(true); - std::list > defaultViews; - defaultViews.push_back(std::make_pair("Main","")); - std::string encodedDefaultViews = KnobPath::encodeToMultiPathFormat(defaultViews); - _imp->viewsList->setDefaultValue(encodedDefaultViews); - viewsPage->addKnob(_imp->viewsList); - - _imp->setupForStereoButton = AppManager::createKnob(this, "Setup views for stereo"); - _imp->setupForStereoButton->setName("setupForStereo"); - _imp->setupForStereoButton->setHintToolTip("Quickly setup the views list for stereo"); - _imp->setupForStereoButton->setEvaluateOnChange(false); - viewsPage->addKnob(_imp->setupForStereoButton); - _imp->previewMode = AppManager::createKnob(this, "Auto Previews"); _imp->previewMode->setName("autoPreviews"); _imp->previewMode->setHintToolTip("When checked, preview images on the node graph will be " - "refreshed automatically. You can uncheck this option to improve performances." - "Press P in the node graph to refresh the previews yourself."); + "refreshed automatically. You can uncheck this option to improve performances."); _imp->previewMode->setAnimationEnabled(false); _imp->previewMode->setEvaluateOnChange(false); page->addKnob(_imp->previewMode); bool autoPreviewEnabled = appPTR->getCurrentSettings()->isAutoPreviewOnForNewProjects(); _imp->previewMode->setDefaultValue(autoPreviewEnabled,0); - std::vector colorSpaces; - colorSpaces.push_back("sRGB"); - colorSpaces.push_back("Linear"); - colorSpaces.push_back("Rec.709"); - _imp->colorSpace8u = AppManager::createKnob(this, "Colorspace for 8-Bit Integer Images"); - _imp->colorSpace8u->setName("defaultColorSpace8u"); - _imp->colorSpace8u->setHintToolTip("Defines the color-space in which 8-bit images are assumed to be by default."); - _imp->colorSpace8u->setAnimationEnabled(false); - _imp->colorSpace8u->populateChoices(colorSpaces); - _imp->colorSpace8u->setDefaultValue(0); - page->addKnob(_imp->colorSpace8u); - - _imp->colorSpace16u = AppManager::createKnob(this, "Colorspace for 16-Bit Integer Images"); - _imp->colorSpace16u->setName("defaultColorSpace16u"); - _imp->colorSpace16u->setHintToolTip("Defines the color-space in which 16-bit integer images are assumed to be by default."); - _imp->colorSpace16u->setAnimationEnabled(false); - _imp->colorSpace16u->populateChoices(colorSpaces); - _imp->colorSpace16u->setDefaultValue(2); - page->addKnob(_imp->colorSpace16u); - - _imp->colorSpace32f = AppManager::createKnob(this, "Colorspace for 32-Bit Floating Point Images"); - _imp->colorSpace32f->setName("defaultColorSpace32f"); - _imp->colorSpace32f->setHintToolTip("Defines the color-space in which 32-bit floating point images are assumed to be by default."); - _imp->colorSpace32f->setAnimationEnabled(false); - _imp->colorSpace32f->populateChoices(colorSpaces); - _imp->colorSpace32f->setDefaultValue(1); - page->addKnob(_imp->colorSpace32f); _imp->frameRange = AppManager::createKnob(this, "Frame Range",2); _imp->frameRange->setDefaultValue(1,0); @@ -843,6 +795,92 @@ Project::initializeKnobs() _imp->frameRate->setDisplayMaximum(50.); page->addKnob(_imp->frameRate); + + boost::shared_ptr viewsPage = AppManager::createKnob(this, "Views"); + + _imp->viewsList = AppManager::createKnob(this, "Views List"); + _imp->viewsList->setName("viewsList"); + _imp->viewsList->setHintToolTip("The list of the views in the project"); + _imp->viewsList->setAnimationEnabled(false); + _imp->viewsList->setEvaluateOnChange(false); + _imp->viewsList->setAsStringList(true); + std::list defaultViews; + defaultViews.push_back("Main"); + std::string encodedDefaultViews = _imp->viewsList->encodeToKnobTableFormatSingleCol(defaultViews); + _imp->viewsList->setDefaultValue(encodedDefaultViews); + viewsPage->addKnob(_imp->viewsList); + + _imp->setupForStereoButton = AppManager::createKnob(this, "Setup views for stereo"); + _imp->setupForStereoButton->setName("setupForStereo"); + _imp->setupForStereoButton->setHintToolTip("Quickly setup the views list for stereo"); + _imp->setupForStereoButton->setEvaluateOnChange(false); + viewsPage->addKnob(_imp->setupForStereoButton); + + + boost::shared_ptr LayersPage = AppManager::createKnob(this, "Layers"); + + _imp->defaultLayersList = AppManager::createKnob(this, "Default Layers"); + _imp->defaultLayersList->setName("defaultLayers"); + _imp->defaultLayersList->setHintToolTip("The list of the default layers available in layers menus on nodes."); + _imp->defaultLayersList->setAnimationEnabled(false); + _imp->defaultLayersList->setEvaluateOnChange(false); + std::list > defaultLayers; + { + //Do not add the color plane, because it is handled in a separate case to make sure it is always the first choice + int i = 3; + while (ImageComponents::defaultComponents[i][0]) { + std::vector row(2); + row[0] = ImageComponents::defaultComponents[i][1]; + const ImageComponents& comps = ImageComponents::getDefaultComponent(ImageComponents::defaultComponents[i][0]); + std::string channelsStr; + const std::vector& channels = comps.getComponentsNames(); + for (std::size_t i = 0; i < channels.size(); ++i) { + channelsStr += channels[i]; + if (i < (channels.size() - 1)) { + channelsStr += ' '; + } + } + row[1] = channelsStr; + defaultLayers.push_back(row); + ++i; + } + } + std::string encodedDefaultLayers = _imp->defaultLayersList->encodeToKnobTableFormat(defaultLayers); + _imp->defaultLayersList->setDefaultValue(encodedDefaultLayers); + LayersPage->addKnob(_imp->defaultLayersList); + + + + boost::shared_ptr lutPages = AppManager::createKnob(this, "LUT"); + + std::vector colorSpaces; + colorSpaces.push_back("sRGB"); + colorSpaces.push_back("Linear"); + colorSpaces.push_back("Rec.709"); + _imp->colorSpace8u = AppManager::createKnob(this, "8-Bit Colorspace"); + _imp->colorSpace8u->setName("defaultColorSpace8u"); + _imp->colorSpace8u->setHintToolTip("Defines the color-space in which 8-bit images are assumed to be by default."); + _imp->colorSpace8u->setAnimationEnabled(false); + _imp->colorSpace8u->populateChoices(colorSpaces); + _imp->colorSpace8u->setDefaultValue(0); + lutPages->addKnob(_imp->colorSpace8u); + + _imp->colorSpace16u = AppManager::createKnob(this, "16-Bit Colorspace"); + _imp->colorSpace16u->setName("defaultColorSpace16u"); + _imp->colorSpace16u->setHintToolTip("Defines the color-space in which 16-bit integer images are assumed to be by default."); + _imp->colorSpace16u->setAnimationEnabled(false); + _imp->colorSpace16u->populateChoices(colorSpaces); + _imp->colorSpace16u->setDefaultValue(2); + lutPages->addKnob(_imp->colorSpace16u); + + _imp->colorSpace32f = AppManager::createKnob(this, "32-Bit f.p Colorspace "); + _imp->colorSpace32f->setName("defaultColorSpace32f"); + _imp->colorSpace32f->setHintToolTip("Defines the color-space in which 32-bit floating point images are assumed to be by default."); + _imp->colorSpace32f->setAnimationEnabled(false); + _imp->colorSpace32f->populateChoices(colorSpaces); + _imp->colorSpace32f->setDefaultValue(1); + lutPages->addKnob(_imp->colorSpace32f); + boost::shared_ptr infoPage = AppManager::createKnob(this, tr("Info").toStdString()); _imp->projectName = AppManager::createKnob(this, "Project Name"); @@ -932,7 +970,7 @@ Project::initializeKnobs() "- app: points to the current application instance\n"); _imp->onProjectLoadCB->setAnimationEnabled(false); std::string onProjectLoad = appPTR->getCurrentSettings()->getDefaultOnProjectLoadedCB(); - _imp->onProjectLoadCB->setValue(onProjectLoad); + _imp->onProjectLoadCB->setDefaultValue(onProjectLoad); pythonPage->addKnob(_imp->onProjectLoadCB); @@ -948,7 +986,7 @@ Project::initializeKnobs() "You should return the new filename under which the project should be saved."); _imp->onProjectSaveCB->setAnimationEnabled(false); std::string onProjectSave = appPTR->getCurrentSettings()->getDefaultOnProjectSaveCB(); - _imp->onProjectSaveCB->setValue(onProjectSave); + _imp->onProjectSaveCB->setDefaultValue(onProjectSave); pythonPage->addKnob(_imp->onProjectSaveCB); _imp->onProjectCloseCB = AppManager::createKnob(this, "Before Project Close"); @@ -975,7 +1013,7 @@ Project::initializeKnobs() "- app: points to the current application instance\n"); _imp->onNodeCreated->setAnimationEnabled(false); std::string onNodeCreated = appPTR->getCurrentSettings()->getDefaultOnNodeCreatedCB(); - _imp->onNodeCreated->setValue(onNodeCreated); + _imp->onNodeCreated->setDefaultValue(onNodeCreated); pythonPage->addKnob(_imp->onNodeCreated); _imp->onNodeDeleted = AppManager::createKnob(this, "Before Node Removal"); @@ -987,7 +1025,7 @@ Project::initializeKnobs() "- app: points to the current application instance\n"); _imp->onNodeDeleted->setAnimationEnabled(false); std::string onNodeDelete = appPTR->getCurrentSettings()->getDefaultOnNodeDeleteCB(); - _imp->onNodeDeleted->setValue(onNodeDelete); + _imp->onNodeDeleted->setDefaultValue(onNodeDelete); pythonPage->addKnob(_imp->onNodeDeleted); @@ -1006,8 +1044,12 @@ Project::getProjectDefaultFormat(Format *f) const { assert(f); QMutexLocker l(&_imp->formatMutex); - int index = _imp->formatKnob->getValue(); - _imp->findFormat(index, f); + std::string formatSpec = _imp->formatKnob->getActiveEntryText_mt_safe(); + if (!formatSpec.empty()) { + ProjectPrivate::generateFormatFromString(QString::fromUtf8(formatSpec.c_str()), f); + } else { + _imp->findFormat(_imp->formatKnob->getValue(), f); + } } bool @@ -1056,9 +1098,8 @@ Project::tryAddProjectFormat(const Format & f) entries.push_back( formatStr.toStdString() ); } QString formatStr = ProjectPrivate::generateStringFromFormat(f); - entries.push_back( formatStr.toStdString() ); _imp->additionalFormats.push_back(f); - _imp->formatKnob->populateChoices(entries); + _imp->formatKnob->appendChoice(formatStr.toStdString()); return ( _imp->builtinFormats.size() + _imp->additionalFormats.size() ) - 1; } @@ -1083,10 +1124,83 @@ Project::getProjectFormatEntries(std::vector* formatStrings, int* c int Project::getProjectViewsCount() const { - std::list > pairs; - _imp->viewsList->getVariables(&pairs); + std::list > pairs; + _imp->viewsList->getTable(&pairs); return (int)pairs.size(); } + +std::vector +Project::getProjectDefaultLayers() const +{ + std::vector ret; + + std::list > pairs; + _imp->defaultLayersList->getTable(&pairs); + for (std::list >::iterator it = pairs.begin(); + it != pairs.end(); ++it) { + + bool found = false; + for (std::size_t i = 0; i < ret.size(); ++i) { + if (ret[i].getLayerName() == (*it)[0]) { + found = true; + break; + } + } + if (!found) { + std::vector componentsName; + QString str = QString::fromUtf8((*it)[1].c_str()); + QStringList channels = str.split(QLatin1Char(' ')); + componentsName.resize(channels.size()); + for (int i = 0; i < channels.size(); ++i) { + componentsName[i] = channels[i].toStdString(); + } + ImageComponents c((*it)[0],std::string(),componentsName); + ret.push_back(c); + } + } + return ret; + +} + +void +Project::addProjectDefaultLayer(const ImageComponents& comps) +{ + const std::vector& channels = comps.getComponentsNames(); + std::vector row(2); + row[0] = comps.getLayerName(); + std::string channelsStr; + for (std::size_t i = 0; i < channels.size(); ++i) { + channelsStr += channels[i]; + if (i < (channels.size() -1)) { + channelsStr += ' '; + } + } + row[1] = channelsStr; + _imp->defaultLayersList->appendRow(row); +} + +std::vector +Project::getProjectDefaultLayerNames() const +{ + std::vector ret; + + std::list > pairs; + _imp->defaultLayersList->getTable(&pairs); + for (std::list >::iterator it = pairs.begin(); + it != pairs.end(); ++it) { + bool found = false; + for (std::size_t i = 0; i < ret.size(); ++i) { + if (ret[i] == (*it)[0]) { + found = true; + break; + } + } + if (!found) { + ret.push_back((*it)[0]); + } + } + return ret; +} const std::vector& Project::getProjectViewNames() const @@ -1096,11 +1210,11 @@ Project::getProjectViewNames() const std::vector& tls = _imp->tlsData->getOrCreateTLSData()->viewNames; tls.clear(); - std::list > pairs; - _imp->viewsList->getVariables(&pairs); - for (std::list >::iterator it = pairs.begin(); + std::list > pairs; + _imp->viewsList->getTable(&pairs); + for (std::list >::iterator it = pairs.begin(); it != pairs.end(); ++it) { - tls.push_back(it->first); + tls.push_back((*it)[0]); } return tls; } @@ -1108,10 +1222,11 @@ Project::getProjectViewNames() const void Project::setupProjectForStereo() { - std::list > pairs; - pairs.push_back(std::make_pair("Left","")); - pairs.push_back(std::make_pair("Right","")); - std::string encoded = KnobPath::encodeToMultiPathFormat(pairs); + + std::list views; + views.push_back("Left"); + views.push_back("Right"); + std::string encoded = _imp->viewsList->encodeToKnobTableFormatSingleCol(views); _imp->viewsList->setValue(encoded); } @@ -1136,13 +1251,13 @@ static bool caseInsensitiveCompare(const std::string& lhs, const std::string& rh void Project::createProjectViews(const std::vector& views) { - std::list > pairs; - _imp->viewsList->getVariables(&pairs); + std::list pairs; + _imp->viewsList->getTableSingleCol(&pairs); for (std::size_t i = 0; i < views.size(); ++i) { bool found = false; - for (std::list >::iterator it = pairs.begin(); it != pairs.end(); ++it) { - if (caseInsensitiveCompare(it->first,views[i])) { + for (std::list::iterator it = pairs.begin(); it != pairs.end(); ++it) { + if (caseInsensitiveCompare(*it,views[i])) { found = true; break; } @@ -1152,9 +1267,9 @@ Project::createProjectViews(const std::vector& views) } std::string view = views[i]; view[0] = std::toupper(view[0]); - pairs.push_back(std::make_pair(view,std::string())); + pairs.push_back(view); } - std::string encoded = KnobPath::encodeToMultiPathFormat(pairs); + std::string encoded = _imp->viewsList->encodeToKnobTableFormatSingleCol(pairs); _imp->viewsList->setValue(encoded); } @@ -1273,6 +1388,11 @@ Project::onKnobValueChanged(KnobI* knob, forceComputeInputDependentDataOnAllTrees(); } Q_EMIT projectViewsChanged(); + } else if (knob == _imp->defaultLayersList.get()) { + if (reason == eValueChangedReasonUserEdited) { + ///default layers change, notify all nodes so they rebuild their layers menus + forceComputeInputDependentDataOnAllTrees(); + } } else if (knob == _imp->setupForStereoButton.get()) { setupProjectForStereo(); } else if ( knob == _imp->formatKnob.get() ) { @@ -1764,63 +1884,17 @@ Project::unescapeXML(const std::string &istr) return str; } -void - Project::makeEnvMapUnordered(const std::string& encoded,std::vector >& variables) -{ - std::string startNameTag(NATRON_ENV_VAR_NAME_START_TAG); - std::string endNameTag(NATRON_ENV_VAR_NAME_END_TAG); - std::string startValueTag(NATRON_ENV_VAR_VALUE_START_TAG); - std::string endValueTag(NATRON_ENV_VAR_VALUE_END_TAG); - - size_t i = encoded.find(startNameTag); - while (i != std::string::npos) { - i += startNameTag.size(); - assert(i < encoded.size()); - size_t endNamePos = encoded.find(endNameTag,i); - assert(endNamePos != std::string::npos && endNamePos < encoded.size()); - if (endNamePos == std::string::npos || endNamePos >= encoded.size()) { - throw std::logic_error("Project::makeEnvMap()"); - } - std::string name,value; - while (i < endNamePos) { - name.push_back(encoded[i]); - ++i; - } - - i = encoded.find(startValueTag,i); - i += startValueTag.size(); - assert(i != std::string::npos && i < encoded.size()); - - size_t endValuePos = encoded.find(endValueTag,i); - assert(endValuePos != std::string::npos && endValuePos < encoded.size()); - - while (endValuePos != std::string::npos && endValuePos < encoded.size() && i < endValuePos) { - value.push_back(encoded.at(i)); - ++i; - } - - // In order to use XML tags, the text inside the tags has to be unescaped. - variables.push_back(std::make_pair(unescapeXML(name), unescapeXML(value))); - - i = encoded.find(startNameTag,i); - } -} - -void -Project::makeEnvMap(const std::string& encoded,std::map& variables) -{ - std::vector > pairs; - makeEnvMapUnordered(encoded,pairs); - for (std::size_t i = 0; i < pairs.size(); ++i) { - variables[pairs[i].first] = pairs[i].second; - } -} + void Project::getEnvironmentVariables(std::map& env) const { - std::string raw = _imp->envVars->getValue(); - makeEnvMap(raw, env); + std::list > table; + _imp->envVars->getTable(&table); + for (std::list >::iterator it = table.begin(); it!=table.end(); ++it) { + assert(it->size() == 2); + env[(*it)[0]] = (*it)[1]; + } } void @@ -2017,30 +2091,30 @@ Project::onOCIOConfigPathChanged(const std::string& path,bool block) beginChanges(); try { - std::string env = _imp->envVars->getValue(); - std::map envMap; - makeEnvMap(env, envMap); + + std::string oldEnv = _imp->envVars->getValue(); + std::list > table; + _imp->envVars->decodeFromKnobTableFormat(oldEnv, &table); ///If there was already a OCIO variable, update it, otherwise create it - - std::map::iterator foundOCIO = envMap.find(NATRON_OCIO_ENV_VAR_NAME); - if (foundOCIO != envMap.end()) { - foundOCIO->second = path; - } else { - envMap.insert(std::make_pair(NATRON_OCIO_ENV_VAR_NAME, path)); + bool found = false; + for (std::list >::iterator it = table.begin(); it!=table.end(); ++it) { + if ((*it)[0] == NATRON_OCIO_ENV_VAR_NAME) { + (*it)[1] = path; + found = true; + break; + } } - - std::string newEnv; - for (std::map::iterator it = envMap.begin(); it != envMap.end(); ++it) { - // In order to use XML tags, the text inside the tags has to be escaped. - newEnv += NATRON_ENV_VAR_NAME_START_TAG; - newEnv += Project::escapeXML(it->first); - newEnv += NATRON_ENV_VAR_NAME_END_TAG; - newEnv += NATRON_ENV_VAR_VALUE_START_TAG; - newEnv += Project::escapeXML(it->second); - newEnv += NATRON_ENV_VAR_VALUE_END_TAG; + if (!found) { + std::vector vec(2); + vec[0] = NATRON_OCIO_ENV_VAR_NAME; + vec[1] = path; + table.push_back(vec); } - if (env != newEnv) { + + std::string newEnv = _imp->envVars->encodeToKnobTableFormat(table); + + if (oldEnv != newEnv) { if (appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled()) { fixRelativeFilePaths(NATRON_OCIO_ENV_VAR_NAME, path,block); } diff --git a/Engine/Project.h b/Engine/Project.h index 4035adb52a..4ebea289bf 100644 --- a/Engine/Project.h +++ b/Engine/Project.h @@ -150,6 +150,12 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON const std::vector& getProjectViewNames() const; int getProjectViewsCount() const; + + std::vector getProjectDefaultLayerNames() const; + + std::vector getProjectDefaultLayers() const; + + void addProjectDefaultLayer(const ImageComponents& comps); void setOrAddProjectFormat(const Format & frmt,bool skipAdd = false); @@ -206,12 +212,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON * @brief Returns the user environment variables for the project **/ void getEnvironmentVariables(std::map& env) const; - /** - * @brief Decode the project variables from the encoded version; - **/ - static void makeEnvMap(const std::string& encoded,std::map& variables); - static void makeEnvMapUnordered(const std::string& encoded,std::vector >& variables); - + /** * @brief Expands the environment variables in the given string that are found in env **/ diff --git a/Engine/ProjectPrivate.cpp b/Engine/ProjectPrivate.cpp index 42503b4860..3b30589423 100644 --- a/Engine/ProjectPrivate.cpp +++ b/Engine/ProjectPrivate.cpp @@ -266,28 +266,29 @@ ProjectPrivate::autoSetProjectDirectory(const QString& path) pathCpy.erase(pathCpy.size() - 1, 1); } std::string env = envVars->getValue(); - std::map envMap; - Project::makeEnvMap(env, envMap); + std::list > table; + envVars->decodeFromKnobTableFormat(env, &table); ///If there was already a OCIO variable, update it, otherwise create it - - std::map::iterator foundPROJECT = envMap.find(NATRON_PROJECT_ENV_VAR_NAME); - if (foundPROJECT != envMap.end()) { - foundPROJECT->second = pathCpy; - } else { - envMap.insert(std::make_pair(NATRON_PROJECT_ENV_VAR_NAME, pathCpy)); + bool foundProject = false; + for (std::list >::iterator it = table.begin(); it != table.end(); ++it) { + if ((*it)[0] == NATRON_PROJECT_ENV_VAR_NAME) { + (*it)[1] = pathCpy; + foundProject = true; + break; + } } - - std::string newEnv; - for (std::map::iterator it = envMap.begin(); it != envMap.end(); ++it) { - newEnv += NATRON_ENV_VAR_NAME_START_TAG; - // In order to use XML tags, the text inside the tags has to be escaped. - newEnv += Project::escapeXML(it->first); - newEnv += NATRON_ENV_VAR_NAME_END_TAG; - newEnv += NATRON_ENV_VAR_VALUE_START_TAG; - newEnv += Project::escapeXML(it->second); - newEnv += NATRON_ENV_VAR_VALUE_END_TAG; + if (!foundProject) { + std::vector vec(2); + vec[0] = NATRON_PROJECT_ENV_VAR_NAME; + vec[1] = pathCpy; + table.push_back(vec); } + + + + + std::string newEnv = envVars->encodeToKnobTableFormat(table); if (env != newEnv) { if (appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled()) { _publicInterface->fixRelativeFilePaths(NATRON_PROJECT_ENV_VAR_NAME, pathCpy,false); diff --git a/Engine/ProjectPrivate.h b/Engine/ProjectPrivate.h index eeaef96efd..f0802d5dc9 100644 --- a/Engine/ProjectPrivate.h +++ b/Engine/ProjectPrivate.h @@ -72,6 +72,7 @@ struct ProjectPrivate boost::shared_ptr formatKnob; //< built from builtinFormats & additionalFormats boost::shared_ptr addFormatKnob; boost::shared_ptr viewsList; + boost::shared_ptr defaultLayersList; boost::shared_ptr setupForStereoButton; boost::shared_ptr previewMode; //< auto or manual boost::shared_ptr colorSpace8u; @@ -113,7 +114,7 @@ struct ProjectPrivate bool restoreFromSerialization(const ProjectSerialization & obj,const QString& name,const QString& path, bool* mustSave); bool findFormat(int index,Format* format) const; - + bool findFormat(const std::string& formatSpec,Format* format) const; /** * @brief Auto fills the project directory parameter given the project file path **/ @@ -154,7 +155,7 @@ struct ProjectPrivate generateFormatFromString(const QString& spec, Format* f) { QStringList splits = spec.split(QLatin1Char(' ')); - if (splits.size() != 3) { + if (splits.size() < 2 || splits.size() > 3) { return false; } @@ -169,7 +170,9 @@ struct ProjectPrivate f->x2 = sizes[0].toInt(); f->y2 = sizes[1].toInt(); - f->setPixelAspectRatio(splits[2].toDouble()); + if (splits.size() > 2) { + f->setPixelAspectRatio(splits[2].toDouble()); + } return true; } diff --git a/Engine/PyAppInstance.cpp b/Engine/PyAppInstance.cpp index fc4ea84682..abf8cbb5b7 100644 --- a/Engine/PyAppInstance.cpp +++ b/Engine/PyAppInstance.cpp @@ -370,4 +370,10 @@ App::getViewNames() const return ret; } +void +App::addProjectLayer(const ImageLayer& layer) +{ + _instance->getProject()->addProjectDefaultLayer(layer.getInternalComps()); +} + NATRON_NAMESPACE_EXIT; diff --git a/Engine/PyAppInstance.h b/Engine/PyAppInstance.h index 9f39d8e82c..cfa6779bb1 100644 --- a/Engine/PyAppInstance.h +++ b/Engine/PyAppInstance.h @@ -121,6 +121,8 @@ class App : public Group std::list getViewNames() const; + void addProjectLayer(const ImageLayer& layer); + protected: void renderInternal(bool forceBlocking,Effect* writeNode,int firstFrame, int lastFrame, int frameStep); diff --git a/Engine/PyNode.h b/Engine/PyNode.h index 664e633fc4..81a4436e06 100644 --- a/Engine/PyNode.h +++ b/Engine/PyNode.h @@ -54,6 +54,10 @@ class ImageLayer ImageLayer(const ImageComponents& internalComps); + ImageComponents getInternalComps() const + { + return _comps; + } ~ImageLayer() {} diff --git a/Engine/Settings.cpp b/Engine/Settings.cpp index b87053a5d5..2bba852edc 100644 --- a/Engine/Settings.cpp +++ b/Engine/Settings.cpp @@ -1469,7 +1469,7 @@ Settings::setDefaultValues() setCachingLabels(); _autoTurbo->setDefaultValue(false); _usePluginIconsInNodeGraph->setDefaultValue(true); - _useAntiAliasing->setDefaultValue(false); + _useAntiAliasing->setDefaultValue(true); _defaultNodeColor->setDefaultValue(0.7,0); _defaultNodeColor->setDefaultValue(0.7,1); _defaultNodeColor->setDefaultValue(0.7,2); @@ -3193,6 +3193,7 @@ void Settings::getPythonGroupsSearchPaths(std::list* templates) const { _templatesPluginPaths->getPaths(templates); + } void diff --git a/Engine/ViewerInstance.cpp b/Engine/ViewerInstance.cpp index 011c7149fa..35e34d1938 100644 --- a/Engine/ViewerInstance.cpp +++ b/Engine/ViewerInstance.cpp @@ -2365,7 +2365,11 @@ ViewerInstance::interpolateGammaLut(float value) void ViewerInstance::markAllOnGoingRendersAsAborted() { - _imp->markAllRendersAsAborted(); + + bool keepOldest = getApp()->isDraftRenderEnabled(); + + //Do not abort the oldest render while scrubbing timeline or sliders so that the user gets some feedback + _imp->markAllRendersAsAborted(keepOldest); } template diff --git a/Engine/ViewerInstancePrivate.h b/Engine/ViewerInstancePrivate.h index 8f047a9a9d..fbc9de149d 100644 --- a/Engine/ViewerInstancePrivate.h +++ b/Engine/ViewerInstancePrivate.h @@ -245,7 +245,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void - markAllRendersAsAborted() + markAllRendersAsAborted(bool keepOldest) { QMutexLocker k(&renderAgeMutex); for (int i = 0; i < 2; ++i) { @@ -255,7 +255,9 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON //Do not abort the oldest render, let it finish OnGoingRenders::iterator it = currentRenderAges[i].begin(); - ++it; + if (!keepOldest) { + ++it; + } for (;it != currentRenderAges[i].end(); ++it) { (*it)->aborted = 1; diff --git a/Global/Macros.h b/Global/Macros.h index c8f693e5a7..0897df573c 100644 --- a/Global/Macros.h +++ b/Global/Macros.h @@ -85,11 +85,6 @@ namespace NATRON_NAMESPACE { } #define NATRON_ENGINE_PYTHON_MODULE_NAME "NatronEngine" #define NATRON_GUI_PYTHON_MODULE_NAME "NatronGui" -#define NATRON_ENV_VAR_NAME_START_TAG "" -#define NATRON_ENV_VAR_NAME_END_TAG "" -#define NATRON_ENV_VAR_VALUE_START_TAG "" -#define NATRON_ENV_VAR_VALUE_END_TAG "" - #define NATRON_PROJECT_ENV_VAR_MAX_RECURSION 100 #define NATRON_MAX_CACHE_FILES_OPENED 20000 #define NATRON_CUSTOM_HTML_TAG_START "<" NATRON_APPLICATION_NAME ">" diff --git a/Gui/ComboBox.cpp b/Gui/ComboBox.cpp index faa58fe733..492e35dc2c 100644 --- a/Gui/ComboBox.cpp +++ b/Gui/ComboBox.cpp @@ -86,7 +86,7 @@ ComboBox::ComboBox(QWidget* parent) , _altered(false) , _cascading(false) , _cascadingIndex(0) - , _currentIndex(0) + , _currentIndex(-1) , _currentText() , _separators() , _rootNode(new ComboBoxMenuNode()) @@ -345,7 +345,12 @@ ComboBox::paintEvent(QPaintEvent* /*e*/) int flags = align | Qt::TextForceLeftToRight; ///Draw the text - QPen pen; + QPen pen = p.pen(); + if (_currentIndex == -1) { + QFont f = p.font(); + f.setItalic(true); + p.setFont(f); + } pen.setColor(textColor); p.setPen(pen); @@ -577,6 +582,9 @@ ComboBox::addItem(const QString & item, QKeySequence key, const QString & toolTip) { + if (item.isEmpty()) { + return; + } if (!_cascading) { QAction* action = new QAction(this); @@ -701,7 +709,7 @@ ComboBox::setCurrentText_internal(const QString & text) } int ret = -1; - if ( (_currentIndex != index) && (index != -1) ) { + if (_currentIndex != index) { _currentIndex = index; ret = index; } @@ -773,6 +781,9 @@ static QString getNodeTextRecursive(ComboBoxMenuNode* node,ComboBoxMenuNode* roo QString ComboBox::getCurrentIndexText() const { + if (_currentIndex == -1) { + return _currentText; + } ComboBoxMenuNode* node = getCurrentIndexNode(_currentIndex, _rootNode.get()); if (!node) { return QString(); @@ -931,7 +942,7 @@ ComboBox::clear() _rootNode->isMenu->clear(); _cascadingIndex = 0; _separators.clear(); - _currentIndex = 0; + _currentIndex = -1; updateLabel(); } diff --git a/Gui/ComboBox.h b/Gui/ComboBox.h index 7562001324..399e4fbdcb 100644 --- a/Gui/ComboBox.h +++ b/Gui/ComboBox.h @@ -107,6 +107,11 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON { _cascading = cascading; } + + bool isCascading() const + { + return _cascading; + } /*Insert a new item BEFORE the specified index.*/ void insertItem( int index,const QString &item,QIcon icon = QIcon(),QKeySequence = QKeySequence(),const QString & toolTip = QString() ); diff --git a/Gui/DockablePanelPrivate.cpp b/Gui/DockablePanelPrivate.cpp index 9823825400..1cedf3270b 100644 --- a/Gui/DockablePanelPrivate.cpp +++ b/Gui/DockablePanelPrivate.cpp @@ -605,7 +605,7 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, ///Create the label if needed KnobClickableLabel* label = 0; - Label* exprLabelWarn = 0; + Label* warningLabel = 0; std::string descriptionLabel; KnobString* isStringKnob = dynamic_cast(knob.get()); bool isLabelKnob = isStringKnob && isStringKnob->isLabel(); @@ -629,14 +629,13 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, } label = new KnobClickableLabel(QString(), ret, page->second.tab); - exprLabelWarn = new Label(page->second.tab); - exprLabelWarn->setToolTip(QObject::tr("Expression invalid, value returned is the underlying curve.")); - exprLabelWarn->setVisible(false); + warningLabel = new Label(page->second.tab); + warningLabel->setVisible(false); QFontMetrics fm(label->font(),0); int pixSize = fm.height(); QPixmap stdErrorPix; stdErrorPix = getStandardIcon(QMessageBox::Critical, pixSize, label); - exprLabelWarn->setPixmap(stdErrorPix); + warningLabel->setPixmap(stdErrorPix); bool pixmapSet = false; if (!labelIconFilePath.empty()) { @@ -673,7 +672,7 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, if (makeNewLine) { - labelLayout->addWidget(exprLabelWarn); + labelLayout->addWidget(warningLabel); labelLayout->addWidget(label); } @@ -733,7 +732,7 @@ DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob, } ///fill the fieldLayout with the widgets - ret->createGUI(layout,fieldContainer, labelContainer, label, exprLabelWarn, fieldLayout,makeNewLine,knobsOnSameLine); + ret->createGUI(layout,fieldContainer, labelContainer, label, warningLabel, fieldLayout,makeNewLine,knobsOnSameLine); ret->setEnabledSlot(); diff --git a/Gui/Gui.pro b/Gui/Gui.pro index ef0f09272c..19b76e7b22 100644 --- a/Gui/Gui.pro +++ b/Gui/Gui.pro @@ -132,6 +132,7 @@ SOURCES += \ KnobGuiColor.cpp \ KnobGuiString.cpp \ KnobGuiGroup.cpp \ + KnobGuiTable.cpp \ KnobGuiParametric.cpp \ KnobUndoCommand.cpp \ KnobWidgetDnD.cpp \ @@ -283,6 +284,7 @@ HEADERS += \ KnobGuiColor.h \ KnobGuiString.h \ KnobGuiGroup.h \ + KnobGuiTable.h \ KnobGuiParametric.h \ KnobUndoCommand.h \ KnobWidgetDnD.h \ diff --git a/Gui/GuiFwd.h b/Gui/GuiFwd.h index 36e4ba0973..a22c948ef0 100644 --- a/Gui/GuiFwd.h +++ b/Gui/GuiFwd.h @@ -132,6 +132,8 @@ class KnobClickableLabel; class KnobCurveGui; class KnobGui; class KnobGuiFactory; +class KnobGuiTable; +class KnobGuiLayers; class KnobHolder; class KnobWidgetDnD; class LineEdit; diff --git a/Gui/KnobGui.cpp b/Gui/KnobGui.cpp index a1031ea22c..3710cd0b06 100644 --- a/Gui/KnobGui.cpp +++ b/Gui/KnobGui.cpp @@ -170,7 +170,7 @@ KnobGui::createGUI(QGridLayout* containerLayout, QWidget* fieldContainer, QWidget* labelContainer, KnobClickableLabel* label, - Label* expressinoLabelWarning, + Label* warningIndicator, QHBoxLayout* layout, bool isOnNewLine, const std::vector< boost::shared_ptr< KnobI > > & knobsOnSameLine) @@ -186,13 +186,13 @@ KnobGui::createGUI(QGridLayout* containerLayout, _imp->field = fieldContainer; _imp->labelContainer = labelContainer; _imp->descriptionLabel = label; - _imp->expressionWarningLabel = expressinoLabelWarning; + _imp->warningIndicator = warningIndicator; _imp->isOnNewLine = isOnNewLine; if (!isOnNewLine) { //layout->addStretch(); layout->addSpacing(TO_DPIX(15)); if (label) { - layout->addWidget(_imp->expressionWarningLabel); + layout->addWidget(_imp->warningIndicator); layout->addWidget(label); } } diff --git a/Gui/KnobGui.h b/Gui/KnobGui.h index 87b8b5792c..cd6dd40130 100644 --- a/Gui/KnobGui.h +++ b/Gui/KnobGui.h @@ -72,6 +72,12 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON public: + enum KnobWarningEnum + { + eKnobWarningExpressionInvalid = 0, + eKnobWarningChoiceMenuOutOfDate + }; + KnobGui(const KnobPtr& knob, DockablePanel* container); @@ -117,7 +123,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON QWidget* fieldContainer, QWidget* labelContainer, KnobClickableLabel* label, - Label* expressinoLabelWarning, + Label* warningIndicator, QHBoxLayout* layout, bool isOnNewLine, const std::vector< boost::shared_ptr< KnobI > > & knobsOnSameLine); @@ -276,6 +282,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual bool getAllDimensionsVisible() const OVERRIDE { return true; } + void setWarningValue(KnobWarningEnum warn,const QString& value); + public Q_SLOTS: void onRemoveAliasLinkActionTriggered(); @@ -427,6 +435,8 @@ public Q_SLOTS: private: + void refreshKnobWarningIndicatorVisibility(); + void updateGuiInternal(int dimension); void copyToClipBoard(KnobClipBoardType type, int dimension) const; diff --git a/Gui/KnobGui20.cpp b/Gui/KnobGui20.cpp index b38dcf146b..16d6cfe826 100644 --- a/Gui/KnobGui20.cpp +++ b/Gui/KnobGui20.cpp @@ -699,6 +699,39 @@ KnobGui::onRedrawGuiCurve(int reason, } +void +KnobGui::setWarningValue(KnobWarningEnum warn,const QString& value) +{ + QString& warning = _imp->warningsMapping[warn]; + if (warning != value) { + warning = value; + refreshKnobWarningIndicatorVisibility(); + } +} + +void +KnobGui::refreshKnobWarningIndicatorVisibility() +{ + if (!_imp->warningIndicator) { + return; + } + QString fullTooltip; + bool hasWarning = false; + for (std::map::iterator it = _imp->warningsMapping.begin(); it!=_imp->warningsMapping.end(); ++it) { + if (!it->second.isEmpty()) { + hasWarning = true; + fullTooltip += QString::fromUtf8("

"); + fullTooltip += it->second; + fullTooltip += QString::fromUtf8("

"); + + } + } + if (hasWarning) { + _imp->warningIndicator->setToolTip(fullTooltip); + } + _imp->warningIndicator->setVisible(hasWarning); + +} void KnobGui::onExprChanged(int dimension) @@ -721,7 +754,7 @@ KnobGui::onExprChanged(int dimension) } } - if (_imp->expressionWarningLabel) { + if (_imp->warningIndicator) { bool invalid = false; QString fullErrTooltip; int dims = knob->getDimension(); @@ -740,10 +773,15 @@ KnobGui::onExprChanged(int dimension) } } if (invalid) { - _imp->expressionWarningLabel->show(); - _imp->expressionWarningLabel->setToolTip(fullErrTooltip); + QString toPrepend; + toPrepend += QString::fromUtf8("

"); + toPrepend += QObject::tr("Invalid expression(s), value returned is the underlying curve:"); + toPrepend += QString::fromUtf8("

"); + fullErrTooltip.prepend(toPrepend); + + setWarningValue(eKnobWarningExpressionInvalid, fullErrTooltip); } else { - _imp->expressionWarningLabel->hide(); + setWarningValue(eKnobWarningExpressionInvalid, QString()); } } onHelpChanged(); diff --git a/Gui/KnobGuiChoice.cpp b/Gui/KnobGuiChoice.cpp index bb630f5c09..04707e4ffc 100644 --- a/Gui/KnobGuiChoice.cpp +++ b/Gui/KnobGuiChoice.cpp @@ -36,7 +36,9 @@ CLANG_DIAG_OFF(uninitialized) #include #include #include +#include #include +#include #include #include #include @@ -239,6 +241,7 @@ KnobGuiChoice::createWidget(QHBoxLayout* layout) void KnobGuiChoice::onCurrentIndexChanged(int i) { + setWarningValue(KnobGui::eKnobWarningChoiceMenuOutOfDate, QString()); pushUndoCommand( new KnobUndoCommand(shared_from_this(),_knob.lock()->getValue(0),i, 0, false, 0) ); } @@ -253,17 +256,41 @@ KnobGuiChoice::onEntryAppended(const QString& entry, const QString& help) _comboBox->addItem(entry, QIcon(), QKeySequence(), help); } int activeIndex = knob->getValue(); - _comboBox->setCurrentIndex_no_emit(activeIndex); + if (activeIndex >= 0) { + _comboBox->setCurrentIndex_no_emit(activeIndex); + } else { + _comboBox->setCurrentText(QString::fromUtf8(knob->getActiveEntryText_mt_safe().c_str())); + } + } void KnobGuiChoice::onEntriesReset() { - _comboBox->clear(); + onEntriesPopulated(); +} + +void +KnobGuiChoice::addRightClickMenuEntries(QMenu* menu) +{ boost::shared_ptr knob = _knob.lock(); - if (knob->getHostCanAddOptions() && - (knob->getName() == kNatronOfxParamOutputChannels || knob->getName() == kOutputChannelsKnobName)) { - _comboBox->addItemNew(); + if (!knob) { + return; + } + + QAction* refreshMenuAction = new QAction(QObject::tr("Refresh Menu"),menu); + QObject::connect(refreshMenuAction,SIGNAL(triggered()),this,SLOT(onRefreshMenuActionTriggered())); + refreshMenuAction->setToolTip(QObject::tr("Synchronize the menu with the actual state of the parameter")); + menu->addAction(refreshMenuAction); + +} + +void +KnobGuiChoice::onRefreshMenuActionTriggered() +{ + boost::shared_ptr knob = _knob.lock(); + if (knob) { + knob->refreshMenu(); } } @@ -271,16 +298,19 @@ void KnobGuiChoice::onEntriesPopulated() { boost::shared_ptr knob = _knob.lock(); - int activeIndex = knob->getValue(); _comboBox->clear(); std::vector entries = knob->getEntries_mt_safe(); const std::vector help = knob->getEntriesHelp_mt_safe(); + + std::string activeEntry = knob->getActiveEntryText_mt_safe(); + for (U32 i = 0; i < entries.size(); ++i) { std::string helpStr; if ( !help.empty() && !help[i].empty() ) { helpStr = help[i]; } + _comboBox->addItem( QString::fromUtf8(entries[i].c_str()), QIcon(), QKeySequence(), QString::fromUtf8( helpStr.c_str() ) ); } // the "New" menu is only added to known parameters (e.g. the choice of output channels) @@ -290,18 +320,36 @@ KnobGuiChoice::onEntriesPopulated() } ///we don't use setCurrentIndex because the signal emitted by combobox will call onCurrentIndexChanged and ///we don't want that to happen because the index actually didn't change. - _comboBox->setCurrentIndex_no_emit(activeIndex); - + if (_comboBox->isCascading() || activeEntry.empty()) { + _comboBox->setCurrentIndex_no_emit(knob->getValue()); + } else { + _comboBox->setCurrentText_no_emit(QString::fromUtf8(activeEntry.c_str())); + } + + + if (!activeEntry.empty()) { + bool activeIndexPresent = knob->isActiveEntryPresentInEntries(); + if (!activeIndexPresent) { + QString error = tr("The value set to this parameter no longer exist in the menu. Right click and press Refresh Menu to update the menu and then pick a new value."); + setWarningValue(KnobGui::eKnobWarningChoiceMenuOutOfDate, GuiUtils::convertFromPlainText(error, Qt::WhiteSpaceNormal)); + } else { + setWarningValue(KnobGui::eKnobWarningChoiceMenuOutOfDate, QString()); + } + + } } + void KnobGuiChoice::onItemNewSelected() { - NewLayerDialog dialog(getGui()); + NewLayerDialog dialog(ImageComponents::getNoneComponents(),getGui()); if (dialog.exec()) { ImageComponents comps = dialog.getComponents(); if (comps == ImageComponents::getNoneComponents()) { - Dialogs::errorDialog(tr("Layer").toStdString(), tr("Invalid layer").toStdString()); + Dialogs::errorDialog(tr("Layer").toStdString(), tr("A layer must contain at least 1 channel and channel names must be " + "Python compliant.").toStdString()); + return; } KnobHolder* holder = _knob.lock()->getHolder(); @@ -341,7 +389,24 @@ KnobGuiChoice::updateGUI(int /*dimension*/) ///change the internal value of the knob again... ///The slot connected to onCurrentIndexChanged is reserved to catch user interaction with the combobox. ///This function is called in response to an internal change. - _comboBox->setCurrentIndex_no_emit( _knob.lock()->getValue(0) ); + boost::shared_ptr knob = _knob.lock(); + + std::string activeEntry = knob->getActiveEntryText_mt_safe(); + if (!activeEntry.empty()) { + bool activeIndexPresent = knob->isActiveEntryPresentInEntries(); + if (!activeIndexPresent) { + QString error = tr("The value set to this parameter no longer exist in the menu. Right click and press Refresh Menu to update the menu and then pick a new value."); + setWarningValue(KnobGui::eKnobWarningChoiceMenuOutOfDate, GuiUtils::convertFromPlainText(error, Qt::WhiteSpaceNormal)); + } else { + setWarningValue(KnobGui::eKnobWarningChoiceMenuOutOfDate, QString()); + } + + } + if (_comboBox->isCascading() || activeEntry.empty()) { + _comboBox->setCurrentIndex_no_emit(knob->getValue()); + } else { + _comboBox->setCurrentText(QString::fromUtf8(activeEntry.c_str())); + } } void diff --git a/Gui/KnobGuiChoice.h b/Gui/KnobGuiChoice.h index f84f11abae..e08ade3564 100644 --- a/Gui/KnobGuiChoice.h +++ b/Gui/KnobGuiChoice.h @@ -120,8 +120,11 @@ public Q_SLOTS: void onItemNewSelected(); + void onRefreshMenuActionTriggered(); + private: - + + virtual void addRightClickMenuEntries(QMenu* menu) OVERRIDE FINAL; virtual void createWidget(QHBoxLayout* layout) OVERRIDE FINAL; virtual void _hide() OVERRIDE FINAL; virtual void _show() OVERRIDE FINAL; diff --git a/Gui/KnobGuiFactory.cpp b/Gui/KnobGuiFactory.cpp index 5fc2828167..02dd5346f0 100644 --- a/Gui/KnobGuiFactory.cpp +++ b/Gui/KnobGuiFactory.cpp @@ -103,7 +103,7 @@ KnobGuiFactory::loadBultinKnobs() _loadedKnobs.insert( knobGuiFactoryEntry() ); _loadedKnobs.insert( knobGuiFactoryEntry() ); _loadedKnobs.insert( knobGuiFactoryEntry() ); - // _loadedKnobs.insert(knobGuiFactoryEntry()); + _loadedKnobs.insert( knobGuiFactoryEntry() ); } KnobGui * diff --git a/Gui/KnobGuiFile.cpp b/Gui/KnobGuiFile.cpp index 18730070c9..36bf8a7605 100644 --- a/Gui/KnobGuiFile.cpp +++ b/Gui/KnobGuiFile.cpp @@ -722,17 +722,10 @@ KnobGuiOutputFile::updateToolTip() //============================PATH_KNOB_GUI==================================== KnobGuiPath::KnobGuiPath(KnobPtr knob, DockablePanel *container) - : KnobGui(knob, container) + : KnobGuiTable(knob, container) , _mainContainer(0) , _lineEdit(0) , _openFileButton(0) - , _table(0) - , _model(0) - , _addPathButton(0) - , _removePathButton(0) - , _editPathButton(0) - , _isInsertingItem(false) - , _dragAndDropping(false) { _knob = boost::dynamic_pointer_cast(knob); assert(_knob.lock()); @@ -744,165 +737,24 @@ KnobGuiPath::~KnobGuiPath() void KnobGuiPath::removeSpecificGui() { - _mainContainer->deleteLater(); - _mainContainer = 0; -} - -////////////// TableView delegate - -class PathKnobTableItemDelegate -: public QStyledItemDelegate -{ - TableView* _view; - bool _isStringList; -public: - - explicit PathKnobTableItemDelegate(TableView* view, bool isStringList); - -private: - - virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const OVERRIDE FINAL; -}; - -PathKnobTableItemDelegate::PathKnobTableItemDelegate(TableView* view,bool isStringList) -: QStyledItemDelegate(view) -, _view(view) -, _isStringList(isStringList) -{ -} - -void -PathKnobTableItemDelegate::paint(QPainter * painter, - const QStyleOptionViewItem & option, - const QModelIndex & index) const -{ - - if (!index.isValid() || option.state & QStyle::State_Selected) { - QStyledItemDelegate::paint(painter,option,index); - - return; - } - TableModel* model = dynamic_cast( _view->model() ); - assert(model); - if (!model) { - // coverity[dead_error_begin] - QStyledItemDelegate::paint(painter, option, index); - return; - } - TableItem* item = model->item(index); - if (!item) { - QStyledItemDelegate::paint(painter, option, index); - return; - } - QPen pen; - - if (!item->flags().testFlag(Qt::ItemIsEnabled)) { - pen.setColor(Qt::black); - } else { - pen.setColor( QColor(200,200,200) ); - + if (_mainContainer) { + _mainContainer->deleteLater(); + _mainContainer = 0; } - painter->setPen(pen); - - // get the proper subrect from the style - QStyle *style = QApplication::style(); - QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &option); - - ///Draw the item name column - if (option.state & QStyle::State_Selected) { - painter->fillRect( geom, option.palette.highlight() ); - } - QRect r; - QString str = item->data(Qt::DisplayRole).toString(); - if (!_isStringList && index.column() == 0) { - ///Env vars are used between brackets - str.prepend(QLatin1Char('[')); - str.append(QLatin1Char(']')); - } - painter->drawText(geom,Qt::TextSingleLine,str,&r); + KnobGuiTable::removeSpecificGui(); } void KnobGuiPath::createWidget(QHBoxLayout* layout) { - _mainContainer = new QWidget(layout->parentWidget()); boost::shared_ptr knob = _knob.lock(); if (knob->isMultiPath()) { - QVBoxLayout* mainLayout = new QVBoxLayout(_mainContainer); - mainLayout->setContentsMargins(0, 0, 0, 0); - - _table = new TableView( _mainContainer ); - QObject::connect( _table,SIGNAL(aboutToDrop()),this,SLOT(onItemAboutToDrop()) ); - QObject::connect( _table,SIGNAL(itemDropped()),this,SLOT(onItemDropped()) ); - layout->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - // QObject::connect( _table, SIGNAL(editingFinished()), this, SLOT(onReturnPressed()) ); - - _table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - _table->setAttribute(Qt::WA_MacShowFocusRect,0); - -#if QT_VERSION < 0x050000 - _table->header()->setResizeMode(QHeaderView::ResizeToContents); -#else - _table->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif - _table->setDragDropMode(QAbstractItemView::InternalMove); - _table->header()->setStretchLastSection(true); - _table->setUniformRowHeights(true); - _table->setItemDelegate(new PathKnobTableItemDelegate(_table, knob->getIsStringList())); - - _model = new TableModel(0,0,_table); - QObject::connect( _model,SIGNAL(s_itemChanged(TableItem*)),this,SLOT(onItemDataChanged(TableItem*)) ); - - - _table->setTableModel(_model); - _table->setColumnCount(2); - if (knob->getIsStringList()) { - _table->setColumnHidden(1, true); - _table->header()->hide(); - } - QStringList headers; - headers << tr("Variable name") << tr("Value"); - _table->setHorizontalHeaderLabels(headers); - - ///set the copy/link actions in the right click menu - enableRightClickMenu(_table, 0); - - QWidget* buttonsContainer = new QWidget(_mainContainer); - QHBoxLayout* buttonsLayout = new QHBoxLayout(buttonsContainer); - buttonsLayout->setContentsMargins(0, 0, 0, 0); - - _addPathButton = new Button( tr("Add..."),buttonsContainer ); - if (!knob->getIsStringList()) { - _addPathButton->setToolTip(GuiUtils::convertFromPlainText(tr("Click to add a new project path."), Qt::WhiteSpaceNormal)); - } - QObject::connect( _addPathButton, SIGNAL(clicked()), this, SLOT(onAddButtonClicked()) ); - - _removePathButton = new Button( tr("Remove"),buttonsContainer); - QObject::connect( _removePathButton, SIGNAL(clicked()), this, SLOT(onRemoveButtonClicked()) ); - if (!knob->getIsStringList()) { - _removePathButton->setToolTip(GuiUtils::convertFromPlainText(tr("Click to remove selected project path."), Qt::WhiteSpaceNormal)); - } - - _editPathButton = new Button( tr("Edit..."), buttonsContainer); - QObject::connect( _editPathButton, SIGNAL(clicked()), this, SLOT(onEditButtonClicked()) ); - _editPathButton->setToolTip(GuiUtils::convertFromPlainText(tr("Click to change the path of the selected project path."), Qt::WhiteSpaceNormal)); - - - buttonsLayout->addWidget(_addPathButton); - buttonsLayout->addWidget(_removePathButton); - buttonsLayout->addWidget(_editPathButton); - buttonsLayout->addStretch(); - - mainLayout->addWidget(_table); - mainLayout->addWidget(buttonsContainer); - - if (knob->getIsStringList()) { - _editPathButton->hide(); - } + KnobGuiTable::createWidget(layout); } else { // _knob->isMultiPath() + _mainContainer = new QWidget(layout->parentWidget()); QHBoxLayout* mainLayout = new QHBoxLayout(_mainContainer); mainLayout->setContentsMargins(0, 0, 0, 0); _lineEdit = new LineEdit(_mainContainer); @@ -920,152 +772,123 @@ KnobGuiPath::createWidget(QHBoxLayout* layout) mainLayout->addWidget(_lineEdit); mainLayout->addWidget(_openFileButton); - + layout->addWidget(_mainContainer); + } - layout->addWidget(_mainContainer); } void -KnobGuiPath::onAddButtonClicked() +KnobGuiPath::onOpenFileButtonClicked() { - boost::shared_ptr knob = _knob.lock(); - if (knob->getIsStringList()) { - QStringList existingEntries; - for (Variables::iterator it = _items.begin(); it!=_items.end(); ++it) { - existingEntries.push_back(it->second.varName->text()); - } - - QString newItemName = QString::fromUtf8("Placeholder"); - int i = 1; - while (existingEntries.contains(newItemName)) { - newItemName = QString::fromUtf8("Placeholder") + QString::number(i); - ++i; - } + std::vector filters; + SequenceFileDialog dialog( _mainContainer, filters, false, SequenceFileDialog::eFileDialogModeDir, _lastOpened.toStdString(),getGui(),true ); + + if ( dialog.exec() ) { + std::string dirPath = dialog.selectedDirectory(); + updateLastOpened(QString::fromUtf8(dirPath.c_str())); - std::string oldValue = knob->getValue(); - int rowCount = (int)_items.size(); - createItem(rowCount, QString(), newItemName); - std::string newPath = rebuildPath(); - pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,newPath)); - } else { - std::vector filters; - SequenceFileDialog dialog( _mainContainer, filters, false, SequenceFileDialog::eFileDialogModeDir, _lastOpened.toStdString(),getGui(),true); + std::string oldValue = _knob.lock()->getValue(); - if (dialog.exec()) { - std::string dirPath = dialog.selectedDirectory(); - if (!dirPath.empty() && dirPath[dirPath.size() - 1] == '/') { - dirPath.erase(dirPath.size() - 1, 1); - } - updateLastOpened(QString::fromUtf8(dirPath.c_str())); - - - std::string oldValue = knob->getValue(); - - int rowCount = (int)_items.size(); - - QString varName = QString(tr("Path") + QString::fromUtf8("%1")).arg(rowCount); - - createItem(rowCount, QString::fromUtf8(dirPath.c_str()), varName); - - std::string newPath = rebuildPath(); - - pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,newPath ) ); - } + pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,dirPath ) ); } + } -void -KnobGuiPath::onEditButtonClicked() +bool +KnobGuiPath::addNewUserEntry(QStringList& row) { - std::string oldValue = _knob.lock()->getValue(); - QModelIndexList selection = _table->selectionModel()->selectedRows(); - - if (selection.size() != 1) { - return; - } + std::vector filters; + SequenceFileDialog dialog( getGui(), filters, false, SequenceFileDialog::eFileDialogModeDir, _lastOpened.toStdString(),getGui(),true); - Variables::iterator found = _items.find(selection[0].row()); - if (found != _items.end()) { - std::vector filters; - - SequenceFileDialog dialog( _mainContainer, filters, false, SequenceFileDialog::eFileDialogModeDir, found->second.value->text().toStdString(),getGui(),true ); - if (dialog.exec()) { - - std::string dirPath = dialog.selectedDirectory(); - if (!dirPath.empty() && dirPath[dirPath.size() - 1] == '/') { - dirPath.erase(dirPath.size() - 1, 1); - } - updateLastOpened(QString::fromUtf8(dirPath.c_str())); - - found->second.value->setText(QString::fromUtf8(dirPath.c_str())); - std::string newPath = rebuildPath(); - - pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,newPath ) ); + if (dialog.exec()) { + std::string dirPath = dialog.selectedDirectory(); + if (!dirPath.empty() && dirPath[dirPath.size() - 1] == '/') { + dirPath.erase(dirPath.size() - 1, 1); } + QString path = QString::fromUtf8(dirPath.c_str()); + updateLastOpened(path); + + int rc = rowCount(); + QString varName = QString(tr("Path") + QString::fromUtf8("%1")).arg(rc); + row.push_back(path); + return true; } - - - + return false; } -void -KnobGuiPath::onOpenFileButtonClicked() +bool +KnobGuiPath::editUserEntry(QStringList& row) { std::vector filters; - SequenceFileDialog dialog( _mainContainer, filters, false, SequenceFileDialog::eFileDialogModeDir, _lastOpened.toStdString(),getGui(),true ); - if ( dialog.exec() ) { + SequenceFileDialog dialog(getGui(), filters, false, SequenceFileDialog::eFileDialogModeDir, row[1].toStdString(),getGui(),true ); + if (dialog.exec()) { std::string dirPath = dialog.selectedDirectory(); - updateLastOpened(QString::fromUtf8(dirPath.c_str())); - - std::string oldValue = _knob.lock()->getValue(); - - pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,dirPath ) ); + if (!dirPath.empty() && dirPath[dirPath.size() - 1] == '/') { + dirPath.erase(dirPath.size() - 1, 1); + } + QString path = QString::fromUtf8(dirPath.c_str()); + updateLastOpened(path); + row[1] = path; + return true; } - + return false; } void -KnobGuiPath::onRemoveButtonClicked() +KnobGuiPath::entryRemoved(const QStringList& row) { boost::shared_ptr knob = _knob.lock(); - std::string oldValue = knob->getValue(); - QModelIndexList selection = _table->selectionModel()->selectedRows(); - - if (selection.isEmpty()) { - return; - } - - std::list removeVars; - for (int i = 0; i < selection.size(); ++i) { - Variables::iterator found = _items.find(selection[i].row()); - if (found != _items.end()) { - removeVars.push_back(found->second.varName->text().toStdString()); - _items.erase(found); - } + ///Fix all variables if needed + if (knob && knob->getHolder() && knob->getHolder() == getGui()->getApp()->getProject().get() && + appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled()) { + getGui()->getApp()->getProject()->fixRelativeFilePaths(row[0].toStdString(), std::string(),false); } - - _model->removeRows(selection.front().row(),selection.size()); +} +void +KnobGuiPath::tableChanged(int row, int col,std::string* newEncodedValue) +{ + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); - ///Fix all variables if needed - if (knob->getHolder() && knob->getHolder() == getGui()->getApp()->getProject().get() && + if (knob->getHolder() && knob->getHolder()->isProject() && appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled()) { - for (std::list::iterator it = removeVars.begin(); it != removeVars.end(); ++it) { - getGui()->getApp()->getProject()->fixRelativeFilePaths(*it, "",false); - } + if (col == 0) { + + std::list > oldTable,newTable; + knob->decodeFromKnobTableFormat(knob->getValue(), &oldTable); + knob->decodeFromKnobTableFormat(*newEncodedValue, &newTable); + + + ///Compare the 2 maps to find-out if a path has changed or just a name + if (oldTable.size() == newTable.size() && row < (int)oldTable.size()) { + std::list >::iterator itOld = oldTable.begin(); + std::list >::iterator itNew = newTable.begin(); + std::advance(itOld, row); + std::advance(itNew, row); + + + if ((*itOld)[0] != (*itNew)[0]) { + ///a name has changed + getGui()->getApp()->getProject()->fixPathName((*itOld)[0], (*itNew)[0]); + } else if ((*itOld)[1] != (*itNew)[1]) { + getGui()->getApp()->getProject()->fixRelativeFilePaths((*itOld)[0], (*itNew)[1],false); + } + + } + } + } - std::string newPath = rebuildPath(); - pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,newPath ) ); + } - void KnobGuiPath::onTextEdited() { @@ -1075,13 +898,6 @@ KnobGuiPath::onTextEdited() } updateLastOpened(QString::fromUtf8(dirPath.c_str())); - - -// if (allowSimplification && _knob->getHolder() && _knob->getHolder()->getApp()) { -// std::map envvar; -// _knob->getHolder()->getApp()->getProject()->getEnvironmentVariables(envvar); -// Project::findReplaceVariable(envvar,dirPath); -// } std::string oldValue = _knob.lock()->getValue(); @@ -1099,91 +915,46 @@ KnobGuiPath::updateLastOpened(const QString &str) } void -KnobGuiPath::updateGUI(int /*dimension*/) +KnobGuiPath::updateGUI(int dimension) { - boost::shared_ptr knob = _knob.lock(); - std::string value = _knob.lock()->getValue(); - - if (_knob.lock()->isMultiPath()) { - std::vector > variables; - Project::makeEnvMapUnordered(value, variables); - + + boost::shared_ptr knob = _knob.lock(); + if (!knob->isMultiPath()) { - _model->clear(); - _items.clear(); - int i = 0; - - for (std::vector >::const_iterator it = variables.begin(); it != variables.end(); ++it, ++i) { - createItem(i, QString::fromUtf8(it->second.c_str()), QString::fromUtf8(it->first.c_str())); - } - } else { + std::string value = knob->getValue(); _lineEdit->setText(QString::fromUtf8(value.c_str())); + } else { + KnobGuiTable::updateGUI(dimension); } } -void -KnobGuiPath::createItem(int row,const QString& value,const QString& varName) -{ - - - Qt::ItemFlags flags; - - boost::shared_ptr knob = _knob.lock(); - - ///Project env var is disabled and uneditable and set automatically by the project - if (varName != QString::fromUtf8(NATRON_PROJECT_ENV_VAR_NAME) && varName != QString::fromUtf8(NATRON_OCIO_ENV_VAR_NAME)) { - flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; - if (knob->getIsStringList()) { - flags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable; - } - } - TableItem* cell0 = new TableItem; - cell0->setText(varName); - cell0->setFlags(flags); - - TableItem* cell1 = new TableItem; - cell1->setText(value); - cell1->setFlags(flags); - - Row r; - r.varName = cell0; - r.value = cell1; - - _items.insert(std::make_pair(row, r)); - int modelRowCount = _model->rowCount(); - if (row >= modelRowCount) { - _model->insertRow(row); - } - _isInsertingItem = true; - _table->setItem(row, 0, cell0); - _table->setItem(row, 1, cell1); - _isInsertingItem = false; - _table->resizeColumnToContents(0); - _table->resizeColumnToContents(1); -} - void KnobGuiPath::_hide() { - _mainContainer->hide(); + if (_mainContainer) { + _mainContainer->hide(); + } + KnobGuiTable::_hide(); } void KnobGuiPath::_show() { - _mainContainer->show(); + if (_mainContainer) { + _mainContainer->show(); + } + KnobGuiTable::_show(); } void KnobGuiPath::setEnabled() { - bool enabled = getKnob()->isEnabled(0); + if (_knob.lock()->isMultiPath()) { - _table->setEnabled(enabled); - _addPathButton->setEnabled(enabled); - _removePathButton->setEnabled(enabled); + KnobGuiTable::setEnabled(); } else { + bool enabled = getKnob()->isEnabled(0); _lineEdit->setReadOnly_NoFocusRect(!enabled); _openFileButton->setEnabled(enabled); } @@ -1191,12 +962,10 @@ KnobGuiPath::setEnabled() void KnobGuiPath::setReadOnly(bool readOnly, - int /*dimension*/) + int dimension) { if (_knob.lock()->isMultiPath()) { - _table->setEnabled(!readOnly); - _addPathButton->setEnabled(!readOnly); - _removePathButton->setEnabled(!readOnly); + KnobGuiTable::setReadOnly(readOnly, dimension); } else { _lineEdit->setReadOnly_NoFocusRect(readOnly); _openFileButton->setEnabled(!readOnly); @@ -1206,7 +975,7 @@ KnobGuiPath::setReadOnly(bool readOnly, void KnobGuiPath::setDirty(bool /*dirty*/) { - + } KnobPtr KnobGuiPath::getKnob() const @@ -1214,108 +983,6 @@ KnobPtr KnobGuiPath::getKnob() const return _knob.lock(); } -void -KnobGuiPath::onItemAboutToDrop() -{ - _dragAndDropping = true; -} - -void -KnobGuiPath::onItemDropped() -{ - _items.clear(); - - ///Rebuild the mapping - int rowCount = _table->rowCount(); - int colCount = _table->columnCount(); - assert(colCount == 2); - for (int i = 0; i < rowCount; ++i) { - Row& r = _items[i]; - r.varName = _table->item(i, 0); - r.value = _table->item(i, 1); - } - _dragAndDropping = false; - - //Now refresh the knob balue - onItemDataChanged(0); -} - -void -KnobGuiPath::onItemDataChanged(TableItem* /*item*/) -{ - if (_isInsertingItem || _dragAndDropping) { - return; - } - boost::shared_ptr knob = _knob.lock(); - std::string newPath = rebuildPath(); - std::string oldPath = knob->getValue(); - - if (oldPath != newPath) { - - if (knob->getHolder() && knob->getHolder()->isProject() && - appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled()) { - std::map oldEnv,newEnv; - - Project::makeEnvMap(oldPath,oldEnv); - Project::makeEnvMap(newPath, newEnv); - - ///Compare the 2 maps to find-out if a path has changed or just a name - if (oldEnv.size() == newEnv.size()) { - std::map::iterator itOld = oldEnv.begin(); - for (std::map::iterator itNew = newEnv.begin(); itNew != newEnv.end(); ++itNew, ++itOld) { - - if (itOld->first != itNew->first) { - ///a name has changed - getGui()->getApp()->getProject()->fixPathName(itOld->first, itNew->first); - break; - } else if (itOld->second != itOld->second) { - getGui()->getApp()->getProject()->fixRelativeFilePaths(itOld->first, itNew->second,false); - break; - } - } - } - } - - pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldPath,newPath ) ); - } -} - -/** - * @brief A Path knob could also be called Environment_variable_Knob. - * The string is encoded the following way: - * [VariableName1]:[Value1];[VariableName2]:[Value2] etc... - * Split all the ';' characters to get all different variables - * then for each variable split the ':' to get the name and the value of the variable. - **/ -std::string -KnobGuiPath::rebuildPath() const -{ - std::string path; - - Variables::const_iterator next = _items.begin(); - if (next != _items.end()) { - ++next; - } - for (Variables::const_iterator it = _items.begin(); it != _items.end(); ++it) { - // In order to use XML tags, the text inside the tags has to be escaped. - path += NATRON_ENV_VAR_NAME_START_TAG; - path += Project::escapeXML(it->second.varName->text().toStdString()); - path += NATRON_ENV_VAR_NAME_END_TAG; - path += NATRON_ENV_VAR_VALUE_START_TAG; - std::string value = it->second.value->text().toStdString(); - std::string escaped = Project::escapeXML(value); - assert(value == Project::unescapeXML(escaped)); - path += escaped; - path += NATRON_ENV_VAR_VALUE_END_TAG; - - // increment for next iteration - if (next != _items.end()) { - ++next; - } - } // for(it) - return path; -} - void @@ -1409,7 +1076,7 @@ KnobGuiPath::updateToolTip() if (!_knob.lock()->isMultiPath()) { _lineEdit->setToolTip(tt); } else { - _table->setToolTip(tt); + KnobGuiTable::updateToolTip(); } } } diff --git a/Gui/KnobGuiFile.h b/Gui/KnobGuiFile.h index 3b27293c70..eaebf8ee83 100644 --- a/Gui/KnobGuiFile.h +++ b/Gui/KnobGuiFile.h @@ -38,7 +38,7 @@ CLANG_DIAG_ON(uninitialized) #include "Global/GlobalDefines.h" -#include "Gui/KnobGui.h" +#include "Gui/KnobGuiTable.h" #include "Gui/GuiFwd.h" NATRON_NAMESPACE_ENTER; @@ -188,7 +188,7 @@ public Q_SLOTS: //================================ class KnobGuiPath - : public KnobGui + : public KnobGuiTable { GCC_DIAG_SUGGEST_OVERRIDE_OFF Q_OBJECT @@ -212,19 +212,9 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual KnobPtr getKnob() const OVERRIDE FINAL; public Q_SLOTS: - - - - void onAddButtonClicked(); - - void onRemoveButtonClicked(); - - void onEditButtonClicked(); - + void onOpenFileButtonClicked(); - void onItemDataChanged(TableItem* item); - void onTextEdited(); void onMakeAbsoluteTriggered(); @@ -232,13 +222,10 @@ public Q_SLOTS: void onMakeRelativeTriggered(); void onSimplifyTriggered(); - - void onItemAboutToDrop(); - void onItemDropped(); + private: virtual void addRightClickMenuEntries(QMenu* menu) OVERRIDE FINAL; - virtual bool shouldAddStretch() const OVERRIDE FINAL { return false; } virtual void createWidget(QHBoxLayout *layout) OVERRIDE FINAL; virtual void _hide() OVERRIDE FINAL; virtual void _show() OVERRIDE FINAL; @@ -251,41 +238,20 @@ public Q_SLOTS: virtual void updateToolTip() OVERRIDE FINAL; void updateLastOpened(const QString &str); - /** - * @brief A Path knob could also be called Environment_variable_Knob. - * The string is encoded the following way: - * [VariableName1]:[Value1];[VariableName2]:[Value2] etc... - * Split all the ';' characters to get all different variables - * then for each variable split the ':' to get the name and the value of the variable. - **/ - std::string rebuildPath() const; - - void createItem(int row,const QString& value,const QString& varName); - - struct Row - { - TableItem* varName; - TableItem* value; - }; - typedef std::map Variables; - + virtual bool addNewUserEntry(QStringList& row) OVERRIDE FINAL; + // row has been set-up with old value + virtual bool editUserEntry(QStringList& row) OVERRIDE FINAL; + virtual void entryRemoved(const QStringList& row) OVERRIDE FINAL; + virtual void tableChanged(int row, int col,std::string* newEncodedValue) OVERRIDE FINAL; QWidget* _mainContainer; LineEdit* _lineEdit; Button* _openFileButton; - - TableView *_table; - TableModel* _model; - Button *_addPathButton; - Button* _removePathButton; - Button* _editPathButton; + QString _lastOpened; boost::weak_ptr _knob; - bool _isInsertingItem; - Variables _items; - bool _dragAndDropping; }; NATRON_NAMESPACE_EXIT; diff --git a/Gui/KnobGuiPrivate.cpp b/Gui/KnobGuiPrivate.cpp index b2801c6dc8..4cab13404d 100644 --- a/Gui/KnobGuiPrivate.cpp +++ b/Gui/KnobGuiPrivate.cpp @@ -41,7 +41,7 @@ KnobGuiPrivate::KnobGuiPrivate(DockablePanel* container) , field(NULL) , labelContainer(NULL) , descriptionLabel(NULL) -, expressionWarningLabel(NULL) +, warningIndicator(NULL) , isOnNewLine(false) , customInteract(NULL) , guiCurves() diff --git a/Gui/KnobGuiPrivate.h b/Gui/KnobGuiPrivate.h index e0cd441753..0cef664418 100644 --- a/Gui/KnobGuiPrivate.h +++ b/Gui/KnobGuiPrivate.h @@ -33,7 +33,7 @@ #include #include #include - +#include #include @@ -102,6 +102,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON NATRON_NAMESPACE_ENTER; + struct KnobGuiPrivate { bool triggerNewLine; @@ -117,7 +118,8 @@ struct KnobGuiPrivate QWidget* field; QWidget* labelContainer; KnobClickableLabel* descriptionLabel; - Label* expressionWarningLabel; + Label* warningIndicator; + std::map warningsMapping; bool isOnNewLine; CustomParamInteract* customInteract; diff --git a/Gui/KnobGuiTable.cpp b/Gui/KnobGuiTable.cpp new file mode 100644 index 0000000000..25d763b19a --- /dev/null +++ b/Gui/KnobGuiTable.cpp @@ -0,0 +1,759 @@ +#include "KnobGuiTable.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "Engine/KnobTypes.h" +#include "Engine/Project.h" + +#include "Gui/Button.h" +#include "Gui/KnobUndoCommand.h" +#include "Gui/NewLayerDialog.h" +#include "Gui/TableModelView.h" +#include "Gui/Utils.h" + +NATRON_NAMESPACE_ENTER; + +namespace { +struct Row +{ + std::vector items; +}; +typedef std::vector Variables; +} + + +struct KnobGuiTablePrivate +{ + + std::string encodeTable(const boost::shared_ptr& knob) const; + + void createItem(const boost::shared_ptr& knob, int row,const QStringList& values); + + QWidget* mainContainer; + + TableView *table; + TableModel* model; + Button *addPathButton; + Button* removePathButton; + Button* editPathButton; + bool isInsertingItem; + Variables items; + bool dragAndDropping; + + KnobGuiTablePrivate() + : mainContainer(0) + , table(0) + , model(0) + , addPathButton(0) + , removePathButton(0) + , editPathButton(0) + , isInsertingItem(false) + , items() + , dragAndDropping(false) + { + + } +}; + +KnobGuiTable::KnobGuiTable(KnobPtr knob, + DockablePanel *container) +: KnobGui(knob, container) +, _imp(new KnobGuiTablePrivate()) +{ + +} + +KnobGuiTable::~KnobGuiTable() +{ + +} + +void KnobGuiTable::removeSpecificGui() +{ + if (_imp->mainContainer) { + _imp->mainContainer->deleteLater(); + _imp->mainContainer = 0; + } +} + +int +KnobGuiTable::rowCount() const +{ + return _imp->model->rowCount(); +} + +////////////// TableView delegate + +class KnobTableItemDelegate +: public QStyledItemDelegate +{ + TableView* _view; + boost::weak_ptr _knob; + +public: + + explicit KnobTableItemDelegate(const boost::shared_ptr& knob, TableView* view); + +private: + + virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const OVERRIDE FINAL; +}; + +KnobTableItemDelegate::KnobTableItemDelegate(const boost::shared_ptr& knob, TableView* view) +: QStyledItemDelegate(view) +, _view(view) +, _knob(knob) +{ +} + +void +KnobTableItemDelegate::paint(QPainter * painter, + const QStyleOptionViewItem & option, + const QModelIndex & index) const +{ + + if (!index.isValid() || option.state & QStyle::State_Selected) { + QStyledItemDelegate::paint(painter,option,index); + + return; + } + + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + + + TableModel* model = dynamic_cast( _view->model() ); + assert(model); + if (!model) { + // coverity[dead_error_begin] + QStyledItemDelegate::paint(painter, option, index); + return; + } + TableItem* item = model->item(index); + if (!item) { + QStyledItemDelegate::paint(painter, option, index); + return; + } + QPen pen; + + if (!item->flags().testFlag(Qt::ItemIsEnabled)) { + pen.setColor(Qt::black); + } else { + pen.setColor( QColor(200,200,200) ); + + } + painter->setPen(pen); + + // get the proper subrect from the style + QStyle *style = QApplication::style(); + QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &option); + + ///Draw the item name column + if (option.state & QStyle::State_Selected) { + painter->fillRect( geom, option.palette.highlight() ); + } + QRect r; + QString str = item->data(Qt::DisplayRole).toString(); + + bool decorateWithBrackets = knob->isCellBracketDecorated(index.row(), index.column()); + + if (decorateWithBrackets) { + ///Env vars are used between brackets + str.prepend(QLatin1Char('[')); + str.append(QLatin1Char(']')); + } + painter->drawText(geom,Qt::TextSingleLine,str,&r); +} + + +void +KnobGuiTable::createWidget(QHBoxLayout* layout) +{ + + + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + + _imp->mainContainer = new QWidget(layout->parentWidget()); + QVBoxLayout* mainLayout = new QVBoxLayout(_imp->mainContainer); + mainLayout->setContentsMargins(0, 0, 0, 0); + + _imp->table = new TableView(_imp->mainContainer); + QObject::connect(_imp->table,SIGNAL(aboutToDrop()),this,SLOT(onItemAboutToDrop())); + QObject::connect(_imp->table,SIGNAL(itemDropped()),this,SLOT(onItemDropped())); + QObject::connect(_imp->table,SIGNAL(itemDoubleClicked(TableItem*)),this,SLOT(onItemDoubleClicked(TableItem*))); + + layout->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + _imp->table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + _imp->table->setAttribute(Qt::WA_MacShowFocusRect,0); + +#if QT_VERSION < 0x050000 + _imp->table->header()->setResizeMode(QHeaderView::ResizeToContents); +#else + _imp->table->header()->setSectionResizeMode(QHeaderView::ResizeToContents); +#endif + _imp->table->setDragDropMode(QAbstractItemView::InternalMove); + _imp->table->header()->setStretchLastSection(true); + _imp->table->setUniformRowHeights(true); + _imp->table->setItemDelegate(new KnobTableItemDelegate(knob, _imp->table)); + + _imp->model = new TableModel(0,0,_imp->table); + QObject::connect(_imp->model,SIGNAL(s_itemChanged(TableItem*)),this,SLOT(onItemDataChanged(TableItem*))); + + + + _imp->table->setTableModel(_imp->model); + const int numCols = knob->getColumnsCount(); + _imp->table->setColumnCount(numCols); + if (numCols == 1) { + _imp->table->header()->hide(); + } + QStringList headers; + for (int i = 0; i < numCols; ++i) { + headers.push_back(QString::fromUtf8(knob->getColumnLabel(i).c_str())); + } + _imp->table->setHorizontalHeaderLabels(headers); + + ///set the copy/link actions in the right click menu + enableRightClickMenu(_imp->table, 0); + + QWidget* buttonsContainer = new QWidget(_imp->mainContainer); + QHBoxLayout* buttonsLayout = new QHBoxLayout(buttonsContainer); + buttonsLayout->setContentsMargins(0, 0, 0, 0); + + _imp->addPathButton = new Button( tr("Add..."),buttonsContainer ); + _imp->addPathButton->setToolTip(GuiUtils::convertFromPlainText(tr("Add a new value"), Qt::WhiteSpaceNormal)); + + QObject::connect( _imp->addPathButton, SIGNAL(clicked()), this, SLOT(onAddButtonClicked()) ); + + _imp->removePathButton = new Button( tr("Remove"),buttonsContainer); + QObject::connect(_imp->removePathButton, SIGNAL(clicked()), this, SLOT(onRemoveButtonClicked())); + _imp->removePathButton->setToolTip(GuiUtils::convertFromPlainText(tr("Remove selected values"), Qt::WhiteSpaceNormal)); + + _imp->editPathButton = new Button( tr("Edit..."), buttonsContainer); + QObject::connect(_imp->editPathButton, SIGNAL(clicked()), this, SLOT(onEditButtonClicked()) ); + _imp->editPathButton->setToolTip(GuiUtils::convertFromPlainText(tr("Click to edit seleted value."), Qt::WhiteSpaceNormal)); + + + buttonsLayout->addWidget(_imp->addPathButton); + buttonsLayout->addWidget(_imp->removePathButton); + buttonsLayout->addWidget(_imp->editPathButton); + buttonsLayout->addStretch(); + + mainLayout->addWidget(_imp->table); + mainLayout->addWidget(buttonsContainer); + + if (!knob->useEditButton()) { + _imp->editPathButton->hide(); + } + + layout->addWidget(_imp->mainContainer); +} + +std::string +KnobGuiTablePrivate::encodeTable(const boost::shared_ptr& knob) const +{ + std::stringstream ss; + + for (Variables::const_iterator it = items.begin(); it != items.end(); ++it) { + // In order to use XML tags, the text inside the tags has to be escaped. + for (std::size_t c = 0; c < it->items.size(); ++c) { + std::string label = knob->getColumnLabel(c); + ss << "<" << label << ">"; + ss << Project::escapeXML(it->items[c]->text().toStdString()); + ss << ""; + } + } + return ss.str(); + +} + +void +KnobGuiTablePrivate::createItem(const boost::shared_ptr& knob, int row,const QStringList& values) +{ + + + assert(values.size() == knob->getColumnsCount()); + int col = 0; + + Row r; + + for (QStringList::const_iterator it = values.begin(); it!= values.end(); ++it, ++col) { + + Qt::ItemFlags flags; + if (knob->isCellEnabled(row, col, values)) { + + flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; + if (knob->isColumnEditable(col)) { + flags |= Qt::ItemIsEditable; + } + + if (values.size() == 1) { + flags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable; + } + } + + TableItem* cell = new TableItem; + cell->setText(*it); + cell->setFlags(flags); + r.items.push_back(cell); + } + + if (row >= (int)items.size()) { + items.push_back(r); + } else { + std::vector::iterator it = items.begin(); + std::advance(it, row); + items.insert(it, r); + } + int modelRowCount = model->rowCount(); + if (row >= modelRowCount) { + model->insertRow(row); + } + isInsertingItem = true; + for (std::size_t i = 0; i < r.items.size(); ++i) { + table->setItem(row, i, r.items[i]); + table->resizeColumnToContents(i); + } + isInsertingItem = false; +} + +void +KnobGuiTable::onAddButtonClicked() +{ + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + + const int numCols = knob->getColumnsCount(); + + std::string oldTable = knob->getValue(); + QStringList row; + + if (numCols == 1) { + QStringList existingEntries; + for (Variables::iterator it = _imp->items.begin(); it!= _imp->items.end(); ++it) { + existingEntries.push_back(it->items[0]->text()); + } + + QString newItemName = QString::fromUtf8("Placeholder"); + int i = 1; + while (existingEntries.contains(newItemName)) { + newItemName = QString::fromUtf8("Placeholder") + QString::number(i); + ++i; + } + row.push_back(newItemName); + + } else { + + if (!addNewUserEntry(row)) { + return; + } + + } + + int rowCount = (int)_imp->items.size(); + + _imp->createItem(knob, rowCount, row); + std::string newTable = _imp->encodeTable(knob); + pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldTable,newTable)); +} + +void +KnobGuiTable::onEditButtonClicked() +{ + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + std::string oldTable = knob->getValue(); + + QModelIndexList selection = _imp->table->selectionModel()->selectedRows(); + + if (selection.size() != 1) { + return; + } + + if (selection[0].row() >= 0 && selection[0].row() < (int)_imp->items.size()) { + Row& r = _imp->items[selection[0].row()]; + QStringList row; + for (std::size_t i = 0; i < r.items.size(); ++i) { + row.push_back(r.items[i]->text()); + } + if (!editUserEntry(row)) { + return; + } + + for (std::size_t i = 0; i < r.items.size(); ++i) { + r.items[i]->setText(row[i]); + } + + std::string newTable = _imp->encodeTable(knob); + pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldTable,newTable)); + + } + +} + +void +KnobGuiTable::onRemoveButtonClicked() +{ + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + QModelIndexList selection = _imp->table->selectionModel()->selectedRows(); + + if (selection.size() < 1) { + return; + } + + + + for (int i = 0; i < selection.size(); ++i) { + + QStringList removedRow; + if (selection[0].row() >= 0 && selection[0].row() < (int)_imp->items.size()) { + Row& r = _imp->items[selection[0].row()]; + for (std::size_t i = 0; i < r.items.size(); ++i) { + removedRow.push_back(r.items[i]->text()); + } + _imp->items.erase(_imp->items.begin() + selection[0].row()); + } + + entryRemoved(removedRow); + + } + + _imp->model->removeRows(selection.front().row(),selection.size()); + + + std::string oldTable = knob->getValue(); + std::string newTable = _imp->encodeTable(knob); + pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldTable,newTable)); +} + +void +KnobGuiTable::updateGUI(int /*dimension*/) +{ + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + + std::list > table; + knob->getTable(&table); + + _imp->model->clear(); + _imp->items.clear(); + int i = 0; + for (std::list >::const_iterator it = table.begin(); it != table.end(); ++it, ++i) { + + QStringList row; + for (std::size_t i = 0; i < it->size(); ++i) { + row.push_back(QString::fromUtf8((*it)[i].c_str())); + } + _imp->createItem(knob, i, row); + } + +} + + +void +KnobGuiTable::_hide() +{ + if (_imp->mainContainer) { + _imp->mainContainer->hide(); + } +} + +void +KnobGuiTable::_show() +{ + if (_imp->mainContainer) { + _imp->mainContainer->show(); + } +} + +void +KnobGuiTable::setEnabled() +{ + bool enabled = getKnob()->isEnabled(0); + if (_imp->table) { + _imp->table->setEnabled(enabled); + _imp->addPathButton->setEnabled(enabled); + _imp->removePathButton->setEnabled(enabled); + } + +} + +void +KnobGuiTable::setReadOnly(bool readOnly, + int /*dimension*/) +{ + if (_imp->table) { + _imp->table->setEnabled(!readOnly); + _imp->addPathButton->setEnabled(!readOnly); + _imp->removePathButton->setEnabled(!readOnly); + } +} + + +void +KnobGuiTable::onItemAboutToDrop() +{ + _imp->dragAndDropping = true; +} + + +void +KnobGuiTable::onItemDropped() +{ + _imp->items.clear(); + + ///Rebuild the mapping + int rowCount = _imp->table->rowCount(); + int colCount = _imp->table->columnCount(); + for (int i = 0; i < rowCount; ++i) { + Row& r = _imp->items[i]; + r.items.resize(colCount); + for (int j = 0; j < colCount; ++j) { + r.items[j] = _imp->table->item(i, j); + } + } + _imp->dragAndDropping = false; + + //Now refresh the knob balue + onItemDataChanged(0); +} + +void +KnobGuiTable::onItemDoubleClicked(TableItem* item) +{ + int row = -1; + int col = -1; + for (std::size_t i = 0; i < _imp->items.size(); ++i) { + for (std::size_t j = 0; j < _imp->items[i].items.size(); ++j) { + if (_imp->items[i].items[j] == item) { + row = i; + col = j; + break; + } + } + if (row != -1) { + break; + } + } + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + + + Row& r = _imp->items[row]; + QStringList values; + for (std::size_t i = 0; i < r.items.size(); ++i) { + values.push_back(r.items[i]->text()); + } + + // Not enabled + if (!knob->isCellEnabled(row,col,values)) { + return; + } + + // Let the standard editor + if (knob->isColumnEditable(col)) { + return; + } + if (!editUserEntry(values)) { + return; + } + + for (std::size_t i = 0; i < r.items.size(); ++i) { + r.items[i]->setText(values[i]); + } + + std::string oldTable = knob->getValue(); + std::string newTable = _imp->encodeTable(knob); + pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldTable,newTable)); + + + +} + +void +KnobGuiTable::onItemDataChanged(TableItem* item) +{ + if (_imp->isInsertingItem || _imp->dragAndDropping) { + return; + } + + int row = -1; + int col = -1; + for (std::size_t i = 0; i < _imp->items.size(); ++i) { + for (std::size_t j = 0; j < _imp->items[i].items.size(); ++j) { + if (_imp->items[i].items[j] == item) { + row = i; + col = j; + break; + } + } + if (row != -1) { + break; + } + } + + if (row != -1) { + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + + std::string oldValue = knob->getValue(); + std::string newValue = _imp->encodeTable(knob); + if (oldValue != newValue) { + + tableChanged(row, col, &newValue); + pushUndoCommand( new KnobUndoCommand( shared_from_this(),oldValue,newValue)); + } + } +} + + +void +KnobGuiTable::updateToolTip() +{ + if (hasToolTip()) { + QString tt = toolTip(); + _imp->table->setToolTip(tt); + } +} + +KnobGuiLayers::KnobGuiLayers(KnobPtr knob, + DockablePanel *container) +: KnobGuiTable(knob,container) +{ + _knob = boost::dynamic_pointer_cast(knob); +} + +KnobGuiLayers::~KnobGuiLayers() +{ + +} + +bool +KnobGuiLayers::addNewUserEntry(QStringList& row) +{ + NewLayerDialog dialog(ImageComponents::getNoneComponents(),getGui()); + if (dialog.exec()) { + ImageComponents comps = dialog.getComponents(); + if (comps == ImageComponents::getNoneComponents()) { + Dialogs::errorDialog(tr("Layer").toStdString(), tr("A layer must contain at least 1 channel and channel names must be " + "Python compliant.").toStdString()); + return false; + } + row.push_back(QString::fromUtf8(comps.getLayerName().c_str())); + + std::list > table; + _knob.lock()->getTable(&table); + for (std::list >::iterator it = table.begin(); it!=table.end(); ++it) { + if ((*it)[0] == comps.getLayerName()) { + Dialogs::errorDialog(tr("Layer").toStdString(), tr("A Layer with the same name already exists").toStdString()); + return false; + } + } + + std::string channelsStr; + const std::vector& channels = comps.getComponentsNames(); + for (std::size_t i = 0; i < channels.size(); ++i) { + channelsStr += channels[i]; + if (i < (channels.size() - 1)) { + channelsStr += ' '; + } + } + row.push_back(QString::fromUtf8(channelsStr.c_str())); + return true; + } + return false; +} + +bool +KnobGuiLayers::editUserEntry(QStringList& row) +{ + std::vector channels; + QStringList splits = row[1].split(QLatin1Char(' ')); + for (int i = 0; i < splits.size(); ++i) { + channels.push_back(splits[i].toStdString()); + } + ImageComponents original(row[0].toStdString(),std::string(),channels);; + + NewLayerDialog dialog(original,getGui()); + if (dialog.exec()) { + ImageComponents comps = dialog.getComponents(); + if (comps == ImageComponents::getNoneComponents()) { + Dialogs::errorDialog(tr("Layer").toStdString(), tr("A layer must contain at least 1 channel and channel names must be " + "Python compliant.").toStdString()); + return false; + } + + std::string oldLayerName = row[0].toStdString(); + row[0] = (QString::fromUtf8(comps.getLayerName().c_str())); + + std::list > table; + _knob.lock()->getTable(&table); + for (std::list >::iterator it = table.begin(); it!=table.end(); ++it) { + if ((*it)[0] == comps.getLayerName() && (*it)[0] != oldLayerName) { + Dialogs::errorDialog(tr("Layer").toStdString(), tr("A Layer with the same name already exists").toStdString()); + return false; + } + } + + std::string channelsStr; + const std::vector& channels = comps.getComponentsNames(); + for (std::size_t i = 0; i < channels.size(); ++i) { + channelsStr += channels[i]; + if (i < (channels.size() - 1)) { + channelsStr += ' '; + } + } + row[1] = (QString::fromUtf8(channelsStr.c_str())); + return true; + } + return false; +} + +void +KnobGuiLayers::tableChanged(int row, int col, std::string* newEncodedValue) +{ + if (col != 0) { + return; + } + boost::shared_ptr knob = boost::dynamic_pointer_cast(getKnob()); + assert(knob); + std::list > table; + knob->decodeFromKnobTableFormat(*newEncodedValue, &table); + + if (row < (int)table.size()) { + + std::list >::iterator it = table.begin(); + std::advance(it, row); + std::string copy = Python::makeNameScriptFriendlyWithDots((*it)[0]); + if (copy != (*it)[0]) { + (*it)[0] = copy; + *newEncodedValue = knob->encodeToKnobTableFormat(table); + } + + } + +} + +KnobPtr +KnobGuiLayers::getKnob() const +{ + return _knob.lock(); +} + +NATRON_NAMESPACE_EXIT; + +NATRON_NAMESPACE_USING; +#include "moc_KnobGuiTable.cpp" \ No newline at end of file diff --git a/Gui/KnobGuiTable.h b/Gui/KnobGuiTable.h new file mode 100644 index 0000000000..b5404aa58f --- /dev/null +++ b/Gui/KnobGuiTable.h @@ -0,0 +1,152 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * This file is part of Natron , + * Copyright (C) 2016 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 + * ***** END LICENSE BLOCK ***** */ + +#ifndef Gui_KnobGuiLayer_h +#define Gui_KnobGuiLayer_h + +// ***** BEGIN PYTHON BLOCK ***** +// from : +// "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 +// ***** END PYTHON BLOCK ***** + +#include "Global/Macros.h" +#include "Gui/GuiFwd.h" +#include "Gui/KnobGui.h" + +NATRON_NAMESPACE_ENTER; + +struct KnobGuiTablePrivate; +class KnobGuiTable : public KnobGui +{ + GCC_DIAG_SUGGEST_OVERRIDE_OFF + Q_OBJECT + GCC_DIAG_SUGGEST_OVERRIDE_ON + +public: + + KnobGuiTable(KnobPtr knob, + DockablePanel *container); + + virtual ~KnobGuiTable() OVERRIDE; + + virtual void removeSpecificGui() OVERRIDE; + + int rowCount() const; + +public Q_SLOTS: + + + void onAddButtonClicked(); + + void onRemoveButtonClicked(); + + void onEditButtonClicked(); + + void onItemDataChanged(TableItem* item); + + void onItemAboutToDrop(); + + void onItemDropped(); + + void onItemDoubleClicked(TableItem* item); + +protected: + + virtual void setDirty(bool /*dirty*/) OVERRIDE + { + + } + + virtual void createWidget(QHBoxLayout *layout) OVERRIDE; + virtual void _hide() OVERRIDE; + virtual void _show() OVERRIDE; + virtual void setEnabled() OVERRIDE; + virtual void setReadOnly(bool readOnly,int dimension) OVERRIDE; + virtual void updateGUI(int dimension) OVERRIDE; + virtual void reflectAnimationLevel(int /*dimension*/,AnimationLevelEnum /*level*/) OVERRIDE + { + + } + virtual void reflectExpressionState(int /*dimension*/,bool /*hasExpr*/) OVERRIDE + { + + } + virtual void updateToolTip() OVERRIDE; + + virtual bool addNewUserEntry(QStringList& row) = 0; + + // row has been set-up with old value + virtual bool editUserEntry(QStringList& row) = 0; + + virtual void entryRemoved(const QStringList& /*row*/) {} + + virtual void tableChanged(int /*row*/, int /*col*/, std::string* /*newEncodedValue*/) + { + + } + +private: + + virtual bool shouldAddStretch() const OVERRIDE FINAL { return false; } + + boost::scoped_ptr _imp; + +}; + +class KnobGuiLayers +: public KnobGuiTable +{ + +public: + + static KnobGui * BuildKnobGui(KnobPtr knob, + DockablePanel *container) + { + return new KnobGuiLayers(knob, container); + } + + KnobGuiLayers(KnobPtr knob, + DockablePanel *container); + + virtual ~KnobGuiLayers() OVERRIDE; + + + virtual KnobPtr getKnob() const OVERRIDE FINAL; + + +private: + + + virtual bool addNewUserEntry(QStringList& row) OVERRIDE FINAL WARN_UNUSED_RETURN; + + // row has been set-up with old value + virtual bool editUserEntry(QStringList& row) OVERRIDE FINAL WARN_UNUSED_RETURN; + + virtual void entryRemoved(const QStringList& /*row*/) OVERRIDE {} + + virtual void tableChanged(int row, int col, std::string* newEncodedValue) OVERRIDE FINAL; + + + boost::weak_ptr _knob; + +}; + +NATRON_NAMESPACE_EXIT; + +#endif // Gui_KnobGuiLayer_h diff --git a/Gui/NatronGui/natrongui_module_wrapper.cpp b/Gui/NatronGui/natrongui_module_wrapper.cpp index ce1c8ac380..640b7726cf 100644 --- a/Gui/NatronGui/natrongui_module_wrapper.cpp +++ b/Gui/NatronGui/natrongui_module_wrapper.cpp @@ -35,9 +35,9 @@ static PyMethodDef NatronGui_methods[] = { }; // Classes initialization functions ------------------------------------------------------------ -void init_PyViewer(PyObject* module); void init_PyGuiApplication(PyObject* module); void init_GuiApp(PyObject* module); +void init_PyViewer(PyObject* module); void init_PyTabWidget(PyObject* module); void init_PyModalDialog(PyObject* module); void init_PyPanel(PyObject* module); @@ -497,9 +497,9 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronGui) #endif // Initialize classes in the type system - init_PyViewer(module); init_PyGuiApplication(module); init_GuiApp(module); + init_PyViewer(module); init_PyTabWidget(module); init_PyModalDialog(module); init_PyPanel(module); diff --git a/Gui/NatronGui/natrongui_python.h b/Gui/NatronGui/natrongui_python.h index c34fa91041..dbeefb6fb8 100644 --- a/Gui/NatronGui/natrongui_python.h +++ b/Gui/NatronGui/natrongui_python.h @@ -56,11 +56,11 @@ CLANG_DIAG_ON(uninitialized) // Type indices #define SBK_PYTABWIDGET_IDX 4 +#define SBK_PYVIEWER_IDX 5 #define SBK_GUIAPP_IDX 0 #define SBK_PYGUIAPPLICATION_IDX 1 #define SBK_PYPANEL_IDX 3 #define SBK_PYMODALDIALOG_IDX 2 -#define SBK_PYVIEWER_IDX 5 #define SBK_NatronGui_IDX_COUNT 6 // This variable stores all Python types exported by this module. @@ -90,11 +90,11 @@ namespace Shiboken // PyType functions, to get the PyObjectType for a type T template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYTABWIDGET_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYVIEWER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_GUIAPP_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYGUIAPPLICATION_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYPANEL_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYMODALDIALOG_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronGuiTypes[SBK_PYVIEWER_IDX]); } } // namespace Shiboken diff --git a/Gui/NewLayerDialog.cpp b/Gui/NewLayerDialog.cpp index 30eda765ca..da7e25ca8d 100644 --- a/Gui/NewLayerDialog.cpp +++ b/Gui/NewLayerDialog.cpp @@ -122,10 +122,11 @@ struct NewLayerDialogPrivate } }; -NewLayerDialog::NewLayerDialog(QWidget* parent) +NewLayerDialog::NewLayerDialog(const ImageComponents& original, QWidget* parent) : QDialog(parent) , _imp(new NewLayerDialogPrivate()) { + _imp->mainLayout = new QGridLayout(this); _imp->layerLabel = new Label(tr("Layer Name"),this); _imp->layerEdit = new LineEdit(this); @@ -178,7 +179,22 @@ NewLayerDialog::NewLayerDialog(QWidget* parent) _imp->mainLayout->addWidget(_imp->buttons, 7, 0, 1, 2); - + if (original.getNumComponents() != 0) { + _imp->layerEdit->setText(QString::fromUtf8(original.getLayerName().c_str())); + + LineEdit* edits[4] = {_imp->rEdit, _imp->gEdit, _imp->bEdit, _imp->aEdit}; + Label* labels[4] = {_imp->rLabel, _imp->gLabel, _imp->bLabel, _imp->aLabel}; + const std::vector& channels = original.getComponentsNames(); + for (int i = 0; i < 4; ++i) { + if (i >= (int)channels.size() ) { + edits[i]->setVisible(false); + labels[i]->setVisible(false); + } else { + edits[i]->setText(QString::fromUtf8(channels[i].c_str())); + } + } + _imp->numCompsBox->setValue((double)channels.size()); + } } @@ -238,7 +254,13 @@ NewLayerDialog::getComponents() const QString g = _imp->gEdit->text(); QString b = _imp->bEdit->text(); QString a = _imp->aEdit->text(); - std::string layerFixed = Python::makeNameScriptFriendly(layer.toStdString()); + std::string layerFixed = Python::makeNameScriptFriendlyWithDots(layer.toStdString()); + + std::string rFixed = Python::makeNameScriptFriendlyWithDots(r.toStdString()); + std::string gFixed = Python::makeNameScriptFriendlyWithDots(g.toStdString()); + std::string bFixed = Python::makeNameScriptFriendlyWithDots(b.toStdString()); + std::string aFixed = Python::makeNameScriptFriendlyWithDots(a.toStdString()); + if (layerFixed.empty()) { return ImageComponents::getNoneComponents(); } @@ -249,47 +271,47 @@ NewLayerDialog::getComponents() const } std::vector comps; std::string compsGlobal; - comps.push_back(a.toStdString()); - compsGlobal.append(a.toStdString()); + comps.push_back(aFixed); + compsGlobal.append(aFixed); return ImageComponents(layerFixed,compsGlobal,comps); } else if (nComps == 2) { - if (r.isEmpty() || g.isEmpty()) { + if (rFixed.empty() || gFixed.empty()) { return ImageComponents::getNoneComponents(); } std::vector comps; std::string compsGlobal; - comps.push_back(r.toStdString()); - compsGlobal.append(r.toStdString()); - comps.push_back(g.toStdString()); - compsGlobal.append(g.toStdString()); + comps.push_back(rFixed); + compsGlobal.append(rFixed); + comps.push_back(gFixed); + compsGlobal.append(gFixed); return ImageComponents(layerFixed,compsGlobal,comps); } else if (nComps == 3) { - if (r.isEmpty() || g.isEmpty() || b.isEmpty()) { + if (rFixed.empty() || gFixed.empty() || bFixed.empty()) { return ImageComponents::getNoneComponents(); } std::vector comps; std::string compsGlobal; - comps.push_back(r.toStdString()); - compsGlobal.append(r.toStdString()); - comps.push_back(g.toStdString()); - compsGlobal.append(g.toStdString()); - comps.push_back(b.toStdString()); - compsGlobal.append(b.toStdString()); + comps.push_back(rFixed); + compsGlobal.append(rFixed); + comps.push_back(gFixed); + compsGlobal.append(gFixed); + comps.push_back(bFixed); + compsGlobal.append(bFixed); return ImageComponents(layerFixed,compsGlobal,comps); } else if (nComps == 4) { - if (r.isEmpty() || g.isEmpty() || b.isEmpty() | a.isEmpty()) { + if (rFixed.empty() || gFixed.empty() || bFixed.empty() || aFixed.empty()) { return ImageComponents::getNoneComponents(); } std::vector comps; std::string compsGlobal; - comps.push_back(r.toStdString()); - compsGlobal.append(r.toStdString()); - comps.push_back(g.toStdString()); - compsGlobal.append(g.toStdString()); - comps.push_back(b.toStdString()); - compsGlobal.append(b.toStdString()); - comps.push_back(a.toStdString()); - compsGlobal.append(a.toStdString()); + comps.push_back(rFixed); + compsGlobal.append(rFixed); + comps.push_back(gFixed); + compsGlobal.append(gFixed); + comps.push_back(bFixed); + compsGlobal.append(bFixed); + comps.push_back(aFixed); + compsGlobal.append(aFixed); return ImageComponents(layerFixed,compsGlobal,comps); } return ImageComponents::getNoneComponents(); diff --git a/Gui/NewLayerDialog.h b/Gui/NewLayerDialog.h index 05bba15448..ceebb98c75 100644 --- a/Gui/NewLayerDialog.h +++ b/Gui/NewLayerDialog.h @@ -47,7 +47,7 @@ class NewLayerDialog : public QDialog Q_OBJECT public: - NewLayerDialog(QWidget* parent); + NewLayerDialog(const ImageComponents& original, QWidget* parent); virtual ~NewLayerDialog(); diff --git a/Gui/NodeGraph.cpp b/Gui/NodeGraph.cpp index db602641ac..e26e9a8d18 100644 --- a/Gui/NodeGraph.cpp +++ b/Gui/NodeGraph.cpp @@ -415,9 +415,9 @@ NodeGraph::createNodeGUI(const NodePtr & node, _imp->_nodes.push_back(node_ui); } - NodeGroup* parentIsGroup = dynamic_cast(node->getGroup().get());; + //NodeGroup* parentIsGroup = dynamic_cast(node->getGroup().get());; - if (args.reason != eCreateNodeReasonProjectLoad && (!getGui()->getApp()->isCreatingPythonGroup() || node->isEffectGroup()) && !parentIsGroup) { + if (args.reason != eCreateNodeReasonProjectLoad && (!getGui()->getApp()->isCreatingPythonGroup() || node->isEffectGroup()) ) { node_ui->ensurePanelCreated(); } diff --git a/Gui/NodeGraphPrivate10.cpp b/Gui/NodeGraphPrivate10.cpp index 8e4050f6c0..b33a3097e3 100644 --- a/Gui/NodeGraphPrivate10.cpp +++ b/Gui/NodeGraphPrivate10.cpp @@ -158,7 +158,6 @@ NodeGraphPrivate::pasteNode(const boost::shared_ptr & interna args.serialization = internalSerialization; NodePtr n = _publicInterface->getGui()->getApp()->createNode(args); - assert(n); if (!n) { return NodeGuiPtr(); } diff --git a/Gui/NodeGui.cpp b/Gui/NodeGui.cpp index 1d3152ee38..cd00806986 100644 --- a/Gui/NodeGui.cpp +++ b/Gui/NodeGui.cpp @@ -376,7 +376,7 @@ NodeGui::restoreStateAfterCreation() { NodePtr internalNode = getNode(); ///Refresh the disabled knob - + setColorFromGrouping(); boost::shared_ptr disabledknob = internalNode->getDisabledKnob(); if (disabledknob && disabledknob->getValue()) { @@ -388,6 +388,7 @@ NodeGui::restoreStateAfterCreation() } ///Refresh the name in the line edit onInternalNameChanged( QString::fromUtf8(internalNode->getLabel().c_str()) ); + onOutputLayerChanged(); internalNode->refreshIdentityState(); onPersistentMessageChanged(); } diff --git a/Gui/ProjectGui.cpp b/Gui/ProjectGui.cpp index 029343c624..41ea58ff2b 100644 --- a/Gui/ProjectGui.cpp +++ b/Gui/ProjectGui.cpp @@ -399,6 +399,9 @@ void loadNodeGuiSerialization(Gui* gui, tab->setInfobarVisible(found->second.infobarVisible); tab->setTimelineVisible(found->second.timelineVisible); tab->setCheckerboardEnabled(found->second.checkerboardEnabled); + if (!found->second.layerName.empty()) { + tab->setCurrentLayers(QString::fromUtf8(found->second.layerName.c_str()), QString::fromUtf8(found->second.alphaLayerName.c_str())); + } if (found->second.isPauseEnabled[0] && found->second.isPauseEnabled[1]) { tab->setViewerPaused(true, true); diff --git a/Gui/ProjectGuiSerialization.cpp b/Gui/ProjectGuiSerialization.cpp index a46ba788eb..7bbf0ad6ec 100644 --- a/Gui/ProjectGuiSerialization.cpp +++ b/Gui/ProjectGuiSerialization.cpp @@ -113,6 +113,8 @@ ProjectGuiSerialization::initialize(const ProjectGui* projectGui) viewerData.fpsLocked = tab->isFPSLocked(); viewerData.isPauseEnabled[0] = tab->isViewerPaused(0); viewerData.isPauseEnabled[1] = tab->isViewerPaused(1); + viewerData.layerName = tab->getCurrentLayerName().toStdString(); + viewerData.alphaLayerName = tab->getCurrentAlphaLayerName().toStdString(); tab->getTimelineBounds(&viewerData.leftBound, &viewerData.rightBound); tab->getActiveInputs(&viewerData.aChoice, &viewerData.bChoice); viewerData.version = VIEWER_DATA_SERIALIZATION_VERSION; diff --git a/Gui/ProjectGuiSerialization.h b/Gui/ProjectGuiSerialization.h index 15366228b1..f590df08fd 100644 --- a/Gui/ProjectGuiSerialization.h +++ b/Gui/ProjectGuiSerialization.h @@ -65,7 +65,8 @@ GCC_DIAG_ON(unused-parameter) #define VIEWER_DATA_INTRODUCES_GAMMA 10 #define VIEWER_DATA_INTRODUCES_ACTIVE_INPUTS 11 #define VIEWER_DATA_INTRODUCES_PAUSE_VIEWER 12 -#define VIEWER_DATA_SERIALIZATION_VERSION VIEWER_DATA_INTRODUCES_PAUSE_VIEWER +#define VIEWER_DATA_INTRODUCES_LAYER 13 +#define VIEWER_DATA_SERIALIZATION_VERSION VIEWER_DATA_INTRODUCES_LAYER #define PROJECT_GUI_INTRODUCES_BACKDROPS 2 #define PROJECT_GUI_REMOVES_ALL_NODE_PREVIEW_TOGGLED 3 @@ -110,6 +111,7 @@ struct ViewerData int mipMapLevel; std::string colorSpace; std::string channels; + std::string layerName,alphaLayerName; bool zoomOrPanSinceLastFit; int wipeCompositingOp; @@ -158,6 +160,10 @@ struct ViewerData gamma = 1.; } ar & ::boost::serialization::make_nvp("ColorSpace",colorSpace); + if (version >= VIEWER_DATA_INTRODUCES_LAYER) { + ar & ::boost::serialization::make_nvp("Layer",layerName); + ar & ::boost::serialization::make_nvp("AlphaLayer",alphaLayerName); + } ar & ::boost::serialization::make_nvp("Channels",channels); ar & ::boost::serialization::make_nvp("RenderScaleActivated",renderScaleActivated); ar & ::boost::serialization::make_nvp("MipMapLevel",mipMapLevel); diff --git a/Gui/Resources/PyPlugs/ZMask.py b/Gui/Resources/PyPlugs/ZMask.py index f618d348b9..b7f3a056d5 100644 --- a/Gui/Resources/PyPlugs/ZMask.py +++ b/Gui/Resources/PyPlugs/ZMask.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # DO NOT EDIT THIS FILE -# This file was automatically generated by Natron PyPlug exporter version 3. +# This file was automatically generated by Natron PyPlug exporter version 7. # Hand-written code should be added in a separate file named ZMaskExt.py # See http://natron.readthedocs.org/en/master/groups.html#adding-hand-written-code-callbacks-etc @@ -49,33 +49,12 @@ def createInstance(app,group): param = lastNode.getParam("operation") if param is not None: - options = param.getOptions() - foundOption = False - for i in range(len(options)): - if options[i] == "difference": - param.setValue(i) - foundOption = True - break - if not foundOption: - app.writeToScriptEditor("Could not set option for parameter operation of node ZMask.Merge1") + param.set("difference") del param param = lastNode.getParam("B_channels") if param is not None: - options = param.getOptions() - foundOption = False - for i in range(len(options)): - if options[i] == "RGBA": - param.setValue(i) - foundOption = True - break - if not foundOption: - app.writeToScriptEditor("Could not set option for parameter B_channels of node ZMask.Merge1") - del param - - param = lastNode.getParam("userTextArea") - if param is not None: - param.setValue("(difference)") + param.set("Color.RGBA") del param del lastNode @@ -90,12 +69,6 @@ def createInstance(app,group): lastNode.setColor(0.3, 0.5, 0.2) groupSolid1 = lastNode - param = lastNode.getParam("size") - if param is not None: - param.setValue(1920, 0) - param.setValue(1080, 1) - del param - param = lastNode.getParam("color") if param is not None: param.setValue(1, 0) @@ -149,14 +122,6 @@ def createInstance(app,group): lastNode.setColor(0.48, 0.66, 1) groupColorCorrect1 = lastNode - param = lastNode.getParam("MasterGain") - if param is not None: - param.setValue(1, 0) - param.setValue(1, 1) - param.setValue(1, 2) - param.setValue(1, 3) - del param - param = lastNode.getParam("toneRanges") if param is not None: param.setCurveColor(0, 0.6, 0.4, 0.6) @@ -215,15 +180,7 @@ def createInstance(app,group): param = lastNode.getParam("p1_channels") if param is not None: - options = param.getOptions() - foundOption = False - for i in range(len(options)): - if options[i] == "RGBA": - param.setValue(i) - foundOption = True - break - if not foundOption: - app.writeToScriptEditor("Could not set option for parameter p1_channels of node ZMask.Switch1") + param.set("Color.RGBA") del param del lastNode @@ -406,34 +363,7 @@ def createInstance(app,group): del param param = lastNode.createChoiceParam("Source_channels", "Source Layer") - entries = [ ("None", ""), - ("RGBA", ""), - ("Composite.Combined", ""), - ("RenderLayer.AO", ""), - ("RenderLayer.Combined", ""), - ("RenderLayer.Depth", ""), - ("RenderLayer.DiffCol", ""), - ("RenderLayer.DiffDir", ""), - ("RenderLayer.DiffInd", ""), - ("RenderLayer.Emit", ""), - ("RenderLayer.Env", ""), - ("RenderLayer.GlossCol", ""), - ("RenderLayer.GlossDir", ""), - ("RenderLayer.GlossInd", ""), - ("RenderLayer.IndexMA", ""), - ("RenderLayer.IndexOB", ""), - ("RenderLayer.Normal", ""), - ("RenderLayer.Shadow", ""), - ("RenderLayer.TransCol", ""), - ("RenderLayer.TransInd", ""), - ("RenderLayer.UV", ""), - ("Backward", ""), - ("DisparityLeft", ""), - ("DisparityRight", ""), - ("Forward", "")] - param.setOptions(entries) - del entries - param.setDefaultValue("RGBA") + param.setDefaultValue(1) # Add the param to the page lastNode.controls.addParam(param) @@ -459,7 +389,7 @@ def createInstance(app,group): del param # Refresh the GUI with the newly created parameters - lastNode.setPagesOrder(['controls', 'Node', 'Info']) + lastNode.setPagesOrder(['controls', 'Node', 'Info', 'Settings']) lastNode.refreshUserParamsGUI() del lastNode diff --git a/Gui/ViewerTab.h b/Gui/ViewerTab.h index e8b8aa2dbe..692ca3136a 100644 --- a/Gui/ViewerTab.h +++ b/Gui/ViewerTab.h @@ -282,6 +282,13 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON bool isViewerPaused(int texIndex) const; + QString getCurrentLayerName() const; + + QString getCurrentAlphaLayerName() const; + + void setCurrentLayers(const QString& layer, const QString& alphaLayer); + + public Q_SLOTS: void onPauseViewerButtonClicked(bool clicked); diff --git a/Gui/ViewerTab40.cpp b/Gui/ViewerTab40.cpp index 5455ab8d55..e7b2f0fe0b 100644 --- a/Gui/ViewerTab40.cpp +++ b/Gui/ViewerTab40.cpp @@ -182,6 +182,8 @@ ViewerTab::isViewerPaused(int texIndex) const return _imp->viewerNode->isViewerPaused(texIndex); } + + void ViewerTab::toggleViewerPauseMode(bool allInputs) { @@ -916,16 +918,9 @@ ViewerTab::refreshLayerAndAlphaChannelComboBox() } - int layerIdx; - if (foundCurIt == components.end()) { - layerCurChoice = QString::fromUtf8("-"); - } - - - - if (layerCurChoice == QString::fromUtf8("-")) { + if (layerCurChoice == QString::fromUtf8("-") || layerCurChoice.isEmpty() || foundCurIt == components.end()) { - ///Try to find color plane, otherwise fallback on any other layer + // Try to find color plane, otherwise fallback on any other layer if (foundColorIt != components.end()) { layerCurChoice = QString::fromUtf8(foundColorIt->getLayerName().c_str()) + QLatin1Char('.') + QString::fromUtf8(foundColorIt->getComponentsGlobalName().c_str()); @@ -942,15 +937,16 @@ ViewerTab::refreshLayerAndAlphaChannelComboBox() } - layerIdx = _imp->layerChoice->itemIndex(layerCurChoice); - assert(layerIdx != -1); - - _imp->layerChoice->setCurrentIndex_no_emit(layerIdx); if (foundCurIt == components.end()) { + _imp->layerChoice->setCurrentText_no_emit(layerCurChoice); _imp->viewerNode->setActiveLayer(ImageComponents::getNoneComponents(), false); } else { + + int layerIdx = _imp->layerChoice->itemIndex(layerCurChoice); + assert(layerIdx != -1); + _imp->layerChoice->setCurrentIndex_no_emit(layerIdx); if (foundCurIt->getNumComponents() == 1) { //Switch auto to alpha if there's only this to view _imp->viewerChannels->setCurrentIndex_no_emit(5); @@ -966,12 +962,7 @@ ViewerTab::refreshLayerAndAlphaChannelComboBox() _imp->viewerNode->setActiveLayer(*foundCurIt, false); } - int alphaIdx; - if (foundCurAlphaIt == components.end() || foundAlphaChannel.empty()) { - alphaCurChoice = QString::fromUtf8("-"); - } - - if (alphaCurChoice == QString::fromUtf8("-")) { + if (alphaCurChoice == QString::fromUtf8("-") || alphaCurChoice.isEmpty() || foundCurAlphaIt == components.end()) { ///Try to find color plane, otherwise fallback on any other layer if (foundColorIt != components.end() && @@ -993,18 +984,24 @@ ViewerTab::refreshLayerAndAlphaChannelComboBox() } - alphaIdx = _imp->alphaChannelChoice->itemIndex(alphaCurChoice); - if (alphaIdx == -1) { - alphaIdx = 0; - } - - _imp->alphaChannelChoice->setCurrentIndex_no_emit(alphaIdx); - if (foundCurAlphaIt != components.end()) { - _imp->viewerNode->setAlphaChannel(*foundCurAlphaIt, foundAlphaChannel, false); - } else { + if (foundCurAlphaIt == components.end() || foundAlphaChannel.empty()) { + _imp->alphaChannelChoice->setCurrentText_no_emit(alphaCurChoice); _imp->viewerNode->setAlphaChannel(ImageComponents::getNoneComponents(), std::string(), false); + } else { + int layerIdx = _imp->alphaChannelChoice->itemIndex(alphaCurChoice); + assert(layerIdx != -1); + _imp->alphaChannelChoice->setCurrentIndex_no_emit(layerIdx); + + _imp->viewerNode->setAlphaChannel(*foundCurAlphaIt, foundAlphaChannel, false); + } + { + QMutexLocker k(&_imp->currentLayerMutex); + _imp->currentLayerChoice = layerCurChoice; + _imp->currentAlphaLayerChoice = alphaCurChoice; + } + } void @@ -1012,6 +1009,11 @@ ViewerTab::onAlphaChannelComboChanged(int index) { std::set components; _imp->getComponentsAvailabel(&components); + + { + QMutexLocker k(&_imp->currentLayerMutex); + _imp->currentAlphaLayerChoice = _imp->alphaChannelChoice->getCurrentIndexText(); + } int i = 1; // because of the "-" choice for (std::set::iterator it = components.begin(); it != components.end(); ++it) { @@ -1029,6 +1031,7 @@ ViewerTab::onAlphaChannelComboChanged(int index) } } _imp->viewerNode->setAlphaChannel(ImageComponents::getNoneComponents(), std::string(), true); + } void @@ -1036,6 +1039,10 @@ ViewerTab::onLayerComboChanged(int index) { std::set components; _imp->getComponentsAvailabel(&components); + { + QMutexLocker k(&_imp->currentLayerMutex); + _imp->currentLayerChoice = _imp->layerChoice->getCurrentIndexText(); + } if (index >= (int)(components.size() + 1) || index < 0) { qDebug() << "ViewerTab::onLayerComboChanged: invalid index"; return; @@ -1063,6 +1070,28 @@ ViewerTab::onLayerComboChanged(int index) } +QString +ViewerTab::getCurrentLayerName() const +{ + QMutexLocker k(&_imp->currentLayerMutex); + return _imp->currentLayerChoice; +} + +QString +ViewerTab::getCurrentAlphaLayerName() const +{ + QMutexLocker k(&_imp->currentLayerMutex); + return _imp->currentAlphaLayerChoice; +} + +void +ViewerTab::setCurrentLayers(const QString& layer, const QString& alphaLayer) +{ + _imp->layerChoice->setCurrentText_no_emit(layer); + _imp->alphaChannelChoice->setCurrentText_no_emit(alphaLayer); + refreshLayerAndAlphaChannelComboBox(); +} + void ViewerTab::onGainToggled(bool clicked) { diff --git a/Gui/ViewerTabPrivate.h b/Gui/ViewerTabPrivate.h index 2db08bbf70..bf6cf70a82 100644 --- a/Gui/ViewerTabPrivate.h +++ b/Gui/ViewerTabPrivate.h @@ -77,6 +77,8 @@ struct ViewerTabPrivate //ComboBox* viewerLayers; ComboBox* layerChoice; ComboBox* alphaChannelChoice; + mutable QMutex currentLayerMutex; + QString currentLayerChoice,currentAlphaLayerChoice; ChannelsComboBox* viewerChannels; bool viewerChannelsAutoswitchedToAlpha; ComboBox* zoomCombobox; diff --git a/global.pri b/global.pri index 825278ac14..87336dad36 100644 --- a/global.pri +++ b/global.pri @@ -27,7 +27,7 @@ DEFINES += OFX_SUPPORTS_DIALOG #for QString(const char*) assumes ASCII strings, we may run into troubles DEFINES += QT_NO_CAST_FROM_ASCII -//Uncomment to run Natron without Python functionnalities (for debug purposes) +#Uncomment to run Natron without Python functionnalities (for debug purposes) #DEFINES += NATRON_RUN_WITHOUT_PYTHON *g++* | *clang* { From 25e7172f17c2977cb51372a5cf5f65f6f1803a39 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Thu, 31 Mar 2016 19:32:28 +0200 Subject: [PATCH 13/30] Do not call evaluateOnChange --- Engine/Node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/Node.cpp b/Engine/Node.cpp index c4c7717ce9..01ebfd1043 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -915,7 +915,7 @@ Node::load(const CreateNodeArgs& args) ///Now that the instance is created, make sure instanceChangedActino is called for all extra default values ///that we set - double time = getEffectInstance()->getCurrentTime(); + /* double time = getEffectInstance()->getCurrentTime(); for (std::list >::const_iterator it = args.paramValues.begin(); it != args.paramValues.end(); ++it) { KnobPtr knob = getKnobByName((*it)->getName()); if (knob) { @@ -935,7 +935,7 @@ Node::load(const CreateNodeArgs& args) } } #endif - + */ } // load bool From 5879ab5b39387df5de7271b12fc5e8b10d1163a2 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 14:55:38 +0200 Subject: [PATCH 14/30] Changes - When loading PyPlugs: load the serialisation after loading the python script. - Relax renderRoI when some planes are not rendered - Better conforming to ofxNatron.h for multi-plane extension - Fix a bug where choice would not be deserialised correctly - Abort: abort all renders. If draft is enabled (because user is scrubbing a slider/timeline) then keep the oldest render active. --- Engine/AppInstance.cpp | 6 +- Engine/EffectInstanceRenderRoI.cpp | 41 +++++---- Engine/ImageComponents.cpp | 8 +- Engine/Knob.cpp | 1 + Engine/KnobTypes.cpp | 22 +++-- Engine/Node.cpp | 131 +++++++++++++++++------------ Engine/NodeGroupSerialization.cpp | 4 + Engine/OfxClipInstance.cpp | 23 +++-- Engine/OfxClipInstance.h | 18 +++- Engine/OfxEffectInstance.cpp | 9 +- Engine/ViewerInstance.cpp | 19 ++++- Engine/ViewerInstancePrivate.h | 21 ----- Gui/Gui20.cpp | 5 +- 13 files changed, 194 insertions(+), 114 deletions(-) diff --git a/Engine/AppInstance.cpp b/Engine/AppInstance.cpp index 637df94d12..ad4c719208 100644 --- a/Engine/AppInstance.cpp +++ b/Engine/AppInstance.cpp @@ -848,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); diff --git a/Engine/EffectInstanceRenderRoI.cpp b/Engine/EffectInstanceRenderRoI.cpp index 413cdd6394..62e4d850c6 100644 --- a/Engine/EffectInstanceRenderRoI.cpp +++ b/Engine/EffectInstanceRenderRoI.cpp @@ -574,28 +574,33 @@ EffectInstance::renderRoI(const RenderRoIArgs & args, RenderRoIRetCode ret = inputEffectIdentity->renderRoI(*inputArgs, &identityPlanes); if (ret == eRenderRoIRetCodeOk) { outputPlanes->insert(identityPlanes.begin(),identityPlanes.end()); - std::map convertedPlanes; - AppInstance* app = getApp(); - assert(args.components.size() == outputPlanes->size() || outputPlanes->empty()); - bool useAlpha0ForRGBToRGBAConversion = args.caller ? args.caller->getNode()->usesAlpha0ToConvertFromRGBToRGBA() : false; - std::list::const_iterator compIt = args.components.begin(); - - for (std::map::iterator it = outputPlanes->begin(); it!=outputPlanes->end(); ++it,++compIt) { + if (fetchUserSelectedComponentsUpstream) { + // We fetched potentially different components, so convert them to the format requested + std::map convertedPlanes; + AppInstance* app = getApp(); - ImagePremultiplicationEnum premult; - const ImageComponents & outComp = outputComponents.front(); - if ( outComp.isColorPlane() ) { - premult = thisEffectOutputPremult; - } else { - premult = eImagePremultiplicationOpaque; - } + bool useAlpha0ForRGBToRGBAConversion = args.caller ? args.caller->getNode()->usesAlpha0ToConvertFromRGBToRGBA() : false; + + std::list::const_iterator compIt = args.components.begin(); - ImagePtr tmp = convertPlanesFormatsIfNeeded(app, it->second, args.roi, *compIt, inputArgs->bitdepth, useAlpha0ForRGBToRGBAConversion, premult, -1); - assert(tmp); - convertedPlanes[it->first] = tmp; + for (std::map::iterator it = outputPlanes->begin(); it!=outputPlanes->end(); ++it,++compIt) { + + ImagePremultiplicationEnum premult; + const ImageComponents & outComp = outputComponents.front(); + if ( outComp.isColorPlane() ) { + premult = thisEffectOutputPremult; + } else { + premult = eImagePremultiplicationOpaque; + } + + ImagePtr tmp = convertPlanesFormatsIfNeeded(app, it->second, args.roi, *compIt, inputArgs->bitdepth, useAlpha0ForRGBToRGBAConversion, premult, -1); + assert(tmp); + convertedPlanes[it->first] = tmp; + } + *outputPlanes = convertedPlanes; } - *outputPlanes = convertedPlanes; + } else { return ret; } diff --git a/Engine/ImageComponents.cpp b/Engine/ImageComponents.cpp index 1bdd1805d2..78698ee5c2 100644 --- a/Engine/ImageComponents.cpp +++ b/Engine/ImageComponents.cpp @@ -193,7 +193,7 @@ ImageComponents::operator==(const ImageComponents& other) const return false; } } - return _layerName == other._layerName; + return _layerName == other._layerName && _pairedLayer == other._pairedLayer; } bool @@ -318,14 +318,16 @@ const ImageComponents& ImageComponents::getPairedMotionVectors() { - static const ImageComponents comp(kFnOfxImagePlaneForwardMotionVector,kFnOfxImagePlaneBackwardMotionVector,kFnOfxImageComponentMotionVectors,motionComps,2); + //static const ImageComponents comp(kFnOfxImagePlaneForwardMotionVector,kFnOfxImagePlaneBackwardMotionVector,kFnOfxImageComponentMotionVectors,motionComps,2); + static const ImageComponents comp(kNatronForwardMotionVectorsPlaneUserName,kNatronBackwardMotionVectorsPlaneUserName,kNatronMotionComponentsName,motionComps,2); return comp; } const ImageComponents& ImageComponents::getPairedStereoDisparity() { - static const ImageComponents comp(kFnOfxImagePlaneStereoDisparityLeft,kFnOfxImagePlaneStereoDisparityRight,kFnOfxImageComponentStereoDisparity,xyComps,2); + //static const ImageComponents comp(kFnOfxImagePlaneStereoDisparityLeft,kFnOfxImagePlaneStereoDisparityRight,kFnOfxImageComponentStereoDisparity,xyComps,2); + static const ImageComponents comp(kNatronDisparityLeftPlaneUserName,kNatronDisparityRightPlaneUserName,kNatronDisparityComponentsName,xyComps,2); return comp; } diff --git a/Engine/Knob.cpp b/Engine/Knob.cpp index 3eedd6cb21..ff1ad12441 100644 --- a/Engine/Knob.cpp +++ b/Engine/Knob.cpp @@ -3894,6 +3894,7 @@ KnobHelper::setKnobAsAliasOfThis(const KnobPtr& master, bool doAlias) unSlave(i, false); } if (doAlias) { + master->clone(this, i); bool ok = slaveTo(i, master, i, eValueChangedReasonNatronInternalEdited, false); assert(ok); Q_UNUSED(ok); diff --git a/Engine/KnobTypes.cpp b/Engine/KnobTypes.cpp index 930d5b0d9f..72abe0f847 100644 --- a/Engine/KnobTypes.cpp +++ b/Engine/KnobTypes.cpp @@ -705,10 +705,16 @@ KnobChoice::findAndSetOldChoice(MergeMenuEqualityFunctor mergingFunctor, mergingFunctor = stringEqualFunctor; } int found = -1; - for (std::size_t i = 0; i < _mergedEntries.size(); ++i) { - if (mergingFunctor(_mergedEntries[i],curEntry, mergingData)) { - found = i; - break; + { + QMutexLocker k(&_entriesMutex); + for (std::size_t i = 0; i < _mergedEntries.size(); ++i) { + if (mergingFunctor(_mergedEntries[i],curEntry, mergingData)) { + found = i; + + // Update the label if different + _currentEntryLabel = _mergedEntries[i]; + break; + } } } if (found != -1) { @@ -752,6 +758,10 @@ KnobChoice::populateChoices(const std::vector &entries, bool found = false; for (std::size_t j = 0; j < _mergedEntries.size(); ++j) { if (mergingFunctor(_mergedEntries[j],entries[i], mergingData)) { + if (_mergedEntries[j] != entries[i]) { + hasChanged = true; + _mergedEntries[j] = entries[i]; + } found = true; break; } @@ -1040,7 +1050,7 @@ KnobChoice::choiceRestoration(KnobChoice* knob,const ChoiceExtraData* data) setEnabled( i, knob->isEnabled(i) ); } } - + { QMutexLocker k(&_entriesMutex); _currentEntryLabel = data->_choiceString; @@ -1074,7 +1084,7 @@ KnobChoice::onOriginalKnobPopulated() if (!isChoice) { return; } - populateChoices(isChoice->_mergedEntries,isChoice->_mergedEntriesHelp, 0, 0, false); + populateChoices(isChoice->_mergedEntries,isChoice->_mergedEntriesHelp, 0, 0, true); } void diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 01ebfd1043..2c72d5afed 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -2145,7 +2145,16 @@ Node::Implementation::restoreUserKnobsRecursive(const std::listcloneDefaultValues(sKnob.get()); - knob->clone(sKnob.get()); + if (isChoice) { + const ChoiceExtraData* data = dynamic_cast(isRegular->getExtraData()); + assert(data); + if (data) { + isChoice->choiceRestoration(dynamic_cast(sKnob.get()), data); + } + } else { + + knob->clone(sKnob.get()); + } knob->setAsUserKnob(); if (group) { group->addKnob(knob); @@ -6747,39 +6756,7 @@ Node::isMaskChannelKnob(const KnobI* knob) const return -1; } -int -Node::getMaskChannel(int inputNb,ImageComponents* comps,NodePtr* maskInput) const -{ - std::map::const_iterator it = _imp->maskSelectors.find(inputNb); - if ( it != _imp->maskSelectors.end() ) { - int index = it->second.channel.lock()->getValue(); - if (index == 0) { - *comps = ImageComponents::getNoneComponents(); - maskInput->reset(); - return -1; - } else { - index -= 1; // None choice - QMutexLocker locker(&it->second.compsMutex); - int k = 0; - for (std::size_t i = 0; i < it->second.compsAvailable.size(); ++i) { - if (index >= k && index < (it->second.compsAvailable[i].first.getNumComponents() + k)) { - int compIndex = index - k; - assert(compIndex >= 0 && compIndex <= 3); - *comps = it->second.compsAvailable[i].first; - *maskInput = it->second.compsAvailable[i].second.lock(); - return compIndex; - } - k += it->second.compsAvailable[i].first.getNumComponents(); - } - - } - //Default to alpha - *comps = ImageComponents::getAlphaComponents(); - return 0; - } - return -1; - -} + bool Node::isMaskEnabled(int inputNb) const @@ -9694,27 +9671,35 @@ static void parseLayerString(const std::string& encoded, bool* isColor) } } -static void parseMaskChannelString(const std::string& encodedChannel, +static bool parseMaskChannelString(const std::string& encodedChannel, std::string* nodeName, std::string* layerName, std::string* channelName, bool *isColor) { - std::size_t foundLastDot = encodedChannel.find_last_of("."); - if (foundLastDot != std::string::npos) { - *layerName = encodedChannel.substr(0, foundLastDot); - std::size_t foundPrevDot = layerName->find_first_of("."); - if (foundPrevDot != std::string::npos) { - //Remove the node name - *layerName = layerName->substr(foundPrevDot + 1); - *nodeName = layerName->substr(0, foundPrevDot); - } else { - *nodeName = *layerName; - layerName->clear(); + std::size_t foundLastDot = encodedChannel.find_last_of('.'); + if (foundLastDot == std::string::npos) { + *isColor = false; + if (encodedChannel == "None") { + *layerName = "None"; + return true; } - *isColor = *layerName == kNatronRGBAComponentsName || *layerName == kNatronRGBComponentsName || *layerName == kNatronAlphaComponentsName; - *channelName = encodedChannel.substr(foundLastDot + 1); + return false; + } + *channelName = encodedChannel.substr(foundLastDot + 1); + + std::string baseName = encodedChannel.substr(0, foundLastDot); + std::size_t foundPrevDot = baseName.find_first_of('.'); + if (foundPrevDot != std::string::npos) { + //Remove the node name + *layerName = baseName.substr(foundPrevDot + 1); + *nodeName = baseName.substr(0, foundPrevDot); + } else { + *layerName = baseName; + nodeName->clear(); } + *isColor = *layerName == kNatronRGBAComponentsName || *layerName == kNatronRGBComponentsName || *layerName == kNatronAlphaComponentsName; + return true; } class MergeMaskChannelData : public KnobChoiceMergeEntriesData @@ -9827,6 +9812,45 @@ static bool layerEqualityFunctor(const std::string& a, const std::string& b, Kno return false; } +int +Node::getMaskChannel(int inputNb,ImageComponents* comps,NodePtr* maskInput) const +{ + std::map::const_iterator it = _imp->maskSelectors.find(inputNb); + if ( it != _imp->maskSelectors.end() ) { + std::string maskEncoded = it->second.channel.lock()->getActiveEntryText_mt_safe(); + std::string nodeName, layerName, channelName; + bool isColor; + bool ok = parseMaskChannelString(maskEncoded, &nodeName, &layerName, &channelName, &isColor); + if (!ok || layerName == "None") { + *comps = ImageComponents::getNoneComponents(); + maskInput->reset(); + return -1; + } else { + QMutexLocker locker(&it->second.compsMutex); + for (std::size_t i = 0; i < it->second.compsAvailable.size(); ++i) { + if (it->second.compsAvailable[i].first.getLayerName() == layerName || + (isColor && it->second.compsAvailable[i].first.isColorPlane())) { + + const std::vector& channels = it->second.compsAvailable[i].first.getComponentsNames(); + for (std::size_t j = 0; j < channels.size(); ++j) { + if (channels[j] == channelName) { + *comps = it->second.compsAvailable[i].first; + *maskInput = it->second.compsAvailable[i].second.lock(); + return j; + } + } + } + } + + } + //Default to alpha + // *comps = ImageComponents::getAlphaComponents(); + //return 0; + } + return -1; + +} + bool Node::refreshChannelSelectors() { @@ -10046,7 +10070,8 @@ Node::refreshChannelSelectors() for (std::vector >::iterator it2 = compsOrdered.begin(); it2!= compsOrdered.end(); ++it2) { const std::vector& channels = it2->first.getComponentsNames(); - const std::string& layerName = it2->first.isColorPlane() ? it2->first.getComponentsGlobalName() : it2->first.getLayerName(); + bool isColor = it2->first.isColorPlane(); + const std::string& layerName = isColor ? it2->first.getComponentsGlobalName() : it2->first.getLayerName(); NodePtr providerNode = it2->second.lock(); std::string nodeName; @@ -10057,9 +10082,11 @@ Node::refreshChannelSelectors() for (std::size_t i = 0; i < channels.size(); ++i) { std::string option; - option += nodeName; - if (!nodeName.empty()) { - option += '.'; + if (!isColor) { + option += nodeName; + if (!nodeName.empty()) { + option += '.'; + } } option += layerName; if (!layerName.empty()) { diff --git a/Engine/NodeGroupSerialization.cpp b/Engine/NodeGroupSerialization.cpp index 55423885b4..42a0497e27 100644 --- a/Engine/NodeGroupSerialization.cpp +++ b/Engine/NodeGroupSerialization.cpp @@ -258,6 +258,10 @@ NodeCollectionSerialization::restoreFromSerialization(const std::list< boost::sh } } + if (!createNodes && n) { + // If we created the node using a PyPlug, deserialize the project too to override any modification made by the user. + n->loadKnobs(**it); + } assert(n); createdNodes[n] = *it; diff --git a/Engine/OfxClipInstance.cpp b/Engine/OfxClipInstance.cpp index 9d6a234d8a..79bc833298 100644 --- a/Engine/OfxClipInstance.cpp +++ b/Engine/OfxClipInstance.cpp @@ -1042,13 +1042,19 @@ OfxClipInstance::ofxPlaneToNatronPlane(const std::string& plane) } } -std::string -OfxClipInstance::natronsPlaneToOfxPlane(const ImageComponents& plane) +void +OfxClipInstance::natronsPlaneToOfxPlane(const ImageComponents& plane, std::list* ofxPlanes) { if (plane.getLayerName() == kNatronColorPlaneName) { - return kFnOfxImagePlaneColour; + ofxPlanes->push_back(kFnOfxImagePlaneColour); + } else if (plane == ImageComponents::getPairedMotionVectors()) { + ofxPlanes->push_back(kFnOfxImagePlaneBackwardMotionVector); + ofxPlanes->push_back(kFnOfxImagePlaneForwardMotionVector); + } else if (plane == ImageComponents::getPairedStereoDisparity()) { + ofxPlanes->push_back(kFnOfxImagePlaneStereoDisparityLeft); + ofxPlanes->push_back(kFnOfxImagePlaneStereoDisparityRight); } else { - return natronCustomCompToOfxComp(plane); + ofxPlanes->push_back(natronCustomCompToOfxComp(plane)); } } @@ -1064,9 +1070,16 @@ OfxClipInstance::natronsComponentsToOfxComponents(const ImageComponents& comp) return kOfxImageComponentRGB; } else if (comp == ImageComponents::getRGBAComponents()) { return kOfxImageComponentRGBA; - } else if (QString::fromUtf8(comp.getComponentsGlobalName().c_str()).compare(QString::fromUtf8("UV"), Qt::CaseInsensitive) == 0) { + /* } + else if (QString::fromUtf8(comp.getComponentsGlobalName().c_str()).compare(QString::fromUtf8("UV"), Qt::CaseInsensitive) == 0) { return kFnOfxImageComponentMotionVectors; } else if (QString::fromUtf8(comp.getComponentsGlobalName().c_str()).compare(QString::fromUtf8("XY"), Qt::CaseInsensitive) == 0) { + return kFnOfxImageComponentStereoDisparity;*/ + } else if (comp == ImageComponents::getXYComponents()) { + return kNatronOfxImageComponentXY; + } else if (comp == ImageComponents::getPairedMotionVectors()) { + return kFnOfxImageComponentMotionVectors; + } else if (comp == ImageComponents::getPairedStereoDisparity()) { return kFnOfxImageComponentStereoDisparity; } else { return natronCustomCompToOfxComp(comp); diff --git a/Engine/OfxClipInstance.h b/Engine/OfxClipInstance.h index fa7f5202d2..36b6b230d5 100644 --- a/Engine/OfxClipInstance.h +++ b/Engine/OfxClipInstance.h @@ -211,11 +211,25 @@ class OfxClipInstance int getInputNb() const WARN_UNUSED_RETURN; EffectInstPtr getAssociatedNode() const WARN_UNUSED_RETURN; - + + + /** + * @brief Used to convert plane argument as passed to the clipGetImage() function to Natron plane. + **/ ImageComponents ofxPlaneToNatronPlane(const std::string& plane); - static std::string natronsPlaneToOfxPlane(const ImageComponents& plane); + + /** + * @brief Used to convert Natron planes given to the render() function to OpenFX layer name. + **/ + static void natronsPlaneToOfxPlane(const ImageComponents& plane, std::list* ofxPlanes); + + /** + * @brief Converts Natron components to OpenFX components. + **/ static std::string natronsComponentsToOfxComponents(const ImageComponents& comp); static ImageComponents ofxComponentsToNatronComponents(const std::string & comp); + + static ImageBitDepthEnum ofxDepthToNatronDepth(const std::string & depth); static const std::string& natronsDepthToOfxDepth(ImageBitDepthEnum depth); static ImagePremultiplicationEnum ofxPremultToNatronPremult(const std::string& premult); diff --git a/Engine/OfxEffectInstance.cpp b/Engine/OfxEffectInstance.cpp index d792570667..8d17b25511 100644 --- a/Engine/OfxEffectInstance.cpp +++ b/Engine/OfxEffectInstance.cpp @@ -1811,9 +1811,10 @@ OfxEffectInstance::render(const RenderActionArgs& args) for (std::list > >::const_iterator it = args.outputPlanes.begin(); it!=args.outputPlanes.end(); ++it) { if (!multiPlanar) { - ofxPlanes.push_back(OfxClipInstance::natronsPlaneToOfxPlane(it->second->getComponents())); + // When not multi-planar, the components of the image will be the colorplane + OfxClipInstance::natronsPlaneToOfxPlane(it->second->getComponents(), &ofxPlanes); } else { - ofxPlanes.push_back(OfxClipInstance::natronsPlaneToOfxPlane(it->first)); + OfxClipInstance::natronsPlaneToOfxPlane(it->first, &ofxPlanes); } } @@ -2564,7 +2565,9 @@ OfxEffectInstance::getComponentsNeededAndProduced(double time, std::vector compNeeded; for (std::list::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { ImageComponents ofxComp = OfxClipInstance::ofxComponentsToNatronComponents(*it2); - compNeeded.push_back(ofxComp); + if (ofxComp.getNumComponents() > 0) { + compNeeded.push_back(ofxComp); + } } comps->insert(std::make_pair(index, compNeeded)); } diff --git a/Engine/ViewerInstance.cpp b/Engine/ViewerInstance.cpp index 35e34d1938..ae54ae8280 100644 --- a/Engine/ViewerInstance.cpp +++ b/Engine/ViewerInstance.cpp @@ -2366,10 +2366,25 @@ void ViewerInstance::markAllOnGoingRendersAsAborted() { + //Do not abort the oldest render while scrubbing timeline or sliders so that the user gets some feedback bool keepOldest = getApp()->isDraftRenderEnabled(); - //Do not abort the oldest render while scrubbing timeline or sliders so that the user gets some feedback - _imp->markAllRendersAsAborted(keepOldest); + QMutexLocker k(&_imp->renderAgeMutex); + for (int i = 0; i < 2; ++i) { + if (_imp->currentRenderAges[i].empty()) { + continue; + } + + //Do not abort the oldest render, let it finish + OnGoingRenders::iterator it = _imp->currentRenderAges[i].begin(); + if (keepOldest) { + ++it; + } + + for (;it != _imp->currentRenderAges[i].end(); ++it) { + (*it)->aborted = 1; + } + } } template diff --git a/Engine/ViewerInstancePrivate.h b/Engine/ViewerInstancePrivate.h index fbc9de149d..f3586ffe77 100644 --- a/Engine/ViewerInstancePrivate.h +++ b/Engine/ViewerInstancePrivate.h @@ -244,27 +244,6 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON } - void - markAllRendersAsAborted(bool keepOldest) - { - QMutexLocker k(&renderAgeMutex); - for (int i = 0; i < 2; ++i) { - if (currentRenderAges[i].empty()) { - continue; - } - - //Do not abort the oldest render, let it finish - OnGoingRenders::iterator it = currentRenderAges[i].begin(); - if (!keepOldest) { - ++it; - } - - for (;it != currentRenderAges[i].end(); ++it) { - (*it)->aborted = 1; - } - } - } - /** * @brief To be called to check if there we are the last requested render (true) or if there were * more recent requests (false). diff --git a/Gui/Gui20.cpp b/Gui/Gui20.cpp index 8c7146ac75..f5de53d893 100644 --- a/Gui/Gui20.cpp +++ b/Gui/Gui20.cpp @@ -1316,13 +1316,16 @@ Gui::createWriter() std::string file; #ifdef NATRON_ENABLE_IO_META_NODES bool useDialogForWriters = appPTR->getCurrentSettings()->isFileDialogEnabledForNewWriters(); +#else + bool useDialogForWriters = true; +#endif if (useDialogForWriters) { file = popSaveFileDialog( true, filters, _imp->_lastSaveSequenceOpenedDir.toStdString(), true ); if (file.empty()) { return NodePtr(); } } -#endif + if (!file.empty()) { std::string patternCpy = file; From c8d7f080d0dd72f36e898e0445607b908114fbc5 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 14:56:07 +0200 Subject: [PATCH 15/30] Update OpenFX --- libs/OpenFX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/OpenFX b/libs/OpenFX index d719e18881..e004385360 160000 --- a/libs/OpenFX +++ b/libs/OpenFX @@ -1 +1 @@ -Subproject commit d719e18881c950ee37f8fee0410e4171f33a1145 +Subproject commit e0043853601b6369f1b2fe1894c49c1f522d6ff0 From f2e2db527fa5ce42be0928eb2c650f62a89b587f Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 17:45:38 +0200 Subject: [PATCH 16/30] Restore compatibility with The Foundry Furnace plug-ins --- Engine/EffectInstance.cpp | 68 +++++++++++++++++++++--------- Engine/EffectInstanceRenderRoI.cpp | 27 +++++++++--- Engine/ImageComponents.cpp | 38 +++++++++++++++++ Engine/ImageComponents.h | 8 ++++ Engine/Node.cpp | 9 ++++ Engine/OfxClipInstance.cpp | 22 +++++++--- Engine/OfxEffectInstance.cpp | 5 ++- 7 files changed, 143 insertions(+), 34 deletions(-) diff --git a/Engine/EffectInstance.cpp b/Engine/EffectInstance.cpp index 50f150d42d..a3b0eb35ce 100644 --- a/Engine/EffectInstance.cpp +++ b/Engine/EffectInstance.cpp @@ -965,21 +965,7 @@ EffectInstance::getImage(int inputNb, * instantaneous thanks to the image cache. */ -#ifdef DEBUG - ///Check that the rendered image contains what we requested. - if ((!isMask && inputImg->getComponents() != components) || (isMask && inputImg->getComponents() != maskComps)) { - ImageComponents cc; - if (isMask) { - cc = maskComps; - } else { - cc = components; - } - qDebug() << "WARNING:"<< getNode()->getScriptName_mt_safe().c_str() << "requested" << cc.getComponentsGlobalName().c_str() << "but" << inputEffect->getScriptName_mt_safe().c_str() << "returned an image with" - << inputImg->getComponents().getComponentsGlobalName().c_str(); - qDebug() << inputEffect->getScriptName_mt_safe().c_str() << "output clip preference is" << inputEffect->getComponents(-1).getComponentsGlobalName().c_str(); - } -#endif if (roiPixel) { *roiPixel = pixelRoI; @@ -1028,6 +1014,22 @@ EffectInstance::getImage(int inputNb, inputImg = convertPlanesFormatsIfNeeded(getApp(), inputImg, pixelRoI, clipPrefComps, depth, getNode()->usesAlpha0ToConvertFromRGBToRGBA(), outputPremult, channelForMask); } +#ifdef DEBUG + ///Check that the rendered image contains what we requested. + if (!mapToClipPrefs && ((!isMask && inputImg->getComponents() != components) || (isMask && inputImg->getComponents() != maskComps))) { + ImageComponents cc; + if (isMask) { + cc = maskComps; + } else { + cc = components; + } + qDebug() << "WARNING:"<< getNode()->getScriptName_mt_safe().c_str() << "requested" << cc.getComponentsGlobalName().c_str() << "but" << inputEffect->getScriptName_mt_safe().c_str() << "returned an image with" + << inputImg->getComponents().getComponentsGlobalName().c_str(); + qDebug() << inputEffect->getScriptName_mt_safe().c_str() << "output clip preference is" << inputEffect->getComponents(-1).getComponentsGlobalName().c_str(); + } + +#endif + if (inputImagesThreadLocal.empty()) { ///If the effect is analysis (e.g: Tracker) there's no input images in the tread local storage, hence add it tls->currentRenderArgs.inputImages[inputNb].push_back(inputImg); @@ -3872,18 +3874,29 @@ EffectInstance::getComponentsNeededAndProduced_public(bool useLayerChoice, ok = getNode()->getSelectedLayer(-1, processChannels, processAllRequested, &layer); } + std::vector clipPrefsAllComps; ImageComponents clipPrefsComps = getComponents(-1); + { + if (clipPrefsComps.isPairedComponents()) { + ImageComponents first,second; + clipPrefsComps.getPlanesPair(&first,&second); + clipPrefsAllComps.push_back(first); + clipPrefsAllComps.push_back(second); + } else { + clipPrefsAllComps.push_back(clipPrefsComps); + } + } if (ok && layer.getNumComponents() != 0 && !layer.isColorPlane()) { compVec.push_back(layer); if (!clipPrefsComps.isColorPlane()) { - compVec.push_back(clipPrefsComps); + compVec.insert(compVec.end() ,clipPrefsAllComps.begin(), clipPrefsAllComps.end()); } } else { - compVec.push_back(clipPrefsComps); + compVec.insert(compVec.end() ,clipPrefsAllComps.begin(), clipPrefsAllComps.end()); } comps->insert( std::make_pair(-1, compVec) ); @@ -3908,12 +3921,25 @@ EffectInstance::getComponentsNeededAndProduced_public(bool useLayerChoice, NodePtr maskInput; int channelMask = getNode()->getMaskChannel(i, &maskComp, &maskInput); + std::vector clipPrefsAllComps; + { + ImageComponents clipPrefsComps = getComponents(i); + if (clipPrefsComps.isPairedComponents()) { + ImageComponents first,second; + clipPrefsComps.getPlanesPair(&first,&second); + clipPrefsAllComps.push_back(first); + clipPrefsAllComps.push_back(second); + } else { + clipPrefsAllComps.push_back(clipPrefsComps); + } + } + if (ok && !isAll) { if ( !layer.isColorPlane() ) { compVec.push_back(layer); } else { //Use regular clip preferences - compVec.push_back(getComponents(i)); + compVec.insert(compVec.end() ,clipPrefsAllComps.begin(), clipPrefsAllComps.end()); } } else if ( (channelMask != -1) && (maskComp.getNumComponents() > 0) ) { std::vector compVec; @@ -3921,7 +3947,7 @@ EffectInstance::getComponentsNeededAndProduced_public(bool useLayerChoice, comps->insert( std::make_pair(i, compVec) ); } else { //Use regular clip preferences - compVec.push_back(getComponents(i)); + compVec.insert(compVec.end() ,clipPrefsAllComps.begin(), clipPrefsAllComps.end()); } comps->insert( std::make_pair(i, compVec) ); } @@ -3932,7 +3958,7 @@ EffectInstance::getComponentsNeededAndProduced_public(bool useLayerChoice, bool EffectInstance::getCreateChannelSelectorKnob() const { - return !isMultiPlanar() && !isReader() && !isWriter() && !isTrackerNode(); + return !isMultiPlanar() && !isReader() && !isWriter() && !isTrackerNode() && getPluginID().find("uk.co.thefoundry.furnace") == std::string::npos; } int @@ -4557,8 +4583,8 @@ static ImageComponents getUnmappedComponentsForInput(EffectInstance* self, rawComps = firstNonOptionalConnectedInputComps; } if (rawComps) { - if (!rawComps.isColorPlane()) { - //this is not the color plane, don't remap + if (!rawComps) { + //None comps return rawComps; } else { rawComps = self->findClosestSupportedComponents(inputNb, rawComps); //turn that into a comp the plugin expects on that clip diff --git a/Engine/EffectInstanceRenderRoI.cpp b/Engine/EffectInstanceRenderRoI.cpp index 62e4d850c6..fe8a7bcfaa 100644 --- a/Engine/EffectInstanceRenderRoI.cpp +++ b/Engine/EffectInstanceRenderRoI.cpp @@ -393,30 +393,43 @@ EffectInstance::renderRoI(const RenderRoIArgs & args, * we try to render with those instead. */ for (std::list::const_iterator it = args.components.begin(); it != args.components.end(); ++it) { + + // We may not request paired layers + assert(*it && !it->isPairedComponents()); assert(it->getNumComponents() > 0); bool isColorComponents = it->isColorPlane(); - ComponentsAvailableMap::iterator found = componentsAvailables.end(); + + bool found = false; + ImageComponents foundComponent; + NodePtr foundNode; + for (ComponentsAvailableMap::iterator it2 = componentsAvailables.begin(); it2 != componentsAvailables.end(); ++it2) { + if (it2->first == *it) { - found = it2; + found = true; + foundComponent = *it; + foundNode = it2->second.lock(); break; } else { if ( isColorComponents && it2->first.isColorPlane() && isSupportedComponent(-1, it2->first) ) { //We found another set of components in the color plane, take it - found = it2; + found = true; + foundComponent = it2->first; + foundNode = it2->second.lock(); break; } + } } // If the requested component is not present, then it will just return black and transparant to the plug-in. - if ( found != componentsAvailables.end() ) { - if ( found->second.lock() == getNode() ) { - requestedComponents.push_back(*it); + if (found) { + if (foundNode == getNode()) { + requestedComponents.push_back(foundComponent); } else { //The component is not available directly from this node, fetch it upstream - componentsToFetchUpstream.push_back( std::make_pair( *it, found->second.lock() ) ); + componentsToFetchUpstream.push_back(std::make_pair(foundComponent, foundNode)); } } } diff --git a/Engine/ImageComponents.cpp b/Engine/ImageComponents.cpp index 78698ee5c2..ebb85a1cab 100644 --- a/Engine/ImageComponents.cpp +++ b/Engine/ImageComponents.cpp @@ -166,6 +166,44 @@ ImageComponents::isColorPlane() const return _layerName == kNatronColorPlaneName; } + +bool +ImageComponents::isEqualToPairedPlane(const ImageComponents& other, ImageComponents* pairedLayer) const +{ + assert(!other.isPairedComponents()); + if (!isPairedComponents()) { + return false; + } + if (_componentNames.size() != other._componentNames.size()) { + return false; + } + + for (std::size_t i = 0; i < _componentNames.size(); ++i) { + if (_componentNames[i] != other._componentNames[i]) { + return false; + } + } + if (_layerName == other._layerName) { + *pairedLayer = ImageComponents(_layerName, _globalComponentsName, _componentNames); + return true; + } else if (_pairedLayer == other._layerName) { + *pairedLayer = ImageComponents(_pairedLayer, _globalComponentsName, _componentNames); + return true; + } + return false; +} + +bool +ImageComponents::getPlanesPair(ImageComponents* first, ImageComponents* second) const +{ + if (!isPairedComponents()) { + return false; + } + *first = ImageComponents(_layerName, _globalComponentsName, _componentNames); + *second = ImageComponents(_pairedLayer, _globalComponentsName, _componentNames); + return true; +} + bool ImageComponents::isConvertibleTo(const ImageComponents& other) const { diff --git a/Engine/ImageComponents.h b/Engine/ImageComponents.h index 78189edc57..5620bba95d 100644 --- a/Engine/ImageComponents.h +++ b/Engine/ImageComponents.h @@ -113,6 +113,14 @@ class ImageComponents ///E.g "rgba" const std::string& getComponentsGlobalName() const; + /** + * @brief If this layer is paired (i.e: isPairedComponents()) then returns true + * and set the pairedLayer + **/ + bool isEqualToPairedPlane(const ImageComponents& other, ImageComponents* pairedLayer) const; + + bool getPlanesPair(ImageComponents* first, ImageComponents* second) const; + bool operator==(const ImageComponents& other) const; bool operator!=(const ImageComponents& other) const { diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 2c72d5afed..c79261ced3 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -798,6 +798,15 @@ Node::load(const CreateNodeArgs& args) #endif assert(_imp->effect); } + + // For readers, set their original frame range when creating them + if (!args.serialization && _imp->effect->isReader()) { + KnobPtr filenameKnob = getKnobByName(kOfxImageEffectFileParamName); + if (filenameKnob) { + computeFrameRangeForReader(filenameKnob.get()); + } + } + _imp->effect->initializeOverlayInteract(); diff --git a/Engine/OfxClipInstance.cpp b/Engine/OfxClipInstance.cpp index 79bc833298..9ddb7ced2a 100644 --- a/Engine/OfxClipInstance.cpp +++ b/Engine/OfxClipInstance.cpp @@ -646,7 +646,15 @@ OfxClipInstance::getImagePlane(OfxTime time, return NULL; } - return getImagePlaneInternal(time, ViewIdx(view), optionalBounds, &plane); + + ViewSpec spec; + // The Foundry Furnace plug-ins pass -1 to the view parameter, we need to deal with it. + if (view == -1) { + spec = ViewSpec::current(); + } else { + spec = ViewIdx(view); + } + return getImagePlaneInternal(time, spec, optionalBounds, &plane); } OFX::Host::ImageEffect::Image* @@ -683,8 +691,11 @@ OfxClipInstance::getInputImageInternal(const OfxTime time, int inputnb = getInputNb(); //If components param is not set (i.e: the plug-in uses regular clipGetImage call) then figure out the plane from the TLS set in OfxEffectInstance::render //otherwise use the param sent by the plug-in call of clipGetImagePlane + + bool isMultiplanar = effect->isMultiPlanar(); + ImageComponents comp; - if (!ofxPlane) { + if (!isMultiplanar) { boost::shared_ptr neededComps; effect->getThreadLocalNeededComponents(&neededComps); @@ -786,7 +797,7 @@ OfxClipInstance::getInputImageInternal(const OfxTime time, //If the plug-in used fetchImage and not fetchImagePlane it is expected that we return //an image mapped to the clip components - const bool mapImageToClipPref = ofxPlane == 0; + const bool mapImageToClipPref = !isMultiplanar; ImagePtr image = effect->getImage(inputnb, time, renderScale, view, optionalBounds ? &bounds : NULL, &comp, @@ -844,6 +855,8 @@ OfxClipInstance::getOutputImageInternal(const std::string* ofxPlane) EffectInstPtr effect = getEffectHolder(); + bool isMultiplanar = effect->isMultiPlanar(); + ImageComponents natronPlane; if (!ofxPlane) { @@ -885,7 +898,6 @@ OfxClipInstance::getOutputImageInternal(const std::string* ofxPlane) If the plugin is multiplanar return exactly what it requested. Otherwise, hack the clipGetImage and return the plane requested by the user via the interface instead of the colour plane. */ - bool multiPlanar = effect->isMultiPlanar(); const std::string& layerName = /*multiPlanar ?*/ natronPlane.getLayerName();// : planeBeingRendered.getLayerName(); for (std::map::iterator it = outputPlanes.begin(); it != outputPlanes.end(); ++it) { @@ -923,7 +935,7 @@ OfxClipInstance::getOutputImageInternal(const std::string* ofxPlane) //This is the firs time the plug-ins asks for this OfxImage, just allocate it and register it in the TLS std::string ofxComponents; int nComps; - if (multiPlanar) { + if (isMultiplanar) { ofxComponents = OfxClipInstance::natronsComponentsToOfxComponents(outputImage->getComponents()); nComps = outputImage->getComponents().getNumComponents(); } else { diff --git a/Engine/OfxEffectInstance.cpp b/Engine/OfxEffectInstance.cpp index 8d17b25511..bf5706f904 100644 --- a/Engine/OfxEffectInstance.cpp +++ b/Engine/OfxEffectInstance.cpp @@ -231,6 +231,7 @@ struct OfxEffectInstancePrivate bool supportsMultipleClipsPar; bool supportsMultipleClipsBitdepth; bool doesTemporalAccess; + bool multiplanar; OfxEffectInstancePrivate() : effect() @@ -254,6 +255,7 @@ struct OfxEffectInstancePrivate , supportsMultipleClipsPar(false) , supportsMultipleClipsBitdepth(false) , doesTemporalAccess(false) + , multiplanar(false) { } @@ -366,6 +368,7 @@ OfxEffectInstance::createOfxImageEffectInstance(OFX::Host::ImageEffect::ImageEff _imp->supportsMultipleClipsPar = _imp->effect->supportsMultipleClipPARs(); _imp->supportsMultipleClipsBitdepth = _imp->effect->supportsMultipleClipDepths(); _imp->doesTemporalAccess = _imp->effect->temporalAccess(); + _imp->multiplanar = _imp->effect->isMultiPlanar(); int sequential = _imp->effect->getPlugin()->getDescriptor().getProps().getIntProperty(kOfxImageEffectInstancePropSequentialRender); switch (sequential) { case 0: @@ -2582,7 +2585,7 @@ OfxEffectInstance::getComponentsNeededAndProduced(double time, bool OfxEffectInstance::isMultiPlanar() const { - return effectInstance()->isMultiPlanar(); + return _imp->multiplanar; } EffectInstance::PassThroughEnum From df98dd266cf5e8d19377c6ebfcedc0ad62e69e9e Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 18:08:06 +0200 Subject: [PATCH 17/30] Bug fixes --- Engine/Node.cpp | 3 +++ Engine/OfxClipInstance.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Engine/Node.cpp b/Engine/Node.cpp index c79261ced3..3ee3028626 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -9730,6 +9730,9 @@ class MergeMaskChannelData : public KnobChoiceMergeEntriesData virtual void clear() { dataSet = false; + bNode.clear(); + bLayer.clear(); + bChannel.clear(); } virtual ~MergeMaskChannelData() diff --git a/Engine/OfxClipInstance.cpp b/Engine/OfxClipInstance.cpp index 9ddb7ced2a..0083c3c054 100644 --- a/Engine/OfxClipInstance.cpp +++ b/Engine/OfxClipInstance.cpp @@ -695,7 +695,7 @@ OfxClipInstance::getInputImageInternal(const OfxTime time, bool isMultiplanar = effect->isMultiPlanar(); ImageComponents comp; - if (!isMultiplanar) { + if (!ofxPlane) { boost::shared_ptr neededComps; effect->getThreadLocalNeededComponents(&neededComps); From cfc60fd244d3abf7c52dac954f633635b2fc3709 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 18:19:09 +0200 Subject: [PATCH 18/30] Paste: do not open settings panel --- Gui/NodeGraph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gui/NodeGraph.cpp b/Gui/NodeGraph.cpp index e26e9a8d18..080f63c53d 100644 --- a/Gui/NodeGraph.cpp +++ b/Gui/NodeGraph.cpp @@ -417,7 +417,7 @@ NodeGraph::createNodeGUI(const NodePtr & node, //NodeGroup* parentIsGroup = dynamic_cast(node->getGroup().get());; - if (args.reason != eCreateNodeReasonProjectLoad && (!getGui()->getApp()->isCreatingPythonGroup() || node->isEffectGroup()) ) { + if (args.reason != eCreateNodeReasonProjectLoad && args.reason != eCreateNodeReasonCopyPaste && ((!getGui()->getApp()->isCreatingPythonGroup()) || isGrp) ) { node_ui->ensurePanelCreated(); } From c42fe36298d214f6f33014afd8a788bbb1d0f6a5 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 18:42:52 +0200 Subject: [PATCH 19/30] Add Script Editor customisable font https://github.com/MrKepzie/Natron/issues/1264 --- Engine/AppInstance.h | 2 ++ Engine/AppManager.h | 1 + Engine/Settings.cpp | 64 ++++++++++++++++++++++++++++----- Engine/Settings.h | 5 +++ Gui/EditScriptDialog.cpp | 15 +++++--- Gui/GuiAppInstance.cpp | 7 ++++ Gui/GuiAppInstance.h | 2 +- Gui/GuiApplicationManager.h | 2 ++ Gui/GuiApplicationManager10.cpp | 12 +++++++ Gui/GuiDefines.h | 1 + Gui/ScriptEditor.cpp | 24 +++++++++---- Gui/ScriptEditor.h | 2 ++ 12 files changed, 115 insertions(+), 22 deletions(-) diff --git a/Engine/AppInstance.h b/Engine/AppInstance.h index ad270f5ed9..7b5e58f493 100644 --- a/Engine/AppInstance.h +++ b/Engine/AppInstance.h @@ -443,6 +443,8 @@ class AppInstance void removeRenderFromQueue(OutputEffectInstance* writer); + virtual void reloadScriptEditorFonts() {} + public Q_SLOTS: void quit(); diff --git a/Engine/AppManager.h b/Engine/AppManager.h index dc9c96a343..6137cb0bb4 100644 --- a/Engine/AppManager.h +++ b/Engine/AppManager.h @@ -520,6 +520,7 @@ class AppManager bool isSpawnedFromCrashReporter() const; + virtual void reloadScriptEditorFonts() {} public Q_SLOTS: diff --git a/Engine/Settings.cpp b/Engine/Settings.cpp index 2bba852edc..2d8e1f9ccb 100644 --- a/Engine/Settings.cpp +++ b/Engine/Settings.cpp @@ -693,6 +693,19 @@ Settings::initializeKnobsAppearance() _dopeSheetEditorColors->addKnob(_dopeSheetEditorGridColor); + _scriptEditorFontChoice = AppManager::createKnob(this, "Font"); + _scriptEditorFontChoice->setHintToolTip("List of all fonts available on your system"); + _scriptEditorFontChoice->setName("scriptEditorFont"); + _scriptEditorFontChoice->setAddNewLine(false); + _scriptEditorFontChoice->setAnimationEnabled(false); + _scriptEditorColors->addKnob(_scriptEditorFontChoice); + + _scriptEditorFontSize = AppManager::createKnob(this, "Font Size"); + _scriptEditorFontSize->setHintToolTip("The font size"); + _scriptEditorFontSize->setName("scriptEditorFontSize"); + _scriptEditorFontSize->setAnimationEnabled(false); + _scriptEditorColors->addKnob(_scriptEditorFontSize); + _curLineColor = AppManager::createKnob(this, "Current Line Color", 3); _curLineColor->setName("currentLineColor"); _curLineColor->setAnimationEnabled(false); @@ -1661,6 +1674,9 @@ Settings::setDefaultValues() _curLineColor->setDefaultValue(0.35,0); _curLineColor->setDefaultValue(0.35,1); _curLineColor->setDefaultValue(0.35,2); + + _scriptEditorFontChoice->setDefaultValue(0); + _scriptEditorFontSize->setDefaultValue(NATRON_FONT_SIZE_DEFAULT); endChanges(); } // setDefaultValues @@ -2162,6 +2178,8 @@ Settings::onKnobValueChanged(KnobI* k, if (reply == eStandardButtonYes) { crash_application(); } + } else if (k == _scriptEditorFontChoice.get() || k == _scriptEditorFontSize.get()) { + appPTR->reloadScriptEditorFonts(); } if ((k == _hostName.get() || k == _customHostName.get()) && !_restoringSettings) { Dialogs::warningDialog(tr("Host-name change").toStdString(), tr("Changing this requires a restart of " NATRON_APPLICATION_NAME @@ -2589,21 +2607,37 @@ void Settings::populateSystemFonts(const QSettings& settings,const std::vector& fonts) { _systemFontChoice->populateChoices(fonts); - + _scriptEditorFontChoice->populateChoices(fonts); for (U32 i = 0; i < fonts.size(); ++i) { if (fonts[i] == NATRON_FONT) { _systemFontChoice->setDefaultValue(i); - break; + } + if (fonts[i] == NATRON_SCRIPT_FONT) { + _scriptEditorFontChoice->setDefaultValue(i); } } ///Now restore properly the system font choice - QString name = QString::fromUtf8(_systemFontChoice->getName().c_str()); - if (settings.contains(name)) { - std::string value = settings.value(name).toString().toStdString(); - for (U32 i = 0; i < fonts.size(); ++i) { - if (fonts[i] == value) { - _systemFontChoice->setValue(i); - break; + { + QString name = QString::fromUtf8(_systemFontChoice->getName().c_str()); + if (settings.contains(name)) { + std::string value = settings.value(name).toString().toStdString(); + for (U32 i = 0; i < fonts.size(); ++i) { + if (fonts[i] == value) { + _systemFontChoice->setValue(i); + break; + } + } + } + } + { + QString name = QString::fromUtf8(_scriptEditorFontChoice->getName().c_str()); + if (settings.contains(name)) { + std::string value = settings.value(name).toString().toStdString(); + for (U32 i = 0; i < fonts.size(); ++i) { + if (fonts[i] == value) { + _scriptEditorFontChoice->setValue(i); + break; + } } } } @@ -3519,6 +3553,18 @@ Settings::getSECurLineColor(double* r,double* g, double* b) const *b = _curLineColor->getValue(2); } +int +Settings::getSEFontSize() const +{ + return _scriptEditorFontSize->getValue(); +} + +std::string +Settings::getSEFontFamily() const +{ + return _scriptEditorFontChoice->getActiveEntryText_mt_safe(); +} + void Settings::getPluginIconFrameColor(int *r, int *g, int *b) const { diff --git a/Engine/Settings.h b/Engine/Settings.h index 9bc3a1b7b9..1964f4448d 100644 --- a/Engine/Settings.h +++ b/Engine/Settings.h @@ -337,6 +337,9 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void getSENumbersColor(double* r,double* g, double* b) const; void getSECurLineColor(double* r,double* g, double* b) const; + int getSEFontSize() const; + std::string getSEFontFamily() const; + void getPluginIconFrameColor(int *r, int *g, int *b) const; int getDopeSheetEditorNodeSeparationWith() const; @@ -556,6 +559,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON boost::shared_ptr _commentsColor; boost::shared_ptr _selfColor; boost::shared_ptr _numbersColor; + boost::shared_ptr _scriptEditorFontChoice; + boost::shared_ptr _scriptEditorFontSize; struct PerPluginKnobs diff --git a/Gui/EditScriptDialog.cpp b/Gui/EditScriptDialog.cpp index 28a2cfd397..ba43928c18 100644 --- a/Gui/EditScriptDialog.cpp +++ b/Gui/EditScriptDialog.cpp @@ -146,7 +146,6 @@ EditScriptDialog::create(const QString& initialScript,bool makeUseRetButton) { setTitle(); - QFont font(appFont,appFontSize); _imp->mainLayout = new QVBoxLayout(this); QStringList modules; @@ -172,14 +171,11 @@ EditScriptDialog::create(const QString& initialScript,bool makeUseRetButton) } _imp->expressionLabel = new Label(labelHtml,this); - //_imp->expressionLabel->setFont(font); _imp->mainLayout->addWidget(_imp->expressionLabel); _imp->expressionEdit = new InputScriptTextEdit(_imp->gui,this); _imp->expressionEdit->setAcceptDrops(true); _imp->expressionEdit->setMouseTracking(true); - QFontMetrics fm = _imp->expressionEdit->fontMetrics(); - _imp->expressionEdit->setTabStopWidth(4 * fm.width(QLatin1Char(' '))); _imp->mainLayout->addWidget(_imp->expressionEdit); _imp->expressionEdit->setPlainText(initialScript); @@ -214,7 +210,6 @@ EditScriptDialog::create(const QString& initialScript,bool makeUseRetButton) _imp->mainLayout->addWidget(_imp->midButtonsContainer); _imp->resultLabel = new Label(tr("Result:"),this); - //_imp->resultLabel->setFont(font); _imp->mainLayout->addWidget(_imp->resultLabel); _imp->resultEdit = new OutputScriptTextEdit(this); @@ -232,6 +227,16 @@ EditScriptDialog::create(const QString& initialScript,bool makeUseRetButton) } QObject::connect(_imp->expressionEdit, SIGNAL(textChanged()), this, SLOT(onTextEditChanged())); _imp->expressionEdit->setFocus(); + + QString fontFamily = QString::fromUtf8(appPTR->getCurrentSettings()->getSEFontFamily().c_str()); + int fontSize = appPTR->getCurrentSettings()->getSEFontSize(); + QFont font(fontFamily, fontSize); + if (font.exactMatch()) { + _imp->expressionEdit->setFont(font); + _imp->resultEdit->setFont(font); + } + QFontMetrics fm = _imp->expressionEdit->fontMetrics(); + _imp->expressionEdit->setTabStopWidth(4 * fm.width(QLatin1Char(' '))); } diff --git a/Gui/GuiAppInstance.cpp b/Gui/GuiAppInstance.cpp index 625cce79bd..1e0b9af1cd 100644 --- a/Gui/GuiAppInstance.cpp +++ b/Gui/GuiAppInstance.cpp @@ -58,6 +58,7 @@ #include "Gui/ProgressPanel.h" #include "Gui/ViewerTab.h" #include "Gui/SplashScreen.h" +#include "Gui/ScriptEditor.h" #include "Gui/ViewerGL.h" NATRON_NAMESPACE_ENTER; @@ -1538,6 +1539,12 @@ GuiAppInstance::checkAllReadersModificationDate(bool errorAndWarn) return changed; } +void +GuiAppInstance::reloadScriptEditorFonts() +{ + _imp->_gui->getScriptEditor()->reloadFont(); +} + NATRON_NAMESPACE_EXIT; NATRON_NAMESPACE_USING; diff --git a/Gui/GuiAppInstance.h b/Gui/GuiAppInstance.h index 47ea46c13d..3838db52c1 100644 --- a/Gui/GuiAppInstance.h +++ b/Gui/GuiAppInstance.h @@ -273,7 +273,7 @@ public Q_SLOTS: boost::shared_ptr* stroke, bool* isPainting) const OVERRIDE FINAL; - + virtual void reloadScriptEditorFonts() OVERRIDE FINAL; ///////////////// OVERRIDEN FROM TIMELINEKEYFRAMES virtual void removeAllKeyframesIndicators() OVERRIDE FINAL; diff --git a/Gui/GuiApplicationManager.h b/Gui/GuiApplicationManager.h index 3c61b9650d..9cc9d5c307 100644 --- a/Gui/GuiApplicationManager.h +++ b/Gui/GuiApplicationManager.h @@ -182,6 +182,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual void reloadStylesheets() OVERRIDE FINAL; + virtual void reloadScriptEditorFonts() OVERRIDE FINAL; + void clearNodeClipBoard(); virtual void addCommand(const QString& grouping,const std::string& pythonFunction, Qt::Key key,const Qt::KeyboardModifiers& modifiers) OVERRIDE; diff --git a/Gui/GuiApplicationManager10.cpp b/Gui/GuiApplicationManager10.cpp index c052b0d09e..8af663e38c 100644 --- a/Gui/GuiApplicationManager10.cpp +++ b/Gui/GuiApplicationManager10.cpp @@ -1227,4 +1227,16 @@ GuiApplicationManager::reloadStylesheets() } } +void +GuiApplicationManager::reloadScriptEditorFonts() +{ + const std::map& instances = getAppInstances(); + for (std::map::const_iterator it = instances.begin(); it != instances.end(); ++it) { + GuiAppInstance* guiApp = dynamic_cast(it->second.app); + if (guiApp) { + guiApp->reloadScriptEditorFonts(); + } + } +} + NATRON_NAMESPACE_EXIT; diff --git a/Gui/GuiDefines.h b/Gui/GuiDefines.h index 96efde6bff..98e98fdd10 100644 --- a/Gui/GuiDefines.h +++ b/Gui/GuiDefines.h @@ -52,6 +52,7 @@ //#define NATRON_FONT_ALT "Times" #define NATRON_FONT "Droid Sans" #define NATRON_FONT_ALT "Droid Sans" +#define NATRON_SCRIPT_FONT "Courier New" #define NATRON_FONT_SIZE_6 6 #define NATRON_FONT_SIZE_8 8 #define NATRON_FONT_SIZE_10 10 diff --git a/Gui/ScriptEditor.cpp b/Gui/ScriptEditor.cpp index 59becbce4f..ce0eea755b 100644 --- a/Gui/ScriptEditor.cpp +++ b/Gui/ScriptEditor.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -245,20 +246,14 @@ ScriptEditor::ScriptEditor(Gui* gui) QSplitter* splitter = new QSplitter(Qt::Vertical,this); - QFont scriptFont(QString::fromUtf8("Courier New"), 12); - if (!scriptFont.exactMatch()) { - scriptFont = font(); - } - + _imp->outputEdit = new OutputScriptTextEdit(this); QObject::connect(_imp->outputEdit, SIGNAL(userScrollChanged(bool)), this, SLOT(onUserScrollChanged(bool))); _imp->outputEdit->setFocusPolicy(Qt::ClickFocus); _imp->outputEdit->setReadOnly(true); - _imp->outputEdit->setFont(scriptFont); _imp->inputEdit = new InputScriptTextEdit(gui, this); QObject::connect(_imp->inputEdit, SIGNAL(textChanged()), this, SLOT(onInputScriptTextChanged())); - _imp->inputEdit->setFont(scriptFont); QFontMetrics fm = _imp->inputEdit->fontMetrics(); _imp->inputEdit->setTabStopWidth(fm.width(QLatin1Char(' ')) * 4); _imp->outputEdit->setTabStopWidth(fm.width(QLatin1Char(' ')) * 4); @@ -272,6 +267,8 @@ ScriptEditor::ScriptEditor(Gui* gui) QObject::connect(&_imp->history, SIGNAL(canRedoChanged(bool)), this, SLOT(onHistoryCanRedoChanged(bool))); _imp->autoSaveTimer.setSingleShot(true); + + reloadFont(); } ScriptEditor::~ScriptEditor() @@ -287,6 +284,19 @@ ScriptEditor::reloadHighlighter() } } +void +ScriptEditor::reloadFont() +{ + QString fontFamily = QString::fromUtf8(appPTR->getCurrentSettings()->getSEFontFamily().c_str()); + int fontSize = appPTR->getCurrentSettings()->getSEFontSize(); + QFont font(fontFamily, fontSize); + if (font.exactMatch()) { + _imp->inputEdit->setFont(font); + _imp->outputEdit->setFont(font); + } + +} + void ScriptEditor::onHistoryCanUndoChanged(bool canUndo) { diff --git a/Gui/ScriptEditor.h b/Gui/ScriptEditor.h index eeb4ae5752..e2e1845396 100644 --- a/Gui/ScriptEditor.h +++ b/Gui/ScriptEditor.h @@ -69,6 +69,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void reloadHighlighter(); + void reloadFont(); + public Q_SLOTS: void doAppendToScriptEditorOnMainThread(const QString& str); From 62d09b3fec4dfb9c03752f92f061fb66e8e7aae3 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 1 Apr 2016 18:46:26 +0200 Subject: [PATCH 20/30] Bug fixes --- Engine/EffectInstance.cpp | 2 +- Engine/Node.cpp | 1 + Gui/MultiInstancePanel.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Engine/EffectInstance.cpp b/Engine/EffectInstance.cpp index a3b0eb35ce..f62f6ff517 100644 --- a/Engine/EffectInstance.cpp +++ b/Engine/EffectInstance.cpp @@ -102,7 +102,7 @@ EffectInstance::EffectInstance(NodePtr node) EffectInstance::~EffectInstance() { - clearPluginMemoryChunks(); + } diff --git a/Engine/Node.cpp b/Engine/Node.cpp index 3ee3028626..331e72efd8 100644 --- a/Engine/Node.cpp +++ b/Engine/Node.cpp @@ -5692,6 +5692,7 @@ Node::destroyNodeInternal(bool fromDest, bool autoReconnect) }*/ ///Kill the effect + _imp->effect->clearPluginMemoryChunks(); _imp->effect.reset(); ///If inside the group, remove it from the group diff --git a/Gui/MultiInstancePanel.cpp b/Gui/MultiInstancePanel.cpp index d9bd94602d..0363fb0b4b 100644 --- a/Gui/MultiInstancePanel.cpp +++ b/Gui/MultiInstancePanel.cpp @@ -465,10 +465,11 @@ MultiInstancePanel::initializeKnobs() for (U32 j = 0; j < otherChildren.size(); ++j) { if ( !otherChildren[j]->isInstanceSpecific() ) { KnobPtr thisChild = getKnobByName( otherChildren[j]->getName() ); - assert(thisChild); - isPage->addKnob(thisChild); - if ( isNodePage && !thisChild->isDeclaredByPlugin() ) { - thisChild->setAllDimensionsEnabled(false); + if (thisChild) { + isPage->addKnob(thisChild); + if ( isNodePage && !thisChild->isDeclaredByPlugin() ) { + thisChild->setAllDimensionsEnabled(false); + } } } } From 51b5fc088ceb85aa3d11e0cd892537121eb2820a Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Sat, 2 Apr 2016 13:32:58 +0200 Subject: [PATCH 21/30] Fix #1277 --- Engine/AppInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/AppInstance.cpp b/Engine/AppInstance.cpp index ad4c719208..be51906681 100644 --- a/Engine/AppInstance.cpp +++ b/Engine/AppInstance.cpp @@ -900,7 +900,7 @@ AppInstance::createReader(const std::string& filename, CreateNodeReason reason, #else std::map 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::iterator found = readersForFormat.find(ext); From cf577f7cd25c3e0e84bc5af869619657256d5045 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Sat, 2 Apr 2016 14:23:44 +0200 Subject: [PATCH 22/30] Drag and drop of files can now take place anywhere and not just on the Nodegraph and it is also possible to d&d python files that will be sourced. --- Gui/Gui.cpp | 1 + Gui/Gui.h | 7 ++ Gui/Gui50.cpp | 204 +++++++++++++++++++++++++++++++++++++++++ Gui/GuiAppInstance.cpp | 10 +- Gui/NodeGraph.cpp | 3 +- Gui/NodeGraph.h | 4 - Gui/NodeGraph35.cpp | 103 --------------------- Gui/ScriptEditor.cpp | 31 +++++-- Gui/ScriptEditor.h | 3 + 9 files changed, 246 insertions(+), 120 deletions(-) diff --git a/Gui/Gui.cpp b/Gui/Gui.cpp index 189dc93f25..3c4961820a 100644 --- a/Gui/Gui.cpp +++ b/Gui/Gui.cpp @@ -101,6 +101,7 @@ Gui::Gui(GuiAppInstance* app, QObject::connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(onFocusChanged(QWidget*,QWidget*))); + setAcceptDrops(true); } diff --git a/Gui/Gui.h b/Gui/Gui.h index c6d549c4b9..10080ec31f 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -36,6 +36,7 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) #include +#include CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) @@ -564,6 +565,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON bool saveProjectAs(const std::string& filename); + static void fileSequencesFromUrls(const QList& urls, std::vector< boost::shared_ptr >* sequences); protected: // Reimplemented Protected Functions @@ -739,6 +741,11 @@ public Q_SLOTS: virtual void keyPressEvent(QKeyEvent* e) OVERRIDE FINAL; virtual void keyReleaseEvent(QKeyEvent* e) OVERRIDE FINAL; + virtual void dragEnterEvent(QDragEnterEvent* e) OVERRIDE FINAL; + virtual void dragMoveEvent(QDragMoveEvent* e) OVERRIDE FINAL; + virtual void dragLeaveEvent(QDragLeaveEvent* e) OVERRIDE FINAL; + virtual void dropEvent(QDropEvent* e) OVERRIDE FINAL; + boost::scoped_ptr _imp; }; diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 9271e0822f..fef661cf08 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -29,6 +29,7 @@ #include // min, max #include #include +#include #include #include @@ -55,10 +56,14 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include +#include "Global/QtCompat.h" + #include "Engine/GroupOutput.h" #include "Engine/Node.h" #include "Engine/NodeGroup.h" // NodesList, NodeCollection #include "Engine/Project.h" +#include "Engine/KnobSerialization.h" +#include "Engine/FileSystemModel.h" #include "Engine/Settings.h" #include "Engine/TimeLine.h" #include "Engine/ViewerInstance.h" @@ -87,6 +92,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/TabWidget.h" #include "Gui/ViewerGL.h" #include "Gui/ViewerTab.h" +#include "Gui/SequenceFileDialog.h" #include "Gui/PropertiesBinWrapper.h" #include "Gui/Histogram.h" @@ -964,4 +970,202 @@ Gui::onFocusChanged(QWidget* /*old*/, QWidget* newFocus) } } +void +Gui::fileSequencesFromUrls(const QList& urls, std::vector< boost::shared_ptr >* sequences) +{ + QStringList filesList; + for (int i = 0; i < urls.size(); ++i) { + const QUrl rl = QtCompat::toLocalFileUrlFixed(urls.at(i)); + QString path = rl.toLocalFile(); + +#ifdef __NATRON_WIN32__ + if ( !path.isEmpty() && ( path.at(0) == QLatin1Char('/') || path.at(0) == QLatin1Char('\\') ) ) { + path = path.remove(0,1); + } + path = FileSystemModel::mapPathWithDriveLetterToPathWithNetworkShareName(path); + +#endif + QDir dir(path); + + //if the path dropped is not a directory append it + if (!dir.exists()) { + filesList << path; + } else { + //otherwise append everything inside the dir recursively + SequenceFileDialog::appendFilesFromDirRecursively(&dir,&filesList); + } + } + + QStringList supportedExtensions; + supportedExtensions.push_back(QString::fromLatin1(NATRON_PROJECT_FILE_EXT)); + supportedExtensions.push_back(QString::fromLatin1("py")); + ///get all the decoders + std::map readersForFormat; + appPTR->getCurrentSettings()->getFileFormatsForReadingAndReader(&readersForFormat); + for (std::map::const_iterator it = readersForFormat.begin(); it != readersForFormat.end(); ++it) { + supportedExtensions.push_back( QString::fromUtf8(it->first.c_str()) ); + } + *sequences = SequenceFileDialog::fileSequencesFromFilesList(filesList,supportedExtensions); + + +} + +void +Gui::dragEnterEvent(QDragEnterEvent* e) +{ + if (!e->mimeData()->hasUrls()) { + return; + } + + QList urls = e->mimeData()->urls(); + + std::vector< boost::shared_ptr > sequences; + fileSequencesFromUrls(urls, &sequences); + + if (!sequences.empty()) { + e->accept(); + } +} + +void +Gui::dragMoveEvent(QDragMoveEvent* e) +{ + if (!e->mimeData()->hasUrls()) { + return; + } + + QList urls = e->mimeData()->urls(); + + std::vector< boost::shared_ptr > sequences; + fileSequencesFromUrls(urls, &sequences); + + if (!sequences.empty()) { + e->accept(); + } +} + +void +Gui::dragLeaveEvent(QDragLeaveEvent* e) +{ + e->accept(); +} + +static NodeGraph* isNodeGraphChild(QWidget* w) { + NodeGraph* n = dynamic_cast(w); + if (n) { + return n; + } else { + QWidget* parent = w->parentWidget(); + if (parent) { + return isNodeGraphChild(parent); + } else { + return 0; + } + } +} + +void +Gui::dropEvent(QDropEvent* e) +{ + if ( !e->mimeData()->hasUrls() ) { + return; + } + + e->accept(); + + QList urls = e->mimeData()->urls(); + + std::vector< boost::shared_ptr > sequences; + fileSequencesFromUrls(urls, &sequences); + + QPoint globalPos = mapToGlobal(e->pos()); + QWidget* widgetUnderMouse = QApplication::widgetAt(globalPos); + NodeGraph* graph = isNodeGraphChild(widgetUnderMouse); + + if (!graph) { + // No grpah under mouse, use top level one + graph = _imp->_nodeGraphArea; + } + assert(graph); + if (!graph) { + return; + } + + QPointF graphScenePos = graph->mapToScene(graph->mapFromGlobal(globalPos)); + + std::locale local; + for (U32 i = 0; i < sequences.size(); ++i) { + + + boost::shared_ptr & sequence = sequences[i]; + if (sequence->count() < 1) { + continue; + } + + ///find a decoder for this file type + std::string ext = sequence->fileExtension(); + std::string extLower; + for (size_t j = 0; j < ext.size(); ++j) { + extLower.append( 1,std::tolower( ext.at(j),local ) ); + } + if (extLower == NATRON_PROJECT_FILE_EXT) { + const std::map& content = sequence->getFrameIndexes(); + assert(!content.empty()); + (void)openProject(content.begin()->second.absoluteFileName()); + } else if (extLower == "py") { + const std::map& content = sequence->getFrameIndexes(); + assert(!content.empty()); + _imp->_scriptEditor->sourceScript(QString::fromUtf8(content.begin()->second.absoluteFileName().c_str())); + + // Ensure that the script editor is visible + TabWidget* pane = _imp->_scriptEditor->getParentPane(); + if (pane != 0) { + pane->setCurrentWidget(_imp->_scriptEditor); + } else { + pane = graph->getParentPane(); + if (!pane) { + std::list tabs; + { + QMutexLocker k(&_imp->_panesMutex); + tabs = _imp->_panes; + } + if (tabs.empty()) { + return; + } + pane = tabs.front(); + } + assert(pane); + pane->moveScriptEditorHere(); + } + + } else { + + std::map readersForFormat; + appPTR->getCurrentSettings()->getFileFormatsForReadingAndReader(&readersForFormat); + std::map::iterator found = readersForFormat.find(extLower); + if ( found == readersForFormat.end() ) { + Dialogs::errorDialog("Reader", "No plugin capable of decoding " + extLower + " was found."); + } else { + + std::string pattern = sequence->generateValidSequencePattern(); + + CreateNodeArgs args(QString::fromUtf8(found->second.c_str()), eCreateNodeReasonUserCreate, graph->getGroup()); + args.xPosHint = graphScenePos.x(); + args.yPosHint = graphScenePos.y(); + args.paramValues.push_back(createDefaultValueForParam(kOfxImageEffectFileParamName, pattern)); + + NodePtr n = getApp()->createNode(args); + + //And offset scenePos by the Width of the previous node created if several nodes are created + double w,h; + n->getSize(&w, &h); + graphScenePos.rx() += (w + 10); + } + } + } +} // dropEvent + + + + NATRON_NAMESPACE_EXIT; diff --git a/Gui/GuiAppInstance.cpp b/Gui/GuiAppInstance.cpp index 1e0b9af1cd..1f599fbc48 100644 --- a/Gui/GuiAppInstance.cpp +++ b/Gui/GuiAppInstance.cpp @@ -1182,9 +1182,13 @@ GuiAppInstance::isRenderStatsActionChecked() const bool GuiAppInstance::save(const std::string& filename) { - boost::shared_ptr project = getProject(); - if (project->hasProjectBeenSavedByUser()) { - return _imp->_gui->saveProject(); + if (filename.empty()) { + boost::shared_ptr project= getProject(); + if (project->hasProjectBeenSavedByUser()) { + return _imp->_gui->saveProject(); + } else { + return _imp->_gui->saveProjectAs(); + } } else { return _imp->_gui->saveProjectAs(filename); } diff --git a/Gui/NodeGraph.cpp b/Gui/NodeGraph.cpp index 080f63c53d..fbcce08edc 100644 --- a/Gui/NodeGraph.cpp +++ b/Gui/NodeGraph.cpp @@ -84,7 +84,6 @@ NodeGraph::NodeGraph(Gui* gui, group->setNodeGraphPointer(this); - setAcceptDrops(true); setAttribute(Qt::WA_MacShowFocusRect,0); NodeGroup* isGrp = dynamic_cast(group.get()); @@ -175,6 +174,8 @@ NodeGraph::NodeGraph(Gui* gui, setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + setAcceptDrops(false); _imp->_menu = new Menu(this); diff --git a/Gui/NodeGraph.h b/Gui/NodeGraph.h index 876517ef20..f00f78b494 100644 --- a/Gui/NodeGraph.h +++ b/Gui/NodeGraph.h @@ -264,10 +264,6 @@ public Q_SLOTS: virtual void resizeEvent(QResizeEvent* e) OVERRIDE FINAL; virtual void paintEvent(QPaintEvent* e) OVERRIDE FINAL; virtual void wheelEvent(QWheelEvent* e) OVERRIDE FINAL; - virtual void dropEvent(QDropEvent* e) OVERRIDE FINAL; - virtual void dragEnterEvent(QDragEnterEvent* e) OVERRIDE FINAL; - virtual void dragMoveEvent(QDragMoveEvent* e) OVERRIDE FINAL; - virtual void dragLeaveEvent(QDragLeaveEvent* e) OVERRIDE FINAL; virtual void focusInEvent(QFocusEvent* e) OVERRIDE FINAL; virtual void focusOutEvent(QFocusEvent* e) OVERRIDE FINAL; virtual QUndoStack* getUndoStack() const OVERRIDE FINAL WARN_UNUSED_RETURN; diff --git a/Gui/NodeGraph35.cpp b/Gui/NodeGraph35.cpp index 36c989c66d..ba0a77b1e5 100644 --- a/Gui/NodeGraph35.cpp +++ b/Gui/NodeGraph35.cpp @@ -481,108 +481,5 @@ NodeGraph::showMenu(const QPoint & pos) } } -void -NodeGraph::dropEvent(QDropEvent* e) -{ - if ( !e->mimeData()->hasUrls() ) { - return; - } - - QStringList filesList; - QList urls = e->mimeData()->urls(); - for (int i = 0; i < urls.size(); ++i) { - const QUrl rl = QtCompat::toLocalFileUrlFixed(urls.at(i)); - QString path = rl.toLocalFile(); - -#ifdef __NATRON_WIN32__ - if ( !path.isEmpty() && ( path.at(0) == QLatin1Char('/') || path.at(0) == QLatin1Char('\\') ) ) { - path = path.remove(0,1); - } - path = FileSystemModel::mapPathWithDriveLetterToPathWithNetworkShareName(path); - -#endif - - - QDir dir(path); - - //if the path dropped is not a directory append it - if ( !dir.exists() ) { - filesList << path; - } else { - //otherwise append everything inside the dir recursively - SequenceFileDialog::appendFilesFromDirRecursively(&dir,&filesList); - } - } - - QStringList supportedExtensions; - supportedExtensions.push_back(QString::fromLatin1(NATRON_PROJECT_FILE_EXT)); - ///get all the decoders - std::map readersForFormat; - appPTR->getCurrentSettings()->getFileFormatsForReadingAndReader(&readersForFormat); - for (std::map::const_iterator it = readersForFormat.begin(); it != readersForFormat.end(); ++it) { - supportedExtensions.push_back( QString::fromUtf8(it->first.c_str()) ); - } - QPointF scenePos = mapToScene(e->pos()); - std::vector< boost::shared_ptr > files = SequenceFileDialog::fileSequencesFromFilesList(filesList,supportedExtensions); - std::locale local; - for (U32 i = 0; i < files.size(); ++i) { - - - boost::shared_ptr & sequence = files[i]; - if (sequence->count() < 1) { - continue; - } - - ///find a decoder for this file type - std::string ext = sequence->fileExtension(); - std::string extLower; - for (size_t j = 0; j < ext.size(); ++j) { - extLower.append( 1,std::tolower( ext.at(j),local ) ); - } - if (extLower == NATRON_PROJECT_FILE_EXT) { - const std::map& content = sequence->getFrameIndexes(); - assert(!content.empty()); - (void)getGui()->openProject(content.begin()->second.absoluteFileName()); - } else { - std::map::iterator found = readersForFormat.find(extLower); - if ( found == readersForFormat.end() ) { - Dialogs::errorDialog("Reader", "No plugin capable of decoding " + extLower + " was found."); - } else { - - std::string pattern = sequence->generateValidSequencePattern(); - - CreateNodeArgs args(QString::fromUtf8(found->second.c_str()), eCreateNodeReasonUserCreate, getGroup()); - args.xPosHint = scenePos.x(); - args.yPosHint = scenePos.y(); - args.paramValues.push_back(createDefaultValueForParam(kOfxImageEffectFileParamName, pattern)); - - NodePtr n = getGui()->getApp()->createNode(args); - - //And offset scenePos by the Width of the previous node created if several nodes are created - double w,h; - n->getSize(&w, &h); - scenePos.rx() += (w + 10); - } - } - } -} // dropEvent - -void -NodeGraph::dragEnterEvent(QDragEnterEvent* e) -{ - e->accept(); -} - -void -NodeGraph::dragLeaveEvent(QDragLeaveEvent* e) -{ - e->accept(); -} - -void -NodeGraph::dragMoveEvent(QDragMoveEvent* e) -{ - e->accept(); -} NATRON_NAMESPACE_EXIT; diff --git a/Gui/ScriptEditor.cpp b/Gui/ScriptEditor.cpp index ce0eea755b..c01f46f59f 100644 --- a/Gui/ScriptEditor.cpp +++ b/Gui/ScriptEditor.cpp @@ -342,6 +342,20 @@ ScriptEditor::onRedoClicked() _imp->history.redo(); } +void +ScriptEditor::sourceScript(const QString& filename) +{ + QFile file(filename); + if (file.open(QIODevice::ReadOnly)) { + QTextStream ts(&file); + QString content = ts.readAll(); + _imp->inputEdit->setPlainText(content); + onExecScriptClicked(); + } else { + Dialogs::errorDialog(tr("Operation failed").toStdString(), tr("Failed to open ").toStdString() + filename.toStdString()); + } +} + void ScriptEditor::onSourceScriptClicked() { @@ -356,15 +370,7 @@ ScriptEditor::onSourceScriptClicked() getGui()->updateLastOpenedProjectPath(currentDir.absolutePath()); QString fileName(QString::fromUtf8(dialog.selectedFiles().c_str())); - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - QTextStream ts(&file); - QString content = ts.readAll(); - _imp->inputEdit->setPlainText(content); - onExecScriptClicked(); - } else { - Dialogs::errorDialog(tr("Operation failed").toStdString(), tr("Failure to open the file").toStdString()); - } + sourceScript(fileName); } } @@ -650,6 +656,13 @@ ScriptEditor::onShowAutoDeclVarsClicked(bool clicked) appPTR->getCurrentSettings()->setAutoDeclaredVariablePrintEnabled(clicked); } +void +ScriptEditor::focusInEvent(QFocusEvent* e) +{ + _imp->inputEdit->setFocus(); + QWidget::focusInEvent(e); +} + NATRON_NAMESPACE_EXIT; NATRON_NAMESPACE_USING; diff --git a/Gui/ScriptEditor.h b/Gui/ScriptEditor.h index e2e1845396..b995692517 100644 --- a/Gui/ScriptEditor.h +++ b/Gui/ScriptEditor.h @@ -71,6 +71,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void reloadFont(); + void sourceScript(const QString& filename); + public Q_SLOTS: void doAppendToScriptEditorOnMainThread(const QString& str); @@ -110,6 +112,7 @@ public Q_SLOTS: private: + virtual void focusInEvent(QFocusEvent* e) OVERRIDE FINAL; virtual void mousePressEvent(QMouseEvent* e) OVERRIDE FINAL; virtual void enterEvent(QEvent *e) OVERRIDE FINAL; virtual void leaveEvent(QEvent *e) OVERRIDE FINAL; From c3fffaa402ff8274bc421bda52c0683ddb1d1ff5 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Sat, 2 Apr 2016 15:37:38 +0200 Subject: [PATCH 23/30] Add possibility to copy/paste python scripts too --- Gui/Gui.h | 3 ++ Gui/Gui40.cpp | 27 +++++++++++++++ Gui/Gui50.cpp | 82 +++++++++++++++++++++++++++------------------ Gui/NodeGraph.h | 4 +-- Gui/NodeGraph25.cpp | 4 ++- Gui/NodeGraph40.cpp | 12 +++---- 6 files changed, 90 insertions(+), 42 deletions(-) diff --git a/Gui/Gui.h b/Gui/Gui.h index 10080ec31f..3c268bc247 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -425,6 +425,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON bool progressUpdate(const NodePtr& node,double t); void ensureProgressPanelVisible(); + void ensureScriptEditorVisible(); /*Useful function that saves on disk the image in png format. The name of the image will be the hash key of the image.*/ @@ -567,6 +568,8 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON static void fileSequencesFromUrls(const QList& urls, std::vector< boost::shared_ptr >* sequences); + void handleOpenFilesFromUrls(const QList& urls, const QPoint& globalPos); + protected: // Reimplemented Protected Functions diff --git a/Gui/Gui40.cpp b/Gui/Gui40.cpp index b7bb1037c8..b61a9a7e66 100644 --- a/Gui/Gui40.cpp +++ b/Gui/Gui40.cpp @@ -67,6 +67,7 @@ #include "Gui/ProgressPanel.h" #include "Gui/Splitter.h" #include "Gui/TabWidget.h" +#include "Gui/ScriptEditor.h" #include "Gui/ViewerGL.h" #include "Gui/ViewerTab.h" #include "Gui/NodeSettingsPanel.h" @@ -668,6 +669,32 @@ Gui::onRenderRestarted(OutputEffectInstance* writer, _imp->_progressPanel->onTaskRestarted(writer->getNode(), process); } +void +Gui::ensureScriptEditorVisible() +{ + // Ensure that the script editor is visible + TabWidget* pane = _imp->_scriptEditor->getParentPane(); + if (pane != 0) { + pane->setCurrentWidget(_imp->_scriptEditor); + } else { + pane = _imp->_nodeGraphArea->getParentPane(); + if (!pane) { + std::list tabs; + { + QMutexLocker k(&_imp->_panesMutex); + tabs = _imp->_panes; + } + if (tabs.empty()) { + return; + } + pane = tabs.front(); + } + assert(pane); + pane->moveScriptEditorHere(); + } + +} + void Gui::ensureProgressPanelVisible() { diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index fef661cf08..927678e554 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -47,11 +47,13 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -78,6 +80,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/GuiAppInstance.h" #include "Gui/GuiApplicationManager.h" // appPTR #include "Gui/GuiPrivate.h" +#include "Gui/GuiMacros.h" #include "Gui/LogWindow.h" #include "Gui/NodeGraph.h" #include "Gui/NodeGui.h" @@ -396,6 +399,34 @@ Gui::keyPressEvent(QKeyEvent* e) if (panel) { panel->getPanel()->closePanel(); } + } else if (key == Qt::Key_V && modCASIsControl(e)) { + // CTRL +V should have been caught by the Nodegraph if it contained a valid Natron graph. + // We still try to check if it is a readable Python script + QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* mimedata = clipboard->mimeData(); + if (mimedata->hasFormat(QLatin1String("text/plain"))) { + + QByteArray data = mimedata->data(QLatin1String("text/plain")); + QString str = QString::fromUtf8(data); + if (QFile::exists(str)) { + QList urls; + urls.push_back(QUrl::fromLocalFile(str)); + handleOpenFilesFromUrls(urls, QCursor::pos()); + } else { + std::string error, output; + if (!Python::interpretPythonScript(str.toStdString(), &error, &output)) { + _imp->_scriptEditor->appendToScriptEditor(QString::fromUtf8(error.c_str())); + ensureScriptEditorVisible(); + } else if (!output.empty()) { + _imp->_scriptEditor->appendToScriptEditor(QString::fromUtf8(output.c_str())); + } + } + + } else if (mimedata->hasUrls()) { + QList urls = mimedata->urls(); + handleOpenFilesFromUrls(urls, QCursor::pos()); + } + } else if ( isKeybind(kShortcutGroupPlayer, kShortcutIDActionPlayerPrevious, modifiers, key) ) { if ( getNodeGraph()->getLastSelectedViewer() ) { getNodeGraph()->getLastSelectedViewer()->previousFrame(); @@ -1065,20 +1096,11 @@ static NodeGraph* isNodeGraphChild(QWidget* w) { } void -Gui::dropEvent(QDropEvent* e) +Gui::handleOpenFilesFromUrls(const QList& urls, const QPoint& globalPos) { - if ( !e->mimeData()->hasUrls() ) { - return; - } - - e->accept(); - - QList urls = e->mimeData()->urls(); - std::vector< boost::shared_ptr > sequences; fileSequencesFromUrls(urls, &sequences); - - QPoint globalPos = mapToGlobal(e->pos()); + QWidget* widgetUnderMouse = QApplication::widgetAt(globalPos); NodeGraph* graph = isNodeGraphChild(widgetUnderMouse); @@ -1116,28 +1138,8 @@ Gui::dropEvent(QDropEvent* e) const std::map& content = sequence->getFrameIndexes(); assert(!content.empty()); _imp->_scriptEditor->sourceScript(QString::fromUtf8(content.begin()->second.absoluteFileName().c_str())); - - // Ensure that the script editor is visible - TabWidget* pane = _imp->_scriptEditor->getParentPane(); - if (pane != 0) { - pane->setCurrentWidget(_imp->_scriptEditor); - } else { - pane = graph->getParentPane(); - if (!pane) { - std::list tabs; - { - QMutexLocker k(&_imp->_panesMutex); - tabs = _imp->_panes; - } - if (tabs.empty()) { - return; - } - pane = tabs.front(); - } - assert(pane); - pane->moveScriptEditorHere(); - } - + ensureScriptEditorVisible(); + } else { std::map readersForFormat; @@ -1163,6 +1165,20 @@ Gui::dropEvent(QDropEvent* e) } } } +} + +void +Gui::dropEvent(QDropEvent* e) +{ + if ( !e->mimeData()->hasUrls() ) { + return; + } + + e->accept(); + + QList urls = e->mimeData()->urls(); + + handleOpenFilesFromUrls(urls, mapToGlobal(e->pos())); } // dropEvent diff --git a/Gui/NodeGraph.h b/Gui/NodeGraph.h index f00f78b494..fa002358d3 100644 --- a/Gui/NodeGraph.h +++ b/Gui/NodeGraph.h @@ -163,7 +163,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void pasteCliboard(const NodeClipBoard& clipboard,std::list >* newNodes); void duplicateSelectedNodes(const QPointF& pos); - void pasteNodeClipBoards(const QPointF& pos); + bool pasteNodeClipBoards(const QPointF& pos); void cloneSelectedNodes(const QPointF& pos); QPointF getRootPos() const; @@ -206,7 +206,7 @@ public Q_SLOTS: void copySelectedNodes(); void cutSelectedNodes(); - void pasteNodeClipBoards(); + bool pasteNodeClipBoards(); void duplicateSelectedNodes(); void cloneSelectedNodes(); void decloneSelectedNodes(); diff --git a/Gui/NodeGraph25.cpp b/Gui/NodeGraph25.cpp index 725d006c65..d94f257bbb 100644 --- a/Gui/NodeGraph25.cpp +++ b/Gui/NodeGraph25.cpp @@ -260,7 +260,9 @@ NodeGraph::keyPressEvent(QKeyEvent* e) } else if ( isKeybind(kShortcutGroupNodegraph, kShortcutIDActionGraphCopy, modifiers, key) ) { copySelectedNodes(); } else if ( isKeybind(kShortcutGroupNodegraph, kShortcutIDActionGraphPaste, modifiers, key) ) { - pasteNodeClipBoards(); + if (!pasteNodeClipBoards()) { + accept = false; + } } else if ( isKeybind(kShortcutGroupNodegraph, kShortcutIDActionGraphCut, modifiers, key) ) { cutSelectedNodes(); } else if ( isKeybind(kShortcutGroupNodegraph, kShortcutIDActionGraphDuplicate, modifiers, key) ) { diff --git a/Gui/NodeGraph40.cpp b/Gui/NodeGraph40.cpp index 5f7f26f1b5..1f6dbb0713 100644 --- a/Gui/NodeGraph40.cpp +++ b/Gui/NodeGraph40.cpp @@ -157,13 +157,13 @@ NodeGraph::pasteCliboard(const NodeClipBoard& clipboard,std::listpasteNodesInternal(clipboard,position, false, newNodes); } -void +bool NodeGraph::pasteNodeClipBoards(const QPointF& pos) { QClipboard* clipboard = QApplication::clipboard(); const QMimeData* mimedata = clipboard->mimeData(); if (!mimedata->hasFormat(QLatin1String("text/plain"))) { - return; + return false; } QByteArray data = mimedata->data(QLatin1String("text/plain")); @@ -179,17 +179,17 @@ NodeGraph::pasteNodeClipBoards(const QPointF& pos) boost::archive::xml_iarchive iArchive(ss); iArchive >> boost::serialization::make_nvp("Clipboard",cb); } catch (...) { - Dialogs::errorDialog(tr("Paste").toStdString(), tr("Clipboard does not contain a Natron graph").toStdString()); - return; + return false; } _imp->pasteNodesInternal(cb,pos, true, &newNodes); + return true; } -void +bool NodeGraph::pasteNodeClipBoards() { QPointF position = _imp->_root->mapFromScene(mapToScene(mapFromGlobal(QCursor::pos()))); - pasteNodeClipBoards(position); + return pasteNodeClipBoards(position); } From 1e07f0ea2ea35d1f9af9eb7bf265feed7610c4e5 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Sat, 2 Apr 2016 15:45:31 +0200 Subject: [PATCH 24/30] Wipe: if B input is empty set it at the same time with A --- Engine/ViewerInstance.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Engine/ViewerInstance.cpp b/Engine/ViewerInstance.cpp index ae54ae8280..f0cca8aecb 100644 --- a/Engine/ViewerInstance.cpp +++ b/Engine/ViewerInstance.cpp @@ -3158,6 +3158,9 @@ ViewerInstance::refreshActiveInputs(int inputNbChanged) } else { _imp->activeInputs[0] = inputNbChanged; + if (_imp->activeInputs[1] == -1) { + _imp->activeInputs[1] = inputNbChanged; + } } } } From fb69a736687b7144c8dd35f4a7fb78d891bf73c0 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Sun, 3 Apr 2016 16:27:03 +0200 Subject: [PATCH 25/30] Nodegraph: optimise mouse event handlers: do not iterate over nodes but use the QGrpahicsView::items function instead --- Gui/NodeGraph.h | 17 ++++ Gui/NodeGraph10.cpp | 203 +++++++++++++++++++++++++++++--------------- Gui/NodeGraph15.cpp | 75 +++++++--------- Gui/NodeGraph20.cpp | 64 +++++++------- Gui/NodeGraph25.cpp | 37 +++----- 5 files changed, 233 insertions(+), 163 deletions(-) diff --git a/Gui/NodeGraph.h b/Gui/NodeGraph.h index fa002358d3..e1ea8e0b3d 100644 --- a/Gui/NodeGraph.h +++ b/Gui/NodeGraph.h @@ -270,6 +270,23 @@ public Q_SLOTS: private: + enum NearbyItemEnum + { + eNearbyItemNone = 0, + eNearbyItemNode, + eNearbyItemBackdropResizeHandle, + eNearbyItemBackdropFrame, + eNearbyItemNodeEdge, + eNearbyItemEdgeBendPoint, + + }; + + void getNodesWithinViewportRect(const QRect& rect, std::set* nodes) const; + + NearbyItemEnum hasItemNearbyMouse(const QPoint& mousePosViewport, + NodeGui** node, + Edge** edge); + void moveRootInternal(double dx, double dy); void wheelEventInternal(bool ctrlDown,double delta); diff --git a/Gui/NodeGraph10.cpp b/Gui/NodeGraph10.cpp index 96059c27da..97cdea6a0c 100644 --- a/Gui/NodeGraph10.cpp +++ b/Gui/NodeGraph10.cpp @@ -44,6 +44,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/Edge.h" #include "Gui/Gui.h" #include "Gui/GuiAppInstance.h" +#include "Gui/GuiApplicationManager.h" #include "Gui/GuiMacros.h" #include "Gui/NodeGui.h" #include "Gui/NodeSettingsPanel.h" @@ -52,6 +53,107 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON NATRON_NAMESPACE_ENTER; +static NodeGui* isNodeGuiChild(QGraphicsItem* item) +{ + NodeGui* n = dynamic_cast(item); + if (n) { + return n; + } + QGraphicsItem* parent = item->parentItem(); + if (parent) { + return isNodeGuiChild(parent); + } else { + return 0; + } +} + +static Edge* isEdgeChild(QGraphicsItem* item) +{ + Edge* n = dynamic_cast(item); + if (n) { + return n; + } + QGraphicsItem* parent = item->parentItem(); + if (parent) { + return isEdgeChild(parent); + } else { + return 0; + } +} + +void +NodeGraph::getNodesWithinViewportRect(const QRect& rect, std::set* nodes) const +{ + QList selectedItems = items(rect, Qt::IntersectsItemShape); + for (QList::Iterator it = selectedItems.begin(); it!=selectedItems.end(); ++it) { + NodeGui* n = isNodeGuiChild(*it); + if (n) { + nodes->insert(n); + } + } +} + +NodeGraph::NearbyItemEnum +NodeGraph::hasItemNearbyMouse(const QPoint& mousePosViewport, + NodeGui** node, + Edge** edge) +{ + assert(node && edge); + *node = 0; + *edge = 0; + double tolerance = TO_DPIX(10.); + QRect toleranceRect(mousePosViewport.x() - tolerance / 2., + mousePosViewport.y() - tolerance / 2., + tolerance, + tolerance); + QList selectedItems = items(toleranceRect, Qt::IntersectsItemShape); + std::set edges; + std::set nodes; + for (QList::Iterator it = selectedItems.begin(); it!=selectedItems.end(); ++it) { + Edge* isEdge = isEdgeChild(*it); + if (isEdge) { + edges.insert(isEdge); + } + NodeGui* n = isNodeGuiChild(*it); + if (n) { + nodes.insert(n); + } + } + + for (std::set::iterator it = nodes.begin(); it!=nodes.end(); ++it) { + if ( (*it)->isVisible() && (*it)->isActive() ) { + + QPointF localPoint = (*it)->mapFromScene(mapToScene(mousePosViewport)); + BackdropGui* isBd = dynamic_cast(*it); + if (isBd) { + if (isBd->isNearbyNameFrame(localPoint)) { + *node = *it; + return eNearbyItemBackdropFrame; + } else if (isBd->isNearbyResizeHandle(localPoint)) { + *node = *it; + return eNearbyItemBackdropResizeHandle; + } + } else { + *node = *it; + return eNearbyItemNode; + } + + } + + } + if (!edges.empty()) { + *edge = *edges.begin(); + + QPointF scenePos = mapToScene(mousePosViewport); + if ((*edge)->hasSource() && (*edge)->isBendPointVisible() && (*edge)->isNearbyBendPoint(scenePos)) { + return eNearbyItemEdgeBendPoint; + } else { + return eNearbyItemNodeEdge; + } + return eNearbyItemNodeEdge; + } + return eNearbyItemNone; +} void NodeGraph::mousePressEvent(QMouseEvent* e) @@ -92,6 +194,7 @@ NodeGraph::mousePressEvent(QMouseEvent* e) groupEdited = isGroup->getNode()->hasPyPlugBeenEdited(); } + if (!groupEdited) { if (isGroupEditable) { @@ -120,74 +223,35 @@ NodeGraph::mousePressEvent(QMouseEvent* e) } } - - NodeGuiPtr selected; - Edge* selectedEdge = 0; - Edge* selectedBendPoint = 0; - { - - QMutexLocker l(&_imp->_nodesMutex); - - ///Find matches, sorted by depth - std::map matches; - for (NodesGuiList::reverse_iterator it = _imp->_nodes.rbegin(); it != _imp->_nodes.rend(); ++it) { - QPointF evpt = (*it)->mapFromScene(lastMousePosScene); - if ( (*it)->isVisible() && (*it)->isActive() ) { - - BackdropGui* isBd = dynamic_cast(it->get()); - if (isBd) { - if (isBd->isNearbyNameFrame(evpt)) { - matches.insert(std::make_pair((*it)->zValue(),*it)); - } else if (isBd->isNearbyResizeHandle(evpt) && groupEdited) { - selected = *it; - _imp->_backdropResized = *it; - _imp->_evtState = eEventStateResizingBackdrop; - break; - } - } else { - if ((*it)->contains(evpt)) { - matches.insert(std::make_pair((*it)->zValue(),*it)); - } - } - - } - } - if (!matches.empty() && _imp->_evtState != eEventStateResizingBackdrop) { - selected = matches.rbegin()->second; - } - if (!selected) { - ///try to find a selected edge - for (NodesGuiList::reverse_iterator it = _imp->_nodes.rbegin(); it != _imp->_nodes.rend(); ++it) { - Edge* bendPointEdge = (*it)->hasBendPointNearbyPoint(lastMousePosScene); - - if (bendPointEdge) { - selectedBendPoint = bendPointEdge; - break; - } - Edge* edge = (*it)->hasEdgeNearbyPoint(lastMousePosScene); - if (edge) { - selectedEdge = edge; - } - - } - } + NodeGui* nearbyNode; + Edge* nearbyEdge; + NearbyItemEnum nearbyItemCode = hasItemNearbyMouse(e->pos(), &nearbyNode, &nearbyEdge); + if (nearbyItemCode == eNearbyItemBackdropResizeHandle) { + assert(nearbyNode); + didSomething = true; + _imp->_backdropResized = nearbyNode->shared_from_this(); + _imp->_evtState = eEventStateResizingBackdrop; } - if (selected) { + if ((nearbyItemCode == eNearbyItemNode || nearbyItemCode == eNearbyItemBackdropFrame) && groupEdited) { + assert(nearbyNode); + + NodeGuiPtr selectedNode = nearbyNode->shared_from_this(); + didSomething = true; - if ( buttonDownIsLeft(e) ) { + if (buttonDownIsLeft(e)) { - BackdropGui* isBd = dynamic_cast(selected.get()); + BackdropGui* isBd = dynamic_cast(selectedNode.get()); if (!isBd) { - _imp->_magnifiedNode = selected; + _imp->_magnifiedNode = selectedNode; } - if ( !selected->getIsSelected() ) { - selectNode( selected, modCASIsShift(e) ); + if (!selectedNode->getIsSelected()) { + selectNode(selectedNode, modCASIsShift(e)); } else if ( modCASIsShift(e) ) { NodesGuiList::iterator it = std::find(_imp->_selection.begin(), - _imp->_selection.end(),selected); + _imp->_selection.end(),selectedNode); if ( it != _imp->_selection.end() ) { (*it)->setUserSelected(false); _imp->_selection.erase(it); @@ -205,20 +269,22 @@ NodeGraph::mousePressEvent(QMouseEvent* e) _imp->_nodesWithinBDAtPenDown.insert(std::make_pair(*it,nodesWithin)); } } - - } else if ( buttonDownIsRight(e) ) { - if ( !selected->getIsSelected() ) { - selectNode(selected,true); ///< don't wipe the selection + + } else if (buttonDownIsRight(e)) { + if ( !selectedNode->getIsSelected() ) { + selectNode(selectedNode,true); //< don't wipe the selection } } - } else if (selectedBendPoint && groupEdited) { + } + + if (nearbyItemCode == eNearbyItemEdgeBendPoint && groupEdited) { _imp->setNodesBendPointsVisible(false); - + assert(nearbyEdge); ///Now connect the node to the edge input - NodePtr inputNode = selectedBendPoint->getSource()->getNode(); + NodePtr inputNode = nearbyEdge->getSource()->getNode(); assert(inputNode); ///disconnect previous connection - NodePtr outputNode = selectedBendPoint->getDest()->getNode(); + NodePtr outputNode = nearbyEdge->getDest()->getNode(); assert(outputNode); int inputNb = outputNode->inputIndex(inputNode); if (inputNb == -1) { @@ -269,8 +335,9 @@ NodeGraph::mousePressEvent(QMouseEvent* e) _imp->_evtState = eEventStateDraggingNode; didSomething = true; - } else if (selectedEdge && groupEdited) { - _imp->_arrowSelected = selectedEdge; + } else if (nearbyItemCode == eNearbyItemNodeEdge && groupEdited) { + assert(nearbyEdge); + _imp->_arrowSelected = nearbyEdge; didSomething = true; _imp->_evtState = eEventStateDraggingArrow; } diff --git a/Gui/NodeGraph15.cpp b/Gui/NodeGraph15.cpp index 19c723a926..2e7a25df96 100644 --- a/Gui/NodeGraph15.cpp +++ b/Gui/NodeGraph15.cpp @@ -125,7 +125,6 @@ NodeGraph::mouseReleaseEvent(QMouseEvent* e) bool hasMovedOnce = modCASIsControl(e) || _imp->_hasMovedOnce; if (state == eEventStateDraggingArrow && hasMovedOnce) { - QRectF sceneR = visibleSceneRect(); bool foundSrc = false; assert(_imp->_arrowSelected); @@ -133,59 +132,49 @@ NodeGraph::mouseReleaseEvent(QMouseEvent* e) _imp->_arrowSelected->getSource() : _imp->_arrowSelected->getDest(); assert(nodeHoldingEdge); - NodesGuiList nodes = getAllActiveNodes_mt_safe(); - QPointF ep = mapToScene( e->pos() ); - for (NodesGuiList::iterator it = _imp->_nodes.begin(); it != _imp->_nodes.end(); ++it) { - NodeGuiPtr & n = *it; - - BackdropGui* isBd = dynamic_cast(n.get()); - if (isBd) { - continue; - } - - QRectF bbox = n->mapToScene(n->boundingRect()).boundingRect(); - - if (n->isActive() && n->isVisible() && bbox.intersects(sceneR) && - n->isNearby(ep) && - n->getNode()->getScriptName() != nodeHoldingEdge->getNode()->getScriptName()) { + NodeGui* nearbyNode; + Edge* nearbyEdge; + NearbyItemEnum nearbyItemCode = hasItemNearbyMouse(e->pos(), &nearbyNode, &nearbyEdge); + + if (nearbyItemCode == eNearbyItemNode) { + NodeGuiPtr targetNode = nearbyNode->shared_from_this(); + if (targetNode != nodeHoldingEdge) { - if ( !_imp->_arrowSelected->isOutputEdge() ) { + if (!_imp->_arrowSelected->isOutputEdge()) { - bool ok = handleConnectionError(nodeHoldingEdge, n, _imp->_arrowSelected->getInputNumber()); - _imp->_arrowSelected->stackBefore( n.get() ); - if (!ok) { - break; + bool ok = handleConnectionError(nodeHoldingEdge, targetNode, _imp->_arrowSelected->getInputNumber()); + _imp->_arrowSelected->stackBefore( targetNode.get() ); + if (ok) { + foundSrc = true; + pushUndoCommand(new ConnectCommand(this,_imp->_arrowSelected,_imp->_arrowSelected->getSource(),targetNode)); } - pushUndoCommand( new ConnectCommand(this,_imp->_arrowSelected,_imp->_arrowSelected->getSource(),n) ); } else { - ///Find the input edge of the node we just released the mouse over, - ///and use that edge to connect to the source of the selected edge. - int preferredInput = n->getNode()->getPreferredInputForConnection(); - if (preferredInput != -1) { - - bool ok = handleConnectionError(n, nodeHoldingEdge, preferredInput); - if (!ok) { - break; + // Find the input edge of the node we just released the mouse over, + // and use that edge to connect to the source of the selected edge. + int preferredInput = targetNode->getNode()->getPreferredInputForConnection(); + if (preferredInput != -1) { + bool ok = handleConnectionError(targetNode, nodeHoldingEdge, preferredInput); + if (ok) { + + Edge* foundInput = targetNode->getInputArrow(preferredInput); + assert(foundInput); + foundSrc = true; + pushUndoCommand(new ConnectCommand(this,foundInput, + foundInput->getSource(),_imp->_arrowSelected->getSource())); } - - Edge* foundInput = n->getInputArrow(preferredInput); - assert(foundInput); - pushUndoCommand( new ConnectCommand( this,foundInput, - foundInput->getSource(),_imp->_arrowSelected->getSource() ) ); } } - foundSrc = true; - break; } } - ///if we disconnected the input edge, use the undo/redo stack. - ///Output edges can never be really connected, they're just there - ///So the user understands some nodes can have output - if ( !foundSrc && !_imp->_arrowSelected->isOutputEdge() && _imp->_arrowSelected->getSource() ) { - pushUndoCommand( new ConnectCommand( this,_imp->_arrowSelected,_imp->_arrowSelected->getSource(), - NodeGuiPtr() ) ); + + // If we disconnected the input edge, use the undo/redo stack. + // Output edges can never be really connected, they're just there + // So the user understands some nodes can have output + if (!foundSrc && !_imp->_arrowSelected->isOutputEdge() && _imp->_arrowSelected->getSource()) { + pushUndoCommand(new ConnectCommand(this,_imp->_arrowSelected,_imp->_arrowSelected->getSource(), + NodeGuiPtr())); } diff --git a/Gui/NodeGraph20.cpp b/Gui/NodeGraph20.cpp index c28834227c..61a8b6cd12 100644 --- a/Gui/NodeGraph20.cpp +++ b/Gui/NodeGraph20.cpp @@ -89,9 +89,12 @@ NodeGraph::checkForHints(bool shiftdown, bool controlDown, const NodeGuiPtr& sel NodePtr selectedNodeInternalNode = selectedNode->getNode(); bool selectedNodeIsReader = selectedNodeInternalNode->getEffectInstance()->isReader() || selectedNodeInternalNode->getMaxInputCount() == 0; Edge* edge = 0; + + std::set nodesWithinRect; + getNodesWithinViewportRect(visibleWidgetRect(), &nodesWithinRect); + { - QMutexLocker l(&_imp->_nodesMutex); - for (NodesGuiList::iterator it = _imp->_nodes.begin(); it != _imp->_nodes.end(); ++it) { + for (std::set::iterator it = nodesWithinRect.begin(); it != nodesWithinRect.end(); ++it) { bool isAlreadyAnOutput = false; const NodesWList& outputs = internalNode->getGuiOutputs(); @@ -109,7 +112,7 @@ NodeGraph::checkForHints(bool shiftdown, bool controlDown, const NodeGuiPtr& sel continue; } QRectF nodeBbox = (*it)->boundingRectWithEdges(); - if ((*it) != selectedNode && (*it)->isVisible() && nodeBbox.intersects(visibleSceneR)) { + if ((*it) != selectedNode.get() && (*it)->isVisible() && nodeBbox.intersects(visibleSceneR)) { if (doMergeHints) { @@ -139,7 +142,7 @@ NodeGraph::checkForHints(bool shiftdown, bool controlDown, const NodeGuiPtr& sel } } if (isValid) { - nodeToShowMergeRect = *it; + nodeToShowMergeRect = (*it)->shared_from_this(); } } else { (*it)->setMergeHintActive(false); @@ -430,38 +433,41 @@ NodeGraph::mouseMoveEvent(QMouseEvent* e) QRectF sceneR = visibleSceneRect(); if (groupEdited && _imp->_evtState != eEventStateSelectionRect && _imp->_evtState != eEventStateDraggingArrow) { - ///set cursor + // Set cursor + + std::set visibleNodes; + getNodesWithinViewportRect(visibleWidgetRect(), &visibleNodes); + NodeGuiPtr selected; Edge* selectedEdge = 0; - { - bool optionalInputsAutoHidden = areOptionalInputsAutoHidden(); - QMutexLocker l(&_imp->_nodesMutex); - for (NodesGuiList::iterator it = _imp->_nodes.begin(); it != _imp->_nodes.end(); ++it) { - QPointF evpt = (*it)->mapFromScene(newPos); - - QRectF bbox = (*it)->mapToScene((*it)->boundingRect()).boundingRect(); - if ((*it)->isActive() && bbox.intersects(sceneR)) { - if ((*it)->contains(evpt)) { - selected = (*it); - if (optionalInputsAutoHidden) { - (*it)->refreshEdgesVisility(true); - } else { - break; - } + + bool optionalInputsAutoHidden = areOptionalInputsAutoHidden(); + + for (std::set::iterator it = visibleNodes.begin(); it!=visibleNodes.end(); ++it) { + QPointF evpt = (*it)->mapFromScene(newPos); + + QRectF bbox = (*it)->mapToScene((*it)->boundingRect()).boundingRect(); + if ((*it)->isActive() && bbox.intersects(sceneR)) { + if ((*it)->contains(evpt)) { + selected = (*it)->shared_from_this(); + if (optionalInputsAutoHidden) { + (*it)->refreshEdgesVisility(true); } else { - Edge* edge = (*it)->hasEdgeNearbyPoint(newPos); - if (edge) { - selectedEdge = edge; - if (!optionalInputsAutoHidden) { - break; - } - } else if (optionalInputsAutoHidden && !(*it)->getIsSelected()) { - (*it)->refreshEdgesVisility(false); + break; + } + } else { + Edge* edge = (*it)->hasEdgeNearbyPoint(newPos); + if (edge) { + selectedEdge = edge; + if (!optionalInputsAutoHidden) { + break; } + } else if (optionalInputsAutoHidden && !(*it)->getIsSelected()) { + (*it)->refreshEdgesVisility(false); } } - } + } if (selected) { _imp->cursorSet = true; diff --git a/Gui/NodeGraph25.cpp b/Gui/NodeGraph25.cpp index d94f257bbb..5600077e8a 100644 --- a/Gui/NodeGraph25.cpp +++ b/Gui/NodeGraph25.cpp @@ -66,31 +66,22 @@ void NodeGraph::mouseDoubleClickEvent(QMouseEvent* e) { - QPointF lastMousePosScene = mapToScene(_imp->_lastMousePos); + NodeGui* nearbyNode; + Edge* nearbyEdge; + NearbyItemEnum nearbyItemCode = hasItemNearbyMouse(e->pos(), &nearbyNode, &nearbyEdge); - NodesGuiList nodes = getAllActiveNodes_mt_safe(); - - ///Matches sorted by depth - std::map matches; - for (NodesGuiList::iterator it = nodes.begin(); it != nodes.end(); ++it) { - QPointF evpt = (*it)->mapFromScene(lastMousePosScene); - if ( (*it)->isVisible() && (*it)->isActive() && (*it)->contains(evpt) ) { - matches.insert(std::make_pair((*it)->zValue(), *it)); - } - } - if (!matches.empty()) { - const NodeGuiPtr& node = matches.rbegin()->second; + if (nearbyItemCode == eNearbyItemNode) { if (modCASIsControl(e)) { - node->ensurePanelCreated(); - if (node->getSettingPanel()) { - node->getSettingPanel()->floatPanel(); + nearbyNode->ensurePanelCreated(); + if (nearbyNode->getSettingPanel()) { + nearbyNode->getSettingPanel()->floatPanel(); } } else { - node->setVisibleSettingsPanel(true); - if (node->getSettingPanel()) { - getGui()->putSettingsPanelFirst( node->getSettingPanel() ); + nearbyNode->setVisibleSettingsPanel(true); + if (nearbyNode->getSettingPanel()) { + getGui()->putSettingsPanelFirst(nearbyNode->getSettingPanel()); } else { - ViewerInstance* isViewer = node->getNode()->isEffectViewer(); + ViewerInstance* isViewer = nearbyNode->getNode()->isEffectViewer(); if (isViewer) { ViewerGL* viewer = dynamic_cast(isViewer->getUiContext()); assert(viewer); @@ -129,12 +120,12 @@ NodeGraph::mouseDoubleClickEvent(QMouseEvent* e) } } } - if ( !node->wasBeginEditCalled() ) { - node->beginEditKnobs(); + if (!nearbyNode->wasBeginEditCalled()) { + nearbyNode->beginEditKnobs(); } if (modCASIsShift(e)) { - NodeGroup* isGrp = node->getNode()->isEffectGroup(); + NodeGroup* isGrp = nearbyNode->getNode()->isEffectGroup(); if (isGrp) { NodeGraphI* graph_i = isGrp->getNodeGraph(); assert(graph_i); From fe44169fcebe0ce7b9e8e3112a0228944f978d6d Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Sun, 3 Apr 2016 17:43:24 +0200 Subject: [PATCH 26/30] Python API: use QString instead of std::string for better Unicode handling. --- Engine/AppInstance.cpp | 2 +- Engine/AppManager.cpp | 43 ++- Engine/AppManager.h | 2 +- Engine/Knob.cpp | 2 +- Engine/NatronEngine/animatedparam_wrapper.cpp | 18 +- Engine/NatronEngine/app_wrapper.cpp | 134 ++++---- Engine/NatronEngine/appsettings_wrapper.cpp | 12 +- Engine/NatronEngine/buttonparam_wrapper.cpp | 12 +- Engine/NatronEngine/choiceparam_wrapper.cpp | 63 ++-- Engine/NatronEngine/effect_wrapper.cpp | 81 +++-- Engine/NatronEngine/group_wrapper.cpp | 12 +- Engine/NatronEngine/imagelayer_wrapper.cpp | 45 ++- Engine/NatronEngine/itembase_wrapper.cpp | 44 +-- .../natronengine_module_wrapper.cpp | 205 +++++-------- Engine/NatronEngine/natronengine_python.h | 56 ++-- Engine/NatronEngine/param_wrapper.cpp | 28 +- .../pycoreapplication_wrapper.cpp | 71 +++-- Engine/NatronEngine/roto_wrapper.cpp | 12 +- .../NatronEngine/stringparambase_wrapper.cpp | 84 ++--- .../NatronEngine/userparamholder_wrapper.cpp | 288 +++++++++--------- Engine/ProjectPrivate.cpp | 2 +- Engine/PyAppInstance.cpp | 52 ++-- Engine/PyAppInstance.h | 24 +- Engine/PyGlobalFunctions.h | 50 +-- Engine/PyNode.cpp | 174 ++++++----- Engine/PyNode.h | 80 ++--- Engine/PyNodeGroup.cpp | 4 +- Engine/PyNodeGroup.h | 2 +- Engine/PyParameter.cpp | 115 +++---- Engine/PyParameter.h | 50 +-- Engine/PyRoto.cpp | 24 +- Engine/PyRoto.h | 12 +- Engine/Pyside_Engine_Python.h | 2 +- Engine/typesystem_engine.xml | 133 +++++--- Gui/CurveWidget.cpp | 4 +- Gui/NatronGui/guiapp_wrapper.cpp | 177 ++++++----- Gui/NatronGui/natrongui_module_wrapper.cpp | 82 ++--- Gui/NatronGui/natrongui_python.h | 21 +- Gui/NatronGui/pyguiapplication_wrapper.cpp | 79 +++-- Gui/NatronGui/pymodaldialog_wrapper.cpp | 24 +- Gui/NatronGui/pypanel_wrapper.cpp | 96 +++--- Gui/NatronGui/pypanel_wrapper.h | 8 +- Gui/NatronGui/pytabwidget_wrapper.cpp | 8 +- Gui/ProjectGui.cpp | 4 +- Gui/ProjectGuiSerialization.cpp | 2 +- Gui/PyGlobalGui.h | 24 +- Gui/PyGuiApp.cpp | 110 ++++--- Gui/PyGuiApp.h | 20 +- Gui/PythonPanels.cpp | 59 ++-- Gui/PythonPanels.h | 30 +- Gui/TabWidget.cpp | 2 +- Gui/typesystem_natronGui.xml | 8 +- 52 files changed, 1367 insertions(+), 1329 deletions(-) diff --git a/Engine/AppInstance.cpp b/Engine/AppInstance.cpp index be51906681..fa97d9bc89 100644 --- a/Engine/AppInstance.cpp +++ b/Engine/AppInstance.cpp @@ -745,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 = Python::PY3String_asString(errorObj); + error = Python::PyString_asString(errorObj); PyObject* unicode = PyUnicode_FromString(""); PyObject_SetAttrString(errCatcher, "value", unicode); Py_DECREF(errorObj); diff --git a/Engine/AppManager.cpp b/Engine/AppManager.cpp index b7f58f84fc..536d534e4a 100644 --- a/Engine/AppManager.cpp +++ b/Engine/AppManager.cpp @@ -1167,7 +1167,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 = Python::PY3String_asString(errorObj); + error = Python::PyString_asString(errorObj); PyObject* unicode = PyUnicode_FromString(""); PyObject_SetAttrString(errCatcher, "value", unicode); Py_DECREF(errorObj); @@ -2456,15 +2456,28 @@ char2wchar(char* arg) std::string -Python::PY3String_asString(PyObject* obj) +Python::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 @@ -3102,7 +3115,7 @@ Python::interpretPythonScript(const std::string& script,std::string* error,std:: 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); @@ -3112,7 +3125,7 @@ Python::interpretPythonScript(const std::string& script,std::string* error,std:: 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); @@ -3323,17 +3336,17 @@ static bool getGroupInfosInternal(const std::string& modulePath, assert(labelObj); - *pluginLabel = Python::PY3String_asString(labelObj); + *pluginLabel = Python::PyString_asString(labelObj); Py_XDECREF(labelObj); if (idObj) { - *pluginID = Python::PY3String_asString(idObj); + *pluginID = Python::PyString_asString(idObj); deleteScript.append("del pluginID\n"); Py_XDECREF(idObj); } if (iconObj) { - *iconFilePath = Python::PY3String_asString(iconObj); + *iconFilePath = Python::PyString_asString(iconObj); QFileInfo iconInfo(QString::fromUtf8(modulePath.c_str()) + QString::fromUtf8(iconFilePath->c_str())); *iconFilePath = iconInfo.canonicalFilePath().toStdString(); @@ -3341,7 +3354,7 @@ static bool getGroupInfosInternal(const std::string& modulePath, Py_XDECREF(iconObj); } if (iconGrouping) { - *grouping = Python::PY3String_asString(iconGrouping); + *grouping = Python::PyString_asString(iconGrouping); deleteScript.append("del templateGrouping\n"); Py_XDECREF(iconGrouping); } @@ -3360,7 +3373,7 @@ static bool getGroupInfosInternal(const std::string& modulePath, if (pluginDescriptionObj) { - *description = Python::PY3String_asString(pluginDescriptionObj); + *description = Python::PyString_asString(pluginDescriptionObj); deleteScript.append("del description\n"); Py_XDECREF(pluginDescriptionObj); } @@ -3482,7 +3495,7 @@ Python::getFunctionArguments(const std::string& pyFunc,std::string* error,std::v 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); diff --git a/Engine/AppManager.h b/Engine/AppManager.h index 6137cb0bb4..6374002370 100644 --- a/Engine/AppManager.h +++ b/Engine/AppManager.h @@ -687,7 +687,7 @@ 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); diff --git a/Engine/Knob.cpp b/Engine/Knob.cpp index ff1ad12441..239e36e1ec 100644 --- a/Engine/Knob.cpp +++ b/Engine/Knob.cpp @@ -2543,7 +2543,7 @@ static bool catchErrors(PyObject* mainModule, std::string* error) { if (errCatcher) { errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref assert(errorObj); - *error = Python::PY3String_asString(errorObj); + *error = Python::PyString_asString(errorObj); PyObject* unicode = PyUnicode_FromString(""); PyObject_SetAttrString(errCatcher, "value", unicode); Py_DECREF(errorObj); diff --git a/Engine/NatronEngine/animatedparam_wrapper.cpp b/Engine/NatronEngine/animatedparam_wrapper.cpp index 206bee2ab1..9dbe475364 100644 --- a/Engine/NatronEngine/animatedparam_wrapper.cpp +++ b/Engine/NatronEngine/animatedparam_wrapper.cpp @@ -247,9 +247,9 @@ static PyObject* Sbk_AnimatedParamFunc_getExpression(PyObject* self, PyObject* p // Begin code injection bool hasRetVar; - std::string cppResult = cppSelf->getExpression(cppArg0,&hasRetVar); + QString cppResult = cppSelf->getExpression(cppArg0,&hasRetVar); pyResult = PyTuple_New(2); - PyTuple_SET_ITEM(pyResult, 0, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult)); + PyTuple_SET_ITEM(pyResult, 0, Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult)); PyTuple_SET_ITEM(pyResult, 1, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &hasRetVar)); return pyResult; @@ -738,14 +738,14 @@ static PyObject* Sbk_AnimatedParamFunc_setExpression(PyObject* self, PyObject* a // Overloaded function decisor - // 0: setExpression(std::string,bool,int) + // 0: setExpression(QString,bool,int) if (numArgs >= 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { if (numArgs == 2) { - overloadId = 0; // setExpression(std::string,bool,int) + overloadId = 0; // setExpression(QString,bool,int) } else if ((pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[2])))) { - overloadId = 0; // setExpression(std::string,bool,int) + overloadId = 0; // setExpression(QString,bool,int) } } @@ -765,7 +765,7 @@ static PyObject* Sbk_AnimatedParamFunc_setExpression(PyObject* self, PyObject* a goto Sbk_AnimatedParamFunc_setExpression_TypeError; } } - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); bool cppArg1; pythonToCpp[1](pyArgs[1], &cppArg1); @@ -773,7 +773,7 @@ static PyObject* Sbk_AnimatedParamFunc_setExpression(PyObject* self, PyObject* a if (pythonToCpp[2]) pythonToCpp[2](pyArgs[2], &cppArg2); if (!PyErr_Occurred()) { - // setExpression(std::string,bool,int) + // setExpression(QString,bool,int) // Begin code injection bool cppResult = cppSelf->setExpression(cppArg0,cppArg1,cppArg2); @@ -792,7 +792,7 @@ static PyObject* Sbk_AnimatedParamFunc_setExpression(PyObject* self, PyObject* a return pyResult; Sbk_AnimatedParamFunc_setExpression_TypeError: - const char* overloads[] = {"std::string, bool, int = 0", 0}; + const char* overloads[] = {"unicode, bool, int = 0", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.AnimatedParam.setExpression", overloads); return 0; } diff --git a/Engine/NatronEngine/app_wrapper.cpp b/Engine/NatronEngine/app_wrapper.cpp index bef4dea91f..9f3fcbc3b6 100644 --- a/Engine/NatronEngine/app_wrapper.cpp +++ b/Engine/NatronEngine/app_wrapper.cpp @@ -53,9 +53,9 @@ static PyObject* Sbk_AppFunc_addFormat(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: addFormat(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // addFormat(std::string) + // 0: addFormat(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // addFormat(QString) } // Function signature not found. @@ -63,11 +63,11 @@ static PyObject* Sbk_AppFunc_addFormat(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // addFormat(std::string) + // addFormat(QString) cppSelf->addFormat(cppArg0); } } @@ -78,7 +78,7 @@ static PyObject* Sbk_AppFunc_addFormat(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_AppFunc_addFormat_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.addFormat", overloads); return 0; } @@ -107,7 +107,7 @@ static PyObject* Sbk_AppFunc_addProjectLayer(PyObject* self, PyObject* pyArg) { if (!Shiboken::Object::isValid(pyArg)) return 0; - ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppArg0_local = ::ImageLayer(::QString(), ::QString(), ::QStringList()); ::ImageLayer* cppArg0 = &cppArg0_local; if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp)) pythonToCpp(pyArg, &cppArg0_local); @@ -187,15 +187,15 @@ static PyObject* Sbk_AppFunc_createNode(PyObject* self, PyObject* args, PyObject // Overloaded function decisor - // 0: createNode(std::string,int,Group*)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { + // 0: createNode(QString,int,Group*)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // createNode(std::string,int,Group*)const + overloadId = 0; // createNode(QString,int,Group*)const } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { if (numArgs == 2) { - overloadId = 0; // createNode(std::string,int,Group*)const + overloadId = 0; // createNode(QString,int,Group*)const } else if ((pythonToCpp[2] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_GROUP_IDX], (pyArgs[2])))) { - overloadId = 0; // createNode(std::string,int,Group*)const + overloadId = 0; // createNode(QString,int,Group*)const } } } @@ -225,7 +225,7 @@ static PyObject* Sbk_AppFunc_createNode(PyObject* self, PyObject* args, PyObject goto Sbk_AppFunc_createNode_TypeError; } } - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); int cppArg1 = -1; if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); @@ -235,7 +235,7 @@ static PyObject* Sbk_AppFunc_createNode(PyObject* self, PyObject* args, PyObject if (pythonToCpp[2]) pythonToCpp[2](pyArgs[2], &cppArg2); if (!PyErr_Occurred()) { - // createNode(std::string,int,Group*)const + // createNode(QString,int,Group*)const // Begin code injection Effect * cppResult = cppSelf->createNode(cppArg0,cppArg1,cppArg2); @@ -257,7 +257,7 @@ static PyObject* Sbk_AppFunc_createNode(PyObject* self, PyObject* args, PyObject return pyResult; Sbk_AppFunc_createNode_TypeError: - const char* overloads[] = {"std::string, int = -1, NatronEngine.Group = None", 0}; + const char* overloads[] = {"unicode, int = -1, NatronEngine.Group = None", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.App.createNode", overloads); return 0; } @@ -291,12 +291,12 @@ static PyObject* Sbk_AppFunc_createReader(PyObject* self, PyObject* args, PyObje // Overloaded function decisor - // 0: createReader(std::string,Group*)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { + // 0: createReader(QString,Group*)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // createReader(std::string,Group*)const + overloadId = 0; // createReader(QString,Group*)const } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_GROUP_IDX], (pyArgs[1])))) { - overloadId = 0; // createReader(std::string,Group*)const + overloadId = 0; // createReader(QString,Group*)const } } @@ -316,7 +316,7 @@ static PyObject* Sbk_AppFunc_createReader(PyObject* self, PyObject* args, PyObje goto Sbk_AppFunc_createReader_TypeError; } } - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); if (!Shiboken::Object::isValid(pyArgs[1])) return 0; @@ -324,7 +324,7 @@ static PyObject* Sbk_AppFunc_createReader(PyObject* self, PyObject* args, PyObje if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createReader(std::string,Group*)const + // createReader(QString,Group*)const // Begin code injection Effect * cppResult = cppSelf->createReader(cppArg0,cppArg1); @@ -346,7 +346,7 @@ static PyObject* Sbk_AppFunc_createReader(PyObject* self, PyObject* args, PyObje return pyResult; Sbk_AppFunc_createReader_TypeError: - const char* overloads[] = {"std::string, NatronEngine.Group = None", 0}; + const char* overloads[] = {"unicode, NatronEngine.Group = None", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.App.createReader", overloads); return 0; } @@ -380,12 +380,12 @@ static PyObject* Sbk_AppFunc_createWriter(PyObject* self, PyObject* args, PyObje // Overloaded function decisor - // 0: createWriter(std::string,Group*)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { + // 0: createWriter(QString,Group*)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // createWriter(std::string,Group*)const + overloadId = 0; // createWriter(QString,Group*)const } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_GROUP_IDX], (pyArgs[1])))) { - overloadId = 0; // createWriter(std::string,Group*)const + overloadId = 0; // createWriter(QString,Group*)const } } @@ -405,7 +405,7 @@ static PyObject* Sbk_AppFunc_createWriter(PyObject* self, PyObject* args, PyObje goto Sbk_AppFunc_createWriter_TypeError; } } - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); if (!Shiboken::Object::isValid(pyArgs[1])) return 0; @@ -413,7 +413,7 @@ static PyObject* Sbk_AppFunc_createWriter(PyObject* self, PyObject* args, PyObje if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createWriter(std::string,Group*)const + // createWriter(QString,Group*)const // Begin code injection Effect * cppResult = cppSelf->createWriter(cppArg0,cppArg1); @@ -435,7 +435,7 @@ static PyObject* Sbk_AppFunc_createWriter(PyObject* self, PyObject* args, PyObje return pyResult; Sbk_AppFunc_createWriter_TypeError: - const char* overloads[] = {"std::string, NatronEngine.Group = None", 0}; + const char* overloads[] = {"unicode, NatronEngine.Group = None", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.App.createWriter", overloads); return 0; } @@ -479,9 +479,9 @@ static PyObject* Sbk_AppFunc_getProjectParam(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getProjectParam(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getProjectParam(std::string)const + // 0: getProjectParam(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getProjectParam(QString)const } // Function signature not found. @@ -489,11 +489,11 @@ static PyObject* Sbk_AppFunc_getProjectParam(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getProjectParam(std::string)const + // getProjectParam(QString)const Param * cppResult = const_cast(cppSelf)->getProjectParam(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAM_IDX], cppResult); @@ -509,7 +509,7 @@ static PyObject* Sbk_AppFunc_getProjectParam(PyObject* self, PyObject* pyArg) return pyResult; Sbk_AppFunc_getProjectParam_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.getProjectParam", overloads); return 0; } @@ -528,8 +528,8 @@ static PyObject* Sbk_AppFunc_getViewNames(PyObject* self) if (!PyErr_Occurred()) { // getViewNames()const - std::list cppResult = const_cast(cppSelf)->getViewNames(); - pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], &cppResult); + std::list cppResult = const_cast(cppSelf)->getViewNames(); + pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_QSTRING_IDX], &cppResult); } } @@ -553,9 +553,9 @@ static PyObject* Sbk_AppFunc_loadProject(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: loadProject(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // loadProject(std::string) + // 0: loadProject(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // loadProject(QString) } // Function signature not found. @@ -563,11 +563,11 @@ static PyObject* Sbk_AppFunc_loadProject(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // loadProject(std::string) + // loadProject(QString) // Begin code injection App * cppResult = cppSelf->loadProject(cppArg0); @@ -589,7 +589,7 @@ static PyObject* Sbk_AppFunc_loadProject(PyObject* self, PyObject* pyArg) return pyResult; Sbk_AppFunc_loadProject_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.loadProject", overloads); return 0; } @@ -819,9 +819,9 @@ static PyObject* Sbk_AppFunc_saveProject(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: saveProject(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // saveProject(std::string) + // 0: saveProject(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // saveProject(QString) } // Function signature not found. @@ -829,11 +829,11 @@ static PyObject* Sbk_AppFunc_saveProject(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // saveProject(std::string) + // saveProject(QString) bool cppResult = cppSelf->saveProject(cppArg0); pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); } @@ -846,7 +846,7 @@ static PyObject* Sbk_AppFunc_saveProject(PyObject* self, PyObject* pyArg) return pyResult; Sbk_AppFunc_saveProject_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.saveProject", overloads); return 0; } @@ -864,9 +864,9 @@ static PyObject* Sbk_AppFunc_saveProjectAs(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: saveProjectAs(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // saveProjectAs(std::string) + // 0: saveProjectAs(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // saveProjectAs(QString) } // Function signature not found. @@ -874,11 +874,11 @@ static PyObject* Sbk_AppFunc_saveProjectAs(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // saveProjectAs(std::string) + // saveProjectAs(QString) bool cppResult = cppSelf->saveProjectAs(cppArg0); pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); } @@ -891,7 +891,7 @@ static PyObject* Sbk_AppFunc_saveProjectAs(PyObject* self, PyObject* pyArg) return pyResult; Sbk_AppFunc_saveProjectAs_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.saveProjectAs", overloads); return 0; } @@ -909,9 +909,9 @@ static PyObject* Sbk_AppFunc_saveTempProject(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: saveTempProject(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // saveTempProject(std::string) + // 0: saveTempProject(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // saveTempProject(QString) } // Function signature not found. @@ -919,11 +919,11 @@ static PyObject* Sbk_AppFunc_saveTempProject(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // saveTempProject(std::string) + // saveTempProject(QString) bool cppResult = cppSelf->saveTempProject(cppArg0); pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); } @@ -936,7 +936,7 @@ static PyObject* Sbk_AppFunc_saveTempProject(PyObject* self, PyObject* pyArg) return pyResult; Sbk_AppFunc_saveTempProject_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.saveTempProject", overloads); return 0; } @@ -1031,9 +1031,9 @@ static PyObject* Sbk_AppFunc_writeToScriptEditor(PyObject* self, PyObject* pyArg SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: writeToScriptEditor(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // writeToScriptEditor(std::string) + // 0: writeToScriptEditor(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // writeToScriptEditor(QString) } // Function signature not found. @@ -1041,11 +1041,11 @@ static PyObject* Sbk_AppFunc_writeToScriptEditor(PyObject* self, PyObject* pyArg // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // writeToScriptEditor(std::string) + // writeToScriptEditor(QString) cppSelf->writeToScriptEditor(cppArg0); } } @@ -1056,7 +1056,7 @@ static PyObject* Sbk_AppFunc_writeToScriptEditor(PyObject* self, PyObject* pyArg Py_RETURN_NONE; Sbk_AppFunc_writeToScriptEditor_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.App.writeToScriptEditor", overloads); return 0; } diff --git a/Engine/NatronEngine/appsettings_wrapper.cpp b/Engine/NatronEngine/appsettings_wrapper.cpp index d4b99a6464..8460495432 100644 --- a/Engine/NatronEngine/appsettings_wrapper.cpp +++ b/Engine/NatronEngine/appsettings_wrapper.cpp @@ -40,9 +40,9 @@ static PyObject* Sbk_AppSettingsFunc_getParam(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getParam(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getParam(std::string)const + // 0: getParam(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getParam(QString)const } // Function signature not found. @@ -50,11 +50,11 @@ static PyObject* Sbk_AppSettingsFunc_getParam(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getParam(std::string)const + // getParam(QString)const Param * cppResult = const_cast(cppSelf)->getParam(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAM_IDX], cppResult); @@ -70,7 +70,7 @@ static PyObject* Sbk_AppSettingsFunc_getParam(PyObject* self, PyObject* pyArg) return pyResult; Sbk_AppSettingsFunc_getParam_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.AppSettings.getParam", overloads); return 0; } diff --git a/Engine/NatronEngine/buttonparam_wrapper.cpp b/Engine/NatronEngine/buttonparam_wrapper.cpp index af6e979f87..dbcb3f4fbc 100644 --- a/Engine/NatronEngine/buttonparam_wrapper.cpp +++ b/Engine/NatronEngine/buttonparam_wrapper.cpp @@ -49,9 +49,9 @@ static PyObject* Sbk_ButtonParamFunc_setIconFilePath(PyObject* self, PyObject* p SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setIconFilePath(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setIconFilePath(std::string) + // 0: setIconFilePath(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setIconFilePath(QString) } // Function signature not found. @@ -59,11 +59,11 @@ static PyObject* Sbk_ButtonParamFunc_setIconFilePath(PyObject* self, PyObject* p // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setIconFilePath(std::string) + // setIconFilePath(QString) cppSelf->setIconFilePath(cppArg0); } } @@ -74,7 +74,7 @@ static PyObject* Sbk_ButtonParamFunc_setIconFilePath(PyObject* self, PyObject* p Py_RETURN_NONE; Sbk_ButtonParamFunc_setIconFilePath_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.ButtonParam.setIconFilePath", overloads); return 0; } diff --git a/Engine/NatronEngine/choiceparam_wrapper.cpp b/Engine/NatronEngine/choiceparam_wrapper.cpp index 35aca311f0..115d260922 100644 --- a/Engine/NatronEngine/choiceparam_wrapper.cpp +++ b/Engine/NatronEngine/choiceparam_wrapper.cpp @@ -22,7 +22,6 @@ NATRON_NAMESPACE_USING #include #include #include -#include // Native --------------------------------------------------------- @@ -124,11 +123,11 @@ static PyObject* Sbk_ChoiceParamFunc_addOption(PyObject* self, PyObject* args) // Overloaded function decisor - // 0: addOption(std::string,std::string) + // 0: addOption(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // addOption(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // addOption(QString,QString) } // Function signature not found. @@ -136,13 +135,13 @@ static PyObject* Sbk_ChoiceParamFunc_addOption(PyObject* self, PyObject* args) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // addOption(std::string,std::string) + // addOption(QString,QString) cppSelf->addOption(cppArg0, cppArg1); } } @@ -153,7 +152,7 @@ static PyObject* Sbk_ChoiceParamFunc_addOption(PyObject* self, PyObject* args) Py_RETURN_NONE; Sbk_ChoiceParamFunc_addOption_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.ChoiceParam.addOption", overloads); return 0; } @@ -310,8 +309,8 @@ static PyObject* Sbk_ChoiceParamFunc_getOption(PyObject* self, PyObject* pyArg) if (!PyErr_Occurred()) { // getOption(int)const - std::string cppResult = const_cast(cppSelf)->getOption(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getOption(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -341,8 +340,8 @@ static PyObject* Sbk_ChoiceParamFunc_getOptions(PyObject* self) if (!PyErr_Occurred()) { // getOptions()const - std::vector cppResult = const_cast(cppSelf)->getOptions(); - pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX], &cppResult); + QStringList cppResult = const_cast(cppSelf)->getOptions(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], &cppResult); } } @@ -468,7 +467,7 @@ static PyObject* Sbk_ChoiceParamFunc_set(PyObject* self, PyObject* args) // Overloaded function decisor - // 0: set(std::string) + // 0: set(QString) // 1: set(int) // 2: set(int,double) if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { @@ -479,8 +478,8 @@ static PyObject* Sbk_ChoiceParamFunc_set(PyObject* self, PyObject* args) overloadId = 2; // set(int,double) } } else if (numArgs == 1 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { - overloadId = 0; // set(std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { + overloadId = 0; // set(QString) } // Function signature not found. @@ -488,13 +487,13 @@ static PyObject* Sbk_ChoiceParamFunc_set(PyObject* self, PyObject* args) // Call function/method switch (overloadId) { - case 0: // set(const std::string & label) + case 0: // set(const QString & label) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); if (!PyErr_Occurred()) { - // set(std::string) + // set(QString) cppSelf->set(cppArg0); } break; @@ -531,7 +530,7 @@ static PyObject* Sbk_ChoiceParamFunc_set(PyObject* self, PyObject* args) Py_RETURN_NONE; Sbk_ChoiceParamFunc_set_TypeError: - const char* overloads[] = {"std::string", "int", "int, float", 0}; + const char* overloads[] = {"unicode", "int", "int, float", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.ChoiceParam.set", overloads); return 0; } @@ -548,12 +547,12 @@ static PyObject* Sbk_ChoiceParamFunc_setDefaultValue(PyObject* self, PyObject* p SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setDefaultValue(std::string) + // 0: setDefaultValue(QString) // 1: setDefaultValue(int) if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { overloadId = 1; // setDefaultValue(int) - } else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setDefaultValue(std::string) + } else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setDefaultValue(QString) } // Function signature not found. @@ -561,13 +560,13 @@ static PyObject* Sbk_ChoiceParamFunc_setDefaultValue(PyObject* self, PyObject* p // Call function/method switch (overloadId) { - case 0: // setDefaultValue(const std::string & value) + case 0: // setDefaultValue(const QString & value) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setDefaultValue(std::string) + // setDefaultValue(QString) cppSelf->setDefaultValue(cppArg0); } break; @@ -591,7 +590,7 @@ static PyObject* Sbk_ChoiceParamFunc_setDefaultValue(PyObject* self, PyObject* p Py_RETURN_NONE; Sbk_ChoiceParamFunc_setDefaultValue_TypeError: - const char* overloads[] = {"std::string", "int", 0}; + const char* overloads[] = {"unicode", "int", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.ChoiceParam.setDefaultValue", overloads); return 0; } @@ -608,9 +607,9 @@ static PyObject* Sbk_ChoiceParamFunc_setOptions(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setOptions(std::list >) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_STD_STRING_STD_STRING_IDX], (pyArg)))) { - overloadId = 0; // setOptions(std::list >) + // 0: setOptions(std::list >) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_QSTRING_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setOptions(std::list >) } // Function signature not found. @@ -618,11 +617,11 @@ static PyObject* Sbk_ChoiceParamFunc_setOptions(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::list > cppArg0; + ::std::list > cppArg0; pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setOptions(std::list >) + // setOptions(std::list >) cppSelf->setOptions(cppArg0); } } diff --git a/Engine/NatronEngine/effect_wrapper.cpp b/Engine/NatronEngine/effect_wrapper.cpp index 363dddbda6..17887afb11 100644 --- a/Engine/NatronEngine/effect_wrapper.cpp +++ b/Engine/NatronEngine/effect_wrapper.cpp @@ -26,7 +26,6 @@ NATRON_NAMESPACE_USING #include #include #include -#include // Native --------------------------------------------------------- @@ -66,11 +65,11 @@ static PyObject* Sbk_EffectFunc_addUserPlane(PyObject* self, PyObject* args) // Overloaded function decisor - // 0: addUserPlane(std::string,std::vector) + // 0: addUserPlane(QString,QStringList) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX], (pyArgs[1])))) { - overloadId = 0; // addUserPlane(std::string,std::vector) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArgs[1])))) { + overloadId = 0; // addUserPlane(QString,QStringList) } // Function signature not found. @@ -78,13 +77,13 @@ static PyObject* Sbk_EffectFunc_addUserPlane(PyObject* self, PyObject* args) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::vector cppArg1; + ::QStringList cppArg1 = ::QStringList(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // addUserPlane(std::string,std::vector) + // addUserPlane(QString,QStringList) bool cppResult = cppSelf->addUserPlane(cppArg0, cppArg1); pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); } @@ -97,7 +96,7 @@ static PyObject* Sbk_EffectFunc_addUserPlane(PyObject* self, PyObject* args) return pyResult; Sbk_EffectFunc_addUserPlane_TypeError: - const char* overloads[] = {"std::string, list", 0}; + const char* overloads[] = {"unicode, QStringList", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.Effect.addUserPlane", overloads); return 0; } @@ -668,8 +667,8 @@ static PyObject* Sbk_EffectFunc_getInputLabel(PyObject* self, PyObject* pyArg) if (!PyErr_Occurred()) { // getInputLabel(int) - std::string cppResult = cppSelf->getInputLabel(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = cppSelf->getInputLabel(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -699,8 +698,8 @@ static PyObject* Sbk_EffectFunc_getLabel(PyObject* self) if (!PyErr_Occurred()) { // getLabel()const - std::string cppResult = const_cast(cppSelf)->getLabel(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getLabel(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -750,9 +749,9 @@ static PyObject* Sbk_EffectFunc_getParam(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getParam(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getParam(std::string)const + // 0: getParam(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getParam(QString)const } // Function signature not found. @@ -760,11 +759,11 @@ static PyObject* Sbk_EffectFunc_getParam(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getParam(std::string)const + // getParam(QString)const Param * cppResult = const_cast(cppSelf)->getParam(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAM_IDX], cppResult); @@ -780,7 +779,7 @@ static PyObject* Sbk_EffectFunc_getParam(PyObject* self, PyObject* pyArg) return pyResult; Sbk_EffectFunc_getParam_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Effect.getParam", overloads); return 0; } @@ -865,8 +864,8 @@ static PyObject* Sbk_EffectFunc_getPluginID(PyObject* self) if (!PyErr_Occurred()) { // getPluginID()const - std::string cppResult = const_cast(cppSelf)->getPluginID(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getPluginID(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1040,8 +1039,8 @@ static PyObject* Sbk_EffectFunc_getScriptName(PyObject* self) if (!PyErr_Occurred()) { // getScriptName()const - std::string cppResult = const_cast(cppSelf)->getScriptName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getScriptName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1213,9 +1212,9 @@ static PyObject* Sbk_EffectFunc_setLabel(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setLabel(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setLabel(std::string) + // 0: setLabel(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setLabel(QString) } // Function signature not found. @@ -1223,11 +1222,11 @@ static PyObject* Sbk_EffectFunc_setLabel(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setLabel(std::string) + // setLabel(QString) // Begin code injection cppSelf->setLabel(cppArg0); @@ -1244,7 +1243,7 @@ static PyObject* Sbk_EffectFunc_setLabel(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_EffectFunc_setLabel_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Effect.setLabel", overloads); return 0; } @@ -1261,9 +1260,9 @@ static PyObject* Sbk_EffectFunc_setPagesOrder(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setPagesOrder(std::list) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], (pyArg)))) { - overloadId = 0; // setPagesOrder(std::list) + // 0: setPagesOrder(QStringList) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArg)))) { + overloadId = 0; // setPagesOrder(QStringList) } // Function signature not found. @@ -1271,11 +1270,11 @@ static PyObject* Sbk_EffectFunc_setPagesOrder(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::list cppArg0; + ::QStringList cppArg0 = ::QStringList(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setPagesOrder(std::list) + // setPagesOrder(QStringList) cppSelf->setPagesOrder(cppArg0); } } @@ -1286,7 +1285,7 @@ static PyObject* Sbk_EffectFunc_setPagesOrder(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_EffectFunc_setPagesOrder_TypeError: - const char* overloads[] = {"list", 0}; + const char* overloads[] = {"QStringList", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Effect.setPagesOrder", overloads); return 0; } @@ -1359,9 +1358,9 @@ static PyObject* Sbk_EffectFunc_setScriptName(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setScriptName(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setScriptName(std::string) + // 0: setScriptName(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setScriptName(QString) } // Function signature not found. @@ -1369,11 +1368,11 @@ static PyObject* Sbk_EffectFunc_setScriptName(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setScriptName(std::string) + // setScriptName(QString) // Begin code injection bool cppResult = cppSelf->setScriptName(cppArg0); @@ -1392,7 +1391,7 @@ static PyObject* Sbk_EffectFunc_setScriptName(PyObject* self, PyObject* pyArg) return pyResult; Sbk_EffectFunc_setScriptName_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Effect.setScriptName", overloads); return 0; } diff --git a/Engine/NatronEngine/group_wrapper.cpp b/Engine/NatronEngine/group_wrapper.cpp index cf87a124cf..d0a8773714 100644 --- a/Engine/NatronEngine/group_wrapper.cpp +++ b/Engine/NatronEngine/group_wrapper.cpp @@ -125,9 +125,9 @@ static PyObject* Sbk_GroupFunc_getNode(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getNode(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getNode(std::string)const + // 0: getNode(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getNode(QString)const } // Function signature not found. @@ -135,11 +135,11 @@ static PyObject* Sbk_GroupFunc_getNode(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getNode(std::string)const + // getNode(QString)const Effect * cppResult = const_cast(cppSelf)->getNode(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_EFFECT_IDX], cppResult); @@ -155,7 +155,7 @@ static PyObject* Sbk_GroupFunc_getNode(PyObject* self, PyObject* pyArg) return pyResult; Sbk_GroupFunc_getNode_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Group.getNode", overloads); return 0; } diff --git a/Engine/NatronEngine/imagelayer_wrapper.cpp b/Engine/NatronEngine/imagelayer_wrapper.cpp index f2535714b0..a079c38096 100644 --- a/Engine/NatronEngine/imagelayer_wrapper.cpp +++ b/Engine/NatronEngine/imagelayer_wrapper.cpp @@ -20,7 +20,6 @@ GCC_DIAG_UNUSED_LOCAL_TYPEDEFS_OFF // Extra includes NATRON_NAMESPACE_USING #include -#include @@ -51,12 +50,12 @@ Sbk_ImageLayer_Init(PyObject* self, PyObject* args, PyObject* kwds) // Overloaded function decisor // 0: ImageLayer(ImageLayer) - // 1: ImageLayer(std::string,std::string,std::vector) + // 1: ImageLayer(QString,QString,QStringList) if (numArgs == 3 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1]))) - && (pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX], (pyArgs[2])))) { - overloadId = 1; // ImageLayer(std::string,std::string,std::vector) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1]))) + && (pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArgs[2])))) { + overloadId = 1; // ImageLayer(QString,QString,QStringList) } else if (numArgs == 1 && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppReferenceConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], (pyArgs[0])))) { overloadId = 0; // ImageLayer(ImageLayer) @@ -71,7 +70,7 @@ Sbk_ImageLayer_Init(PyObject* self, PyObject* args, PyObject* kwds) { if (!Shiboken::Object::isValid(pyArgs[0])) return -1; - ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppArg0_local = ::ImageLayer(::QString(), ::QString(), ::QStringList()); ::ImageLayer* cppArg0 = &cppArg0_local; if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp[0])) pythonToCpp[0](pyArgs[0], &cppArg0_local); @@ -85,17 +84,17 @@ Sbk_ImageLayer_Init(PyObject* self, PyObject* args, PyObject* kwds) } break; } - case 1: // ImageLayer(const std::string & layerName, const std::string & componentsPrettyName, const std::vector & componentsName) + case 1: // ImageLayer(const QString & layerName, const QString & componentsPrettyName, const QStringList & componentsName) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); - ::std::vector cppArg2; + ::QStringList cppArg2 = ::QStringList(); pythonToCpp[2](pyArgs[2], &cppArg2); if (!PyErr_Occurred()) { - // ImageLayer(std::string,std::string,std::vector) + // ImageLayer(QString,QString,QStringList) cptr = new ::ImageLayer(cppArg0, cppArg1, cppArg2); } break; @@ -115,7 +114,7 @@ Sbk_ImageLayer_Init(PyObject* self, PyObject* args, PyObject* kwds) return 1; Sbk_ImageLayer_Init_TypeError: - const char* overloads[] = {"NatronEngine.ImageLayer", "std::string, std::string, list", 0}; + const char* overloads[] = {"NatronEngine.ImageLayer", "unicode, unicode, QStringList", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.ImageLayer", overloads); return -1; } @@ -176,8 +175,8 @@ static PyObject* Sbk_ImageLayerFunc_getComponentsNames(PyObject* self) if (!PyErr_Occurred()) { // getComponentsNames()const - const std::vector & cppResult = const_cast(cppSelf)->getComponentsNames(); - pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX], &cppResult); + const QStringList & cppResult = const_cast(cppSelf)->getComponentsNames(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], &cppResult); } } @@ -202,8 +201,8 @@ static PyObject* Sbk_ImageLayerFunc_getComponentsPrettyName(PyObject* self) if (!PyErr_Occurred()) { // getComponentsPrettyName()const - const std::string & cppResult = const_cast(cppSelf)->getComponentsPrettyName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + const QString & cppResult = const_cast(cppSelf)->getComponentsPrettyName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -297,7 +296,7 @@ static PyObject* Sbk_ImageLayerFunc_getHash(PyObject* self, PyObject* pyArg) { if (!Shiboken::Object::isValid(pyArg)) return 0; - ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppArg0_local = ::ImageLayer(::QString(), ::QString(), ::QStringList()); ::ImageLayer* cppArg0 = &cppArg0_local; if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp)) pythonToCpp(pyArg, &cppArg0_local); @@ -338,8 +337,8 @@ static PyObject* Sbk_ImageLayerFunc_getLayerName(PyObject* self) if (!PyErr_Occurred()) { // getLayerName()const - const std::string & cppResult = const_cast(cppSelf)->getLayerName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + const QString & cppResult = const_cast(cppSelf)->getLayerName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -515,7 +514,7 @@ static PyObject* Sbk_ImageLayer_richcompare(PyObject* self, PyObject* pyArg, int // operator!=(const ImageLayer & other) const if (!Shiboken::Object::isValid(pyArg)) return 0; - ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppArg0_local = ::ImageLayer(::QString(), ::QString(), ::QStringList()); ::ImageLayer* cppArg0 = &cppArg0_local; if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp)) pythonToCpp(pyArg, &cppArg0_local); @@ -535,7 +534,7 @@ static PyObject* Sbk_ImageLayer_richcompare(PyObject* self, PyObject* pyArg, int // operator<(const ImageLayer & other) const if (!Shiboken::Object::isValid(pyArg)) return 0; - ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppArg0_local = ::ImageLayer(::QString(), ::QString(), ::QStringList()); ::ImageLayer* cppArg0 = &cppArg0_local; if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp)) pythonToCpp(pyArg, &cppArg0_local); @@ -554,7 +553,7 @@ static PyObject* Sbk_ImageLayer_richcompare(PyObject* self, PyObject* pyArg, int // operator==(const ImageLayer & other) const if (!Shiboken::Object::isValid(pyArg)) return 0; - ::ImageLayer cppArg0_local = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppArg0_local = ::ImageLayer(::QString(), ::QString(), ::QStringList()); ::ImageLayer* cppArg0 = &cppArg0_local; if (Shiboken::Conversions::isImplicitConversion((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], pythonToCpp)) pythonToCpp(pyArg, &cppArg0_local); diff --git a/Engine/NatronEngine/itembase_wrapper.cpp b/Engine/NatronEngine/itembase_wrapper.cpp index a90a6de417..f8b4fc0bee 100644 --- a/Engine/NatronEngine/itembase_wrapper.cpp +++ b/Engine/NatronEngine/itembase_wrapper.cpp @@ -52,8 +52,8 @@ static PyObject* Sbk_ItemBaseFunc_getLabel(PyObject* self) if (!PyErr_Occurred()) { // getLabel()const - std::string cppResult = const_cast(cppSelf)->getLabel(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getLabel(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -129,9 +129,9 @@ static PyObject* Sbk_ItemBaseFunc_getParam(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getParam(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getParam(std::string)const + // 0: getParam(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getParam(QString)const } // Function signature not found. @@ -139,11 +139,11 @@ static PyObject* Sbk_ItemBaseFunc_getParam(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getParam(std::string)const + // getParam(QString)const Param * cppResult = const_cast(cppSelf)->getParam(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAM_IDX], cppResult); } @@ -156,7 +156,7 @@ static PyObject* Sbk_ItemBaseFunc_getParam(PyObject* self, PyObject* pyArg) return pyResult; Sbk_ItemBaseFunc_getParam_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.ItemBase.getParam", overloads); return 0; } @@ -204,8 +204,8 @@ static PyObject* Sbk_ItemBaseFunc_getScriptName(PyObject* self) if (!PyErr_Occurred()) { // getScriptName()const - std::string cppResult = const_cast(cppSelf)->getScriptName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getScriptName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -254,9 +254,9 @@ static PyObject* Sbk_ItemBaseFunc_setLabel(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setLabel(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setLabel(std::string) + // 0: setLabel(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setLabel(QString) } // Function signature not found. @@ -264,11 +264,11 @@ static PyObject* Sbk_ItemBaseFunc_setLabel(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setLabel(std::string) + // setLabel(QString) // Begin code injection cppSelf->setLabel(cppArg0); @@ -285,7 +285,7 @@ static PyObject* Sbk_ItemBaseFunc_setLabel(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_ItemBaseFunc_setLabel_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.ItemBase.setLabel", overloads); return 0; } @@ -345,9 +345,9 @@ static PyObject* Sbk_ItemBaseFunc_setScriptName(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setScriptName(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setScriptName(std::string) + // 0: setScriptName(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setScriptName(QString) } // Function signature not found. @@ -355,11 +355,11 @@ static PyObject* Sbk_ItemBaseFunc_setScriptName(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setScriptName(std::string) + // setScriptName(QString) // Begin code injection bool cppResult = cppSelf->setScriptName(cppArg0); @@ -378,7 +378,7 @@ static PyObject* Sbk_ItemBaseFunc_setScriptName(PyObject* self, PyObject* pyArg) return pyResult; Sbk_ItemBaseFunc_setScriptName_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.ItemBase.setScriptName", overloads); return 0; } diff --git a/Engine/NatronEngine/natronengine_module_wrapper.cpp b/Engine/NatronEngine/natronengine_module_wrapper.cpp index 942001f608..3bb5d611f0 100644 --- a/Engine/NatronEngine/natronengine_module_wrapper.cpp +++ b/Engine/NatronEngine/natronengine_module_wrapper.cpp @@ -47,8 +47,13 @@ void init_ImageLayer(PyObject* module); void init_UserParamHolder(PyObject* module); void init_Effect(PyObject* module); void init_Param(PyObject* module); -void init_SeparatorParam(PyObject* module); void init_AnimatedParam(PyObject* module); +void init_BooleanParam(PyObject* module); +void init_StringParamBase(PyObject* module); +void init_StringParam(PyObject* module); +void init_FileParam(PyObject* module); +void init_OutputFileParam(PyObject* module); +void init_PathParam(PyObject* module); void init_IntParam(PyObject* module); void init_Int2DParam(PyObject* module); void init_Int3DParam(PyObject* module); @@ -57,23 +62,18 @@ void init_Double2DParam(PyObject* module); void init_Double3DParam(PyObject* module); void init_ColorParam(PyObject* module); void init_ChoiceParam(PyObject* module); -void init_BooleanParam(PyObject* module); -void init_StringParamBase(PyObject* module); -void init_StringParam(PyObject* module); -void init_FileParam(PyObject* module); -void init_OutputFileParam(PyObject* module); -void init_PathParam(PyObject* module); +void init_ButtonParam(PyObject* module); +void init_SeparatorParam(PyObject* module); void init_GroupParam(PyObject* module); -void init_ParametricParam(PyObject* module); void init_PageParam(PyObject* module); -void init_ButtonParam(PyObject* module); -void init_RectI(PyObject* module); -void init_RectD(PyObject* module); +void init_ParametricParam(PyObject* module); void init_Int2DTuple(PyObject* module); void init_Int3DTuple(PyObject* module); void init_Double2DTuple(PyObject* module); void init_Double3DTuple(PyObject* module); void init_ColorTuple(PyObject* module); +void init_RectI(PyObject* module); +void init_RectD(PyObject* module); void init_NATRON_NAMESPACE(PyObject* module); // Required modules' type and converter arrays. @@ -142,96 +142,60 @@ static PythonToCppFunc is_std_vector_RectI__PythonToCpp_std_vector_RectI__Conver return 0; } -// C++ to Python conversion for type 'std::vector'. -static PyObject* std_vector_std_string__CppToPython_std_vector_std_string_(const void* cppIn) { - ::std::vector& cppInRef = *((::std::vector*)cppIn); - - // TEMPLATE - stdVectorToPyList - START - ::std::vector::size_type vectorSize = cppInRef.size(); - PyObject* pyOut = PyList_New((int) vectorSize); - for (::std::vector::size_type idx = 0; idx < vectorSize; ++idx) { - ::std::string cppItem(cppInRef[idx]); - PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppItem)); - } - return pyOut; - // TEMPLATE - stdVectorToPyList - END - -} -static void std_vector_std_string__PythonToCpp_std_vector_std_string_(PyObject* pyIn, void* cppOut) { - ::std::vector& cppOutRef = *((::std::vector*)cppOut); - - // TEMPLATE - pySeqToStdVector - START - int vectorSize = PySequence_Size(pyIn); - cppOutRef.reserve(vectorSize); - for (int idx = 0; idx < vectorSize; ++idx) { - Shiboken::AutoDecRef pyItem(PySequence_GetItem(pyIn, idx)); - ::std::string cppItem; - Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), pyItem, &(cppItem)); - cppOutRef.push_back(cppItem); - } - // TEMPLATE - pySeqToStdVector - END - -} -static PythonToCppFunc is_std_vector_std_string__PythonToCpp_std_vector_std_string__Convertible(PyObject* pyIn) { - if (Shiboken::Conversions::convertibleSequenceTypes(Shiboken::Conversions::PrimitiveTypeConverter(), pyIn)) - return std_vector_std_string__PythonToCpp_std_vector_std_string_; - return 0; -} - -// C++ to Python conversion for type 'std::pair'. -static PyObject* std_pair_std_string_std_string__CppToPython_std_pair_std_string_std_string_(const void* cppIn) { - ::std::pair& cppInRef = *((::std::pair*)cppIn); +// C++ to Python conversion for type 'std::pair'. +static PyObject* std_pair_QString_QString__CppToPython_std_pair_QString_QString_(const void* cppIn) { + ::std::pair& cppInRef = *((::std::pair*)cppIn); PyObject* pyOut = PyTuple_New(2); - PyTuple_SET_ITEM(pyOut, 0, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppInRef.first)); - PyTuple_SET_ITEM(pyOut, 1, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppInRef.second)); + PyTuple_SET_ITEM(pyOut, 0, Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppInRef.first)); + PyTuple_SET_ITEM(pyOut, 1, Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppInRef.second)); return pyOut; } -static void std_pair_std_string_std_string__PythonToCpp_std_pair_std_string_std_string_(PyObject* pyIn, void* cppOut) { - ::std::pair& cppOutRef = *((::std::pair*)cppOut); +static void std_pair_QString_QString__PythonToCpp_std_pair_QString_QString_(PyObject* pyIn, void* cppOut) { + ::std::pair& cppOutRef = *((::std::pair*)cppOut); - Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), PySequence_Fast_GET_ITEM(pyIn, 0), &(cppOutRef.first)); - Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), PySequence_Fast_GET_ITEM(pyIn, 1), &(cppOutRef.second)); + Shiboken::Conversions::pythonToCppCopy(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], PySequence_Fast_GET_ITEM(pyIn, 0), &(cppOutRef.first)); + Shiboken::Conversions::pythonToCppCopy(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], PySequence_Fast_GET_ITEM(pyIn, 1), &(cppOutRef.second)); } -static PythonToCppFunc is_std_pair_std_string_std_string__PythonToCpp_std_pair_std_string_std_string__Convertible(PyObject* pyIn) { - if (Shiboken::Conversions::convertiblePairTypes(Shiboken::Conversions::PrimitiveTypeConverter(), false, Shiboken::Conversions::PrimitiveTypeConverter(), false, pyIn)) - return std_pair_std_string_std_string__PythonToCpp_std_pair_std_string_std_string_; +static PythonToCppFunc is_std_pair_QString_QString__PythonToCpp_std_pair_QString_QString__Convertible(PyObject* pyIn) { + if (Shiboken::Conversions::convertiblePairTypes(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], false, SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], false, pyIn)) + return std_pair_QString_QString__PythonToCpp_std_pair_QString_QString_; return 0; } -// C++ to Python conversion for type 'const std::list > &'. -static PyObject* conststd_list_std_pair_std_string_std_string__REF_CppToPython_conststd_list_std_pair_std_string_std_string__REF(const void* cppIn) { - ::std::list >& cppInRef = *((::std::list >*)cppIn); +// C++ to Python conversion for type 'const std::list > &'. +static PyObject* conststd_list_std_pair_QString_QString__REF_CppToPython_conststd_list_std_pair_QString_QString__REF(const void* cppIn) { + ::std::list >& cppInRef = *((::std::list >*)cppIn); // TEMPLATE - stdListToPyList - START PyObject* pyOut = PyList_New((int) cppInRef.size()); - ::std::list >::const_iterator it = cppInRef.begin(); + ::std::list >::const_iterator it = cppInRef.begin(); for (int idx = 0; it != cppInRef.end(); ++it, ++idx) { - ::std::pair cppItem(*it); - PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX], &cppItem)); + ::std::pair cppItem(*it); + PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX], &cppItem)); } return pyOut; // TEMPLATE - stdListToPyList - END } -static void conststd_list_std_pair_std_string_std_string__REF_PythonToCpp_conststd_list_std_pair_std_string_std_string__REF(PyObject* pyIn, void* cppOut) { - ::std::list >& cppOutRef = *((::std::list >*)cppOut); +static void conststd_list_std_pair_QString_QString__REF_PythonToCpp_conststd_list_std_pair_QString_QString__REF(PyObject* pyIn, void* cppOut) { + ::std::list >& cppOutRef = *((::std::list >*)cppOut); // TEMPLATE - pyListToStdList - START for (int i = 0; i < PySequence_Size(pyIn); i++) { Shiboken::AutoDecRef pyItem(PySequence_GetItem(pyIn, i)); - ::std::pair cppItem = ::std::pair(); - Shiboken::Conversions::pythonToCppCopy(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX], pyItem, &(cppItem)); + ::std::pair cppItem = ::std::pair(); + Shiboken::Conversions::pythonToCppCopy(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX], pyItem, &(cppItem)); cppOutRef.push_back(cppItem); } // TEMPLATE - pyListToStdList - END } -static PythonToCppFunc is_conststd_list_std_pair_std_string_std_string__REF_PythonToCpp_conststd_list_std_pair_std_string_std_string__REF_Convertible(PyObject* pyIn) { - if (Shiboken::Conversions::convertibleSequenceTypes(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX], pyIn)) - return conststd_list_std_pair_std_string_std_string__REF_PythonToCpp_conststd_list_std_pair_std_string_std_string__REF; +static PythonToCppFunc is_conststd_list_std_pair_QString_QString__REF_PythonToCpp_conststd_list_std_pair_QString_QString__REF_Convertible(PyObject* pyIn) { + if (Shiboken::Conversions::convertibleSequenceTypes(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX], pyIn)) + return conststd_list_std_pair_QString_QString__REF_PythonToCpp_conststd_list_std_pair_QString_QString__REF; return 0; } @@ -337,37 +301,37 @@ static PythonToCppFunc is_std_list_EffectPTR__PythonToCpp_std_list_EffectPTR__Co return 0; } -// C++ to Python conversion for type 'std::list'. -static PyObject* std_list_std_string__CppToPython_std_list_std_string_(const void* cppIn) { - ::std::list& cppInRef = *((::std::list*)cppIn); +// C++ to Python conversion for type 'std::list'. +static PyObject* std_list_QString__CppToPython_std_list_QString_(const void* cppIn) { + ::std::list& cppInRef = *((::std::list*)cppIn); // TEMPLATE - stdListToPyList - START PyObject* pyOut = PyList_New((int) cppInRef.size()); - ::std::list::const_iterator it = cppInRef.begin(); + ::std::list::const_iterator it = cppInRef.begin(); for (int idx = 0; it != cppInRef.end(); ++it, ++idx) { - ::std::string cppItem(*it); - PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppItem)); + ::QString cppItem(*it); + PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppItem)); } return pyOut; // TEMPLATE - stdListToPyList - END } -static void std_list_std_string__PythonToCpp_std_list_std_string_(PyObject* pyIn, void* cppOut) { - ::std::list& cppOutRef = *((::std::list*)cppOut); +static void std_list_QString__PythonToCpp_std_list_QString_(PyObject* pyIn, void* cppOut) { + ::std::list& cppOutRef = *((::std::list*)cppOut); // TEMPLATE - pyListToStdList - START for (int i = 0; i < PySequence_Size(pyIn); i++) { Shiboken::AutoDecRef pyItem(PySequence_GetItem(pyIn, i)); - ::std::string cppItem; - Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), pyItem, &(cppItem)); + ::QString cppItem = ::QString(); + Shiboken::Conversions::pythonToCppCopy(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], pyItem, &(cppItem)); cppOutRef.push_back(cppItem); } // TEMPLATE - pyListToStdList - END } -static PythonToCppFunc is_std_list_std_string__PythonToCpp_std_list_std_string__Convertible(PyObject* pyIn) { - if (Shiboken::Conversions::convertibleSequenceTypes(Shiboken::Conversions::PrimitiveTypeConverter(), pyIn)) - return std_list_std_string__PythonToCpp_std_list_std_string_; +static PythonToCppFunc is_std_list_QString__PythonToCpp_std_list_QString__Convertible(PyObject* pyIn) { + if (Shiboken::Conversions::convertibleSequenceTypes(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], pyIn)) + return std_list_QString__PythonToCpp_std_list_QString_; return 0; } @@ -433,7 +397,7 @@ static void std_map_ImageLayer_EffectPTR__PythonToCpp_std_map_ImageLayer_EffectP PyObject* value; Py_ssize_t pos = 0; while (PyDict_Next(pyIn, &pos, &key, &value)) { - ::ImageLayer cppKey = ::ImageLayer(::std::string(), ::std::string(), ::std::vector()); + ::ImageLayer cppKey = ::ImageLayer(::QString(), ::QString(), ::QStringList()); Shiboken::Conversions::pythonToCppCopy((SbkObjectType*)SbkNatronEngineTypes[SBK_IMAGELAYER_IDX], key, &(cppKey)); ::Effect* cppValue = ((::Effect*)0); Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkNatronEngineTypes[SBK_EFFECT_IDX], value, &(cppValue)); @@ -618,8 +582,13 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) init_UserParamHolder(module); init_Effect(module); init_Param(module); - init_SeparatorParam(module); init_AnimatedParam(module); + init_BooleanParam(module); + init_StringParamBase(module); + init_StringParam(module); + init_FileParam(module); + init_OutputFileParam(module); + init_PathParam(module); init_IntParam(module); init_Int2DParam(module); init_Int3DParam(module); @@ -628,23 +597,18 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) init_Double3DParam(module); init_ColorParam(module); init_ChoiceParam(module); - init_BooleanParam(module); - init_StringParamBase(module); - init_StringParam(module); - init_FileParam(module); - init_OutputFileParam(module); - init_PathParam(module); + init_ButtonParam(module); + init_SeparatorParam(module); init_GroupParam(module); - init_ParametricParam(module); init_PageParam(module); - init_ButtonParam(module); - init_RectI(module); - init_RectD(module); + init_ParametricParam(module); init_Int2DTuple(module); init_Int3DTuple(module); init_Double2DTuple(module); init_Double3DTuple(module); init_ColorTuple(module); + init_RectI(module); + init_RectD(module); init_NATRON_NAMESPACE(module); // Register converter for type 'NatronEngine.std::size_t'. @@ -663,27 +627,20 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) std_vector_RectI__PythonToCpp_std_vector_RectI_, is_std_vector_RectI__PythonToCpp_std_vector_RectI__Convertible); - // Register converter for type 'std::vector'. - SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, std_vector_std_string__CppToPython_std_vector_std_string_); - Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX], "std::vector"); - Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX], - std_vector_std_string__PythonToCpp_std_vector_std_string_, - is_std_vector_std_string__PythonToCpp_std_vector_std_string__Convertible); - - // Register converter for type 'std::pair'. - SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, std_pair_std_string_std_string__CppToPython_std_pair_std_string_std_string_); - Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX], "std::pair"); - Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX], - std_pair_std_string_std_string__PythonToCpp_std_pair_std_string_std_string_, - is_std_pair_std_string_std_string__PythonToCpp_std_pair_std_string_std_string__Convertible); - - // Register converter for type 'const std::list>&'. - SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_STD_STRING_STD_STRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, conststd_list_std_pair_std_string_std_string__REF_CppToPython_conststd_list_std_pair_std_string_std_string__REF); - Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_STD_STRING_STD_STRING_IDX], "const std::list>&"); - Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_STD_STRING_STD_STRING_IDX], "std::list>"); - Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_STD_STRING_STD_STRING_IDX], - conststd_list_std_pair_std_string_std_string__REF_PythonToCpp_conststd_list_std_pair_std_string_std_string__REF, - is_conststd_list_std_pair_std_string_std_string__REF_PythonToCpp_conststd_list_std_pair_std_string_std_string__REF_Convertible); + // Register converter for type 'std::pair'. + SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, std_pair_QString_QString__CppToPython_std_pair_QString_QString_); + Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX], "std::pair"); + Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX], + std_pair_QString_QString__PythonToCpp_std_pair_QString_QString_, + is_std_pair_QString_QString__PythonToCpp_std_pair_QString_QString__Convertible); + + // Register converter for type 'const std::list>&'. + SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_QSTRING_QSTRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, conststd_list_std_pair_QString_QString__REF_CppToPython_conststd_list_std_pair_QString_QString__REF); + Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_QSTRING_QSTRING_IDX], "const std::list>&"); + Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_QSTRING_QSTRING_IDX], "std::list>"); + Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_PAIR_QSTRING_QSTRING_IDX], + conststd_list_std_pair_QString_QString__REF_PythonToCpp_conststd_list_std_pair_QString_QString__REF, + is_conststd_list_std_pair_QString_QString__REF_PythonToCpp_conststd_list_std_pair_QString_QString__REF_Convertible); // Register converter for type 'std::list'. SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_ITEMBASEPTR_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, std_list_ItemBasePTR__CppToPython_std_list_ItemBasePTR_); @@ -706,12 +663,12 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronEngine) std_list_EffectPTR__PythonToCpp_std_list_EffectPTR_, is_std_list_EffectPTR__PythonToCpp_std_list_EffectPTR__Convertible); - // Register converter for type 'std::list'. - SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, std_list_std_string__CppToPython_std_list_std_string_); - Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], "std::list"); - Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], - std_list_std_string__PythonToCpp_std_list_std_string_, - is_std_list_std_string__PythonToCpp_std_list_std_string__Convertible); + // Register converter for type 'std::list'. + SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_QSTRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, std_list_QString__CppToPython_std_list_QString_); + Shiboken::Conversions::registerConverterName(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_QSTRING_IDX], "std::list"); + Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_QSTRING_IDX], + std_list_QString__PythonToCpp_std_list_QString_, + is_std_list_QString__PythonToCpp_std_list_QString__Convertible); // Register converter for type 'const std::list&'. SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_INT_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, conststd_list_int_REF_CppToPython_conststd_list_int_REF); diff --git a/Engine/NatronEngine/natronengine_python.h b/Engine/NatronEngine/natronengine_python.h index 0484f58b1c..eaaa5a8700 100644 --- a/Engine/NatronEngine/natronengine_python.h +++ b/Engine/NatronEngine/natronengine_python.h @@ -71,17 +71,25 @@ CLANG_DIAG_ON(uninitialized) #define SBK_NATRON_NAMESPACE_PLAYBACKMODEENUM_IDX 36 #define SBK_NATRON_NAMESPACE_PIXMAPENUM_IDX 35 #define SBK_NATRON_NAMESPACE_VIEWERCOLORSPACEENUM_IDX 40 +#define SBK_RECTD_IDX 49 +#define SBK_RECTI_IDX 50 #define SBK_COLORTUPLE_IDX 9 #define SBK_DOUBLE3DTUPLE_IDX 13 #define SBK_DOUBLE2DTUPLE_IDX 11 #define SBK_INT3DTUPLE_IDX 23 #define SBK_INT2DTUPLE_IDX 21 -#define SBK_RECTD_IDX 49 -#define SBK_RECTI_IDX 50 #define SBK_PARAM_IDX 44 -#define SBK_BUTTONPARAM_IDX 6 #define SBK_PARAMETRICPARAM_IDX 45 +#define SBK_PAGEPARAM_IDX 43 +#define SBK_GROUPPARAM_IDX 18 +#define SBK_SEPARATORPARAM_IDX 52 +#define SBK_BUTTONPARAM_IDX 6 #define SBK_ANIMATEDPARAM_IDX 0 +#define SBK_CHOICEPARAM_IDX 7 +#define SBK_COLORPARAM_IDX 8 +#define SBK_DOUBLEPARAM_IDX 14 +#define SBK_DOUBLE2DPARAM_IDX 10 +#define SBK_DOUBLE3DPARAM_IDX 12 #define SBK_INTPARAM_IDX 24 #define SBK_INT2DPARAM_IDX 20 #define SBK_INT3DPARAM_IDX 22 @@ -92,14 +100,6 @@ CLANG_DIAG_ON(uninitialized) #define SBK_STRINGPARAM_IDX 53 #define SBK_STRINGPARAM_TYPEENUM_IDX 54 #define SBK_BOOLEANPARAM_IDX 5 -#define SBK_CHOICEPARAM_IDX 7 -#define SBK_COLORPARAM_IDX 8 -#define SBK_DOUBLEPARAM_IDX 14 -#define SBK_DOUBLE2DPARAM_IDX 10 -#define SBK_DOUBLE3DPARAM_IDX 12 -#define SBK_PAGEPARAM_IDX 43 -#define SBK_GROUPPARAM_IDX 18 -#define SBK_SEPARATORPARAM_IDX 52 #define SBK_USERPARAMHOLDER_IDX 56 #define SBK_IMAGELAYER_IDX 19 #define SBK_ROTO_IDX 51 @@ -121,15 +121,15 @@ extern PyTypeObject** SbkNatronEngineTypes; extern SbkConverter** SbkNatronEngineTypeConverters; // Converter indices -#define SBK_STD_SIZE_T_IDX 0 -#define SBK_NATRONENGINE_STD_VECTOR_RECTI_IDX 1 // std::vector -#define SBK_NATRONENGINE_STD_VECTOR_STD_STRING_IDX 2 // std::vector -#define SBK_NATRONENGINE_STD_PAIR_STD_STRING_STD_STRING_IDX 3 // std::pair -#define SBK_NATRONENGINE_STD_LIST_STD_PAIR_STD_STRING_STD_STRING_IDX 4 // const std::list > & +#define SBK_STD_STRING_IDX 0 +#define SBK_STD_SIZE_T_IDX 1 +#define SBK_NATRONENGINE_STD_VECTOR_RECTI_IDX 2 // std::vector +#define SBK_NATRONENGINE_STD_PAIR_QSTRING_QSTRING_IDX 3 // std::pair +#define SBK_NATRONENGINE_STD_LIST_STD_PAIR_QSTRING_QSTRING_IDX 4 // const std::list > & #define SBK_NATRONENGINE_STD_LIST_ITEMBASEPTR_IDX 5 // std::list #define SBK_NATRONENGINE_STD_LIST_PARAMPTR_IDX 6 // std::list #define SBK_NATRONENGINE_STD_LIST_EFFECTPTR_IDX 7 // std::list -#define SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX 8 // std::list +#define SBK_NATRONENGINE_STD_LIST_QSTRING_IDX 8 // std::list #define SBK_NATRONENGINE_STD_LIST_INT_IDX 9 // const std::list & #define SBK_NATRONENGINE_STD_MAP_IMAGELAYER_EFFECTPTR_IDX 10 // std::map #define SBK_NATRONENGINE_QLIST_QVARIANT_IDX 11 // QList @@ -158,17 +158,25 @@ template<> inline PyTypeObject* SbkType inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_NATRON_NAMESPACE_PLAYBACKMODEENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_NATRON_NAMESPACE_PIXMAPENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_NATRON_NAMESPACE_VIEWERCOLORSPACEENUM_IDX]; } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTD_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTI_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_COLORTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE3DTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE2DTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT3DTUPLE_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT2DTUPLE_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTD_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_RECTI_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_BUTTONPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PARAMETRICPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PAGEPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_GROUPPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_SEPARATORPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_BUTTONPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_ANIMATEDPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_CHOICEPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_COLORPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLEPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE2DPARAM_IDX]); } +template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE3DPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INTPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT2DPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_INT3DPARAM_IDX]); } @@ -179,14 +187,6 @@ template<> inline PyTypeObject* SbkType() { return template<> inline PyTypeObject* SbkType() { return SbkNatronEngineTypes[SBK_STRINGPARAM_TYPEENUM_IDX]; } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_STRINGPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_BOOLEANPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_CHOICEPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_COLORPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLEPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE2DPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_DOUBLE3DPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_PAGEPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_GROUPPARAM_IDX]); } -template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_SEPARATORPARAM_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_USERPARAMHOLDER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_IMAGELAYER_IDX]); } template<> inline PyTypeObject* SbkType() { return reinterpret_cast(SbkNatronEngineTypes[SBK_ROTO_IDX]); } diff --git a/Engine/NatronEngine/param_wrapper.cpp b/Engine/NatronEngine/param_wrapper.cpp index efba7462b8..a8308f8bcf 100644 --- a/Engine/NatronEngine/param_wrapper.cpp +++ b/Engine/NatronEngine/param_wrapper.cpp @@ -347,8 +347,8 @@ static PyObject* Sbk_ParamFunc_getHelp(PyObject* self) if (!PyErr_Occurred()) { // getHelp()const - std::string cppResult = const_cast(cppSelf)->getHelp(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getHelp(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -522,8 +522,8 @@ static PyObject* Sbk_ParamFunc_getLabel(PyObject* self) if (!PyErr_Occurred()) { // getLabel()const - std::string cppResult = const_cast(cppSelf)->getLabel(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getLabel(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -603,8 +603,8 @@ static PyObject* Sbk_ParamFunc_getScriptName(PyObject* self) if (!PyErr_Occurred()) { // getScriptName()const - std::string cppResult = const_cast(cppSelf)->getScriptName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getScriptName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -629,8 +629,8 @@ static PyObject* Sbk_ParamFunc_getTypeName(PyObject* self) if (!PyErr_Occurred()) { // getTypeName()const - std::string cppResult = const_cast(cppSelf)->getTypeName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getTypeName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1153,9 +1153,9 @@ static PyObject* Sbk_ParamFunc_setHelp(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setHelp(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setHelp(std::string) + // 0: setHelp(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setHelp(QString) } // Function signature not found. @@ -1163,11 +1163,11 @@ static PyObject* Sbk_ParamFunc_setHelp(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setHelp(std::string) + // setHelp(QString) cppSelf->setHelp(cppArg0); } } @@ -1178,7 +1178,7 @@ static PyObject* Sbk_ParamFunc_setHelp(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_ParamFunc_setHelp_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Param.setHelp", overloads); return 0; } diff --git a/Engine/NatronEngine/pycoreapplication_wrapper.cpp b/Engine/NatronEngine/pycoreapplication_wrapper.cpp index 7c137b8ffe..b47c1f5056 100644 --- a/Engine/NatronEngine/pycoreapplication_wrapper.cpp +++ b/Engine/NatronEngine/pycoreapplication_wrapper.cpp @@ -20,7 +20,6 @@ GCC_DIAG_UNUSED_LOCAL_TYPEDEFS_OFF // Extra includes NATRON_NAMESPACE_USING #include -#include // Native --------------------------------------------------------- @@ -84,9 +83,9 @@ static PyObject* Sbk_PyCoreApplicationFunc_appendToNatronPath(PyObject* self, Py SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: appendToNatronPath(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // appendToNatronPath(std::string) + // 0: appendToNatronPath(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // appendToNatronPath(QString) } // Function signature not found. @@ -94,11 +93,11 @@ static PyObject* Sbk_PyCoreApplicationFunc_appendToNatronPath(PyObject* self, Py // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // appendToNatronPath(std::string) + // appendToNatronPath(QString) cppSelf->appendToNatronPath(cppArg0); } } @@ -109,7 +108,7 @@ static PyObject* Sbk_PyCoreApplicationFunc_appendToNatronPath(PyObject* self, Py Py_RETURN_NONE; Sbk_PyCoreApplicationFunc_appendToNatronPath_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.PyCoreApplication.appendToNatronPath", overloads); return 0; } @@ -231,8 +230,8 @@ static PyObject* Sbk_PyCoreApplicationFunc_getNatronDevelopmentStatus(PyObject* if (!PyErr_Occurred()) { // getNatronDevelopmentStatus()const - std::string cppResult = const_cast(cppSelf)->getNatronDevelopmentStatus(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getNatronDevelopmentStatus(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -257,8 +256,8 @@ static PyObject* Sbk_PyCoreApplicationFunc_getNatronPath(PyObject* self) if (!PyErr_Occurred()) { // getNatronPath()const - std::list cppResult = const_cast(cppSelf)->getNatronPath(); - pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], &cppResult); + QStringList cppResult = const_cast(cppSelf)->getNatronPath(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], &cppResult); } } @@ -387,8 +386,8 @@ static PyObject* Sbk_PyCoreApplicationFunc_getNatronVersionString(PyObject* self if (!PyErr_Occurred()) { // getNatronVersionString()const - std::string cppResult = const_cast(cppSelf)->getNatronVersionString(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getNatronVersionString(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -474,12 +473,12 @@ static PyObject* Sbk_PyCoreApplicationFunc_getPluginIDs(PyObject* self, PyObject // Overloaded function decisor // 0: getPluginIDs()const - // 1: getPluginIDs(std::string)const + // 1: getPluginIDs(QString)const if (numArgs == 0) { overloadId = 0; // getPluginIDs()const } else if (numArgs == 1 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { - overloadId = 1; // getPluginIDs(std::string)const + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { + overloadId = 1; // getPluginIDs(QString)const } // Function signature not found. @@ -492,20 +491,20 @@ static PyObject* Sbk_PyCoreApplicationFunc_getPluginIDs(PyObject* self, PyObject if (!PyErr_Occurred()) { // getPluginIDs()const - std::list cppResult = const_cast(cppSelf)->getPluginIDs(); - pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], &cppResult); + QStringList cppResult = const_cast(cppSelf)->getPluginIDs(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], &cppResult); } break; } - case 1: // getPluginIDs(const std::string & filter) const + case 1: // getPluginIDs(const QString & filter) const { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); if (!PyErr_Occurred()) { - // getPluginIDs(std::string)const - std::list cppResult = const_cast(cppSelf)->getPluginIDs(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(SbkNatronEngineTypeConverters[SBK_NATRONENGINE_STD_LIST_STD_STRING_IDX], &cppResult); + // getPluginIDs(QString)const + QStringList cppResult = const_cast(cppSelf)->getPluginIDs(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], &cppResult); } break; } @@ -518,7 +517,7 @@ static PyObject* Sbk_PyCoreApplicationFunc_getPluginIDs(PyObject* self, PyObject return pyResult; Sbk_PyCoreApplicationFunc_getPluginIDs_TypeError: - const char* overloads[] = {"", "std::string", 0}; + const char* overloads[] = {"", "unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.PyCoreApplication.getPluginIDs", overloads); return 0; } @@ -720,9 +719,9 @@ static PyObject* Sbk_PyCoreApplicationFunc_setOnProjectCreatedCallback(PyObject* SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setOnProjectCreatedCallback(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setOnProjectCreatedCallback(std::string) + // 0: setOnProjectCreatedCallback(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setOnProjectCreatedCallback(QString) } // Function signature not found. @@ -730,11 +729,11 @@ static PyObject* Sbk_PyCoreApplicationFunc_setOnProjectCreatedCallback(PyObject* // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setOnProjectCreatedCallback(std::string) + // setOnProjectCreatedCallback(QString) cppSelf->setOnProjectCreatedCallback(cppArg0); } } @@ -745,7 +744,7 @@ static PyObject* Sbk_PyCoreApplicationFunc_setOnProjectCreatedCallback(PyObject* Py_RETURN_NONE; Sbk_PyCoreApplicationFunc_setOnProjectCreatedCallback_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.PyCoreApplication.setOnProjectCreatedCallback", overloads); return 0; } @@ -762,9 +761,9 @@ static PyObject* Sbk_PyCoreApplicationFunc_setOnProjectLoadedCallback(PyObject* SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setOnProjectLoadedCallback(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setOnProjectLoadedCallback(std::string) + // 0: setOnProjectLoadedCallback(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setOnProjectLoadedCallback(QString) } // Function signature not found. @@ -772,11 +771,11 @@ static PyObject* Sbk_PyCoreApplicationFunc_setOnProjectLoadedCallback(PyObject* // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setOnProjectLoadedCallback(std::string) + // setOnProjectLoadedCallback(QString) cppSelf->setOnProjectLoadedCallback(cppArg0); } } @@ -787,7 +786,7 @@ static PyObject* Sbk_PyCoreApplicationFunc_setOnProjectLoadedCallback(PyObject* Py_RETURN_NONE; Sbk_PyCoreApplicationFunc_setOnProjectLoadedCallback_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.PyCoreApplication.setOnProjectLoadedCallback", overloads); return 0; } diff --git a/Engine/NatronEngine/roto_wrapper.cpp b/Engine/NatronEngine/roto_wrapper.cpp index 966ab92c89..2b61945dbe 100644 --- a/Engine/NatronEngine/roto_wrapper.cpp +++ b/Engine/NatronEngine/roto_wrapper.cpp @@ -322,9 +322,9 @@ static PyObject* Sbk_RotoFunc_getItemByName(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getItemByName(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getItemByName(std::string)const + // 0: getItemByName(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getItemByName(QString)const } // Function signature not found. @@ -332,11 +332,11 @@ static PyObject* Sbk_RotoFunc_getItemByName(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getItemByName(std::string)const + // getItemByName(QString)const ItemBase * cppResult = const_cast(cppSelf)->getItemByName(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_ITEMBASE_IDX], cppResult); @@ -352,7 +352,7 @@ static PyObject* Sbk_RotoFunc_getItemByName(PyObject* self, PyObject* pyArg) return pyResult; Sbk_RotoFunc_getItemByName_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.Roto.getItemByName", overloads); return 0; } diff --git a/Engine/NatronEngine/stringparambase_wrapper.cpp b/Engine/NatronEngine/stringparambase_wrapper.cpp index a27d104075..ac79786d93 100644 --- a/Engine/NatronEngine/stringparambase_wrapper.cpp +++ b/Engine/NatronEngine/stringparambase_wrapper.cpp @@ -83,8 +83,8 @@ static PyObject* Sbk_StringParamBaseFunc_addAsDependencyOf(PyObject* self, PyObj if (!PyErr_Occurred()) { // addAsDependencyOf(int,Param*,int) - std::string cppResult = cppSelf->addAsDependencyOf(cppArg0, cppArg1, cppArg2); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = cppSelf->addAsDependencyOf(cppArg0, cppArg1, cppArg2); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -141,8 +141,8 @@ static PyObject* Sbk_StringParamBaseFunc_get(PyObject* self, PyObject* args) if (!PyErr_Occurred()) { // get()const - std::string cppResult = const_cast(cppSelf)->get(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->get(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } break; } @@ -153,8 +153,8 @@ static PyObject* Sbk_StringParamBaseFunc_get(PyObject* self, PyObject* args) if (!PyErr_Occurred()) { // get(double)const - std::string cppResult = const_cast(cppSelf)->get(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->get(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } break; } @@ -186,8 +186,8 @@ static PyObject* Sbk_StringParamBaseFunc_getDefaultValue(PyObject* self) if (!PyErr_Occurred()) { // getDefaultValue()const - std::string cppResult = const_cast(cppSelf)->getDefaultValue(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getDefaultValue(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -212,8 +212,8 @@ static PyObject* Sbk_StringParamBaseFunc_getValue(PyObject* self) if (!PyErr_Occurred()) { // getValue()const - std::string cppResult = const_cast(cppSelf)->getValue(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getValue(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -252,8 +252,8 @@ static PyObject* Sbk_StringParamBaseFunc_getValueAtTime(PyObject* self, PyObject if (!PyErr_Occurred()) { // getValueAtTime(double)const - std::string cppResult = const_cast(cppSelf)->getValueAtTime(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getValueAtTime(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -313,14 +313,14 @@ static PyObject* Sbk_StringParamBaseFunc_set(PyObject* self, PyObject* args) // Overloaded function decisor - // 0: set(std::string) - // 1: set(std::string,double) - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { + // 0: set(QString) + // 1: set(QString,double) + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // set(std::string) + overloadId = 0; // set(QString) } else if (numArgs == 2 && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 1; // set(std::string,double) + overloadId = 1; // set(QString,double) } } @@ -329,26 +329,26 @@ static PyObject* Sbk_StringParamBaseFunc_set(PyObject* self, PyObject* args) // Call function/method switch (overloadId) { - case 0: // set(const std::string & x) + case 0: // set(const QString & x) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); if (!PyErr_Occurred()) { - // set(std::string) + // set(QString) cppSelf->set(cppArg0); } break; } - case 1: // set(const std::string & x, double frame) + case 1: // set(const QString & x, double frame) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); double cppArg1; pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // set(std::string,double) + // set(QString,double) cppSelf->set(cppArg0, cppArg1); } break; @@ -361,7 +361,7 @@ static PyObject* Sbk_StringParamBaseFunc_set(PyObject* self, PyObject* args) Py_RETURN_NONE; Sbk_StringParamBaseFunc_set_TypeError: - const char* overloads[] = {"std::string", "std::string, float", 0}; + const char* overloads[] = {"unicode", "unicode, float", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.StringParamBase.set", overloads); return 0; } @@ -378,9 +378,9 @@ static PyObject* Sbk_StringParamBaseFunc_setDefaultValue(PyObject* self, PyObjec SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setDefaultValue(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setDefaultValue(std::string) + // 0: setDefaultValue(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setDefaultValue(QString) } // Function signature not found. @@ -388,11 +388,11 @@ static PyObject* Sbk_StringParamBaseFunc_setDefaultValue(PyObject* self, PyObjec // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setDefaultValue(std::string) + // setDefaultValue(QString) cppSelf->setDefaultValue(cppArg0); } } @@ -403,7 +403,7 @@ static PyObject* Sbk_StringParamBaseFunc_setDefaultValue(PyObject* self, PyObjec Py_RETURN_NONE; Sbk_StringParamBaseFunc_setDefaultValue_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.StringParamBase.setDefaultValue", overloads); return 0; } @@ -420,9 +420,9 @@ static PyObject* Sbk_StringParamBaseFunc_setValue(PyObject* self, PyObject* pyAr SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setValue(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setValue(std::string) + // 0: setValue(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setValue(QString) } // Function signature not found. @@ -430,11 +430,11 @@ static PyObject* Sbk_StringParamBaseFunc_setValue(PyObject* self, PyObject* pyAr // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setValue(std::string) + // setValue(QString) cppSelf->setValue(cppArg0); } } @@ -445,7 +445,7 @@ static PyObject* Sbk_StringParamBaseFunc_setValue(PyObject* self, PyObject* pyAr Py_RETURN_NONE; Sbk_StringParamBaseFunc_setValue_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronEngine.StringParamBase.setValue", overloads); return 0; } @@ -471,11 +471,11 @@ static PyObject* Sbk_StringParamBaseFunc_setValueAtTime(PyObject* self, PyObject // Overloaded function decisor - // 0: setValueAtTime(std::string,double) + // 0: setValueAtTime(QString,double) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // setValueAtTime(std::string,double) + overloadId = 0; // setValueAtTime(QString,double) } // Function signature not found. @@ -483,13 +483,13 @@ static PyObject* Sbk_StringParamBaseFunc_setValueAtTime(PyObject* self, PyObject // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); double cppArg1; pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // setValueAtTime(std::string,double) + // setValueAtTime(QString,double) cppSelf->setValueAtTime(cppArg0, cppArg1); } } @@ -500,7 +500,7 @@ static PyObject* Sbk_StringParamBaseFunc_setValueAtTime(PyObject* self, PyObject Py_RETURN_NONE; Sbk_StringParamBaseFunc_setValueAtTime_TypeError: - const char* overloads[] = {"std::string, float", 0}; + const char* overloads[] = {"unicode, float", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.StringParamBase.setValueAtTime", overloads); return 0; } diff --git a/Engine/NatronEngine/userparamholder_wrapper.cpp b/Engine/NatronEngine/userparamholder_wrapper.cpp index 9092b22c16..943e6638b0 100644 --- a/Engine/NatronEngine/userparamholder_wrapper.cpp +++ b/Engine/NatronEngine/userparamholder_wrapper.cpp @@ -93,11 +93,11 @@ static PyObject* Sbk_UserParamHolderFunc_createBooleanParam(PyObject* self, PyOb // Overloaded function decisor - // 0: createBooleanParam(std::string,std::string) + // 0: createBooleanParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createBooleanParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createBooleanParam(QString,QString) } // Function signature not found. @@ -105,13 +105,13 @@ static PyObject* Sbk_UserParamHolderFunc_createBooleanParam(PyObject* self, PyOb // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createBooleanParam(std::string,std::string) + // createBooleanParam(QString,QString) BooleanParam * cppResult = cppSelf->createBooleanParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_BOOLEANPARAM_IDX], cppResult); @@ -127,7 +127,7 @@ static PyObject* Sbk_UserParamHolderFunc_createBooleanParam(PyObject* self, PyOb return pyResult; Sbk_UserParamHolderFunc_createBooleanParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createBooleanParam", overloads); return 0; } @@ -154,11 +154,11 @@ static PyObject* Sbk_UserParamHolderFunc_createButtonParam(PyObject* self, PyObj // Overloaded function decisor - // 0: createButtonParam(std::string,std::string) + // 0: createButtonParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createButtonParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createButtonParam(QString,QString) } // Function signature not found. @@ -166,13 +166,13 @@ static PyObject* Sbk_UserParamHolderFunc_createButtonParam(PyObject* self, PyObj // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createButtonParam(std::string,std::string) + // createButtonParam(QString,QString) ButtonParam * cppResult = cppSelf->createButtonParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_BUTTONPARAM_IDX], cppResult); @@ -188,7 +188,7 @@ static PyObject* Sbk_UserParamHolderFunc_createButtonParam(PyObject* self, PyObj return pyResult; Sbk_UserParamHolderFunc_createButtonParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createButtonParam", overloads); return 0; } @@ -215,11 +215,11 @@ static PyObject* Sbk_UserParamHolderFunc_createChoiceParam(PyObject* self, PyObj // Overloaded function decisor - // 0: createChoiceParam(std::string,std::string) + // 0: createChoiceParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createChoiceParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createChoiceParam(QString,QString) } // Function signature not found. @@ -227,13 +227,13 @@ static PyObject* Sbk_UserParamHolderFunc_createChoiceParam(PyObject* self, PyObj // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createChoiceParam(std::string,std::string) + // createChoiceParam(QString,QString) ChoiceParam * cppResult = cppSelf->createChoiceParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_CHOICEPARAM_IDX], cppResult); @@ -249,7 +249,7 @@ static PyObject* Sbk_UserParamHolderFunc_createChoiceParam(PyObject* self, PyObj return pyResult; Sbk_UserParamHolderFunc_createChoiceParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createChoiceParam", overloads); return 0; } @@ -276,12 +276,12 @@ static PyObject* Sbk_UserParamHolderFunc_createColorParam(PyObject* self, PyObje // Overloaded function decisor - // 0: createColorParam(std::string,std::string,bool) + // 0: createColorParam(QString,QString,bool) if (numArgs == 3 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1]))) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1]))) && (pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[2])))) { - overloadId = 0; // createColorParam(std::string,std::string,bool) + overloadId = 0; // createColorParam(QString,QString,bool) } // Function signature not found. @@ -289,15 +289,15 @@ static PyObject* Sbk_UserParamHolderFunc_createColorParam(PyObject* self, PyObje // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); bool cppArg2; pythonToCpp[2](pyArgs[2], &cppArg2); if (!PyErr_Occurred()) { - // createColorParam(std::string,std::string,bool) + // createColorParam(QString,QString,bool) ColorParam * cppResult = cppSelf->createColorParam(cppArg0, cppArg1, cppArg2); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_COLORPARAM_IDX], cppResult); @@ -313,7 +313,7 @@ static PyObject* Sbk_UserParamHolderFunc_createColorParam(PyObject* self, PyObje return pyResult; Sbk_UserParamHolderFunc_createColorParam_TypeError: - const char* overloads[] = {"std::string, std::string, bool", 0}; + const char* overloads[] = {"unicode, unicode, bool", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createColorParam", overloads); return 0; } @@ -340,11 +340,11 @@ static PyObject* Sbk_UserParamHolderFunc_createDouble2DParam(PyObject* self, PyO // Overloaded function decisor - // 0: createDouble2DParam(std::string,std::string) + // 0: createDouble2DParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createDouble2DParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createDouble2DParam(QString,QString) } // Function signature not found. @@ -352,13 +352,13 @@ static PyObject* Sbk_UserParamHolderFunc_createDouble2DParam(PyObject* self, PyO // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createDouble2DParam(std::string,std::string) + // createDouble2DParam(QString,QString) Double2DParam * cppResult = cppSelf->createDouble2DParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_DOUBLE2DPARAM_IDX], cppResult); @@ -374,7 +374,7 @@ static PyObject* Sbk_UserParamHolderFunc_createDouble2DParam(PyObject* self, PyO return pyResult; Sbk_UserParamHolderFunc_createDouble2DParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createDouble2DParam", overloads); return 0; } @@ -401,11 +401,11 @@ static PyObject* Sbk_UserParamHolderFunc_createDouble3DParam(PyObject* self, PyO // Overloaded function decisor - // 0: createDouble3DParam(std::string,std::string) + // 0: createDouble3DParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createDouble3DParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createDouble3DParam(QString,QString) } // Function signature not found. @@ -413,13 +413,13 @@ static PyObject* Sbk_UserParamHolderFunc_createDouble3DParam(PyObject* self, PyO // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createDouble3DParam(std::string,std::string) + // createDouble3DParam(QString,QString) Double3DParam * cppResult = cppSelf->createDouble3DParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_DOUBLE3DPARAM_IDX], cppResult); @@ -435,7 +435,7 @@ static PyObject* Sbk_UserParamHolderFunc_createDouble3DParam(PyObject* self, PyO return pyResult; Sbk_UserParamHolderFunc_createDouble3DParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createDouble3DParam", overloads); return 0; } @@ -462,11 +462,11 @@ static PyObject* Sbk_UserParamHolderFunc_createDoubleParam(PyObject* self, PyObj // Overloaded function decisor - // 0: createDoubleParam(std::string,std::string) + // 0: createDoubleParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createDoubleParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createDoubleParam(QString,QString) } // Function signature not found. @@ -474,13 +474,13 @@ static PyObject* Sbk_UserParamHolderFunc_createDoubleParam(PyObject* self, PyObj // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createDoubleParam(std::string,std::string) + // createDoubleParam(QString,QString) DoubleParam * cppResult = cppSelf->createDoubleParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_DOUBLEPARAM_IDX], cppResult); @@ -496,7 +496,7 @@ static PyObject* Sbk_UserParamHolderFunc_createDoubleParam(PyObject* self, PyObj return pyResult; Sbk_UserParamHolderFunc_createDoubleParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createDoubleParam", overloads); return 0; } @@ -523,11 +523,11 @@ static PyObject* Sbk_UserParamHolderFunc_createFileParam(PyObject* self, PyObjec // Overloaded function decisor - // 0: createFileParam(std::string,std::string) + // 0: createFileParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createFileParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createFileParam(QString,QString) } // Function signature not found. @@ -535,13 +535,13 @@ static PyObject* Sbk_UserParamHolderFunc_createFileParam(PyObject* self, PyObjec // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createFileParam(std::string,std::string) + // createFileParam(QString,QString) FileParam * cppResult = cppSelf->createFileParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_FILEPARAM_IDX], cppResult); @@ -557,7 +557,7 @@ static PyObject* Sbk_UserParamHolderFunc_createFileParam(PyObject* self, PyObjec return pyResult; Sbk_UserParamHolderFunc_createFileParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createFileParam", overloads); return 0; } @@ -584,11 +584,11 @@ static PyObject* Sbk_UserParamHolderFunc_createGroupParam(PyObject* self, PyObje // Overloaded function decisor - // 0: createGroupParam(std::string,std::string) + // 0: createGroupParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createGroupParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createGroupParam(QString,QString) } // Function signature not found. @@ -596,13 +596,13 @@ static PyObject* Sbk_UserParamHolderFunc_createGroupParam(PyObject* self, PyObje // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createGroupParam(std::string,std::string) + // createGroupParam(QString,QString) GroupParam * cppResult = cppSelf->createGroupParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_GROUPPARAM_IDX], cppResult); @@ -618,7 +618,7 @@ static PyObject* Sbk_UserParamHolderFunc_createGroupParam(PyObject* self, PyObje return pyResult; Sbk_UserParamHolderFunc_createGroupParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createGroupParam", overloads); return 0; } @@ -645,11 +645,11 @@ static PyObject* Sbk_UserParamHolderFunc_createInt2DParam(PyObject* self, PyObje // Overloaded function decisor - // 0: createInt2DParam(std::string,std::string) + // 0: createInt2DParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createInt2DParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createInt2DParam(QString,QString) } // Function signature not found. @@ -657,13 +657,13 @@ static PyObject* Sbk_UserParamHolderFunc_createInt2DParam(PyObject* self, PyObje // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createInt2DParam(std::string,std::string) + // createInt2DParam(QString,QString) Int2DParam * cppResult = cppSelf->createInt2DParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_INT2DPARAM_IDX], cppResult); @@ -679,7 +679,7 @@ static PyObject* Sbk_UserParamHolderFunc_createInt2DParam(PyObject* self, PyObje return pyResult; Sbk_UserParamHolderFunc_createInt2DParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createInt2DParam", overloads); return 0; } @@ -706,11 +706,11 @@ static PyObject* Sbk_UserParamHolderFunc_createInt3DParam(PyObject* self, PyObje // Overloaded function decisor - // 0: createInt3DParam(std::string,std::string) + // 0: createInt3DParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createInt3DParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createInt3DParam(QString,QString) } // Function signature not found. @@ -718,13 +718,13 @@ static PyObject* Sbk_UserParamHolderFunc_createInt3DParam(PyObject* self, PyObje // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createInt3DParam(std::string,std::string) + // createInt3DParam(QString,QString) Int3DParam * cppResult = cppSelf->createInt3DParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_INT3DPARAM_IDX], cppResult); @@ -740,7 +740,7 @@ static PyObject* Sbk_UserParamHolderFunc_createInt3DParam(PyObject* self, PyObje return pyResult; Sbk_UserParamHolderFunc_createInt3DParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createInt3DParam", overloads); return 0; } @@ -767,11 +767,11 @@ static PyObject* Sbk_UserParamHolderFunc_createIntParam(PyObject* self, PyObject // Overloaded function decisor - // 0: createIntParam(std::string,std::string) + // 0: createIntParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createIntParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createIntParam(QString,QString) } // Function signature not found. @@ -779,13 +779,13 @@ static PyObject* Sbk_UserParamHolderFunc_createIntParam(PyObject* self, PyObject // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createIntParam(std::string,std::string) + // createIntParam(QString,QString) IntParam * cppResult = cppSelf->createIntParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_INTPARAM_IDX], cppResult); @@ -801,7 +801,7 @@ static PyObject* Sbk_UserParamHolderFunc_createIntParam(PyObject* self, PyObject return pyResult; Sbk_UserParamHolderFunc_createIntParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createIntParam", overloads); return 0; } @@ -828,11 +828,11 @@ static PyObject* Sbk_UserParamHolderFunc_createOutputFileParam(PyObject* self, P // Overloaded function decisor - // 0: createOutputFileParam(std::string,std::string) + // 0: createOutputFileParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createOutputFileParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createOutputFileParam(QString,QString) } // Function signature not found. @@ -840,13 +840,13 @@ static PyObject* Sbk_UserParamHolderFunc_createOutputFileParam(PyObject* self, P // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createOutputFileParam(std::string,std::string) + // createOutputFileParam(QString,QString) OutputFileParam * cppResult = cppSelf->createOutputFileParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_OUTPUTFILEPARAM_IDX], cppResult); @@ -862,7 +862,7 @@ static PyObject* Sbk_UserParamHolderFunc_createOutputFileParam(PyObject* self, P return pyResult; Sbk_UserParamHolderFunc_createOutputFileParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createOutputFileParam", overloads); return 0; } @@ -889,11 +889,11 @@ static PyObject* Sbk_UserParamHolderFunc_createPageParam(PyObject* self, PyObjec // Overloaded function decisor - // 0: createPageParam(std::string,std::string) + // 0: createPageParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createPageParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createPageParam(QString,QString) } // Function signature not found. @@ -901,13 +901,13 @@ static PyObject* Sbk_UserParamHolderFunc_createPageParam(PyObject* self, PyObjec // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createPageParam(std::string,std::string) + // createPageParam(QString,QString) PageParam * cppResult = cppSelf->createPageParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PAGEPARAM_IDX], cppResult); @@ -923,7 +923,7 @@ static PyObject* Sbk_UserParamHolderFunc_createPageParam(PyObject* self, PyObjec return pyResult; Sbk_UserParamHolderFunc_createPageParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createPageParam", overloads); return 0; } @@ -950,12 +950,12 @@ static PyObject* Sbk_UserParamHolderFunc_createParametricParam(PyObject* self, P // Overloaded function decisor - // 0: createParametricParam(std::string,std::string,int) + // 0: createParametricParam(QString,QString,int) if (numArgs == 3 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1]))) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1]))) && (pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[2])))) { - overloadId = 0; // createParametricParam(std::string,std::string,int) + overloadId = 0; // createParametricParam(QString,QString,int) } // Function signature not found. @@ -963,15 +963,15 @@ static PyObject* Sbk_UserParamHolderFunc_createParametricParam(PyObject* self, P // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); int cppArg2; pythonToCpp[2](pyArgs[2], &cppArg2); if (!PyErr_Occurred()) { - // createParametricParam(std::string,std::string,int) + // createParametricParam(QString,QString,int) ParametricParam * cppResult = cppSelf->createParametricParam(cppArg0, cppArg1, cppArg2); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAMETRICPARAM_IDX], cppResult); @@ -987,7 +987,7 @@ static PyObject* Sbk_UserParamHolderFunc_createParametricParam(PyObject* self, P return pyResult; Sbk_UserParamHolderFunc_createParametricParam_TypeError: - const char* overloads[] = {"std::string, std::string, int", 0}; + const char* overloads[] = {"unicode, unicode, int", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createParametricParam", overloads); return 0; } @@ -1014,11 +1014,11 @@ static PyObject* Sbk_UserParamHolderFunc_createPathParam(PyObject* self, PyObjec // Overloaded function decisor - // 0: createPathParam(std::string,std::string) + // 0: createPathParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createPathParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createPathParam(QString,QString) } // Function signature not found. @@ -1026,13 +1026,13 @@ static PyObject* Sbk_UserParamHolderFunc_createPathParam(PyObject* self, PyObjec // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createPathParam(std::string,std::string) + // createPathParam(QString,QString) PathParam * cppResult = cppSelf->createPathParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PATHPARAM_IDX], cppResult); @@ -1048,7 +1048,7 @@ static PyObject* Sbk_UserParamHolderFunc_createPathParam(PyObject* self, PyObjec return pyResult; Sbk_UserParamHolderFunc_createPathParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createPathParam", overloads); return 0; } @@ -1075,11 +1075,11 @@ static PyObject* Sbk_UserParamHolderFunc_createSeparatorParam(PyObject* self, Py // Overloaded function decisor - // 0: createSeparatorParam(std::string,std::string) + // 0: createSeparatorParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createSeparatorParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createSeparatorParam(QString,QString) } // Function signature not found. @@ -1087,13 +1087,13 @@ static PyObject* Sbk_UserParamHolderFunc_createSeparatorParam(PyObject* self, Py // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createSeparatorParam(std::string,std::string) + // createSeparatorParam(QString,QString) SeparatorParam * cppResult = cppSelf->createSeparatorParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_SEPARATORPARAM_IDX], cppResult); @@ -1109,7 +1109,7 @@ static PyObject* Sbk_UserParamHolderFunc_createSeparatorParam(PyObject* self, Py return pyResult; Sbk_UserParamHolderFunc_createSeparatorParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createSeparatorParam", overloads); return 0; } @@ -1136,11 +1136,11 @@ static PyObject* Sbk_UserParamHolderFunc_createStringParam(PyObject* self, PyObj // Overloaded function decisor - // 0: createStringParam(std::string,std::string) + // 0: createStringParam(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // createStringParam(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // createStringParam(QString,QString) } // Function signature not found. @@ -1148,13 +1148,13 @@ static PyObject* Sbk_UserParamHolderFunc_createStringParam(PyObject* self, PyObj // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // createStringParam(std::string,std::string) + // createStringParam(QString,QString) StringParam * cppResult = cppSelf->createStringParam(cppArg0, cppArg1); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_STRINGPARAM_IDX], cppResult); @@ -1170,7 +1170,7 @@ static PyObject* Sbk_UserParamHolderFunc_createStringParam(PyObject* self, PyObj return pyResult; Sbk_UserParamHolderFunc_createStringParam_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronEngine.UserParamHolder.createStringParam", overloads); return 0; } diff --git a/Engine/ProjectPrivate.cpp b/Engine/ProjectPrivate.cpp index 3b30589423..d9ed6f414d 100644 --- a/Engine/ProjectPrivate.cpp +++ b/Engine/ProjectPrivate.cpp @@ -356,7 +356,7 @@ ProjectPrivate::runOnProjectSaveCallback(const std::string& filename, bool autoS } std::string filePath = filename; if (ret) { - filePath = Python::PY3String_asString(ret); + filePath = Python::PyString_asString(ret); std::string script = "del ret\n"; bool ok = Python::interpretPythonScript(script, &err, 0); assert(ok); diff --git a/Engine/PyAppInstance.cpp b/Engine/PyAppInstance.cpp index abf8cbb5b7..7af6c48b41 100644 --- a/Engine/PyAppInstance.cpp +++ b/Engine/PyAppInstance.cpp @@ -91,14 +91,14 @@ App::getCollectionFromGroup(Group* group) const } Effect* -App::createNode(const std::string& pluginID, +App::createNode(const QString& pluginID, int majorVersion, Group* group) const { boost::shared_ptr collection = getCollectionFromGroup(group); assert(collection); - CreateNodeArgs args(QString::fromUtf8(pluginID.c_str()), eCreateNodeReasonInternal, collection); + CreateNodeArgs args(pluginID, eCreateNodeReasonInternal, collection); args.majorV = majorVersion; NodePtr node = _instance->createNode(args); @@ -110,12 +110,12 @@ App::createNode(const std::string& pluginID, } Effect* -App::createReader(const std::string& filename, +App::createReader(const QString& filename, Group* group) const { boost::shared_ptr collection = getCollectionFromGroup(group); assert(collection); - NodePtr node = _instance->createReader(filename, eCreateNodeReasonInternal, collection); + NodePtr node = _instance->createReader(filename.toStdString(), eCreateNodeReasonInternal, collection); if (node) { return new Effect(node); } else { @@ -124,12 +124,12 @@ App::createReader(const std::string& filename, } Effect* -App::createWriter(const std::string& filename, +App::createWriter(const QString& filename, Group* group) const { boost::shared_ptr collection = getCollectionFromGroup(group); assert(collection); - NodePtr node = _instance->createWriter(filename, eCreateNodeReasonInternal, collection); + NodePtr node = _instance->createWriter(filename.toStdString(), eCreateNodeReasonInternal, collection); if (node) { return new Effect(node); } else { @@ -167,9 +167,9 @@ AppSettings::AppSettings(const boost::shared_ptr& settings) } Param* -AppSettings::getParam(const std::string& scriptName) const +AppSettings::getParam(const QString& scriptName) const { - KnobPtr knob = _settings->getKnobByName(scriptName); + KnobPtr knob = _settings->getKnobByName(scriptName.toStdString()); if (!knob) { return 0; } @@ -281,9 +281,9 @@ App::renderInternal(bool forceBlocking,const std::list& effects,const s } Param* -App::getProjectParam(const std::string& name) const +App::getProjectParam(const QString& name) const { - KnobPtr knob = _instance->getProject()->getKnobByName(name); + KnobPtr knob = _instance->getProject()->getKnobByName(name.toStdString()); if (!knob) { return 0; } @@ -291,42 +291,42 @@ App::getProjectParam(const std::string& name) const } void -App::writeToScriptEditor(const std::string& message) +App::writeToScriptEditor(const QString& message) { - _instance->appendToScriptEditor(message); + _instance->appendToScriptEditor(message.toStdString()); } void -App::addFormat(const std::string& formatSpec) +App::addFormat(const QString& formatSpec) { - if (!_instance->getProject()->addFormat(formatSpec)) { - _instance->appendToScriptEditor(formatSpec); + if (!_instance->getProject()->addFormat(formatSpec.toStdString())) { + _instance->appendToScriptEditor(formatSpec.toStdString()); } } bool -App::saveTempProject(const std::string& filename) +App::saveTempProject(const QString& filename) { - return _instance->saveTemp(filename); + return _instance->saveTemp(filename.toStdString()); } bool -App::saveProject(const std::string& filename) +App::saveProject(const QString& filename) { - return _instance->save(filename); + return _instance->save(filename.toStdString()); } bool -App::saveProjectAs(const std::string& filename) +App::saveProjectAs(const QString& filename) { - return _instance->saveAs(filename); + return _instance->saveAs(filename.toStdString()); } App* -App::loadProject(const std::string& filename) +App::loadProject(const QString& filename) { - AppInstance* app =_instance->loadProject(filename); + AppInstance* app =_instance->loadProject(filename.toStdString()); if (!app) { return 0; } @@ -359,13 +359,13 @@ App::newProject() } -std::list +std::list App::getViewNames() const { - std::list ret; + std::list ret; const std::vector& v = _instance->getProject()->getProjectViewNames(); for (std::size_t i = 0; i < v.size(); ++i) { - ret.push_back(v[i]); + ret.push_back(QString::fromUtf8(v[i].c_str())); } return ret; } diff --git a/Engine/PyAppInstance.h b/Engine/PyAppInstance.h index cfa6779bb1..e8e2c198cd 100644 --- a/Engine/PyAppInstance.h +++ b/Engine/PyAppInstance.h @@ -44,7 +44,7 @@ class AppSettings AppSettings(const boost::shared_ptr& settings); - Param* getParam(const std::string& scriptName) const; + Param* getParam(const QString& scriptName) const; std::list getParams() const; @@ -80,14 +80,14 @@ class App : public Group * @param group If not NULL, this should be a pointer to a group node where-in to insert the newly created effect. * If NULL, the newly created node will be inserted in the project's root. **/ - Effect* createNode(const std::string& pluginID, + Effect* createNode(const QString& pluginID, int majorVersion = -1, Group* group = 0) const; - Effect* createReader(const std::string& filename, + Effect* createReader(const QString& filename, Group* group = 0) const; - Effect* createWriter(const std::string& filename, + Effect* createWriter(const QString& filename, Group* group = 0) const; int timelineGetTime() const; @@ -96,19 +96,19 @@ class App : public Group int timelineGetRightBound() const; - void addFormat(const std::string& formatSpec); + void addFormat(const QString& formatSpec); void render(Effect* writeNode,int firstFrame, int lastFrame, int frameStep = 1); void render(const std::list& effects,const std::list& firstFrames,const std::list& lastFrames, const std::list& frameSteps); - Param* getProjectParam(const std::string& name) const; + Param* getProjectParam(const QString& name) const; - void writeToScriptEditor(const std::string& message); + void writeToScriptEditor(const QString& message); - bool saveProject(const std::string& filename); - bool saveProjectAs(const std::string& filename); - bool saveTempProject(const std::string& filename); - App* loadProject(const std::string& filename); + bool saveProject(const QString& filename); + bool saveProjectAs(const QString& filename); + bool saveTempProject(const QString& filename); + App* loadProject(const QString& filename); ///Close the current project but keep the window bool resetProject(); @@ -119,7 +119,7 @@ class App : public Group ///Opens a new window App* newProject(); - std::list getViewNames() const; + std::list getViewNames() const; void addProjectLayer(const ImageLayer& layer); diff --git a/Engine/PyGlobalFunctions.h b/Engine/PyGlobalFunctions.h index 159144b856..62fc47087a 100644 --- a/Engine/PyGlobalFunctions.h +++ b/Engine/PyGlobalFunctions.h @@ -41,22 +41,33 @@ NATRON_NAMESPACE_ENTER; class PyCoreApplication { + public: PyCoreApplication() {} virtual ~PyCoreApplication() {} - inline std::list + inline QStringList getPluginIDs() const { - return appPTR->getPluginIDs(); + QStringList ret; + std::list list = appPTR->getPluginIDs(); + for (std::list::iterator it = list.begin(); it!=list.end(); ++it) { + ret.push_back(QString::fromUtf8(it->c_str())); + } + return ret; } - inline std::list - getPluginIDs(const std::string& filter) const + inline QStringList + getPluginIDs(const QString& filter) const { - return appPTR->getPluginIDs(filter); + QStringList ret; + std::list list = appPTR->getPluginIDs(filter.toStdString()); + for (std::list::iterator it = list.begin(); it!=list.end(); ++it) { + ret.push_back(QString::fromUtf8(it->c_str())); + } + return ret; } inline int @@ -65,16 +76,21 @@ class PyCoreApplication return appPTR->getNumInstances(); } - inline std::list + inline QStringList getNatronPath() const { - return appPTR->getNatronPath(); + QStringList ret; + std::list list = appPTR->getNatronPath(); + for (std::list::iterator it = list.begin(); it!=list.end(); ++it) { + ret.push_back(QString::fromUtf8(it->c_str())); + } + return ret; } inline void - appendToNatronPath(const std::string& path) + appendToNatronPath(const QString& path) { - appPTR->appendToNatronPath(path); + appPTR->appendToNatronPath(path.toStdString()); } inline bool isLinux() const @@ -113,9 +129,9 @@ class PyCoreApplication #endif } - inline std::string getNatronVersionString() const + inline QString getNatronVersionString() const { - return NATRON_VERSION_STRING; + return QString::fromUtf8(NATRON_VERSION_STRING); } inline int getNatronVersionMajor() const @@ -138,9 +154,9 @@ class PyCoreApplication return NATRON_VERSION_ENCODED; } - inline std::string getNatronDevelopmentStatus() const + inline QString getNatronDevelopmentStatus() const { - return std::string(NATRON_DEVELOPMENT_STATUS); + return QString::fromUtf8(NATRON_DEVELOPMENT_STATUS); } inline int getBuildNumber() const @@ -189,14 +205,14 @@ class PyCoreApplication return new AppSettings(appPTR->getCurrentSettings()); } - inline void setOnProjectCreatedCallback(const std::string& pythonFunctionName) + inline void setOnProjectCreatedCallback(const QString& pythonFunctionName) { - appPTR->setOnProjectCreatedCallback(pythonFunctionName); + appPTR->setOnProjectCreatedCallback(pythonFunctionName.toStdString()); } - inline void setOnProjectLoadedCallback(const std::string& pythonFunctionName) + inline void setOnProjectLoadedCallback(const QString& pythonFunctionName) { - appPTR->setOnProjectLoadedCallback(pythonFunctionName); + appPTR->setOnProjectLoadedCallback(pythonFunctionName.toStdString()); } diff --git a/Engine/PyNode.cpp b/Engine/PyNode.cpp index f5aee4d4e7..cda17fb31e 100644 --- a/Engine/PyNode.cpp +++ b/Engine/PyNode.cpp @@ -38,26 +38,40 @@ NATRON_NAMESPACE_ENTER; -ImageLayer::ImageLayer(const std::string& layerName, - const std::string& componentsPrettyName, - const std::vector& componentsName) -: _comps(layerName,componentsPrettyName, componentsName) +ImageLayer::ImageLayer(const QString& layerName, + const QString& componentsPrettyName, + const QStringList& componentsName) +: _layerName(layerName) +, _componentsPrettyName(componentsPrettyName) +, _componentsName(componentsName) +, _comps() { + std::vector channels(componentsName.size()); + int i = 0; + for (QStringList::const_iterator it = componentsName.begin(); it!=componentsName.end(); ++it,++i) { + channels[i] = it->toStdString(); + } + _comps.reset(new ImageComponents(layerName.toStdString(), componentsPrettyName.toStdString(), channels)); } -ImageLayer::ImageLayer(const ImageComponents& internalComps) -: _comps(internalComps) +ImageLayer::ImageLayer(const ImageComponents& comps) +: _layerName(QString::fromUtf8(comps.getLayerName().c_str())) +, _componentsPrettyName(QString::fromUtf8(comps.getComponentsGlobalName().c_str())) { - + const std::vector& channels = comps.getComponentsNames(); + for (std::size_t i = 0; i < channels.size(); ++i) { + _componentsName.push_back(QString::fromUtf8(channels[i].c_str())); + } + _comps.reset(new ImageComponents(comps)); } int ImageLayer::getHash(const ImageLayer& layer) { Hash64 h; - Hash64_appendQString(&h, QString::fromUtf8(layer._comps.getLayerName().c_str())); - const std::vector& comps = layer._comps.getComponentsNames(); + Hash64_appendQString(&h, QString::fromUtf8(layer._comps->getLayerName().c_str())); + const std::vector& comps = layer._comps->getComponentsNames(); for (std::size_t i = 0; i < comps.size(); ++i) { Hash64_appendQString(&h, QString::fromUtf8(comps[i].c_str())); } @@ -67,31 +81,31 @@ ImageLayer::getHash(const ImageLayer& layer) bool ImageLayer::isColorPlane() const { - return _comps.isColorPlane(); + return _comps->isColorPlane(); } int ImageLayer::getNumComponents() const { - return _comps.getNumComponents(); + return _comps->getNumComponents(); } -const std::string& +const QString& ImageLayer::getLayerName() const { - return _comps.getLayerName(); + return _layerName; } -const std::vector& +const QStringList& ImageLayer::getComponentsNames() const { - return _comps.getComponentsNames(); + return _componentsName; } -const std::string& +const QString& ImageLayer::getComponentsPrettyName() const { - return _comps.getComponentsGlobalName(); + return _componentsPrettyName; } bool ImageLayer::operator==(const ImageLayer& other) const @@ -249,51 +263,51 @@ Effect::getInput(int inputNumber) const return NULL; } -std::string +QString Effect::getScriptName() const { - return getInternalNode()->getScriptName_mt_safe(); + return QString::fromUtf8(getInternalNode()->getScriptName_mt_safe().c_str()); } bool -Effect::setScriptName(const std::string& scriptName) +Effect::setScriptName(const QString& scriptName) { try { - getInternalNode()->setScriptName(scriptName); + getInternalNode()->setScriptName(scriptName.toStdString()); } catch (...) { return false; } return true; } -std::string +QString Effect::getLabel() const { - return getInternalNode()->getLabel_mt_safe(); + return QString::fromUtf8(getInternalNode()->getLabel_mt_safe().c_str()); } void -Effect::setLabel(const std::string& name) +Effect::setLabel(const QString& name) { - return getInternalNode()->setLabel(name); + return getInternalNode()->setLabel(name.toStdString()); } -std::string +QString Effect::getInputLabel(int inputNumber) { try { - return getInternalNode()->getInputLabel(inputNumber); + return QString::fromUtf8(getInternalNode()->getInputLabel(inputNumber).c_str()); } catch (const std::exception& e) { getInternalNode()->getApp()->appendToScriptEditor(e.what()); } - return std::string(); + return QString(); } -std::string +QString Effect::getPluginID() const { - return getInternalNode()->getPluginID(); + return QString::fromUtf8(getInternalNode()->getPluginID().c_str()); } Param* @@ -380,9 +394,9 @@ Effect::getParams() const } Param* -Effect::getParam(const std::string& name) const +Effect::getParam(const QString& name) const { - KnobPtr knob = getInternalNode()->getKnobByName(name); + KnobPtr knob = getInternalNode()->getKnobByName(name.toStdString()); if (knob) { return createParamWrapperForKnob(knob); } else { @@ -453,9 +467,9 @@ Effect::endChanges() } IntParam* -UserParamHolder::createIntParam(const std::string& name, const std::string& label) +UserParamHolder::createIntParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createIntKnob(name, label, 1); + boost::shared_ptr knob = _holder->createIntKnob(name.toStdString(), label.toStdString(), 1); if (knob) { return new IntParam(knob); } else { @@ -464,9 +478,9 @@ UserParamHolder::createIntParam(const std::string& name, const std::string& labe } Int2DParam* -UserParamHolder::createInt2DParam(const std::string& name, const std::string& label) +UserParamHolder::createInt2DParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createIntKnob(name, label, 2); + boost::shared_ptr knob = _holder->createIntKnob(name.toStdString(), label.toStdString(), 2); if (knob) { return new Int2DParam(knob); } else { @@ -476,9 +490,9 @@ UserParamHolder::createInt2DParam(const std::string& name, const std::string& la } Int3DParam* -UserParamHolder::createInt3DParam(const std::string& name, const std::string& label) +UserParamHolder::createInt3DParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createIntKnob(name, label, 3); + boost::shared_ptr knob = _holder->createIntKnob(name.toStdString(), label.toStdString(), 3); if (knob) { return new Int3DParam(knob); } else { @@ -488,9 +502,9 @@ UserParamHolder::createInt3DParam(const std::string& name, const std::string& la } DoubleParam* -UserParamHolder::createDoubleParam(const std::string& name, const std::string& label) +UserParamHolder::createDoubleParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createDoubleKnob(name, label, 1); + boost::shared_ptr knob = _holder->createDoubleKnob(name.toStdString(), label.toStdString(), 1); if (knob) { return new DoubleParam(knob); } else { @@ -500,9 +514,9 @@ UserParamHolder::createDoubleParam(const std::string& name, const std::string& l } Double2DParam* -UserParamHolder::createDouble2DParam(const std::string& name, const std::string& label) +UserParamHolder::createDouble2DParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createDoubleKnob(name, label, 2); + boost::shared_ptr knob = _holder->createDoubleKnob(name.toStdString(), label.toStdString(), 2); if (knob) { return new Double2DParam(knob); } else { @@ -511,9 +525,9 @@ UserParamHolder::createDouble2DParam(const std::string& name, const std::string& } Double3DParam* -UserParamHolder::createDouble3DParam(const std::string& name, const std::string& label) +UserParamHolder::createDouble3DParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createDoubleKnob(name, label, 3); + boost::shared_ptr knob = _holder->createDoubleKnob(name.toStdString(), label.toStdString(), 3); if (knob) { return new Double3DParam(knob); } else { @@ -522,9 +536,9 @@ UserParamHolder::createDouble3DParam(const std::string& name, const std::string& } BooleanParam* -UserParamHolder::createBooleanParam(const std::string& name, const std::string& label) +UserParamHolder::createBooleanParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createBoolKnob(name, label); + boost::shared_ptr knob = _holder->createBoolKnob(name.toStdString(), label.toStdString()); if (knob) { return new BooleanParam(knob); } else { @@ -533,9 +547,9 @@ UserParamHolder::createBooleanParam(const std::string& name, const std::string& } ChoiceParam* -UserParamHolder::createChoiceParam(const std::string& name, const std::string& label) +UserParamHolder::createChoiceParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createChoiceKnob(name, label); + boost::shared_ptr knob = _holder->createChoiceKnob(name.toStdString(), label.toStdString()); if (knob) { return new ChoiceParam(knob); } else { @@ -544,9 +558,9 @@ UserParamHolder::createChoiceParam(const std::string& name, const std::string& l } ColorParam* -UserParamHolder::createColorParam(const std::string& name, const std::string& label, bool useAlpha) +UserParamHolder::createColorParam(const QString& name, const QString& label, bool useAlpha) { - boost::shared_ptr knob = _holder->createColorKnob(name, label, useAlpha ? 4 : 3); + boost::shared_ptr knob = _holder->createColorKnob(name.toStdString(), label.toStdString(), useAlpha ? 4 : 3); if (knob) { return new ColorParam(knob); } else { @@ -555,9 +569,9 @@ UserParamHolder::createColorParam(const std::string& name, const std::string& la } StringParam* -UserParamHolder::createStringParam(const std::string& name, const std::string& label) +UserParamHolder::createStringParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createStringKnob(name, label); + boost::shared_ptr knob = _holder->createStringKnob(name.toStdString(), label.toStdString()); if (knob) { return new StringParam(knob); } else { @@ -566,9 +580,9 @@ UserParamHolder::createStringParam(const std::string& name, const std::string& l } FileParam* -UserParamHolder::createFileParam(const std::string& name, const std::string& label) +UserParamHolder::createFileParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createFileKnob(name, label); + boost::shared_ptr knob = _holder->createFileKnob(name.toStdString(), label.toStdString()); if (knob) { return new FileParam(knob); } else { @@ -577,9 +591,9 @@ UserParamHolder::createFileParam(const std::string& name, const std::string& lab } OutputFileParam* -UserParamHolder::createOutputFileParam(const std::string& name, const std::string& label) +UserParamHolder::createOutputFileParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createOuptutFileKnob(name, label); + boost::shared_ptr knob = _holder->createOuptutFileKnob(name.toStdString(), label.toStdString()); if (knob) { return new OutputFileParam(knob); } else { @@ -588,9 +602,9 @@ UserParamHolder::createOutputFileParam(const std::string& name, const std::strin } PathParam* -UserParamHolder::createPathParam(const std::string& name, const std::string& label) +UserParamHolder::createPathParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createPathKnob(name, label); + boost::shared_ptr knob = _holder->createPathKnob(name.toStdString(), label.toStdString()); if (knob) { return new PathParam(knob); } else { @@ -599,9 +613,9 @@ UserParamHolder::createPathParam(const std::string& name, const std::string& lab } ButtonParam* -UserParamHolder::createButtonParam(const std::string& name, const std::string& label) +UserParamHolder::createButtonParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createButtonKnob(name, label); + boost::shared_ptr knob = _holder->createButtonKnob(name.toStdString(), label.toStdString()); if (knob) { return new ButtonParam(knob); } else { @@ -610,9 +624,9 @@ UserParamHolder::createButtonParam(const std::string& name, const std::string& l } SeparatorParam* -UserParamHolder::createSeparatorParam(const std::string& name, const std::string& label) +UserParamHolder::createSeparatorParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createSeparatorKnob(name, label); + boost::shared_ptr knob = _holder->createSeparatorKnob(name.toStdString(), label.toStdString()); if (knob) { return new SeparatorParam(knob); } else { @@ -621,9 +635,9 @@ UserParamHolder::createSeparatorParam(const std::string& name, const std::string } GroupParam* -UserParamHolder::createGroupParam(const std::string& name, const std::string& label) +UserParamHolder::createGroupParam(const QString& name, const QString& label) { - boost::shared_ptr knob = _holder->createGroupKnob(name, label); + boost::shared_ptr knob = _holder->createGroupKnob(name.toStdString(), label.toStdString()); if (knob) { return new GroupParam(knob); } else { @@ -632,13 +646,13 @@ UserParamHolder::createGroupParam(const std::string& name, const std::string& la } PageParam* -UserParamHolder::createPageParam(const std::string& name, const std::string& label) +UserParamHolder::createPageParam(const QString& name, const QString& label) { if (!_holder) { assert(false); return 0; } - boost::shared_ptr knob = _holder->createPageKnob(name, label); + boost::shared_ptr knob = _holder->createPageKnob(name.toStdString(), label.toStdString()); if (knob) { return new PageParam(knob); } else { @@ -647,9 +661,9 @@ UserParamHolder::createPageParam(const std::string& name, const std::string& lab } ParametricParam* -UserParamHolder::createParametricParam(const std::string& name, const std::string& label, int nbCurves) +UserParamHolder::createParametricParam(const QString& name, const QString& label, int nbCurves) { - boost::shared_ptr knob = _holder->createParametricKnob(name, label, nbCurves); + boost::shared_ptr knob = _holder->createParametricKnob(name.toStdString(), label.toStdString(), nbCurves); if (knob) { return new ParametricParam(knob); } else { @@ -746,18 +760,23 @@ Effect::setSubGraphEditable(bool editable) } bool -Effect::addUserPlane(const std::string& planeName, const std::vector& channels) +Effect::addUserPlane(const QString& planeName, const QStringList& channels) { - if (planeName.empty() || + if (planeName.isEmpty() || channels.size() < 1 || channels.size() > 4) { return false; } std::string compsGlobal; - for (std::size_t i = 0; i < channels.size(); ++i) { - compsGlobal.append(channels[i]); + std::vector chans(channels.size()); + int i = 0; + for (QStringList::const_iterator it = channels.begin(); it != channels.end(); ++it,++i) { + std::string c = it->toStdString(); + compsGlobal.append(c); + chans[i] = c; + } - ImageComponents comp(planeName,compsGlobal,channels); + ImageComponents comp(planeName.toStdString(),compsGlobal,chans); return getInternalNode()->addUserComponents(comp); } @@ -823,12 +842,17 @@ Effect::getPremult() const void -Effect::setPagesOrder(const std::list& pages) +Effect::setPagesOrder(const QStringList& pages) { if (!getInternalNode()) { return; } - getInternalNode()->setPagesOrder(pages); + + std::list order; + for (QStringList::const_iterator it= pages.begin() ; it!=pages.end(); ++it) { + order.push_back(it->toStdString()); + } + getInternalNode()->setPagesOrder(order); } NATRON_NAMESPACE_EXIT; diff --git a/Engine/PyNode.h b/Engine/PyNode.h index 81a4436e06..7e572e8f18 100644 --- a/Engine/PyNode.h +++ b/Engine/PyNode.h @@ -45,18 +45,22 @@ NATRON_NAMESPACE_ENTER; class ImageLayer { - ImageComponents _comps; -public: + QString _layerName; + QString _componentsPrettyName; + QStringList _componentsName; + boost::shared_ptr _comps; - ImageLayer(const std::string& layerName, - const std::string& componentsPrettyName, - const std::vector& componentsName); +public: - ImageLayer(const ImageComponents& internalComps); + ImageLayer(const QString& layerName, + const QString& componentsPrettyName, + const QStringList& componentsName); + + ImageLayer(const ImageComponents& comps); - ImageComponents getInternalComps() const + const ImageComponents& getInternalComps() const { - return _comps; + return *_comps; } ~ImageLayer() {} @@ -67,11 +71,11 @@ class ImageLayer int getNumComponents() const; - const std::string& getLayerName() const; + const QString& getLayerName() const; - const std::vector& getComponentsNames() const; + const QStringList& getComponentsNames() const; - const std::string& getComponentsPrettyName() const; + const QString& getComponentsPrettyName() const; bool operator==(const ImageLayer& other) const; @@ -167,37 +171,37 @@ class UserParamHolder //////////// Note that ParametricParam , GroupParam, PageParam, ButtonParam, FileParam, OutputFileParam, //////////// PathParam cannot animate at all. - IntParam* createIntParam(const std::string& name, const std::string& label); - Int2DParam* createInt2DParam(const std::string& name, const std::string& label); - Int3DParam* createInt3DParam(const std::string& name, const std::string& label); + IntParam* createIntParam(const QString& name, const QString& label); + Int2DParam* createInt2DParam(const QString& name, const QString& label); + Int3DParam* createInt3DParam(const QString& name, const QString& label); - DoubleParam* createDoubleParam(const std::string& name, const std::string& label); - Double2DParam* createDouble2DParam(const std::string& name, const std::string& label); - Double3DParam* createDouble3DParam(const std::string& name, const std::string& label); + DoubleParam* createDoubleParam(const QString& name, const QString& label); + Double2DParam* createDouble2DParam(const QString& name, const QString& label); + Double3DParam* createDouble3DParam(const QString& name, const QString& label); - BooleanParam* createBooleanParam(const std::string& name, const std::string& label); + BooleanParam* createBooleanParam(const QString& name, const QString& label); - ChoiceParam* createChoiceParam(const std::string& name, const std::string& label); + ChoiceParam* createChoiceParam(const QString& name, const QString& label); - ColorParam* createColorParam(const std::string& name, const std::string& label, bool useAlpha); + ColorParam* createColorParam(const QString& name, const QString& label, bool useAlpha); - StringParam* createStringParam(const std::string& name, const std::string& label); + StringParam* createStringParam(const QString& name, const QString& label); - FileParam* createFileParam(const std::string& name, const std::string& label); + FileParam* createFileParam(const QString& name, const QString& label); - OutputFileParam* createOutputFileParam(const std::string& name, const std::string& label); + OutputFileParam* createOutputFileParam(const QString& name, const QString& label); - PathParam* createPathParam(const std::string& name, const std::string& label); + PathParam* createPathParam(const QString& name, const QString& label); - ButtonParam* createButtonParam(const std::string& name, const std::string& label); + ButtonParam* createButtonParam(const QString& name, const QString& label); - SeparatorParam* createSeparatorParam(const std::string& name, const std::string& label); + SeparatorParam* createSeparatorParam(const QString& name, const QString& label); - GroupParam* createGroupParam(const std::string& name, const std::string& label); + GroupParam* createGroupParam(const QString& name, const QString& label); - PageParam* createPageParam(const std::string& name, const std::string& label); + PageParam* createPageParam(const QString& name, const QString& label); - ParametricParam* createParametricParam(const std::string& name, const std::string& label,int nbCurves); + ParametricParam* createParametricParam(const QString& name, const QString& label,int nbCurves); bool removeParam(Param* param); @@ -260,33 +264,33 @@ class Effect : public Group, public UserParamHolder /** * @brief Returns the name of the Effect as used internally **/ - std::string getScriptName() const; + QString getScriptName() const; /** * @brief Set the internal script name of the effect * @returns False upon failure, True upon success. **/ - bool setScriptName(const std::string& scriptName); + bool setScriptName(const QString& scriptName); /** * @brief Returns the name of the Effect as displayed on the GUI **/ - std::string getLabel() const; + QString getLabel() const; /** * @brief Set the name of the Effect as used on the GUI **/ - void setLabel(const std::string& name); + void setLabel(const QString& name); /** * @brief Returns the ID of the plug-in embedded into the Effect **/ - std::string getPluginID() const; + QString getPluginID() const; /** * @brief Returns the label of the input at the given index **/ - std::string getInputLabel(int inputNumber); + QString getInputLabel(int inputNumber); /** * @brief Returns a list of all parameters for the Effect. These are the parameters located in the settings panel @@ -297,7 +301,7 @@ class Effect : public Group, public UserParamHolder /** * @brief Returns a pointer to the Param named after the given name or NULL if no parameter with the given name could be found. **/ - Param* getParam(const std::string& name) const; + Param* getParam(const QString& name) const; /** * @brief When called, all parameter changes will not call the callback onParamChanged and will not attempt to trigger a new render. @@ -360,7 +364,7 @@ class Effect : public Group, public UserParamHolder void setSubGraphEditable(bool editable); - bool addUserPlane(const std::string& planeName, const std::vector& channels); + bool addUserPlane(const QString& planeName, const QStringList& channels); std::map getAvailableLayers() const; @@ -372,7 +376,7 @@ class Effect : public Group, public UserParamHolder NATRON_NAMESPACE::ImagePremultiplicationEnum getPremult() const; - void setPagesOrder(const std::list& pages); + void setPagesOrder(const QStringList& pages); }; NATRON_NAMESPACE_EXIT; diff --git a/Engine/PyNodeGroup.cpp b/Engine/PyNodeGroup.cpp index 190d129e0e..a614d3a9d3 100644 --- a/Engine/PyNodeGroup.cpp +++ b/Engine/PyNodeGroup.cpp @@ -51,12 +51,12 @@ Group::~Group() } Effect* -Group::getNode(const std::string& fullySpecifiedName) const +Group::getNode(const QString& fullySpecifiedName) const { if (!_collection.lock()) { return 0; } - NodePtr node = _collection.lock()->getNodeByFullySpecifiedName(fullySpecifiedName); + NodePtr node = _collection.lock()->getNodeByFullySpecifiedName(fullySpecifiedName.toStdString()); if (node && node->isActivated()) { return new Effect(node); } else { diff --git a/Engine/PyNodeGroup.h b/Engine/PyNodeGroup.h index 41516a12ef..af53d99e89 100644 --- a/Engine/PyNodeGroup.h +++ b/Engine/PyNodeGroup.h @@ -59,7 +59,7 @@ class Group * This function is called recursively on subgroups until a match is found. * It is meant to be called only on the project's root. **/ - Effect* getNode(const std::string& fullySpecifiedName) const; + Effect* getNode(const QString& fullySpecifiedName) const; /** * @brief Get all nodes in the project's root. diff --git a/Engine/PyParameter.cpp b/Engine/PyParameter.cpp index 649c200b0d..afd68394fa 100644 --- a/Engine/PyParameter.cpp +++ b/Engine/PyParameter.cpp @@ -62,38 +62,38 @@ Param::getNumDimensions() const return getInternalKnob()->getDimension(); } -std::string +QString Param::getScriptName() const { - return getInternalKnob()->getName(); + return QString::fromUtf8(getInternalKnob()->getName().c_str()); } -std::string +QString Param::getLabel() const { - return getInternalKnob()->getLabel(); + return QString::fromUtf8(getInternalKnob()->getLabel().c_str()); } -std::string +QString Param::getTypeName() const { - return getInternalKnob()->typeName(); + return QString::fromUtf8(getInternalKnob()->typeName().c_str()); } -std::string +QString Param::getHelp() const { - return getInternalKnob()->getHintToolTip(); + return QString::fromUtf8(getInternalKnob()->getHintToolTip().c_str()); } void -Param::setHelp(const std::string& help) +Param::setHelp(const QString& help) { if (!getInternalKnob()->isUserKnob()) { return; } - getInternalKnob()->setHintToolTip(help); + getInternalKnob()->setHintToolTip(help.toStdString()); } bool @@ -415,20 +415,20 @@ Param::_addAsDependencyOf(int fromExprDimension,Param* param,int thisDimension) } bool -AnimatedParam::setExpression(const std::string& expr,bool hasRetVariable,int dimension) +AnimatedParam::setExpression(const QString& expr,bool hasRetVariable,int dimension) { try { - _knob.lock()->setExpression(dimension,expr,hasRetVariable, true); + _knob.lock()->setExpression(dimension,expr.toStdString(),hasRetVariable, true); } catch (...) { return false; } return true; } -std::string +QString AnimatedParam::getExpression(int dimension,bool* hasRetVariable) const { - std::string ret = _knob.lock()->getExpression(dimension); + QString ret = QString::fromUtf8(_knob.lock()->getExpression(dimension).c_str()); *hasRetVariable = _knob.lock()->isExpressionUsingRetVariable(dimension); return ret; } @@ -1093,9 +1093,9 @@ ChoiceParam::set(int x, double frame) } void -ChoiceParam::set(const std::string& label) +ChoiceParam::set(const QString& label) { - KnobHelper::ValueChangedReturnCodeEnum s = _choiceKnob.lock()->setValueFromLabel(label, 0); + KnobHelper::ValueChangedReturnCodeEnum s = _choiceKnob.lock()->setValueFromLabel(label.toStdString(), 0); Q_UNUSED(s); } @@ -1130,9 +1130,9 @@ ChoiceParam::setDefaultValue(int value) } void -ChoiceParam::setDefaultValue(const std::string& value) +ChoiceParam::setDefaultValue(const QString& value) { - _choiceKnob.lock()->setDefaultValueFromLabel(value); + _choiceKnob.lock()->setDefaultValueFromLabel(value.toStdString()); } int @@ -1148,7 +1148,7 @@ ChoiceParam::restoreDefaultValue() } void -ChoiceParam::addOption(const std::string& option,const std::string& help) +ChoiceParam::addOption(const QString& option,const QString& help) { boost::shared_ptr knob = _choiceKnob.lock(); if (!knob->isUserKnob()) { @@ -1156,16 +1156,12 @@ ChoiceParam::addOption(const std::string& option,const std::string& help) } std::vector entries = knob->getEntries_mt_safe(); std::vector helps = knob->getEntriesHelp_mt_safe(); - entries.push_back(option); - if (!help.empty()) { - helps.push_back(help); - } - knob->populateChoices(entries,helps); + knob->appendChoice(option.toStdString(), help.toStdString()); } void -ChoiceParam::setOptions(const std::list >& options) +ChoiceParam::setOptions(const std::list >& options) { boost::shared_ptr knob = _choiceKnob.lock(); if (!knob->isUserKnob()) { @@ -1173,21 +1169,21 @@ ChoiceParam::setOptions(const std::list >& op } std::vector entries,helps; - for (std::list >::const_iterator it = options.begin(); it != options.end(); ++it) { - entries.push_back(it->first); - helps.push_back(it->second); + for (std::list >::const_iterator it = options.begin(); it != options.end(); ++it) { + entries.push_back(it->first.toStdString()); + helps.push_back(it->second.toStdString()); } knob->populateChoices(entries,helps); } -std::string +QString ChoiceParam::getOption(int index) const { std::vector entries = _choiceKnob.lock()->getEntries_mt_safe(); if (index < 0 || index >= (int)entries.size()) { - return std::string(); + return QString(); } - return entries[index]; + return QString::fromUtf8(entries[index].c_str()); } @@ -1197,10 +1193,15 @@ ChoiceParam::getNumOptions() const return _choiceKnob.lock()->getNumEntries(); } -std::vector +QStringList ChoiceParam::getOptions() const { - return _choiceKnob.lock()->getEntries_mt_safe(); + QStringList ret; + std::vector entries = _choiceKnob.lock()->getEntries_mt_safe(); + for (std::size_t i = 0; i < entries.size(); ++i) { + ret.push_back(QString::fromUtf8(entries[i].c_str())); + } + return ret; } int @@ -1316,65 +1317,65 @@ StringParamBase::~StringParamBase() } -std::string +QString StringParamBase::get() const { - return _stringKnob.lock()->getValue(0); + return QString::fromUtf8(_stringKnob.lock()->getValue(0).c_str()); } -std::string +QString StringParamBase::get(double frame) const { - return _stringKnob.lock()->getValueAtTime(frame,0); + return QString::fromUtf8(_stringKnob.lock()->getValueAtTime(frame,0).c_str()); } void -StringParamBase::set(const std::string& x) +StringParamBase::set(const QString& x) { - _stringKnob.lock()->setValue(x, ViewSpec::current(), 0); + _stringKnob.lock()->setValue(x.toStdString(), ViewSpec::current(), 0); } void -StringParamBase::set(const std::string& x, double frame) +StringParamBase::set(const QString& x, double frame) { - _stringKnob.lock()->setValueAtTime(frame, x, ViewSpec::current(), 0); + _stringKnob.lock()->setValueAtTime(frame, x.toStdString(), ViewSpec::current(), 0); } -std::string +QString StringParamBase::getValue() const { - return _stringKnob.lock()->getValue(0); + return QString::fromUtf8(_stringKnob.lock()->getValue(0).c_str()); } void -StringParamBase::setValue(const std::string& value) +StringParamBase::setValue(const QString& value) { - _stringKnob.lock()->setValue(value, ViewSpec::current(), 0); + _stringKnob.lock()->setValue(value.toStdString(), ViewSpec::current(), 0); } -std::string +QString StringParamBase::getValueAtTime(double time) const { - return _stringKnob.lock()->getValueAtTime(time,0); + return QString::fromUtf8(_stringKnob.lock()->getValueAtTime(time,0).c_str()); } void -StringParamBase::setValueAtTime(const std::string& value,double time) +StringParamBase::setValueAtTime(const QString& value,double time) { - _stringKnob.lock()->setValueAtTime(time, value, ViewSpec::current(), 0); + _stringKnob.lock()->setValueAtTime(time, value.toStdString(), ViewSpec::current(), 0); } void -StringParamBase::setDefaultValue(const std::string& value) +StringParamBase::setDefaultValue(const QString& value) { - _stringKnob.lock()->setDefaultValue(value,0); + _stringKnob.lock()->setDefaultValue(value.toStdString(),0); } -std::string +QString StringParamBase::getDefaultValue() const { - return _stringKnob.lock()->getDefaultValues_mt_safe()[0]; + return QString::fromUtf8( _stringKnob.lock()->getDefaultValues_mt_safe()[0].c_str()); } void @@ -1384,11 +1385,11 @@ StringParamBase::restoreDefaultValue() } -std::string +QString StringParamBase::addAsDependencyOf(int fromExprDimension,Param* param,int thisDimension) { _addAsDependencyOf(fromExprDimension, param,thisDimension); - return _stringKnob.lock()->getValue(); + return QString::fromUtf8(_stringKnob.lock()->getValue().c_str()); } @@ -1538,9 +1539,9 @@ ButtonParam::~ButtonParam() } void -ButtonParam::setIconFilePath(const std::string& icon) +ButtonParam::setIconFilePath(const QString& icon) { - _buttonKnob.lock()->setIconLabel(icon); + _buttonKnob.lock()->setIconLabel(icon.toStdString()); } void diff --git a/Engine/PyParameter.h b/Engine/PyParameter.h index 555b9955a1..56e77caa35 100644 --- a/Engine/PyParameter.h +++ b/Engine/PyParameter.h @@ -71,24 +71,24 @@ class Param * @brief Returns the name of the Param internally. This is the identifier that allows the Python programmer * to find and identify a specific Param. **/ - std::string getScriptName() const; + QString getScriptName() const; /** * @brief Returns the label of the Param as shown on the GUI. **/ - std::string getLabel() const; + QString getLabel() const; /** * @brief Returns the type of the parameter. The list of known type is: * "Int" "Bool" "Double" "Button" "Choice" "Color" "String" "Group" "Page" "Parametric" "InputFile" "OutputFile" "Path" **/ - std::string getTypeName() const; + QString getTypeName() const; /** * @brief Returns the help that describes the parameter, its effect, etc... **/ - std::string getHelp() const; - void setHelp(const std::string& help); + QString getHelp() const; + void setHelp(const QString& help); /** * @brief Returns true if this parameter is visible in the user interface, false if it is hidden. @@ -258,8 +258,8 @@ class AnimatedParam : public Param /** * @brief Set an expression on the Param. This is a Python script, see documentation for more infos. **/ - bool setExpression(const std::string& expr,bool hasRetVariable,int dimension = 0); - std::string getExpression(int dimension,bool* hasRetVariable) const; + bool setExpression(const QString& expr,bool hasRetVariable,int dimension = 0); + QString getExpression(int dimension,bool* hasRetVariable) const; bool setInterpolationAtTime(double time, NATRON_NAMESPACE::KeyframeTypeEnum interpolation, int dimension = 0); }; @@ -723,7 +723,7 @@ class ChoiceParam : public AnimatedParam * @brief Set the value from label if it exists. * The label will be compared without case sensitivity to existing entries. If it's not found, nothing is done. */ - void set(const std::string& label); + void set(const QString& label); /** * @brief Returns the value held by the parameter. If it is animated, getValueAtTime @@ -757,7 +757,7 @@ class ChoiceParam : public AnimatedParam /** * @brief Set the default value from an existing entry. If it does not match (without case sensitivity) an existing entry, nothing is done. **/ - void setDefaultValue(const std::string& value); + void setDefaultValue(const QString& value); /** * @brief Return the default value for the given dimension @@ -772,17 +772,17 @@ class ChoiceParam : public AnimatedParam /** * @brief Add a new option to the drop-down menu **/ - void addOption(const std::string& option,const std::string& help); + void addOption(const QString& option,const QString& help); /** * @brief Set all options at once **/ - void setOptions(const std::list >& options); + void setOptions(const std::list >& options); /** * @brief Returns the option at the given index **/ - std::string getOption(int index) const; + QString getOption(int index) const; /** * @brief Returns the count of options @@ -792,7 +792,7 @@ class ChoiceParam : public AnimatedParam /** * @brief Returns all options **/ - std::vector getOptions() const; + QStringList getOptions() const; /** * @brief Adds this Param as a dependency of the given Param. This is used mainly by the GUI to notify the user @@ -890,48 +890,48 @@ class StringParamBase : public AnimatedParam /** * @brief Convenience function that calls getValue() for all dimensions and store them in a tuple-like struct. **/ - std::string get() const; - std::string get(double frame) const; + QString get() const; + QString get(double frame) const; /** * @brief Convenience functions for multi-dimensional setting of values **/ - void set(const std::string& x); - void set(const std::string& x, double frame); + void set(const QString& x); + void set(const QString& x, double frame); /** * @brief Returns the value held by the parameter. If it is animated, getValueAtTime * will be called instead at the current's timeline position. **/ - std::string getValue() const; + QString getValue() const; /** * @brief Set the value held by the parameter. If it is animated * this function will either add a new keyframe or modify a keyframe already existing at the current time. **/ - void setValue(const std::string& value); + void setValue(const QString& value); /** * @brief If this parameter is animated for the given dimension, this function returns a value interpolated between the * 2 keyframes surrounding the given time. If time is exactly one keyframe then the value of the keyframe is returned. * If this parameter is not animated for the given dimension, then this function returns the same as getValue(int) **/ - std::string getValueAtTime(double time) const; + QString getValueAtTime(double time) const; /** * @brief Set a new keyframe on the parameter at the given time. If a keyframe already exists, it will modify it. **/ - void setValueAtTime(const std::string& value,double time); + void setValueAtTime(const QString& value,double time); /** * @brief Set the default value for the given dimension **/ - void setDefaultValue(const std::string& value); + void setDefaultValue(const QString& value); /** * @brief Return the default value for the given dimension **/ - std::string getDefaultValue() const; + QString getDefaultValue() const; /** * @brief Restores the default value for the given dimension @@ -943,7 +943,7 @@ class StringParamBase : public AnimatedParam * when a dependency (through expressions) is destroyed (because the holding node has been removed). * You should not call this directly. **/ - std::string addAsDependencyOf(int fromExprDimension,Param* param,int thisDimension); + QString addAsDependencyOf(int fromExprDimension,Param* param,int thisDimension); @@ -1052,7 +1052,7 @@ class ButtonParam : public Param * @brief Set the icon file-path that should be used for the button. * This can only be called right away after the parameter has been created. **/ - void setIconFilePath(const std::string& icon); + void setIconFilePath(const QString& icon); void trigger(); }; diff --git a/Engine/PyRoto.cpp b/Engine/PyRoto.cpp index 3382e15c98..d2cf522491 100644 --- a/Engine/PyRoto.cpp +++ b/Engine/PyRoto.cpp @@ -51,27 +51,27 @@ ItemBase::~ItemBase() } void -ItemBase::setLabel(const std::string & name) +ItemBase::setLabel(const QString & name) { - _item->setLabel(name); + _item->setLabel(name.toStdString()); } -std::string +QString ItemBase::getLabel() const { - return _item->getLabel(); + return QString::fromUtf8(_item->getLabel().c_str()); } bool -ItemBase::setScriptName(const std::string& name) +ItemBase::setScriptName(const QString& name) { - return _item->setScriptName(name); + return _item->setScriptName(name.toStdString()); } -std::string +QString ItemBase::getScriptName() const { - return _item->getScriptName(); + return QString::fromUtf8(_item->getScriptName().c_str()); } void @@ -116,13 +116,13 @@ ItemBase::getParentLayer() const } Param* -ItemBase::getParam(const std::string& name) const +ItemBase::getParam(const QString& name) const { RotoDrawableItem* drawable = dynamic_cast(_item.get()); if (!drawable) { return 0; } - KnobPtr knob = drawable->getKnobByName(name); + KnobPtr knob = drawable->getKnobByName(name.toStdString()); if (!knob) { return 0; } @@ -512,9 +512,9 @@ Roto::getBaseLayer() const } ItemBase* -Roto::getItemByName(const std::string& name) const +Roto::getItemByName(const QString& name) const { - boost::shared_ptr item = _ctx->getItemByName(name); + boost::shared_ptr item = _ctx->getItemByName(name.toStdString()); if (!item) { return 0; } diff --git a/Engine/PyRoto.h b/Engine/PyRoto.h index b215fe69c0..3d6ae42eaf 100644 --- a/Engine/PyRoto.h +++ b/Engine/PyRoto.h @@ -55,11 +55,11 @@ class ItemBase return _item; } - void setLabel(const std::string & name); - std::string getLabel() const; + void setLabel(const QString & name); + QString getLabel() const; - bool setScriptName(const std::string& name); - std::string getScriptName() const; + bool setScriptName(const QString& name); + QString getScriptName() const; void setLocked(bool locked); bool getLocked() const; @@ -70,7 +70,7 @@ class ItemBase Layer* getParentLayer() const; - Param* getParam(const std::string& name) const; + Param* getParam(const QString& name) const; private: @@ -216,7 +216,7 @@ class Roto Layer* getBaseLayer() const; - ItemBase* getItemByName(const std::string& name) const; + ItemBase* getItemByName(const QString& name) const; Layer* createLayer(); diff --git a/Engine/Pyside_Engine_Python.h b/Engine/Pyside_Engine_Python.h index b9cf2a9910..69bf4a66b6 100644 --- a/Engine/Pyside_Engine_Python.h +++ b/Engine/Pyside_Engine_Python.h @@ -34,7 +34,7 @@ #define SBK_RUN #include - +#include //Global #include #include diff --git a/Engine/typesystem_engine.xml b/Engine/typesystem_engine.xml index 7a9133d626..1a59470916 100644 --- a/Engine/typesystem_engine.xml +++ b/Engine/typesystem_engine.xml @@ -37,8 +37,69 @@ - - + + + + return PyUnicode_FromString(%in.c_str()); + + + + std::string %out; + + if (PyString_Check(%in)) { + char* buf = PyString_AsString(obj); + if (buf) { + %out += std::string(buf); + } + } else if (PyUnicode_Check(%in)) { + /*PyObject * temp_bytes = PyUnicode_AsEncodedString(%in, "ASCII", "strict"); // Owned reference + if (temp_bytes != NULL) { + char* cstr = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer + %out.append(cstr); + Py_DECREF(temp_bytes); + }*/ + PyObject* utf8pyobj = PyUnicode_AsUTF8String(%in); // newRef + if (utf8pyobj) { + char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer + %out.append(cstr); + Py_DECREF(utf8pyobj); + } + } else if (PyBytes_Check(%in)) { + char* cstr = PyBytes_AS_STRING(%in); // Borrowed pointer + %out.append(cstr); + } + return %out; + + + std::string %out; + + if (PyString_Check(%in)) { + char* buf = PyString_AsString(obj); + if (buf) { + %out += std::string(buf); + } + } else if (PyUnicode_Check(%in)) { + /*PyObject * temp_bytes = PyUnicode_AsEncodedString(%in, "ASCII", "strict"); // Owned reference + if (temp_bytes != NULL) { + char* cstr = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer + %out.append(cstr); + Py_DECREF(temp_bytes); + }*/ + PyObject* utf8pyobj = PyUnicode_AsUTF8String(%in); // newRef + if (utf8pyobj) { + char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer + %out.append(cstr); + Py_DECREF(utf8pyobj); + } + } else if (PyBytes_Check(%in)) { + char* cstr = PyBytes_AS_STRING(%in); // Borrowed pointer + %out.append(cstr); + } + return %out; + + + + @@ -313,7 +374,7 @@ :doc:`App` which represents an instance of Natron, or more specifically an opened project. :doc:`Effect` which represents a node in the nodegraph. - + @@ -336,7 +397,7 @@ - + @@ -345,7 +406,7 @@ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); - + @@ -354,7 +415,7 @@ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); - + @@ -363,7 +424,7 @@ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); - + @@ -427,7 +488,7 @@ %CPPSELF.%FUNCTION_NAME(effects,firstFrames,lastFrames, frameSteps); - + @@ -448,92 +509,92 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -560,7 +621,7 @@
- + @@ -584,12 +645,12 @@ %CPPSELF.%FUNCTION_NAME(%1); - + %CPPSELF.%FUNCTION_NAME(%1); - + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1); %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); @@ -660,9 +721,9 @@ - @@ -720,7 +781,7 @@ - + @@ -751,7 +812,7 @@ - + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1,%2,%3); %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); @@ -1052,13 +1113,13 @@ - + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1); %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); - + %CPPSELF.%FUNCTION_NAME(%1); @@ -1139,7 +1200,7 @@ - + diff --git a/Gui/CurveWidget.cpp b/Gui/CurveWidget.cpp index af65ad363d..2297a0aff7 100644 --- a/Gui/CurveWidget.cpp +++ b/Gui/CurveWidget.cpp @@ -1756,9 +1756,9 @@ CurveWidget::loopSelectedCurve() throw std::logic_error("CurveWidget::loopSelectedCurve"); } PyModalDialog dialog(_imp->_gui); - boost::shared_ptr firstFrame(dialog.createIntParam("firstFrame", "First frame")); + boost::shared_ptr firstFrame(dialog.createIntParam(QString::fromUtf8("firstFrame"), QString::fromUtf8("First frame"))); firstFrame->setAnimationEnabled(false); - boost::shared_ptr lastFrame(dialog.createIntParam("lastFrame", "Last frame")); + boost::shared_ptr lastFrame(dialog.createIntParam(QString::fromUtf8("lastFrame"), QString::fromUtf8("Last frame"))); lastFrame->setAnimationEnabled(false); dialog.refreshUserParamsGUI(); if (dialog.exec()) { diff --git a/Gui/NatronGui/guiapp_wrapper.cpp b/Gui/NatronGui/guiapp_wrapper.cpp index 1e8d3a00e2..94311b83b8 100644 --- a/Gui/NatronGui/guiapp_wrapper.cpp +++ b/Gui/NatronGui/guiapp_wrapper.cpp @@ -26,7 +26,6 @@ NATRON_NAMESPACE_USING #include #include #include -#include // Native --------------------------------------------------------- @@ -268,11 +267,11 @@ static PyObject* Sbk_GuiAppFunc_getDirectoryDialog(PyObject* self, PyObject* arg // Overloaded function decisor - // 0: getDirectoryDialog(std::string)const + // 0: getDirectoryDialog(QString)const if (numArgs == 0) { - overloadId = 0; // getDirectoryDialog(std::string)const - } else if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) { - overloadId = 0; // getDirectoryDialog(std::string)const + overloadId = 0; // getDirectoryDialog(QString)const + } else if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) { + overloadId = 0; // getDirectoryDialog(QString)const } // Function signature not found. @@ -287,17 +286,17 @@ static PyObject* Sbk_GuiAppFunc_getDirectoryDialog(PyObject* self, PyObject* arg return 0; } else if (value) { pyArgs[0] = value; - if (!(pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0])))) + if (!(pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0])))) goto Sbk_GuiAppFunc_getDirectoryDialog_TypeError; } } - ::std::string cppArg0 = std::string(); + ::QString cppArg0 = QString(); if (pythonToCpp[0]) pythonToCpp[0](pyArgs[0], &cppArg0); if (!PyErr_Occurred()) { - // getDirectoryDialog(std::string)const - std::string cppResult = const_cast(cppSelf)->getDirectoryDialog(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + // getDirectoryDialog(QString)const + QString cppResult = const_cast(cppSelf)->getDirectoryDialog(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -308,7 +307,7 @@ static PyObject* Sbk_GuiAppFunc_getDirectoryDialog(PyObject* self, PyObject* arg return pyResult; Sbk_GuiAppFunc_getDirectoryDialog_TypeError: - const char* overloads[] = {"std::string = std.string()", 0}; + const char* overloads[] = {"unicode = QString()", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.getDirectoryDialog", overloads); return 0; } @@ -342,12 +341,12 @@ static PyObject* Sbk_GuiAppFunc_getFilenameDialog(PyObject* self, PyObject* args // Overloaded function decisor - // 0: getFilenameDialog(std::vector,std::string)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], (pyArgs[0])))) { + // 0: getFilenameDialog(QStringList,QString)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // getFilenameDialog(std::vector,std::string)const - } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // getFilenameDialog(std::vector,std::string)const + overloadId = 0; // getFilenameDialog(QStringList,QString)const + } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // getFilenameDialog(QStringList,QString)const } } @@ -363,19 +362,19 @@ static PyObject* Sbk_GuiAppFunc_getFilenameDialog(PyObject* self, PyObject* args return 0; } else if (value) { pyArgs[1] = value; - if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) + if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) goto Sbk_GuiAppFunc_getFilenameDialog_TypeError; } } - ::std::vector cppArg0; + ::QStringList cppArg0 = ::QStringList(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1 = std::string(); + ::QString cppArg1 = QString(); if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // getFilenameDialog(std::vector,std::string)const - std::string cppResult = const_cast(cppSelf)->getFilenameDialog(cppArg0, cppArg1); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + // getFilenameDialog(QStringList,QString)const + QString cppResult = const_cast(cppSelf)->getFilenameDialog(cppArg0, cppArg1); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -386,7 +385,7 @@ static PyObject* Sbk_GuiAppFunc_getFilenameDialog(PyObject* self, PyObject* args return pyResult; Sbk_GuiAppFunc_getFilenameDialog_TypeError: - const char* overloads[] = {"list, std::string = std.string()", 0}; + const char* overloads[] = {"QStringList, unicode = QString()", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.getFilenameDialog", overloads); return 0; } @@ -533,12 +532,12 @@ static PyObject* Sbk_GuiAppFunc_getSequenceDialog(PyObject* self, PyObject* args // Overloaded function decisor - // 0: getSequenceDialog(std::vector,std::string)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], (pyArgs[0])))) { + // 0: getSequenceDialog(QStringList,QString)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // getSequenceDialog(std::vector,std::string)const - } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // getSequenceDialog(std::vector,std::string)const + overloadId = 0; // getSequenceDialog(QStringList,QString)const + } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // getSequenceDialog(QStringList,QString)const } } @@ -554,19 +553,19 @@ static PyObject* Sbk_GuiAppFunc_getSequenceDialog(PyObject* self, PyObject* args return 0; } else if (value) { pyArgs[1] = value; - if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) + if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) goto Sbk_GuiAppFunc_getSequenceDialog_TypeError; } } - ::std::vector cppArg0; + ::QStringList cppArg0 = ::QStringList(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1 = std::string(); + ::QString cppArg1 = QString(); if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // getSequenceDialog(std::vector,std::string)const - std::string cppResult = const_cast(cppSelf)->getSequenceDialog(cppArg0, cppArg1); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + // getSequenceDialog(QStringList,QString)const + QString cppResult = const_cast(cppSelf)->getSequenceDialog(cppArg0, cppArg1); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -577,7 +576,7 @@ static PyObject* Sbk_GuiAppFunc_getSequenceDialog(PyObject* self, PyObject* args return pyResult; Sbk_GuiAppFunc_getSequenceDialog_TypeError: - const char* overloads[] = {"list, std::string = std.string()", 0}; + const char* overloads[] = {"QStringList, unicode = QString()", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.getSequenceDialog", overloads); return 0; } @@ -595,9 +594,9 @@ static PyObject* Sbk_GuiAppFunc_getTabWidget(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getTabWidget(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getTabWidget(std::string)const + // 0: getTabWidget(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getTabWidget(QString)const } // Function signature not found. @@ -605,11 +604,11 @@ static PyObject* Sbk_GuiAppFunc_getTabWidget(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getTabWidget(std::string)const + // getTabWidget(QString)const PyTabWidget * cppResult = const_cast(cppSelf)->getTabWidget(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronGuiTypes[SBK_PYTABWIDGET_IDX], cppResult); @@ -625,7 +624,7 @@ static PyObject* Sbk_GuiAppFunc_getTabWidget(PyObject* self, PyObject* pyArg) return pyResult; Sbk_GuiAppFunc_getTabWidget_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.GuiApp.getTabWidget", overloads); return 0; } @@ -643,9 +642,9 @@ static PyObject* Sbk_GuiAppFunc_getUserPanel(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getUserPanel(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getUserPanel(std::string)const + // 0: getUserPanel(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getUserPanel(QString)const } // Function signature not found. @@ -653,11 +652,11 @@ static PyObject* Sbk_GuiAppFunc_getUserPanel(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getUserPanel(std::string)const + // getUserPanel(QString)const PyPanel * cppResult = const_cast(cppSelf)->getUserPanel(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronGuiTypes[SBK_PYPANEL_IDX], cppResult); } @@ -670,7 +669,7 @@ static PyObject* Sbk_GuiAppFunc_getUserPanel(PyObject* self, PyObject* pyArg) return pyResult; Sbk_GuiAppFunc_getUserPanel_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.GuiApp.getUserPanel", overloads); return 0; } @@ -688,9 +687,9 @@ static PyObject* Sbk_GuiAppFunc_getViewer(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getViewer(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getViewer(std::string)const + // 0: getViewer(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getViewer(QString)const } // Function signature not found. @@ -698,11 +697,11 @@ static PyObject* Sbk_GuiAppFunc_getViewer(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getViewer(std::string)const + // getViewer(QString)const PyViewer * cppResult = const_cast(cppSelf)->getViewer(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronGuiTypes[SBK_PYVIEWER_IDX], cppResult); @@ -718,7 +717,7 @@ static PyObject* Sbk_GuiAppFunc_getViewer(PyObject* self, PyObject* pyArg) return pyResult; Sbk_GuiAppFunc_getViewer_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.GuiApp.getViewer", overloads); return 0; } @@ -745,11 +744,11 @@ static PyObject* Sbk_GuiAppFunc_moveTab(PyObject* self, PyObject* args) // Overloaded function decisor - // 0: moveTab(std::string,PyTabWidget*) + // 0: moveTab(QString,PyTabWidget*) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronGuiTypes[SBK_PYTABWIDGET_IDX], (pyArgs[1])))) { - overloadId = 0; // moveTab(std::string,PyTabWidget*) + overloadId = 0; // moveTab(QString,PyTabWidget*) } // Function signature not found. @@ -757,7 +756,7 @@ static PyObject* Sbk_GuiAppFunc_moveTab(PyObject* self, PyObject* args) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); if (!Shiboken::Object::isValid(pyArgs[1])) return 0; @@ -765,7 +764,7 @@ static PyObject* Sbk_GuiAppFunc_moveTab(PyObject* self, PyObject* args) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // moveTab(std::string,PyTabWidget*) + // moveTab(QString,PyTabWidget*) bool cppResult = cppSelf->moveTab(cppArg0, cppArg1); pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); } @@ -778,7 +777,7 @@ static PyObject* Sbk_GuiAppFunc_moveTab(PyObject* self, PyObject* args) return pyResult; Sbk_GuiAppFunc_moveTab_TypeError: - const char* overloads[] = {"std::string, NatronGui.PyTabWidget", 0}; + const char* overloads[] = {"unicode, NatronGui.PyTabWidget", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.moveTab", overloads); return 0; } @@ -804,11 +803,11 @@ static PyObject* Sbk_GuiAppFunc_registerPythonPanel(PyObject* self, PyObject* ar // Overloaded function decisor - // 0: registerPythonPanel(PyPanel*,std::string) + // 0: registerPythonPanel(PyPanel*,QString) if (numArgs == 2 && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronGuiTypes[SBK_PYPANEL_IDX], (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // registerPythonPanel(PyPanel*,std::string) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // registerPythonPanel(PyPanel*,QString) } // Function signature not found. @@ -820,11 +819,11 @@ static PyObject* Sbk_GuiAppFunc_registerPythonPanel(PyObject* self, PyObject* ar return 0; ::PyPanel* cppArg0; pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // registerPythonPanel(PyPanel*,std::string) + // registerPythonPanel(PyPanel*,QString) cppSelf->registerPythonPanel(cppArg0, cppArg1); } } @@ -835,7 +834,7 @@ static PyObject* Sbk_GuiAppFunc_registerPythonPanel(PyObject* self, PyObject* ar Py_RETURN_NONE; Sbk_GuiAppFunc_registerPythonPanel_TypeError: - const char* overloads[] = {"NatronGui.PyPanel, std::string", 0}; + const char* overloads[] = {"NatronGui.PyPanel, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.registerPythonPanel", overloads); return 0; } @@ -1020,12 +1019,12 @@ static PyObject* Sbk_GuiAppFunc_saveFilenameDialog(PyObject* self, PyObject* arg // Overloaded function decisor - // 0: saveFilenameDialog(std::vector,std::string)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], (pyArgs[0])))) { + // 0: saveFilenameDialog(QStringList,QString)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // saveFilenameDialog(std::vector,std::string)const - } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // saveFilenameDialog(std::vector,std::string)const + overloadId = 0; // saveFilenameDialog(QStringList,QString)const + } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // saveFilenameDialog(QStringList,QString)const } } @@ -1041,19 +1040,19 @@ static PyObject* Sbk_GuiAppFunc_saveFilenameDialog(PyObject* self, PyObject* arg return 0; } else if (value) { pyArgs[1] = value; - if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) + if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) goto Sbk_GuiAppFunc_saveFilenameDialog_TypeError; } } - ::std::vector cppArg0; + ::QStringList cppArg0 = ::QStringList(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1 = std::string(); + ::QString cppArg1 = QString(); if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // saveFilenameDialog(std::vector,std::string)const - std::string cppResult = const_cast(cppSelf)->saveFilenameDialog(cppArg0, cppArg1); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + // saveFilenameDialog(QStringList,QString)const + QString cppResult = const_cast(cppSelf)->saveFilenameDialog(cppArg0, cppArg1); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1064,7 +1063,7 @@ static PyObject* Sbk_GuiAppFunc_saveFilenameDialog(PyObject* self, PyObject* arg return pyResult; Sbk_GuiAppFunc_saveFilenameDialog_TypeError: - const char* overloads[] = {"list, std::string = std.string()", 0}; + const char* overloads[] = {"QStringList, unicode = QString()", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.saveFilenameDialog", overloads); return 0; } @@ -1098,12 +1097,12 @@ static PyObject* Sbk_GuiAppFunc_saveSequenceDialog(PyObject* self, PyObject* arg // Overloaded function decisor - // 0: saveSequenceDialog(std::vector,std::string)const - if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], (pyArgs[0])))) { + // 0: saveSequenceDialog(QStringList,QString)const + if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRINGLIST_IDX], (pyArgs[0])))) { if (numArgs == 1) { - overloadId = 0; // saveSequenceDialog(std::vector,std::string)const - } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // saveSequenceDialog(std::vector,std::string)const + overloadId = 0; // saveSequenceDialog(QStringList,QString)const + } else if ((pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // saveSequenceDialog(QStringList,QString)const } } @@ -1119,19 +1118,19 @@ static PyObject* Sbk_GuiAppFunc_saveSequenceDialog(PyObject* self, PyObject* arg return 0; } else if (value) { pyArgs[1] = value; - if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) + if (!(pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) goto Sbk_GuiAppFunc_saveSequenceDialog_TypeError; } } - ::std::vector cppArg0; + ::QStringList cppArg0 = ::QStringList(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1 = std::string(); + ::QString cppArg1 = QString(); if (pythonToCpp[1]) pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // saveSequenceDialog(std::vector,std::string)const - std::string cppResult = const_cast(cppSelf)->saveSequenceDialog(cppArg0, cppArg1); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + // saveSequenceDialog(QStringList,QString)const + QString cppResult = const_cast(cppSelf)->saveSequenceDialog(cppArg0, cppArg1); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1142,7 +1141,7 @@ static PyObject* Sbk_GuiAppFunc_saveSequenceDialog(PyObject* self, PyObject* arg return pyResult; Sbk_GuiAppFunc_saveSequenceDialog_TypeError: - const char* overloads[] = {"list, std::string = std.string()", 0}; + const char* overloads[] = {"QStringList, unicode = QString()", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.saveSequenceDialog", overloads); return 0; } diff --git a/Gui/NatronGui/natrongui_module_wrapper.cpp b/Gui/NatronGui/natrongui_module_wrapper.cpp index 640b7726cf..ee257254a0 100644 --- a/Gui/NatronGui/natrongui_module_wrapper.cpp +++ b/Gui/NatronGui/natrongui_module_wrapper.cpp @@ -83,73 +83,37 @@ static PythonToCppFunc is__std_list_EffectPTR__PythonToCpp__std_list_EffectPTR__ return 0; } -// C++ to Python conversion for type 'const std::vector &'. -static PyObject* _conststd_vector_std_string_REF_CppToPython__conststd_vector_std_string_REF(const void* cppIn) { - ::std::vector& cppInRef = *((::std::vector*)cppIn); - - // TEMPLATE - stdVectorToPyList - START - ::std::vector::size_type vectorSize = cppInRef.size(); - PyObject* pyOut = PyList_New((int) vectorSize); - for (::std::vector::size_type idx = 0; idx < vectorSize; ++idx) { - ::std::string cppItem(cppInRef[idx]); - PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppItem)); - } - return pyOut; - // TEMPLATE - stdVectorToPyList - END - -} -static void _conststd_vector_std_string_REF_PythonToCpp__conststd_vector_std_string_REF(PyObject* pyIn, void* cppOut) { - ::std::vector& cppOutRef = *((::std::vector*)cppOut); - - // TEMPLATE - pySeqToStdVector - START - int vectorSize = PySequence_Size(pyIn); - cppOutRef.reserve(vectorSize); - for (int idx = 0; idx < vectorSize; ++idx) { - Shiboken::AutoDecRef pyItem(PySequence_GetItem(pyIn, idx)); - ::std::string cppItem; - Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), pyItem, &(cppItem)); - cppOutRef.push_back(cppItem); - } - // TEMPLATE - pySeqToStdVector - END - -} -static PythonToCppFunc is__conststd_vector_std_string_REF_PythonToCpp__conststd_vector_std_string_REF_Convertible(PyObject* pyIn) { - if (Shiboken::Conversions::convertibleSequenceTypes(Shiboken::Conversions::PrimitiveTypeConverter(), pyIn)) - return _conststd_vector_std_string_REF_PythonToCpp__conststd_vector_std_string_REF; - return 0; -} - -// C++ to Python conversion for type 'std::list'. -static PyObject* _std_list_std_string__CppToPython__std_list_std_string_(const void* cppIn) { - ::std::list& cppInRef = *((::std::list*)cppIn); +// C++ to Python conversion for type 'std::list'. +static PyObject* _std_list_QString__CppToPython__std_list_QString_(const void* cppIn) { + ::std::list& cppInRef = *((::std::list*)cppIn); // TEMPLATE - stdListToPyList - START PyObject* pyOut = PyList_New((int) cppInRef.size()); - ::std::list::const_iterator it = cppInRef.begin(); + ::std::list::const_iterator it = cppInRef.begin(); for (int idx = 0; it != cppInRef.end(); ++it, ++idx) { - ::std::string cppItem(*it); - PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppItem)); + ::QString cppItem(*it); + PyList_SET_ITEM(pyOut, idx, Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppItem)); } return pyOut; // TEMPLATE - stdListToPyList - END } -static void _std_list_std_string__PythonToCpp__std_list_std_string_(PyObject* pyIn, void* cppOut) { - ::std::list& cppOutRef = *((::std::list*)cppOut); +static void _std_list_QString__PythonToCpp__std_list_QString_(PyObject* pyIn, void* cppOut) { + ::std::list& cppOutRef = *((::std::list*)cppOut); // TEMPLATE - pyListToStdList - START for (int i = 0; i < PySequence_Size(pyIn); i++) { Shiboken::AutoDecRef pyItem(PySequence_GetItem(pyIn, i)); - ::std::string cppItem; - Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), pyItem, &(cppItem)); + ::QString cppItem = ::QString(); + Shiboken::Conversions::pythonToCppCopy(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], pyItem, &(cppItem)); cppOutRef.push_back(cppItem); } // TEMPLATE - pyListToStdList - END } -static PythonToCppFunc is__std_list_std_string__PythonToCpp__std_list_std_string__Convertible(PyObject* pyIn) { - if (Shiboken::Conversions::convertibleSequenceTypes(Shiboken::Conversions::PrimitiveTypeConverter(), pyIn)) - return _std_list_std_string__PythonToCpp__std_list_std_string_; +static PythonToCppFunc is__std_list_QString__PythonToCpp__std_list_QString__Convertible(PyObject* pyIn) { + if (Shiboken::Conversions::convertibleSequenceTypes(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], pyIn)) + return _std_list_QString__PythonToCpp__std_list_QString_; return 0; } @@ -511,20 +475,12 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronGui) _std_list_EffectPTR__PythonToCpp__std_list_EffectPTR_, is__std_list_EffectPTR__PythonToCpp__std_list_EffectPTR__Convertible); - // Register converter for type 'const std::vector&'. - SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, _conststd_vector_std_string_REF_CppToPython__conststd_vector_std_string_REF); - Shiboken::Conversions::registerConverterName(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], "const std::vector&"); - Shiboken::Conversions::registerConverterName(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], "std::vector"); - Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX], - _conststd_vector_std_string_REF_PythonToCpp__conststd_vector_std_string_REF, - is__conststd_vector_std_string_REF_PythonToCpp__conststd_vector_std_string_REF_Convertible); - - // Register converter for type 'std::list'. - SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_STD_STRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, _std_list_std_string__CppToPython__std_list_std_string_); - Shiboken::Conversions::registerConverterName(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_STD_STRING_IDX], "std::list"); - Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_STD_STRING_IDX], - _std_list_std_string__PythonToCpp__std_list_std_string_, - is__std_list_std_string__PythonToCpp__std_list_std_string__Convertible); + // Register converter for type 'std::list'. + SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_QSTRING_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, _std_list_QString__CppToPython__std_list_QString_); + Shiboken::Conversions::registerConverterName(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_QSTRING_IDX], "std::list"); + Shiboken::Conversions::addPythonToCppValueConversion(SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_QSTRING_IDX], + _std_list_QString__PythonToCpp__std_list_QString_, + is__std_list_QString__PythonToCpp__std_list_QString__Convertible); // Register converter for type 'const std::list&'. SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_LIST_INT_IDX] = Shiboken::Conversions::createConverter(&PyList_Type, _conststd_list_int_REF_CppToPython__conststd_list_int_REF); diff --git a/Gui/NatronGui/natrongui_python.h b/Gui/NatronGui/natrongui_python.h index dbeefb6fb8..2e41d12a39 100644 --- a/Gui/NatronGui/natrongui_python.h +++ b/Gui/NatronGui/natrongui_python.h @@ -71,17 +71,16 @@ extern SbkConverter** SbkNatronGuiTypeConverters; // Converter indices #define SBK_NATRONGUI_STD_LIST_EFFECTPTR_IDX 0 // std::list -#define SBK_NATRONGUI_STD_VECTOR_STD_STRING_IDX 1 // const std::vector & -#define SBK_NATRONGUI_STD_LIST_STD_STRING_IDX 2 // std::list -#define SBK_NATRONGUI_STD_LIST_INT_IDX 3 // const std::list & -#define SBK_NATRONGUI_QLIST_QACTIONPTR_IDX 4 // QList -#define SBK_NATRONGUI_QLIST_QOBJECTPTR_IDX 5 // const QList & -#define SBK_NATRONGUI_QLIST_QBYTEARRAY_IDX 6 // QList -#define SBK_NATRONGUI_STD_LIST_PARAMPTR_IDX 7 // std::list -#define SBK_NATRONGUI_QLIST_QVARIANT_IDX 8 // QList -#define SBK_NATRONGUI_QLIST_QSTRING_IDX 9 // QList -#define SBK_NATRONGUI_QMAP_QSTRING_QVARIANT_IDX 10 // QMap -#define SBK_NatronGui_CONVERTERS_IDX_COUNT 11 +#define SBK_NATRONGUI_STD_LIST_QSTRING_IDX 1 // std::list +#define SBK_NATRONGUI_STD_LIST_INT_IDX 2 // const std::list & +#define SBK_NATRONGUI_QLIST_QACTIONPTR_IDX 3 // QList +#define SBK_NATRONGUI_QLIST_QOBJECTPTR_IDX 4 // const QList & +#define SBK_NATRONGUI_QLIST_QBYTEARRAY_IDX 5 // QList +#define SBK_NATRONGUI_STD_LIST_PARAMPTR_IDX 6 // std::list +#define SBK_NATRONGUI_QLIST_QVARIANT_IDX 7 // QList +#define SBK_NATRONGUI_QLIST_QSTRING_IDX 8 // QList +#define SBK_NATRONGUI_QMAP_QSTRING_QVARIANT_IDX 9 // QMap +#define SBK_NatronGui_CONVERTERS_IDX_COUNT 10 // Macros for type check diff --git a/Gui/NatronGui/pyguiapplication_wrapper.cpp b/Gui/NatronGui/pyguiapplication_wrapper.cpp index a803f8589a..594df566f7 100644 --- a/Gui/NatronGui/pyguiapplication_wrapper.cpp +++ b/Gui/NatronGui/pyguiapplication_wrapper.cpp @@ -21,7 +21,6 @@ GCC_DIAG_UNUSED_LOCAL_TYPEDEFS_OFF NATRON_NAMESPACE_USING #include #include -#include // Native --------------------------------------------------------- @@ -95,17 +94,17 @@ static PyObject* Sbk_PyGuiApplicationFunc_addMenuCommand(PyObject* self, PyObjec // Overloaded function decisor - // 0: addMenuCommand(std::string,std::string) - // 1: addMenuCommand(std::string,std::string,Qt::Key,QFlags) + // 0: addMenuCommand(QString,QString) + // 1: addMenuCommand(QString,QString,Qt::Key,QFlags) if (numArgs >= 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { if (numArgs == 2) { - overloadId = 0; // addMenuCommand(std::string,std::string) + overloadId = 0; // addMenuCommand(QString,QString) } else if (numArgs == 4 && (pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(SBK_CONVERTER(SbkPySide_QtCoreTypes[SBK_QT_KEY_IDX]), (pyArgs[2]))) && (pythonToCpp[3] = Shiboken::Conversions::isPythonToCppConvertible(SBK_CONVERTER(SbkPySide_QtCoreTypes[SBK_QFLAGS_QT_KEYBOARDMODIFIER__IDX]), (pyArgs[3])))) { - overloadId = 1; // addMenuCommand(std::string,std::string,Qt::Key,QFlags) + overloadId = 1; // addMenuCommand(QString,QString,Qt::Key,QFlags) } } @@ -114,24 +113,24 @@ static PyObject* Sbk_PyGuiApplicationFunc_addMenuCommand(PyObject* self, PyObjec // Call function/method switch (overloadId) { - case 0: // addMenuCommand(const std::string & grouping, const std::string & pythonFunctionName) + case 0: // addMenuCommand(const QString & grouping, const QString & pythonFunctionName) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // addMenuCommand(std::string,std::string) + // addMenuCommand(QString,QString) cppSelf->addMenuCommand(cppArg0, cppArg1); } break; } - case 1: // addMenuCommand(const std::string & grouping, const std::string & pythonFunctionName, Qt::Key key, const QFlags & modifiers) + case 1: // addMenuCommand(const QString & grouping, const QString & pythonFunctionName, Qt::Key key, const QFlags & modifiers) { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); ::Qt::Key cppArg2 = ((::Qt::Key)0); pythonToCpp[2](pyArgs[2], &cppArg2); @@ -139,7 +138,7 @@ static PyObject* Sbk_PyGuiApplicationFunc_addMenuCommand(PyObject* self, PyObjec pythonToCpp[3](pyArgs[3], &cppArg3); if (!PyErr_Occurred()) { - // addMenuCommand(std::string,std::string,Qt::Key,QFlags) + // addMenuCommand(QString,QString,Qt::Key,QFlags) cppSelf->addMenuCommand(cppArg0, cppArg1, cppArg2, cppArg3); } break; @@ -152,7 +151,7 @@ static PyObject* Sbk_PyGuiApplicationFunc_addMenuCommand(PyObject* self, PyObjec Py_RETURN_NONE; Sbk_PyGuiApplicationFunc_addMenuCommand_TypeError: - const char* overloads[] = {"std::string, std::string", "std::string, std::string, PySide.QtCore.Qt.Key, PySide.QtCore.Qt.KeyboardModifiers", 0}; + const char* overloads[] = {"unicode, unicode", "unicode, unicode, PySide.QtCore.Qt.Key, PySide.QtCore.Qt.KeyboardModifiers", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.PyGuiApplication.addMenuCommand", overloads); return 0; } @@ -178,11 +177,11 @@ static PyObject* Sbk_PyGuiApplicationFunc_errorDialog(PyObject* self, PyObject* // Overloaded function decisor - // 0: errorDialog(std::string,std::string) + // 0: errorDialog(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // errorDialog(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // errorDialog(QString,QString) } // Function signature not found. @@ -190,13 +189,13 @@ static PyObject* Sbk_PyGuiApplicationFunc_errorDialog(PyObject* self, PyObject* // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // errorDialog(std::string,std::string) + // errorDialog(QString,QString) cppSelf->errorDialog(cppArg0, cppArg1); } } @@ -207,7 +206,7 @@ static PyObject* Sbk_PyGuiApplicationFunc_errorDialog(PyObject* self, PyObject* Py_RETURN_NONE; Sbk_PyGuiApplicationFunc_errorDialog_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.PyGuiApplication.errorDialog", overloads); return 0; } @@ -281,11 +280,11 @@ static PyObject* Sbk_PyGuiApplicationFunc_informationDialog(PyObject* self, PyOb // Overloaded function decisor - // 0: informationDialog(std::string,std::string) + // 0: informationDialog(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // informationDialog(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // informationDialog(QString,QString) } // Function signature not found. @@ -293,13 +292,13 @@ static PyObject* Sbk_PyGuiApplicationFunc_informationDialog(PyObject* self, PyOb // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // informationDialog(std::string,std::string) + // informationDialog(QString,QString) cppSelf->informationDialog(cppArg0, cppArg1); } } @@ -310,7 +309,7 @@ static PyObject* Sbk_PyGuiApplicationFunc_informationDialog(PyObject* self, PyOb Py_RETURN_NONE; Sbk_PyGuiApplicationFunc_informationDialog_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.PyGuiApplication.informationDialog", overloads); return 0; } @@ -336,11 +335,11 @@ static PyObject* Sbk_PyGuiApplicationFunc_warningDialog(PyObject* self, PyObject // Overloaded function decisor - // 0: warningDialog(std::string,std::string) + // 0: warningDialog(QString,QString) if (numArgs == 2 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1])))) { - overloadId = 0; // warningDialog(std::string,std::string) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1])))) { + overloadId = 0; // warningDialog(QString,QString) } // Function signature not found. @@ -348,13 +347,13 @@ static PyObject* Sbk_PyGuiApplicationFunc_warningDialog(PyObject* self, PyObject // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); if (!PyErr_Occurred()) { - // warningDialog(std::string,std::string) + // warningDialog(QString,QString) cppSelf->warningDialog(cppArg0, cppArg1); } } @@ -365,7 +364,7 @@ static PyObject* Sbk_PyGuiApplicationFunc_warningDialog(PyObject* self, PyObject Py_RETURN_NONE; Sbk_PyGuiApplicationFunc_warningDialog_TypeError: - const char* overloads[] = {"std::string, std::string", 0}; + const char* overloads[] = {"unicode, unicode", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.PyGuiApplication.warningDialog", overloads); return 0; } diff --git a/Gui/NatronGui/pymodaldialog_wrapper.cpp b/Gui/NatronGui/pymodaldialog_wrapper.cpp index 7d0660d0c9..a75c0319e3 100644 --- a/Gui/NatronGui/pymodaldialog_wrapper.cpp +++ b/Gui/NatronGui/pymodaldialog_wrapper.cpp @@ -1382,9 +1382,9 @@ static PyObject* Sbk_PyModalDialogFunc_getParam(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getParam(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getParam(std::string)const + // 0: getParam(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getParam(QString)const } // Function signature not found. @@ -1392,11 +1392,11 @@ static PyObject* Sbk_PyModalDialogFunc_getParam(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getParam(std::string)const + // getParam(QString)const Param * cppResult = const_cast(cppSelf)->getParam(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAM_IDX], cppResult); @@ -1412,7 +1412,7 @@ static PyObject* Sbk_PyModalDialogFunc_getParam(PyObject* self, PyObject* pyArg) return pyResult; Sbk_PyModalDialogFunc_getParam_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.PyModalDialog.getParam", overloads); return 0; } @@ -1486,9 +1486,9 @@ static PyObject* Sbk_PyModalDialogFunc_setParamChangedCallback(PyObject* self, P SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setParamChangedCallback(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setParamChangedCallback(std::string) + // 0: setParamChangedCallback(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setParamChangedCallback(QString) } // Function signature not found. @@ -1496,11 +1496,11 @@ static PyObject* Sbk_PyModalDialogFunc_setParamChangedCallback(PyObject* self, P // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setParamChangedCallback(std::string) + // setParamChangedCallback(QString) cppSelf->setParamChangedCallback(cppArg0); } } @@ -1511,7 +1511,7 @@ static PyObject* Sbk_PyModalDialogFunc_setParamChangedCallback(PyObject* self, P Py_RETURN_NONE; Sbk_PyModalDialogFunc_setParamChangedCallback_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.PyModalDialog.setParamChangedCallback", overloads); return 0; } diff --git a/Gui/NatronGui/pypanel_wrapper.cpp b/Gui/NatronGui/pypanel_wrapper.cpp index 4fc48b1328..3c652ee578 100644 --- a/Gui/NatronGui/pypanel_wrapper.cpp +++ b/Gui/NatronGui/pypanel_wrapper.cpp @@ -65,7 +65,7 @@ void PyPanelWrapper::pysideInitQtMetaTypes() { } -PyPanelWrapper::PyPanelWrapper(const std::string & scriptName, const std::string & label, bool useUserParameters, GuiApp * app) : PyPanel(scriptName, label, useUserParameters, app) { +PyPanelWrapper::PyPanelWrapper(const QString & scriptName, const QString & label, bool useUserParameters, GuiApp * app) : PyPanel(scriptName, label, useUserParameters, app) { // ... middle } @@ -1075,7 +1075,7 @@ void PyPanelWrapper::resizeEvent(QResizeEvent * event) Shiboken::Object::invalidate(PyTuple_GET_ITEM(pyArgs, 0)); } -void PyPanelWrapper::restore(const std::string & arg__1) +void PyPanelWrapper::restore(const QString & arg__1) { Shiboken::GilState gil; if (PyErr_Occurred()) @@ -1087,7 +1087,7 @@ void PyPanelWrapper::restore(const std::string & arg__1) } Shiboken::AutoDecRef pyArgs(Py_BuildValue("(N)", - Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &arg__1) + Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &arg__1) )); Shiboken::AutoDecRef pyResult(PyObject_Call(pyOverride, pyArgs, NULL)); @@ -1098,11 +1098,11 @@ void PyPanelWrapper::restore(const std::string & arg__1) } } -std::string PyPanelWrapper::save() +QString PyPanelWrapper::save() { Shiboken::GilState gil; if (PyErr_Occurred()) - return ::std::string(); + return ::QString(); Shiboken::AutoDecRef pyOverride(Shiboken::BindingManager::instance().getOverride(this, "save")); if (pyOverride.isNull()) { gil.release(); @@ -1115,15 +1115,15 @@ std::string PyPanelWrapper::save() // An error happened in python code! if (pyResult.isNull()) { PyErr_Print(); - return ::std::string(); + return ::QString(); } // Check return type - PythonToCppFunc pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), pyResult); + PythonToCppFunc pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], pyResult); if (!pythonToCpp) { - Shiboken::warning(PyExc_RuntimeWarning, 2, "Invalid return value in function %s, expected %s, got %s.", "PyPanel.save", "string", pyResult->ob_type->tp_name); - return ::std::string(); + Shiboken::warning(PyExc_RuntimeWarning, 2, "Invalid return value in function %s, expected %s, got %s.", "PyPanel.save", "QString", pyResult->ob_type->tp_name); + return ::QString(); } - ::std::string cppResult; + ::QString cppResult = ::QString(); pythonToCpp(pyResult, &cppResult); return cppResult; } @@ -1350,13 +1350,13 @@ Sbk_PyPanel_Init(PyObject* self, PyObject* args, PyObject* kwds) // Overloaded function decisor - // 0: PyPanel(std::string,std::string,bool,GuiApp*) + // 0: PyPanel(QString,QString,bool,GuiApp*) if (numArgs == 4 - && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[0]))) - && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[1]))) + && (pythonToCpp[0] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[0]))) + && (pythonToCpp[1] = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArgs[1]))) && (pythonToCpp[2] = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArgs[2]))) && (pythonToCpp[3] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronGuiTypes[SBK_GUIAPP_IDX], (pyArgs[3])))) { - overloadId = 0; // PyPanel(std::string,std::string,bool,GuiApp*) + overloadId = 0; // PyPanel(QString,QString,bool,GuiApp*) } // Function signature not found. @@ -1364,9 +1364,9 @@ Sbk_PyPanel_Init(PyObject* self, PyObject* args, PyObject* kwds) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp[0](pyArgs[0], &cppArg0); - ::std::string cppArg1; + ::QString cppArg1 = ::QString(); pythonToCpp[1](pyArgs[1], &cppArg1); bool cppArg2; pythonToCpp[2](pyArgs[2], &cppArg2); @@ -1376,7 +1376,7 @@ Sbk_PyPanel_Init(PyObject* self, PyObject* args, PyObject* kwds) pythonToCpp[3](pyArgs[3], &cppArg3); if (!PyErr_Occurred()) { - // PyPanel(std::string,std::string,bool,GuiApp*) + // PyPanel(QString,QString,bool,GuiApp*) void* addr = PySide::nextQObjectMemoryAddr(); if (addr) { cptr = new (addr) ::PyPanelWrapper(cppArg0, cppArg1, cppArg2, cppArg3); @@ -1408,7 +1408,7 @@ Sbk_PyPanel_Init(PyObject* self, PyObject* args, PyObject* kwds) return 1; Sbk_PyPanel_Init_TypeError: - const char* overloads[] = {"std::string, std::string, bool, NatronGui.GuiApp", 0}; + const char* overloads[] = {"unicode, unicode, bool, NatronGui.GuiApp", 0}; Shiboken::setErrorAboutWrongArguments(args, "NatronGui.PyPanel", overloads); return -1; } @@ -1471,8 +1471,8 @@ static PyObject* Sbk_PyPanelFunc_getPanelLabel(PyObject* self) if (!PyErr_Occurred()) { // getPanelLabel()const - std::string cppResult = const_cast(cppSelf)->getPanelLabel(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getPanelLabel(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1497,8 +1497,8 @@ static PyObject* Sbk_PyPanelFunc_getPanelScriptName(PyObject* self) if (!PyErr_Occurred()) { // getPanelScriptName()const - std::string cppResult = const_cast(cppSelf)->getPanelScriptName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getPanelScriptName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1522,9 +1522,9 @@ static PyObject* Sbk_PyPanelFunc_getParam(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: getParam(std::string)const - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // getParam(std::string)const + // 0: getParam(QString)const + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // getParam(QString)const } // Function signature not found. @@ -1532,11 +1532,11 @@ static PyObject* Sbk_PyPanelFunc_getParam(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // getParam(std::string)const + // getParam(QString)const Param * cppResult = const_cast(cppSelf)->getParam(cppArg0); pyResult = Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_PARAM_IDX], cppResult); @@ -1552,7 +1552,7 @@ static PyObject* Sbk_PyPanelFunc_getParam(PyObject* self, PyObject* pyArg) return pyResult; Sbk_PyPanelFunc_getParam_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.PyPanel.getParam", overloads); return 0; } @@ -1689,9 +1689,9 @@ static PyObject* Sbk_PyPanelFunc_restore(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: restore(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // restore(std::string) + // 0: restore(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // restore(QString) } // Function signature not found. @@ -1699,11 +1699,11 @@ static PyObject* Sbk_PyPanelFunc_restore(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // restore(std::string) + // restore(QString) Shiboken::Object::hasCppWrapper(reinterpret_cast(self)) ? cppSelf->::PyPanel::restore(cppArg0) : cppSelf->restore(cppArg0); } } @@ -1714,7 +1714,7 @@ static PyObject* Sbk_PyPanelFunc_restore(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_PyPanelFunc_restore_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.PyPanel.restore", overloads); return 0; } @@ -1733,8 +1733,8 @@ static PyObject* Sbk_PyPanelFunc_save(PyObject* self) if (!PyErr_Occurred()) { // save() - std::string cppResult = ((::PyPanelWrapper*) cppSelf)->PyPanelWrapper::save_protected(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = ((::PyPanelWrapper*) cppSelf)->PyPanelWrapper::save_protected(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -1757,9 +1757,9 @@ static PyObject* Sbk_PyPanelFunc_setPanelLabel(PyObject* self, PyObject* pyArg) SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setPanelLabel(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setPanelLabel(std::string) + // 0: setPanelLabel(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setPanelLabel(QString) } // Function signature not found. @@ -1767,11 +1767,11 @@ static PyObject* Sbk_PyPanelFunc_setPanelLabel(PyObject* self, PyObject* pyArg) // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setPanelLabel(std::string) + // setPanelLabel(QString) cppSelf->setPanelLabel(cppArg0); } } @@ -1782,7 +1782,7 @@ static PyObject* Sbk_PyPanelFunc_setPanelLabel(PyObject* self, PyObject* pyArg) Py_RETURN_NONE; Sbk_PyPanelFunc_setPanelLabel_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.PyPanel.setPanelLabel", overloads); return 0; } @@ -1799,9 +1799,9 @@ static PyObject* Sbk_PyPanelFunc_setParamChangedCallback(PyObject* self, PyObjec SBK_UNUSED(pythonToCpp) // Overloaded function decisor - // 0: setParamChangedCallback(std::string) - if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), (pyArg)))) { - overloadId = 0; // setParamChangedCallback(std::string) + // 0: setParamChangedCallback(QString) + if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], (pyArg)))) { + overloadId = 0; // setParamChangedCallback(QString) } // Function signature not found. @@ -1809,11 +1809,11 @@ static PyObject* Sbk_PyPanelFunc_setParamChangedCallback(PyObject* self, PyObjec // Call function/method { - ::std::string cppArg0; + ::QString cppArg0 = ::QString(); pythonToCpp(pyArg, &cppArg0); if (!PyErr_Occurred()) { - // setParamChangedCallback(std::string) + // setParamChangedCallback(QString) cppSelf->setParamChangedCallback(cppArg0); } } @@ -1824,7 +1824,7 @@ static PyObject* Sbk_PyPanelFunc_setParamChangedCallback(PyObject* self, PyObjec Py_RETURN_NONE; Sbk_PyPanelFunc_setParamChangedCallback_TypeError: - const char* overloads[] = {"std::string", 0}; + const char* overloads[] = {"unicode", 0}; Shiboken::setErrorAboutWrongArguments(pyArg, "NatronGui.PyPanel.setParamChangedCallback", overloads); return 0; } diff --git a/Gui/NatronGui/pypanel_wrapper.h b/Gui/NatronGui/pypanel_wrapper.h index 8c1b9086d5..77043b5183 100644 --- a/Gui/NatronGui/pypanel_wrapper.h +++ b/Gui/NatronGui/pypanel_wrapper.h @@ -11,7 +11,7 @@ NATRON_NAMESPACE_ENTER; class PyPanelWrapper : public PyPanel { public: - PyPanelWrapper(const std::string & scriptName, const std::string & label, bool useUserParameters, GuiApp * app); + PyPanelWrapper(const QString & scriptName, const QString & label, bool useUserParameters, GuiApp * app); inline void actionEvent_protected(QActionEvent * event) { PyPanel::actionEvent(event); } virtual void actionEvent(QActionEvent * event); inline void changeEvent_protected(QEvent * event) { PyPanel::changeEvent(event); } @@ -87,9 +87,9 @@ class PyPanelWrapper : public PyPanel inline void resetInputContext_protected() { PyPanel::resetInputContext(); } inline void resizeEvent_protected(QResizeEvent * event) { PyPanel::resizeEvent(event); } virtual void resizeEvent(QResizeEvent * event); - virtual void restore(const std::string & arg__1); - inline std::string save_protected() { return PyPanel::save(); } - virtual std::string save(); + virtual void restore(const QString & arg__1); + inline QString save_protected() { return PyPanel::save(); } + virtual QString save(); inline QObject * sender_protected() const { return PyPanel::sender(); } inline int senderSignalIndex_protected() const { return PyPanel::senderSignalIndex(); } virtual void setVisible(bool visible); diff --git a/Gui/NatronGui/pytabwidget_wrapper.cpp b/Gui/NatronGui/pytabwidget_wrapper.cpp index 376029b446..b654d86c95 100644 --- a/Gui/NatronGui/pytabwidget_wrapper.cpp +++ b/Gui/NatronGui/pytabwidget_wrapper.cpp @@ -306,8 +306,8 @@ static PyObject* Sbk_PyTabWidgetFunc_getScriptName(PyObject* self) if (!PyErr_Occurred()) { // getScriptName()const - std::string cppResult = const_cast(cppSelf)->getScriptName(); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getScriptName(); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } @@ -346,8 +346,8 @@ static PyObject* Sbk_PyTabWidgetFunc_getTabLabel(PyObject* self, PyObject* pyArg if (!PyErr_Occurred()) { // getTabLabel(int)const - std::string cppResult = const_cast(cppSelf)->getTabLabel(cppArg0); - pyResult = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &cppResult); + QString cppResult = const_cast(cppSelf)->getTabLabel(cppArg0); + pyResult = Shiboken::Conversions::copyToPython(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], &cppResult); } } diff --git a/Gui/ProjectGui.cpp b/Gui/ProjectGui.cpp index 41ea58ff2b..395e8a6a0a 100644 --- a/Gui/ProjectGui.cpp +++ b/Gui/ProjectGui.cpp @@ -559,9 +559,9 @@ ProjectGui::load(boost::archive::xml_iarchive & ar if (found != registeredTabs.end()) { PyPanel* panel = dynamic_cast(found->second.first); if (panel) { - panel->restore((*it)->userData); + panel->restore(QString::fromUtf8((*it)->userData.c_str())); for (std::list >::iterator it2 = (*it)->knobs.begin(); it2!=(*it)->knobs.end(); ++it2) { - Param* param = panel->getParam((*it2)->getName()); + Param* param = panel->getParam(QString::fromUtf8((*it2)->getName().c_str())); if (param) { param->getInternalKnob()->clone((*it2)->getKnob()); delete param; diff --git a/Gui/ProjectGuiSerialization.cpp b/Gui/ProjectGuiSerialization.cpp index 7bbf0ad6ec..f6b71b4a5d 100644 --- a/Gui/ProjectGuiSerialization.cpp +++ b/Gui/ProjectGuiSerialization.cpp @@ -305,7 +305,7 @@ PythonPanelSerialization::initialize(PyPanel* tab,const std::string& func) delete *it; } - userData = tab->save_serialization_thread(); + userData = tab->save_serialization_thread().toStdString(); } NATRON_NAMESPACE_EXIT; diff --git a/Gui/PyGlobalGui.h b/Gui/PyGlobalGui.h index 6e6c746143..2df0741cdb 100644 --- a/Gui/PyGlobalGui.h +++ b/Gui/PyGlobalGui.h @@ -78,36 +78,36 @@ class PyGuiApplication : public PyCoreApplication return new GuiApp(app); } - void informationDialog(const std::string& title,const std::string& message) + void informationDialog(const QString& title,const QString& message) { - Dialogs::informationDialog(title, message); + Dialogs::informationDialog(title.toStdString(), message.toStdString()); } - void warningDialog(const std::string& title,const std::string& message) + void warningDialog(const QString& title,const QString& message) { - Dialogs::warningDialog(title,message); + Dialogs::warningDialog(title.toStdString(),message.toStdString()); } - void errorDialog(const std::string& title,const std::string& message) + void errorDialog(const QString& title,const QString& message) { - Dialogs::errorDialog(title,message); + Dialogs::errorDialog(title.toStdString(),message.toStdString()); } - StandardButtonEnum questionDialog(const std::string& title,const std::string& message) + StandardButtonEnum questionDialog(const QString& title,const QString& message) { - return Dialogs::questionDialog(title, message, false); + return Dialogs::questionDialog(title.toStdString(), message.toStdString(), false); } - void addMenuCommand(const std::string& grouping,const std::string& pythonFunctionName) + void addMenuCommand(const QString& grouping,const QString& pythonFunctionName) { - appPTR->addCommand(QString::fromUtf8(grouping.c_str()), pythonFunctionName, (Qt::Key)0, Qt::NoModifier); + appPTR->addCommand(grouping, pythonFunctionName.toStdString(), (Qt::Key)0, Qt::NoModifier); } - void addMenuCommand(const std::string& grouping,const std::string& pythonFunctionName, + void addMenuCommand(const QString& grouping,const QString& pythonFunctionName, Qt::Key key, const Qt::KeyboardModifiers& modifiers) { - appPTR->addCommand(QString::fromUtf8(grouping.c_str()), pythonFunctionName, key, modifiers); + appPTR->addCommand(grouping, pythonFunctionName.toStdString(), key, modifiers); } }; diff --git a/Gui/PyGuiApp.cpp b/Gui/PyGuiApp.cpp index 42f2611905..19ea392b18 100644 --- a/Gui/PyGuiApp.cpp +++ b/Gui/PyGuiApp.cpp @@ -82,11 +82,11 @@ GuiApp::createModalDialog() PyTabWidget* -GuiApp::getTabWidget(const std::string& name) const +GuiApp::getTabWidget(const QString& name) const { const std::list& tabs = _app->getGui()->getPanes(); for ( std::list::const_iterator it = tabs.begin(); it != tabs.end(); ++it) { - if ((*it)->objectName_mt_safe().toStdString() == name) { + if ((*it)->objectName_mt_safe() == name) { return new PyTabWidget(*it); } } @@ -104,11 +104,11 @@ GuiApp::getActiveTabWidget() const } bool -GuiApp::moveTab(const std::string& scriptName,PyTabWidget* pane) +GuiApp::moveTab(const QString& scriptName,PyTabWidget* pane) { PanelWidget* w; ScriptObject* o; - _app->getGui()->findExistingTab(scriptName, &w, &o); + _app->getGui()->findExistingTab(scriptName.toStdString(), &w, &o); if (!w || !o) { return false; } @@ -117,9 +117,9 @@ GuiApp::moveTab(const std::string& scriptName,PyTabWidget* pane) } void -GuiApp::registerPythonPanel(PyPanel* panel,const std::string& pythonFunction) +GuiApp::registerPythonPanel(PyPanel* panel,const QString& pythonFunction) { - _app->getGui()->registerPyPanel(panel,pythonFunction); + _app->getGui()->registerPyPanel(panel,pythonFunction.toStdString()); } void @@ -128,105 +128,119 @@ GuiApp::unregisterPythonPanel(PyPanel* panel) _app->getGui()->unregisterPyPanel(panel); } -std::string -GuiApp::getFilenameDialog(const std::vector& filters, - const std::string& location) const +QString +GuiApp::getFilenameDialog(const QStringList& filters, + const QString& location) const { Gui* gui = _app->getGui(); + std::vector f; + for (QStringList::const_iterator it = filters.begin(); it!=filters.end(); ++it) { + f.push_back(it->toStdString()); + } SequenceFileDialog dialog(gui, - filters, + f, false, SequenceFileDialog::eFileDialogModeOpen, - location, + location.toStdString(), gui, false); if (dialog.exec()) { - std::string ret = dialog.selectedFiles(); + QString ret = QString::fromUtf8(dialog.selectedFiles().c_str()); return ret; } - return std::string(); + return QString(); } -std::string -GuiApp::getSequenceDialog(const std::vector& filters, - const std::string& location) const +QString +GuiApp::getSequenceDialog(const QStringList& filters, + const QString& location) const { Gui* gui = _app->getGui(); - + std::vector f; + for (QStringList::const_iterator it = filters.begin(); it!=filters.end(); ++it) { + f.push_back(it->toStdString()); + } SequenceFileDialog dialog(gui, - filters, + f, true, SequenceFileDialog::eFileDialogModeOpen, - location, + location.toStdString(), gui, false); if (dialog.exec()) { - std::string ret = dialog.selectedFiles(); + QString ret = QString::fromUtf8(dialog.selectedFiles().c_str()); return ret; } - return std::string(); + return QString(); } -std::string -GuiApp::getDirectoryDialog(const std::string& location) const +QString +GuiApp::getDirectoryDialog(const QString& location) const { Gui* gui = _app->getGui(); - std::vector filters; + std::vector f; + SequenceFileDialog dialog(gui, - filters, + f, false, SequenceFileDialog::eFileDialogModeDir, - location, + location.toStdString(), gui, false); if (dialog.exec()) { - std::string ret = dialog.selectedDirectory(); + QString ret = QString::fromUtf8(dialog.selectedDirectory().c_str()); return ret; } - return std::string(); + return QString(); } -std::string -GuiApp::saveFilenameDialog(const std::vector& filters, - const std::string& location) const +QString +GuiApp::saveFilenameDialog(const QStringList& filters, + const QString& location) const { Gui* gui = _app->getGui(); - + std::vector f; + for (QStringList::const_iterator it = filters.begin(); it!=filters.end(); ++it) { + f.push_back(it->toStdString()); + } SequenceFileDialog dialog(gui, - filters, + f, false, SequenceFileDialog::eFileDialogModeSave, - location, + location.toStdString(), gui, false); if (dialog.exec()) { - std::string ret = dialog.filesToSave(); + QString ret = QString::fromUtf8(dialog.filesToSave().c_str()); return ret; } - return std::string(); + return QString(); } -std::string -GuiApp::saveSequenceDialog(const std::vector& filters, - const std::string& location) const +QString +GuiApp::saveSequenceDialog(const QStringList& filters, + const QString& location) const { Gui* gui = _app->getGui(); - + std::vector f; + for (QStringList::const_iterator it = filters.begin(); it!=filters.end(); ++it) { + f.push_back(it->toStdString()); + } SequenceFileDialog dialog(gui, - filters, + f, true, SequenceFileDialog::eFileDialogModeSave, - location, + location.toStdString(), gui, false); if (dialog.exec()) { - std::string ret = dialog.filesToSave(); + QString ret = QString::fromUtf8(dialog.filesToSave().c_str()); return ret; } - return std::string(); + return QString(); } @@ -458,9 +472,9 @@ GuiApp::clearSelection(Group* group) } PyViewer* -GuiApp::getViewer(const std::string& scriptName) const +GuiApp::getViewer(const QString& scriptName) const { - NodePtr ptr = _app->getNodeByFullySpecifiedName(scriptName); + NodePtr ptr = _app->getNodeByFullySpecifiedName(scriptName.toStdString()); if (!ptr || !ptr->isActivated()) { return 0; } @@ -493,9 +507,9 @@ GuiApp::getActiveViewer() const PyPanel* -GuiApp::getUserPanel(const std::string& scriptName) const +GuiApp::getUserPanel(const QString& scriptName) const { - PanelWidget* w = _app->getGui()->findExistingTab(scriptName); + PanelWidget* w = _app->getGui()->findExistingTab(scriptName.toStdString()); if (!w) { return 0; } diff --git a/Gui/PyGuiApp.h b/Gui/PyGuiApp.h index 8824a08c70..a7389cbd44 100644 --- a/Gui/PyGuiApp.h +++ b/Gui/PyGuiApp.h @@ -117,24 +117,24 @@ class GuiApp : public App PyModalDialog* createModalDialog(); - PyTabWidget* getTabWidget(const std::string& name) const; + PyTabWidget* getTabWidget(const QString& name) const; PyTabWidget* getActiveTabWidget() const; - bool moveTab(const std::string& scriptName,PyTabWidget* pane); + bool moveTab(const QString& scriptName,PyTabWidget* pane); - void registerPythonPanel(PyPanel* panel,const std::string& pythonFunction); + void registerPythonPanel(PyPanel* panel,const QString& pythonFunction); void unregisterPythonPanel(PyPanel* panel); - std::string getFilenameDialog(const std::vector& filters,const std::string& location = std::string()) const; + QString getFilenameDialog(const QStringList& filters,const QString& location = QString()) const; - std::string getSequenceDialog(const std::vector& filters,const std::string& location = std::string()) const; + QString getSequenceDialog(const QStringList& filters,const QString& location = QString()) const; - std::string getDirectoryDialog(const std::string& location = std::string()) const; + QString getDirectoryDialog(const QString& location = QString()) const; - std::string saveFilenameDialog(const std::vector& filters,const std::string& location = std::string()) const; + QString saveFilenameDialog(const QStringList& filters,const QString& location = QString()) const; - std::string saveSequenceDialog(const std::vector& filters,const std::string& location = std::string()) const; + QString saveSequenceDialog(const QStringList& filters,const QString& location = QString()) const; ColorTuple getRGBColorDialog() const; @@ -146,11 +146,11 @@ class GuiApp : public App void deselectNode(Effect* effect); void clearSelection(Group* group = 0); - PyViewer* getViewer(const std::string& scriptName) const; + PyViewer* getViewer(const QString& scriptName) const; PyViewer* getActiveViewer() const; - PyPanel* getUserPanel(const std::string& scriptName) const; + PyPanel* getUserPanel(const QString& scriptName) const; void renderBlocking(Effect* writeNode,int firstFrame, int lastFrame,int frameStep = 1); void renderBlocking(const std::list& effects,const std::list& firstFrames,const std::list& lastFrames,const std::list& frameSteps); diff --git a/Gui/PythonPanels.cpp b/Gui/PythonPanels.cpp index 4552946c46..620a7c906d 100644 --- a/Gui/PythonPanels.cpp +++ b/Gui/PythonPanels.cpp @@ -54,8 +54,8 @@ struct DialogParamHolderPrivate QMutex paramChangedCBMutex; std::string paramChangedCB; - DialogParamHolderPrivate(const std::string& uniqueID) - : uniqueID(uniqueID) + DialogParamHolderPrivate(const QString& uniqueID) + : uniqueID(uniqueID.toStdString()) , paramChangedCBMutex() , paramChangedCB() { @@ -63,7 +63,7 @@ struct DialogParamHolderPrivate } }; -DialogParamHolder::DialogParamHolder(const std::string& uniqueID,AppInstance* app) +DialogParamHolder::DialogParamHolder(const QString& uniqueID,AppInstance* app) : NamedKnobHolder(app) , _imp(new DialogParamHolderPrivate(uniqueID)) { @@ -82,10 +82,10 @@ DialogParamHolder::getScriptName_mt_safe() const } void -DialogParamHolder::setParamChangedCallback(const std::string& callback) +DialogParamHolder::setParamChangedCallback(const QString& callback) { QMutexLocker k(&_imp->paramChangedCBMutex); - _imp->paramChangedCB = callback; + _imp->paramChangedCB = callback.toStdString(); } void @@ -186,7 +186,7 @@ PyModalDialog::PyModalDialog(Gui* gui) , UserParamHolder() , _imp(new PyModalDialogPrivate(gui)) { - _imp->holder = new DialogParamHolder(std::string(),gui->getApp()); + _imp->holder = new DialogParamHolder(QString(),gui->getApp()); setHolder(_imp->holder); _imp->holder->initializeKnobsPublic(); _imp->mainLayout = new QVBoxLayout(this); @@ -239,15 +239,15 @@ PyModalDialog::addWidget(QWidget* widget) void -PyModalDialog::setParamChangedCallback(const std::string& callback) +PyModalDialog::setParamChangedCallback(const QString& callback) { _imp->holder->setParamChangedCallback(callback); } Param* -PyModalDialog::getParam(const std::string& scriptName) const +PyModalDialog::getParam(const QString& scriptName) const { - KnobPtr knob = _imp->holder->getKnobByName(scriptName); + KnobPtr knob = _imp->holder->getKnobByName(scriptName.toStdString()); if (!knob) { return 0; } @@ -269,7 +269,7 @@ struct PyPanelPrivate QVBoxLayout* centerLayout; mutable QMutex serializationMutex; - std::string serialization; + QString serialization; PyPanelPrivate() @@ -287,17 +287,17 @@ struct PyPanelPrivate -PyPanel::PyPanel(const std::string& scriptName,const std::string& label,bool useUserParameters,GuiApp* app) +PyPanel::PyPanel(const QString& scriptName,const QString& label,bool useUserParameters,GuiApp* app) : QWidget(app->getGui()) , UserParamHolder() , PanelWidget(this,app->getGui()) , _imp(new PyPanelPrivate()) { - setLabel(label.c_str()); + setLabel(label.toStdString()); int idx = 1; - std::string name = Python::makeNameScriptFriendly(scriptName); + std::string name = Python::makeNameScriptFriendly(scriptName.toStdString()); PanelWidget* existing = 0; existing = getGui()->findExistingTab(name); while (existing) { @@ -315,7 +315,7 @@ PyPanel::PyPanel(const std::string& scriptName,const std::string& label,bool use if (useUserParameters) { - _imp->holder = new DialogParamHolder(name,getGui()->getApp()); + _imp->holder = new DialogParamHolder(QString::fromUtf8(name.c_str()),getGui()->getApp()); setHolder(_imp->holder); _imp->holder->initializeKnobsPublic(); _imp->mainLayout = new QVBoxLayout(this); @@ -348,36 +348,35 @@ PyPanel::~PyPanel() getGui()->unregisterPyPanel(this); } -std::string +QString PyPanel::getPanelScriptName() const { - return getScriptName(); + return QString::fromUtf8(getScriptName().c_str()); } void -PyPanel::setPanelLabel(const std::string& label) +PyPanel::setPanelLabel(const QString& label) { - setLabel(label); - QString name = QString::fromUtf8(label.c_str()); + setLabel(label.toStdString()); TabWidget* parent = dynamic_cast(parentWidget()); if (parent) { - parent->setTabLabel(this, name); + parent->setTabLabel(this, label); } } -std::string +QString PyPanel::getPanelLabel() const { - return getLabel(); + return QString::fromUtf8(getLabel().c_str()); } Param* -PyPanel::getParam(const std::string& scriptName) const +PyPanel::getParam(const QString& scriptName) const { if (!_imp->holder) { return 0; } - KnobPtr knob = _imp->holder->getKnobByName(scriptName); + KnobPtr knob = _imp->holder->getKnobByName(scriptName.toStdString()); if (!knob) { return 0; } @@ -404,7 +403,7 @@ PyPanel::getParams() const void -PyPanel::setParamChangedCallback(const std::string& callback) +PyPanel::setParamChangedCallback(const QString& callback) { if (_imp->holder) { _imp->holder->setParamChangedCallback(callback); @@ -436,7 +435,7 @@ PyPanel::onUserDataChanged() _imp->serialization = save(); } -std::string +QString PyPanel::save_serialization_thread() const { QMutexLocker k(&_imp->serializationMutex); @@ -515,10 +514,10 @@ PyTabWidget::closeTab(int index) _tab->removeTab(index, true); } -std::string +QString PyTabWidget::getTabLabel(int index) const { - return _tab->getTabLabel(index).toStdString(); + return QString::fromUtf8(_tab->getTabLabel(index).toStdString().c_str()); } int @@ -607,10 +606,10 @@ PyTabWidget::closeCurrentTab() _tab->closeCurrentWidget(); } -std::string +QString PyTabWidget::getScriptName() const { - return _tab->objectName_mt_safe().toStdString(); + return _tab->objectName_mt_safe(); } NATRON_NAMESPACE_EXIT; diff --git a/Gui/PythonPanels.h b/Gui/PythonPanels.h index 2c9da12bab..6bf1164a2e 100644 --- a/Gui/PythonPanels.h +++ b/Gui/PythonPanels.h @@ -49,13 +49,13 @@ class DialogParamHolder : public NamedKnobHolder public: - DialogParamHolder(const std::string& uniqueID,AppInstance* app); + DialogParamHolder(const QString& uniqueID,AppInstance* app); virtual ~DialogParamHolder(); virtual std::string getScriptName_mt_safe() const OVERRIDE FINAL; - void setParamChangedCallback(const std::string& callback); + void setParamChangedCallback(const QString& callback); private: @@ -85,9 +85,9 @@ class PyModalDialog : public QDialog, public UserParamHolder virtual ~PyModalDialog(); - Param* getParam(const std::string& scriptName) const; + Param* getParam(const QString& scriptName) const; - void setParamChangedCallback(const std::string& callback); + void setParamChangedCallback(const QString& callback); void insertWidget(int index, QWidget* widget); @@ -110,25 +110,25 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON public: - PyPanel(const std::string& scriptName,const std::string& label,bool useUserParameters,GuiApp* app); + PyPanel(const QString& scriptName,const QString& label,bool useUserParameters,GuiApp* app); virtual ~PyPanel(); - std::string save_serialization_thread() const; + QString save_serialization_thread() const; - virtual void restore(const std::string& /*data*/) {} + virtual void restore(const QString& /*data*/) {} - std::string getPanelScriptName() const; + QString getPanelScriptName() const; - void setPanelLabel(const std::string& label); + void setPanelLabel(const QString& label); - std::string getPanelLabel() const; + QString getPanelLabel() const; - Param* getParam(const std::string& scriptName) const; + Param* getParam(const QString& scriptName) const; std::list getParams() const; - void setParamChangedCallback(const std::string& callback); + void setParamChangedCallback(const QString& callback); void insertWidget(int index, QWidget* widget); @@ -136,7 +136,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON protected: - virtual std::string save() { return std::string(); } + virtual QString save() { return QString(); } void onUserDataChanged(); @@ -174,7 +174,7 @@ public : void closeTab(int index); - std::string getTabLabel(int index) const; + QString getTabLabel(int index) const; int count(); @@ -198,7 +198,7 @@ public : void closeCurrentTab(); - std::string getScriptName() const; + QString getScriptName() const; }; NATRON_NAMESPACE_EXIT; diff --git a/Gui/TabWidget.cpp b/Gui/TabWidget.cpp index f051ba6fd4..647c4f0201 100644 --- a/Gui/TabWidget.cpp +++ b/Gui/TabWidget.cpp @@ -434,7 +434,7 @@ TabWidget::createMenu() for (std::map::iterator it = userPanels.begin(); it != userPanels.end(); ++it) { - QAction* pAction = new QAction(QString::fromUtf8(it->first->getPanelLabel().c_str()) + tr(" here"),userPanelsMenu); + QAction* pAction = new QAction(it->first->getPanelLabel() + tr(" here"),userPanelsMenu); QObject::connect(pAction, SIGNAL(triggered()), this, SLOT(onUserPanelActionTriggered())); pAction->setData(QString::fromUtf8(it->first->getScriptName().c_str())); userPanelsMenu->addAction(pAction); diff --git a/Gui/typesystem_natronGui.xml b/Gui/typesystem_natronGui.xml index 48872e0968..940a889301 100644 --- a/Gui/typesystem_natronGui.xml +++ b/Gui/typesystem_natronGui.xml @@ -26,7 +26,7 @@ - + @@ -51,7 +51,7 @@ return ret; - + @@ -152,7 +152,7 @@ - + @@ -160,7 +160,7 @@ - + From d5a735f78542171f9934fad5566d29fa82f311b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 3 Apr 2016 18:23:26 +0200 Subject: [PATCH 27/30] fix build --- Gui/Gui50.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 927678e554..0d07d53ce3 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -47,7 +47,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include #include -#include +#include #include #include #include From 65762c77ffa0379214208b73a8f79a266ff309a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 3 Apr 2016 19:10:47 +0200 Subject: [PATCH 28/30] fix build --- Gui/NodeGraph.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gui/NodeGraph.h b/Gui/NodeGraph.h index e1ea8e0b3d..40abc3e764 100644 --- a/Gui/NodeGraph.h +++ b/Gui/NodeGraph.h @@ -25,6 +25,11 @@ #include // ***** END PYTHON BLOCK ***** +#include +#include +#include +#include + #include "Global/Macros.h" #if !defined(Q_MOC_RUN) && !defined(SBK_RUN) From 280ea50dc1fed1a22cec2aaf0c86d8dd507b0eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 3 Apr 2016 19:12:28 +0200 Subject: [PATCH 29/30] fix warning --- Gui/KnobWidgetDnD.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gui/KnobWidgetDnD.cpp b/Gui/KnobWidgetDnD.cpp index 7ceffb2953..89a4164d0e 100644 --- a/Gui/KnobWidgetDnD.cpp +++ b/Gui/KnobWidgetDnD.cpp @@ -24,6 +24,8 @@ #include "KnobWidgetDnD.h" +CLANG_DIAG_OFF(deprecated) +CLANG_DIAG_OFF(uninitialized) #include #include #include @@ -34,6 +36,8 @@ #include #include #include +CLANG_DIAG_ON(deprecated) +CLANG_DIAG_ON(uninitialized) #include "Engine/Knob.h" #include "Engine/NodeGroup.h" @@ -445,4 +449,4 @@ KnobWidgetDnD::focusOut() _imp->userInputSinceFocusIn = false; } -NATRON_NAMESPACE_EXIT; \ No newline at end of file +NATRON_NAMESPACE_EXIT; From 114b32e83ad263ab7c83df398d2f4d330096f36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 3 Apr 2016 19:21:35 +0200 Subject: [PATCH 30/30] fix warnings --- Gui/KnobGui20.cpp | 4 ++++ Gui/ProgressPanel.h | 4 ++++ Gui/ProgressTaskInfo.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Gui/KnobGui20.cpp b/Gui/KnobGui20.cpp index 16d6cfe826..0aead0064d 100644 --- a/Gui/KnobGui20.cpp +++ b/Gui/KnobGui20.cpp @@ -25,7 +25,11 @@ #include #include +CLANG_DIAG_OFF(deprecated) +CLANG_DIAG_OFF(uninitialized) #include +CLANG_DIAG_ON(deprecated) +CLANG_DIAG_ON(uninitialized) #include "Engine/ViewIdx.h" diff --git a/Gui/ProgressPanel.h b/Gui/ProgressPanel.h index 7c70370e2b..bf4dc7fd62 100644 --- a/Gui/ProgressPanel.h +++ b/Gui/ProgressPanel.h @@ -34,7 +34,11 @@ #include #endif +CLANG_DIAG_OFF(deprecated) +CLANG_DIAG_OFF(uninitialized) #include +CLANG_DIAG_ON(deprecated) +CLANG_DIAG_ON(uninitialized) #include "Gui/PanelWidget.h" #include "Gui/GuiFwd.h" diff --git a/Gui/ProgressTaskInfo.cpp b/Gui/ProgressTaskInfo.cpp index 07fcaa2daa..df3f4dcf97 100644 --- a/Gui/ProgressTaskInfo.cpp +++ b/Gui/ProgressTaskInfo.cpp @@ -24,12 +24,16 @@ #include "ProgressTaskInfo.h" +CLANG_DIAG_OFF(deprecated) +CLANG_DIAG_OFF(uninitialized) #include #include #include #include #include #include +CLANG_DIAG_ON(deprecated) +CLANG_DIAG_ON(uninitialized) #include "Engine/AppInstance.h" #include "Engine/Image.h"