@@ -68,6 +68,11 @@ ofxVisualProgramming::ofxVisualProgramming(){
6868 currentPatchFile = " empty_patch.xml" ;
6969 currentPatchFolderPath = ofToDataPath (" temp/" );
7070
71+ currentSubpatch = " root" ;
72+
73+ vector<string> rootBranch;
74+ subpatchesTree[currentSubpatch] = rootBranch;
75+
7176 resetTime = ofGetElapsedTimeMillis ();
7277 wait = 2000 ;
7378
@@ -175,12 +180,6 @@ void ofxVisualProgramming::update(){
175180 }
176181 }
177182
178- // Sound Context
179- /* unique_lock<std::mutex> lock(inputAudioMutex);
180- {
181-
182- }*/
183-
184183 // Clear map from deleted objects
185184 clearObjectsMap ();
186185
@@ -198,20 +197,22 @@ void ofxVisualProgramming::update(){
198197 ImGuiEx::ProfilerTask *pt = new ImGuiEx::ProfilerTask[leftToRightIndexOrder.size ()];
199198
200199 for (unsigned int i=0 ;i<leftToRightIndexOrder.size ();i++){
201- pt[i].color = profiler.cpuGraph .colors [static_cast <unsigned int >(i%16 )];
202- pt[i].startTime = ofGetElapsedTimef ();
203- pt[i].name = patchObjects[leftToRightIndexOrder[i].second ]->getName ()+ofToString (patchObjects[leftToRightIndexOrder[i].second ]->getId ())+" _update" ;
204- patchObjects[leftToRightIndexOrder[i].second ]->update (patchObjects,*engine);
205- pt[i].endTime = ofGetElapsedTimef ();
206-
207- // update scripts objects files map
208- ofFile tempsofp (patchObjects[leftToRightIndexOrder[i].second ]->getFilepath ());
209- string fileExt = ofToUpper (tempsofp.getExtension ());
210- if (fileExt == " LUA" || fileExt == " PY" || fileExt == " SH" || fileExt == " FRAG" ){
211- map<string,string>::iterator sofpIT = scriptsObjectsFilesPaths.find (tempsofp.getFileName ());
212- if (sofpIT == scriptsObjectsFilesPaths.end ()){
213- // not found, insert it
214- scriptsObjectsFilesPaths.insert ( pair<string,string>(tempsofp.getFileName (),tempsofp.getAbsolutePath ()) );
200+ if (patchObjects[leftToRightIndexOrder[i].second ]->subpatchName == currentSubpatch){
201+ pt[i].color = profiler.cpuGraph .colors [static_cast <unsigned int >(i%16 )];
202+ pt[i].startTime = ofGetElapsedTimef ();
203+ pt[i].name = patchObjects[leftToRightIndexOrder[i].second ]->getName ()+ofToString (patchObjects[leftToRightIndexOrder[i].second ]->getId ())+" _update" ;
204+ patchObjects[leftToRightIndexOrder[i].second ]->update (patchObjects,*engine);
205+ pt[i].endTime = ofGetElapsedTimef ();
206+
207+ // update scripts objects files map
208+ ofFile tempsofp (patchObjects[leftToRightIndexOrder[i].second ]->getFilepath ());
209+ string fileExt = ofToUpper (tempsofp.getExtension ());
210+ if (fileExt == " LUA" || fileExt == " PY" || fileExt == " SH" || fileExt == " FRAG" ){
211+ map<string,string>::iterator sofpIT = scriptsObjectsFilesPaths.find (tempsofp.getFileName ());
212+ if (sofpIT == scriptsObjectsFilesPaths.end ()){
213+ // not found, insert it
214+ scriptsObjectsFilesPaths.insert ( pair<string,string>(tempsofp.getFileName (),tempsofp.getAbsolutePath ()) );
215+ }
215216 }
216217 }
217218 }
@@ -294,22 +295,24 @@ void ofxVisualProgramming::draw(){
294295 ImGuiEx::ProfilerTask *pt = new ImGuiEx::ProfilerTask[leftToRightIndexOrder.size ()];
295296 for (unsigned int i=0 ;i<leftToRightIndexOrder.size ();i++){
296297
297- pt[i].color = profiler.gpuGraph .colors [static_cast <unsigned int >(i%16 )];
298- pt[i].startTime = ofGetElapsedTimef ();
299- pt[i].name = patchObjects[leftToRightIndexOrder[i].second ]->getName ()+ofToString (patchObjects[leftToRightIndexOrder[i].second ]->getId ())+" _draw" ;
298+ if (patchObjects[leftToRightIndexOrder[i].second ]->subpatchName == currentSubpatch){
299+ pt[i].color = profiler.gpuGraph .colors [static_cast <unsigned int >(i%16 )];
300+ pt[i].startTime = ofGetElapsedTimef ();
301+ pt[i].name = patchObjects[leftToRightIndexOrder[i].second ]->getName ()+ofToString (patchObjects[leftToRightIndexOrder[i].second ]->getId ())+" _draw" ;
300302
301- // LivePatchingObject hack, should not be handled by mosaic.
302- if (patchObjects[leftToRightIndexOrder[i].second ]->getName () == " live patching" ){
303- livePatchingObiID = patchObjects[leftToRightIndexOrder[i].second ]->getId ();
304- }
303+ // LivePatchingObject hack, should not be handled by mosaic.
304+ if (patchObjects[leftToRightIndexOrder[i].second ]->getName () == " live patching" ){
305+ livePatchingObiID = patchObjects[leftToRightIndexOrder[i].second ]->getId ();
306+ }
305307
306- // Draw
307- patchObjects[leftToRightIndexOrder[i].second ]->draw (font);
308- if (isCanvasVisible){
309- patchObjects[leftToRightIndexOrder[i].second ]->drawImGuiNode (nodeCanvas,patchObjects);
310- }
308+ // Draw
309+ patchObjects[leftToRightIndexOrder[i].second ]->draw (font);
310+ if (isCanvasVisible){
311+ patchObjects[leftToRightIndexOrder[i].second ]->drawImGuiNode (nodeCanvas,patchObjects);
312+ }
311313
312- pt[i].endTime = ofGetElapsedTimef ();
314+ pt[i].endTime = ofGetElapsedTimef ();
315+ }
313316
314317 }
315318
@@ -374,7 +377,7 @@ void ofxVisualProgramming::drawInspector(){
374377
375378// --------------------------------------------------------------
376379void ofxVisualProgramming::drawLivePatchingSession (){
377- if (weAlreadyHaveObject (" live patching" ) && livePatchingObiID != -1 ){
380+ if (weAlreadyHaveObject (" live patching" ) && livePatchingObiID != -1 && currentSubpatch == " root " ){
378381 if (patchObjects[livePatchingObiID]->inletsConnected [0 ] && static_cast <ofTexture *>(patchObjects[livePatchingObiID]->_inletParams [0 ])->isAllocated ()){
379382 float lpDrawW, lpDrawH, lpPosX, lpPosY;
380383 if (static_cast <ofTexture *>(patchObjects[livePatchingObiID]->_inletParams [0 ])->getWidth () >= static_cast <ofTexture *>(patchObjects[livePatchingObiID]->_inletParams [0 ])->getHeight ()){ // horizontal texture
@@ -596,6 +599,7 @@ void ofxVisualProgramming::addObject(string name,ofVec2f pos){
596599 tempObj->setupDSP (*engine);
597600 tempObj->move (static_cast <int >(pos.x -(OBJECT_STANDARD_WIDTH/2 *scaleFactor)),static_cast <int >(pos.y -(OBJECT_STANDARD_HEIGHT/2 *scaleFactor)));
598601 tempObj->setIsRetina (isRetina);
602+ tempObj->setSubpatch (currentSubpatch);
599603 ofAddListener (tempObj->removeEvent ,this ,&ofxVisualProgramming::removeObject);
600604 ofAddListener (tempObj->resetEvent ,this ,&ofxVisualProgramming::resetObject);
601605 ofAddListener (tempObj->reconnectOutletsEvent ,this ,&ofxVisualProgramming::reconnectObjectOutlets);
@@ -1283,9 +1287,7 @@ void ofxVisualProgramming::loadPatch(string patchFile){
12831287
12841288 shared_ptr<PatchObject> tempObj = selectObject (objname);
12851289 if (tempObj != nullptr ){
1286- ofLog (OF_LOG_NOTICE," BEFORE LOADING OBJECT CONFIG...." );
12871290 loaded = tempObj->loadConfig (mainWindow,*engine,i,patchFile);
1288- ofLog (OF_LOG_NOTICE," AFTER LOADING OBJECT CONFIG...." );
12891291 if (loaded){
12901292 tempObj->setPatchfile (currentPatchFile);
12911293 tempObj->setIsRetina (isRetina);
0 commit comments