Skip to content

Commit 6b1fb78

Browse files
committed
code cleaning
1 parent ef116cc commit 6b1fb78

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/PatchObject.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,6 @@ void PatchObject::keyReleased(ofKeyEventArgs &e,map<int,shared_ptr<PatchObject>>
10001000
if(objectsSelected.at(j) == this->nId){
10011001
ofNotifyEvent(removeEvent, objectsSelected.at(j));
10021002
this->setWillErase(true);
1003-
break;
10041003
}
10051004
}
10061005
objectsSelected.clear();

src/ofxVisualProgramming.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ofxVisualProgramming::ofxVisualProgramming(){
5858
isRetina = false;
5959
scaleFactor = 1;
6060

61+
actualObjectID = 0;
6162
lastAddedObjectID = -1;
6263
bLoadingNewObject = false;
6364
bLoadingNewPatch = false;
@@ -74,7 +75,7 @@ ofxVisualProgramming::ofxVisualProgramming(){
7475
subpatchesTree[currentSubpatch] = rootBranch;
7576

7677
resetTime = ofGetElapsedTimeMillis();
77-
wait = 2000;
78+
wait = 1000;
7879

7980
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY";
8081
newFileCounter = 0;
@@ -887,6 +888,19 @@ void ofxVisualProgramming::clearObjectsMap(){
887888
}
888889
}
889890

891+
//--------------------------------------------------------------
892+
string ofxVisualProgramming::getSubpatchParent(string subpatchName){
893+
for(map<string,vector<string>>::iterator it = subpatchesTree.begin(); it != subpatchesTree.end(); it++ ){
894+
for(int s=0;s<it->second.size();s++){
895+
if(it->second.at(s) == subpatchName){
896+
return it->first;
897+
}
898+
}
899+
}
900+
// return root if subpatch searched do not exists
901+
return "root";
902+
}
903+
890904
//--------------------------------------------------------------
891905
void ofxVisualProgramming::removeObject(int &id){
892906
resetTime = ofGetElapsedTimeMillis();
@@ -1069,16 +1083,14 @@ void ofxVisualProgramming::resetSpecificSystemObjects(string name){
10691083

10701084
//--------------------------------------------------------------
10711085
bool ofxVisualProgramming::weAlreadyHaveObject(string name){
1072-
bool found = false;
10731086

10741087
for(map<int,shared_ptr<PatchObject>>::iterator it = patchObjects.begin(); it != patchObjects.end(); it++ ){
10751088
if(it->second->getName() == name){
1076-
found = true;
1077-
break;
1089+
return true;
10781090
}
10791091
}
10801092

1081-
return found;
1093+
return false;
10821094
}
10831095

10841096
//--------------------------------------------------------------
@@ -1131,6 +1143,8 @@ void ofxVisualProgramming::preloadPatch(string patchFile){
11311143
currentPatchFile = patchFile;
11321144
tempPatchFile = currentPatchFile;
11331145

1146+
actualObjectID = 0;
1147+
11341148
// clear previous patch
11351149
for(map<int,shared_ptr<PatchObject>>::iterator it = patchObjects.begin(); it != patchObjects.end(); it++ ){
11361150
if(it->second->getName() != "audio device"){
@@ -1143,8 +1157,10 @@ void ofxVisualProgramming::preloadPatch(string patchFile){
11431157

11441158
it->second->outPut.clear();
11451159

1146-
glm::vec3 temp = canvas.screenToWorld(glm::vec3(ofGetWindowWidth()/2,ofGetWindowHeight()/2 + 100,0));
1147-
it->second->move(temp.x,temp.y);
1160+
//glm::vec3 temp = canvas.screenToWorld(glm::vec3(ofGetWindowWidth()/2,ofGetWindowHeight()/2 + 100,0));
1161+
//it->second->move(temp.x,temp.y);
1162+
it->second->setWillErase(true);
1163+
11481164
}
11491165
}
11501166
resetTime = ofGetElapsedTimeMillis();
@@ -1359,6 +1375,8 @@ void ofxVisualProgramming::loadPatch(string patchFile){
13591375
}
13601376
}
13611377

1378+
activateDSP();
1379+
13621380
bLoadingNewPatch = false;
13631381

13641382
}

src/ofxVisualProgramming.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class ofxVisualProgramming : public pdsp::Wrapper {
9898
void deleteObject(int id);
9999
void clearObjectsMap();
100100

101+
string getSubpatchParent(string subpatchName);
102+
101103
void newPatch();
102104
void newTempPatchFromFile(string patchFile);
103105
void preloadPatch(string patchFile);

0 commit comments

Comments
 (0)