@@ -1759,51 +1759,56 @@ void ofxVisualProgramming::loadPatch(std::string patchFile){
17591759 for (auto & obj: objs){
17601760 auto o = obj.node ();
17611761 std::string objname = ofxVPXml.getPatchChildString (o," name" );
1762- bool loaded = false ;
17631762
1764- if (isObjectInLibrary (objname)){
1765- std::shared_ptr<PatchObject> tempObj = selectObject (objname);
1766- if (tempObj != nullptr && !tempObj->getIsSharedContextObject ()){
1767- loaded = tempObj->loadConfig (mainWindow,*engine,oi,patchFile);
1768- if (loaded){
1769- tempObj->setPatchfile (currentPatchFile);
1770- tempObj->setIsRetina (isRetina,scaleFactor);
1771- std::string objSubpatch = ofxVPXml.getPatchChildString (o," subpatch" );
1772- if (objSubpatch == " " ) objSubpatch = " root" ; // retro compatibility for pre-subpatch patches
1773- tempObj->setSubpatch (objSubpatch);
1774- if (subpatchesMap.find (objSubpatch) == subpatchesMap.end ()) {
1775- std::vector<SubpatchConnection> _sp;
1776- subpatchesMap[objSubpatch] = _sp;
1777- }
1778- ofAddListener (tempObj->removeEvent ,this ,&ofxVisualProgramming::removeObject);
1779- ofAddListener (tempObj->resetEvent ,this ,&ofxVisualProgramming::resetObject);
1780- ofAddListener (tempObj->reconnectOutletsEvent ,this ,&ofxVisualProgramming::reconnectObjectOutlets);
1781- ofAddListener (tempObj->duplicateEvent ,this ,&ofxVisualProgramming::duplicateObject);
1782- // Insert the new object into the map
1783- patchObjects[tempObj->getId ()] = tempObj;
1784- actualObjectID = tempObj->getId ();
1785- lastAddedObjectID = tempObj->getId ();
1786- nodeCanvas.addNodeToMap (tempObj->getId (),tempObj->getName ());
1787- // if wireless object, add reference to subpatch data map
1788- if (objname == " sender" ){
1789- SubpatchConnection _t;
1790- _t.objID = tempObj->getId ();
1791- _t.inOut = 1 ;
1792- subpatchesMap[objSubpatch].push_back (_t);
1793- }else if (objname == " receiver" ){
1794- SubpatchConnection _t;
1795- _t.objID = tempObj->getId ();
1796- _t.inOut = 0 ;
1797- subpatchesMap[objSubpatch].push_back (_t);
1798- }
17991763
1800- #ifdef OFXVP_DEBUG
1801- std::cout << " Loading " << tempObj->getName () << std::endl;
1802- #endif
1764+ if (objname != " timeline" && objname != " output window" && objname != " projection mapping" && objname != " scheme live coding" ){
1765+ bool loaded = false ;
1766+ 1767+ if (isObjectInLibrary (objname)){
1768+ std::shared_ptr<PatchObject> tempObj = selectObject (objname);
1769+ if (tempObj != nullptr && !tempObj->getIsSharedContextObject ()){
1770+ loaded = tempObj->loadConfig (mainWindow,*engine,oi,patchFile);
1771+ if (loaded){
1772+ tempObj->setPatchfile (currentPatchFile);
1773+ tempObj->setIsRetina (isRetina,scaleFactor);
1774+ std::string objSubpatch = ofxVPXml.getPatchChildString (o," subpatch" );
1775+ if (objSubpatch == " " ) objSubpatch = " root" ; // retro compatibility for pre-subpatch patches
1776+ tempObj->setSubpatch (objSubpatch);
1777+ if (subpatchesMap.find (objSubpatch) == subpatchesMap.end ()) {
1778+ std::vector<SubpatchConnection> _sp;
1779+ subpatchesMap[objSubpatch] = _sp;
1780+ }
1781+ ofAddListener (tempObj->removeEvent ,this ,&ofxVisualProgramming::removeObject);
1782+ ofAddListener (tempObj->resetEvent ,this ,&ofxVisualProgramming::resetObject);
1783+ ofAddListener (tempObj->reconnectOutletsEvent ,this ,&ofxVisualProgramming::reconnectObjectOutlets);
1784+ ofAddListener (tempObj->duplicateEvent ,this ,&ofxVisualProgramming::duplicateObject);
1785+ // Insert the new object into the map
1786+ patchObjects[tempObj->getId ()] = tempObj;
1787+ actualObjectID = tempObj->getId ();
1788+ lastAddedObjectID = tempObj->getId ();
1789+ nodeCanvas.addNodeToMap (tempObj->getId (),tempObj->getName ());
1790+ // if wireless object, add reference to subpatch data map
1791+ if (objname == " sender" ){
1792+ SubpatchConnection _t;
1793+ _t.objID = tempObj->getId ();
1794+ _t.inOut = 1 ;
1795+ subpatchesMap[objSubpatch].push_back (_t);
1796+ }else if (objname == " receiver" ){
1797+ SubpatchConnection _t;
1798+ _t.objID = tempObj->getId ();
1799+ _t.inOut = 0 ;
1800+ subpatchesMap[objSubpatch].push_back (_t);
1801+ }
18031802
1804- std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
1803+ #ifdef OFXVP_DEBUG
1804+ std::cout << " Loading " << tempObj->getName () << std::endl;
1805+ #endif
1806+ 1807+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
1808+ }
18051809 }
18061810 }
1811+ 18071812 }
18081813 oi++;
18091814 }
@@ -1812,40 +1817,44 @@ void ofxVisualProgramming::loadPatch(std::string patchFile){
18121817 for (auto & obj: objs){
18131818 auto o = obj.node ();
18141819 std::string objname = ofxVPXml.getPatchChildString (o," name" );
1815- if (isObjectInLibrary (objname)){
1816- std::shared_ptr<PatchObject> tempObj = selectObject (objname);
1817- if (tempObj != nullptr && !tempObj->getIsSharedContextObject ()){
1818- int fromID = ofxVPXml.getPatchChildInt (o," id" );
1819- pugi::xpath_node_set objOutlets = ofxVPXml.getObjectOutlets (fromID);
1820- if (!objOutlets.empty ()){
1821- int oIndex = 0 ;
1822- for (auto & outlet: objOutlets){
1823- auto out = outlet.node ();
1824- int linkType = ofxVPXml.getPatchChildInt (out," type" );
1825- if (linkType != VP_LINK_AUDIO){
1826- pugi::xpath_node_set outletLinks = ofxVPXml.getObjectLinks (fromID, oIndex);
1827- if (!outletLinks.empty ()){
1828- for (auto & link: outletLinks){
1829- auto l = link.node ();
1830- int toObjectID = ofxVPXml.getPatchChildInt (l," id" );
1831- int toInletID = ofxVPXml.getPatchChildInt (l," inlet" );
1832- 1833- // fix loading patches with non-existent objects (older OFXVP versions)
1834- if (isObjectIDInPatchMap (toObjectID)){
1835- if (connect (fromID,oIndex,toObjectID,toInletID,linkType)){
1836- // ofLog(OF_LOG_NOTICE,"Connected object %s, outlet %i TO object %s, inlet %i",patchObjects[fromID]->getName().c_str(),oIndex,patchObjects[toObjectID]->getName().c_str(),toInletID);
1837- std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
1820+ if (objname != " timeline" && objname != " output window" && objname != " projection mapping" && objname != " scheme live coding" ){
1821+ 1822+ if (isObjectInLibrary (objname)){
1823+ std::shared_ptr<PatchObject> tempObj = selectObject (objname);
1824+ if (tempObj != nullptr && !tempObj->getIsSharedContextObject ()){
1825+ int fromID = ofxVPXml.getPatchChildInt (o," id" );
1826+ pugi::xpath_node_set objOutlets = ofxVPXml.getObjectOutlets (fromID);
1827+ if (!objOutlets.empty ()){
1828+ int oIndex = 0 ;
1829+ for (auto & outlet: objOutlets){
1830+ auto out = outlet.node ();
1831+ int linkType = ofxVPXml.getPatchChildInt (out," type" );
1832+ if (linkType != VP_LINK_AUDIO){
1833+ pugi::xpath_node_set outletLinks = ofxVPXml.getObjectLinks (fromID, oIndex);
1834+ if (!outletLinks.empty ()){
1835+ for (auto & link: outletLinks){
1836+ auto l = link.node ();
1837+ int toObjectID = ofxVPXml.getPatchChildInt (l," id" );
1838+ int toInletID = ofxVPXml.getPatchChildInt (l," inlet" );
1839+ 1840+ // fix loading patches with non-existent objects (older OFXVP versions)
1841+ if (isObjectIDInPatchMap (toObjectID)){
1842+ if (connect (fromID,oIndex,toObjectID,toInletID,linkType)){
1843+ // ofLog(OF_LOG_NOTICE,"Connected object %s, outlet %i TO object %s, inlet %i",patchObjects[fromID]->getName().c_str(),oIndex,patchObjects[toObjectID]->getName().c_str(),toInletID);
1844+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
1845+ }
18381846 }
18391847 }
18401848 }
18411849 }
1842- }
18431850
1844- oIndex++;
1851+ oIndex++;
1852+ }
18451853 }
18461854 }
18471855 }
18481856 }
1857+ 18491858 }
18501859
18511860 }
@@ -1877,40 +1886,45 @@ void ofxVisualProgramming::loadPatchSharedContextObjects(){
18771886 for (auto & obj: objs){
18781887 auto o = obj.node ();
18791888 std::string objname = ofxVPXml.getPatchChildString (o," name" );
1880- if (isObjectInLibrary (objname)){
1881- std::shared_ptr<PatchObject> tempObj = selectObject (objname);
1882- if (tempObj != nullptr && !tempObj->getIsSharedContextObject ()){
1883- int fromID = ofxVPXml.getPatchChildInt (o," id" );
1884- pugi::xpath_node_set objOutlets = ofxVPXml.getObjectOutlets (fromID);
1885- if (!objOutlets.empty ()){
1886- int oIndex = 0 ;
1887- for (auto & outlet: objOutlets){
1888- auto out = outlet.node ();
1889- int linkType = ofxVPXml.getPatchChildInt (out," type" );
1890- if (linkType == VP_LINK_AUDIO){
1891- pugi::xpath_node_set outletLinks = ofxVPXml.getObjectLinks (fromID, oIndex);
1892- if (!outletLinks.empty ()){
1893- for (auto & link: outletLinks){
1894- auto l = link.node ();
1895- int toObjectID = ofxVPXml.getPatchChildInt (l," id" );
1896- int toInletID = ofxVPXml.getPatchChildInt (l," inlet" );
1897- 1898- // fix loading patches with non-existent objects (older OFXVP versions)
1899- if (isObjectIDInPatchMap (toObjectID)){
1900- if (connect (fromID,oIndex,toObjectID,toInletID,linkType)){
1901- // ofLog(OF_LOG_NOTICE,"Connected object %s, outlet %i TO object %s, inlet %i",patchObjects[fromID]->getName().c_str(),oIndex,patchObjects[toObjectID]->getName().c_str(),toInletID);
1902- std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
1889+ if (objname != " timeline" && objname != " output window" && objname != " projection mapping" && objname != " scheme live coding" ){
1890+ 1891+ if (isObjectInLibrary (objname)){
1892+ std::shared_ptr<PatchObject> tempObj = selectObject (objname);
1893+ 1894+ if (tempObj != nullptr && !tempObj->getIsSharedContextObject ()){
1895+ int fromID = ofxVPXml.getPatchChildInt (o," id" );
1896+ pugi::xpath_node_set objOutlets = ofxVPXml.getObjectOutlets (fromID);
1897+ if (!objOutlets.empty ()){
1898+ int oIndex = 0 ;
1899+ for (auto & outlet: objOutlets){
1900+ auto out = outlet.node ();
1901+ int linkType = ofxVPXml.getPatchChildInt (out," type" );
1902+ if (linkType == VP_LINK_AUDIO){
1903+ pugi::xpath_node_set outletLinks = ofxVPXml.getObjectLinks (fromID, oIndex);
1904+ if (!outletLinks.empty ()){
1905+ for (auto & link: outletLinks){
1906+ auto l = link.node ();
1907+ int toObjectID = ofxVPXml.getPatchChildInt (l," id" );
1908+ int toInletID = ofxVPXml.getPatchChildInt (l," inlet" );
1909+ 1910+ // fix loading patches with non-existent objects (older OFXVP versions)
1911+ if (isObjectIDInPatchMap (toObjectID)){
1912+ if (connect (fromID,oIndex,toObjectID,toInletID,linkType)){
1913+ // ofLog(OF_LOG_NOTICE,"Connected object %s, outlet %i TO object %s, inlet %i",patchObjects[fromID]->getName().c_str(),oIndex,patchObjects[toObjectID]->getName().c_str(),toInletID);
1914+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
1915+ }
19031916 }
19041917 }
19051918 }
19061919 }
1907- }
19081920
1909- oIndex++;
1921+ oIndex++;
1922+ }
19101923 }
19111924 }
19121925 }
19131926 }
1927+ 19141928 }
19151929 }
19161930
@@ -1979,7 +1993,7 @@ void ofxVisualProgramming::loadPatchSharedContextObjects(){
19791993 std::string toObjName = getObjectNameFromID (toObjectID);
19801994
19811995 if (toObjName != " " ){
1982- shared_ptr<PatchObject> _tempToObj = selectObject (toObjName);
1996+ std:: shared_ptr<PatchObject> _tempToObj = selectObject (toObjName);
19831997 if (_tempToObj != nullptr && _tempToObj->getIsSharedContextObject ()){
19841998 // fix loading patches with non-existent objects (older OFXVP versions)
19851999 if (isObjectIDInPatchMap (toObjectID)){
0 commit comments