@@ -62,6 +62,10 @@ PatchObject::PatchObject(const std::string& _customUID ) : ofxVPHasUID(_customUI
6262 isResizable = false ;
6363 willErase = false ;
6464
65+ initWirelessLink = false ;
66+ resetWirelessLink = false ;
67+ resetWirelessPin = -1 ;
68+
6569 width = OBJECT_WIDTH;
6670 height = OBJECT_HEIGHT;
6771 headerHeight= HEADER_HEIGHT;
@@ -169,9 +173,11 @@ void PatchObject::update(map<int,shared_ptr<PatchObject>> &patchObjects, pdsp::E
169173 }
170174 }
171175 }
176+
172177 }
173178 }
174179 }
180+
175181 updateObjectContent (patchObjects);
176182
177183 if (this ->isPDSPPatchableObject ){
@@ -180,6 +186,53 @@ void PatchObject::update(map<int,shared_ptr<PatchObject>> &patchObjects, pdsp::E
180186
181187}
182188
189+ // --------------------------------------------------------------
190+ void PatchObject::updateWirelessLinks (map<int ,shared_ptr<PatchObject>> &patchObjects){
191+ // manually send data through wireless links ( if var ID, transport data )
192+ if (initWirelessLink && resetWirelessPin != -1 ){
193+ initWirelessLink = false ;
194+ if (this ->getOutletWirelessSend (resetWirelessPin)){
195+ for (map<int ,shared_ptr<PatchObject>>::iterator it = patchObjects.begin (); it != patchObjects.end (); it++ ){
196+ for (int in=0 ;in<it->second ->getNumInlets ();in++){
197+ if (this ->getOutletType (resetWirelessPin) == it->second ->getInletType (in) && this ->getOutletID (resetWirelessPin) == it->second ->getInletID (in) && it->second ->getInletWirelessReceive (in)){
198+ if (!it->second ->inletsConnected [in]){ // open wireless transport
199+ it->second ->inletsConnected [in] = true ;
200+ if (this ->getOutletType (resetWirelessPin) == VP_LINK_AUDIO && this ->getIsPDSPPatchableObject () && it->second ->getIsPDSPPatchableObject ()){
201+ this ->pdspOut [resetWirelessPin] >> it->second ->pdspIn [in];
202+ }
203+ it->second ->_inletParams [in] = this ->_outletParams [resetWirelessPin];
204+ // std::cout << "Wireless connection ON between " << this->getName() << " and " << it->second->getName() << std::endl;
205+ }
206+ }
207+ }
208+ }
209+ }
210+ resetWirelessPin = -1 ;
211+ }
212+
213+
214+ // Manually close wireless link from internal object code ( GUI )
215+ if (resetWirelessLink && resetWirelessPin != -1 ){
216+ resetWirelessLink = false ;
217+ for (map<int ,shared_ptr<PatchObject>>::iterator it = patchObjects.begin (); it != patchObjects.end (); it++ ){
218+ if (this ->getId () != it->first ){
219+ for (int in=0 ;in<it->second ->getNumInlets ();in++){
220+ if (this ->getOutletType (resetWirelessPin) == it->second ->getInletType (in) && this ->getOutletID (resetWirelessPin) == it->second ->getInletID (in)){
221+ if (it->second ->inletsConnected [in]){ // close wireless transport
222+ it->second ->inletsConnected [in] = false ;
223+ if (this ->getOutletType (resetWirelessPin) == VP_LINK_AUDIO && this ->getIsPDSPPatchableObject () && it->second ->getIsPDSPPatchableObject () && it->second ->pdspIn [in].getInputsList ().size () > 0 ){
224+ it->second ->pdspIn [in].disconnectIn ();
225+ }
226+ // std::cout << "Wireless connection OFF between " << this->getName() << " and " << it->second->getName() << std::endl;
227+ }
228+ }
229+ }
230+ }
231+ }
232+ resetWirelessPin = -1 ;
233+ }
234+ }
235+
183236// --------------------------------------------------------------
184237void PatchObject::draw (ofTrueTypeFont *font){
185238
@@ -238,7 +291,7 @@ void PatchObject::drawImGuiNode(ImGuiEx::NodeCanvas& _nodeCanvas, map<int,shared
238291 }
239292 }
240293
241- ImGuiEx::NodeConnectData connectData = _nodeCanvas.AddNodePin ( nId, i, inletsNames.at (i).c_str (), tempLinkData, getInletTypeName (i), inletsConnected[i], IM_COL32 (pinCol.r ,pinCol.g ,pinCol.b ,pinCol.a ), ImGuiExNodePinsFlags_Left );
294+ ImGuiEx::NodeConnectData connectData = _nodeCanvas.AddNodePin ( nId, i, inletsNames.at (i).c_str (), tempLinkData, getInletTypeName (i), getInletWirelessReceive (i), inletsConnected[i], IM_COL32 (pinCol.r ,pinCol.g ,pinCol.b ,pinCol.a ), ImGuiExNodePinsFlags_Left );
242295
243296 inletsPositions[i] = _nodeCanvas.getInletPosition (nId,i);
244297
@@ -296,7 +349,7 @@ void PatchObject::drawImGuiNode(ImGuiEx::NodeCanvas& _nodeCanvas, map<int,shared
296349 }
297350 }
298351
299- _nodeCanvas.AddNodePin ( nId, i, getOutletName (i).c_str (), tempLinkData, getOutletTypeName (i), getIsOutletConnected (i), IM_COL32 (pinCol.r ,pinCol.g ,pinCol.b ,pinCol.a ), ImGuiExNodePinsFlags_Right );
352+ _nodeCanvas.AddNodePin ( nId, i, getOutletName (i).c_str (), tempLinkData, getOutletTypeName (i), getOutletWirelessSend (i), getIsOutletConnected (i), IM_COL32 (pinCol.r ,pinCol.g ,pinCol.b ,pinCol.a ), ImGuiExNodePinsFlags_Right );
300353
301354 outletsPositions[i] = _nodeCanvas.getOutletPosition (nId,i);
302355 }
@@ -581,10 +634,14 @@ bool PatchObject::loadConfig(shared_ptr<ofAppGLFWWindow> &mainWindow, pdsp::Engi
581634 if (XML.pushTag (" inlets" )){
582635 int totalInlets = XML.getNumTags (" link" );
583636 inletsPositions.clear ();
637+ inletsIDs.clear ();
638+ inletsWirelessReceive.clear ();
584639 for (int i=0 ;i<totalInlets;i++){
585640 if (XML.pushTag (" link" ,i)){
586641 inletsType.push_back (XML.getValue (" type" , 0 ));
587642 inletsNames.push_back (XML.getValue (" name" , " " ));
643+ inletsIDs.push_back (" " );
644+ inletsWirelessReceive.push_back (false );
588645 inletsPositions.push_back ( ImVec2 (this ->x , this ->y + this ->height *.5f ) );
589646 XML.popTag ();
590647 }
@@ -598,10 +655,14 @@ bool PatchObject::loadConfig(shared_ptr<ofAppGLFWWindow> &mainWindow, pdsp::Engi
598655 if (XML.pushTag (" outlets" )){
599656 int totalOutlets = XML.getNumTags (" link" );
600657 outletsPositions.clear ();
658+ outletsIDs.clear ();
659+ outletsWirelessSend.clear ();
601660 for (int i=0 ;i<totalOutlets;i++){
602661 if (XML.pushTag (" link" ,i)){
603662 outletsType.push_back (XML.getValue (" type" , 0 ));
604663 outletsNames.push_back (XML.getValue (" name" , " " ));
664+ outletsIDs.push_back (" " );
665+ outletsWirelessSend.push_back (false );
605666 outletsPositions.push_back ( ImVec2 ( this ->x + this ->width , this ->y + this ->height *.5f ) );
606667 XML.popTag ();
607668 }
@@ -978,6 +1039,8 @@ string PatchObject::getInletTypeName(const int& iid) const{
9781039 break ;
9791040 case 6 : return " ofPixels" ;
9801041 break ;
1042+ case 7 : return " ofFbo" ;
1043+ break ;
9811044 default :
9821045 break ;
9831046 }
@@ -1002,6 +1065,8 @@ string PatchObject::getOutletTypeName(const int& oid) const{
10021065 break ;
10031066 case 6 : return " ofPixels" ;
10041067 break ;
1068+ case 7 : return " ofFbo" ;
1069+ break ;
10051070 default :
10061071 break ;
10071072 }
0 commit comments