void Network::handleObjectPadMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Utility data structures char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); // Parse OSC message float x, y, radius; osc::Symbol uuid; m.ArgumentStream() >> uuid >> x >> y >> radius >> osc::EndMessage; std::cerr << uuid << ", " << x << ", " << y << ", " << radius << std::endl; // Check for known pad, add & broadcast if unknown WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit = widgets->find(std::string(uuid)); if (wit == widgets->end()) { RoundPad* newPad = new RoundPad(Point2D(x, y), radius); newPad->setUuid(uuid); widgets->insert(WidgetData(std::string(uuid), newPad)); m_engine->addChild(newPad); // Tell the world newPad->toOutboundPacketStream(ps); broadcast(ps); } }
Widget& Layout::get(const string& path) const { WidgetMap::const_iterator it = widgets.find(path); if (it != widgets.end()) return *(*it).second; else throw runtime_error("Widget " + path + " does not exist"); }
void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path) { WidgetMap *map = gtkWidgetMap(); WidgetMap::iterator it = map->find(path); if (it != map->end()) { char* keyData = const_cast<char *>(it.key().data()); map->erase(it); free(keyData); } }
void Network::handleObjectStringMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Utility data structures char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); // Parse OSC message osc::Symbol uuid, padUuid; float startX, startY, endX, endY; m.ArgumentStream() >> uuid >> padUuid >> startX >> startY >> endX >> endY >> osc::EndMessage; std::cerr << uuid << ", " << padUuid << ", " << startX << ", " << startY << ", " << endX << ", " << endY << std::endl; // Check for known arc, add & broadcast if unknown bool unlocked = false; SoundSource::lockGlobals(); SoundSourceMap* soundSources = SoundSource::getAllForEngine(); WidgetMap* widgets = Widget::getAll(); if (soundSources->find(std::string(uuid)) == soundSources->end()) { WidgetMap::iterator wit = m_orphans.find(std::string(uuid)); if (wit == m_orphans.end()) { // Search for pad wit = widgets->find(std::string(padUuid)); if (wit != widgets->end()) { String* newString = new String(Point2D(startX, startY), Point2D(endX, endY), 1); newString->setUuid(uuid); // Add string to soundsource soundSources->insert(SoundSourceData(newString->getUuid(), newString)); wit->second->addChild(newString); newString->setPadRadius(((RoundPad*)wit->second)->getRadius()); // Tell the world newString->toOutboundPacketStream(ps); broadcast(ps); } else {// orphan if we don't know about its pad yet String* newString = new String(Point2D(startX, startY), Point2D(endX, endY), 1); newString->setUuid(uuid); m_orphans.insert(WidgetData(std::string(padUuid), newString)); } SoundSource::unlockGlobals(); unlocked = true; } } if (!unlocked) SoundSource::unlockGlobals(); }
void Network::handlePluckerMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Utility data structures char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); // Parse OSC message osc::Symbol uuid; m.ArgumentStream() >> uuid >> osc::EndMessage; std::cerr << uuid << std::endl; WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit = widgets->find(std::string(uuid)); if (wit != widgets->end() && dynamic_cast<Track*>(wit->second)) ((Track*)wit->second)->addPlucker(); }
void Network::handleObjectPadTextMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Utility data structures char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); // Parse OSC message osc::Symbol uuid, text; m.ArgumentStream() >> uuid >> text >> osc::EndMessage; std::cerr << uuid << ", " << text << std::endl; WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit = widgets->find(std::string(uuid)); if (wit != widgets->end() && dynamic_cast<RoundPad*>(wit->second)) ((RoundPad*)wit->second)->setCommentText(std::string(text)); }
void Network::handleObjectDeleteMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Parse OSC message osc::Symbol uuid; m.ArgumentStream() >> uuid >> osc::EndMessage; std::cerr << uuid << std::endl; WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit = widgets->find(std::string(uuid)); Widget* widget; if (wit != widgets->end() && (widget = wit->second->getParent()->removeChild(wit->second))) { sendObjectMessage(widget, true); delete widget; } }
void WTemplate::clear() { setIgnoreChildRemoves(true); /* * We need to copy them first so that removeChild() will not be confused * by it. */ WidgetMap toDelete = widgets_; widgets_ = WidgetMap(); for (WidgetMap::iterator i = toDelete.begin(); i != toDelete.end(); ++i) delete i->second; setIgnoreChildRemoves(false); strings_.clear(); conditions_.clear(); changed_ = true; repaint(RepaintSizeAffected); }
void Network::rescueOrphans() { WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit, oit; for (oit = m_orphans.begin(); oit != m_orphans.end(); oit++) { if ((wit = widgets->find(oit->first)) != widgets->end()) { // parent found?!! // De-orphan it wit->second->addChild(oit->second); if (dynamic_cast<SpiralTrack*>(oit->second)) ((SpiralTrack*)oit->second)->setCenter(((RoundPad*)wit->second)->getCenter()); else if (dynamic_cast<String*>(oit->second)) ((String*)oit->second)->setPadRadius(((RoundPad*)wit->second)->getRadius()); wit = widgets->insert(WidgetData(oit->second->getUuid(), oit->second)).first; m_orphans.erase(oit); // Tell the world about the now ex-orphan char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); wit->second->toOutboundPacketStream(ps); broadcast(ps); } } }
bool Layout::exists(const string& path) const { WidgetMap::const_iterator it = widgets.find(path); return it != widgets.end(); }
static void ParseActions( const std::string & actions, const ActionMap & vactionmap, const WidgetMap & widgetmap, const WidgetListMap & widgetlistmap, ActionValSet & action_val_set, ActionValnSet & action_valn_set) { size_t len = actions.size(); size_t pos = 0; while(pos < len) { pos = actions.find_first_not_of(' ', pos); if (pos >= len) break; // get next action with value size_t posn = actions.find(' ', pos); size_t n = actions.find(':', pos); if (n > posn) { pos = posn; continue; } if (n + 1 < len && actions[n + 1] == '"') posn = actions.find('"', n + 2) + 1; std::string action = actions.substr(pos, posn - pos); std::string aname = actions.substr(pos, n - pos); pos = posn; // check if action is in vactionmap typename ActionMap::const_iterator vai = vactionmap.find(aname); if (vai != vactionmap.end()) { action_val_set.insert(std::make_pair(action, vai->second)); continue; } size_t wn = aname.find('.'); if (wn == 0 || wn == std::string::npos) continue; std::string wname = aname.substr(0, wn); std::string pname = aname.substr(wn + 1); // check if action is setting a widget property typename WidgetMap::const_iterator wi = widgetmap.find(wname); if (wi != widgetmap.end()) { Slot1<const std::string &> * pslot; if (wi->second->GetProperty(pname, pslot)) action_val_set.insert(std::make_pair(action, pslot)); continue; } // check if action is setting a widget list property (only valid for control lists) typename WidgetListMap::const_iterator wli = widgetlistmap.find(wname); if (wli != widgetlistmap.end()) { Slot2<int, const std::string &> * pslot; if (wli->second->GetProperty(pname, pslot)) action_valn_set.insert(std::make_pair(action, pslot)); } } }
void Network::handleObjectLineMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Utility data structures char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); // Parse OSC message osc::Symbol uuid, padUuid; float startX, startY, endX, endY; m.ArgumentStream() >> uuid >> padUuid >> startX >> startY >> endX >> endY >> osc::EndMessage; std::cerr << uuid << ", " << padUuid << ", " << startX << ", " << startY << ", " << endX << ", " << endY << std::endl; // Check for known arc, add & broadcast if unknown WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit = widgets->find(std::string(uuid)); if (wit == widgets->end()) { wit = m_orphans.find(std::string(uuid)); if (wit == m_orphans.end()) { LineTrack* newLine = NULL; // Search for pad wit = widgets->find(std::string(padUuid)); if (wit != widgets->end()) { Joint *endJoint = NULL, *startJoint = NULL; for (WidgetMap::iterator ptr = widgets->begin(); ptr != widgets->end(); ptr++) { Track *track = dynamic_cast<Track *>(ptr->second); if (track) { Joint *joint = track->getJoint1(); if (!startJoint && joint && joint->hitTest(startX, startY)) startJoint = joint; else if (!endJoint && joint && joint->hitTest(endX, endY)) endJoint = joint; joint = track->getJoint2(); if (!startJoint && joint && joint->hitTest(startX, startY)) startJoint = joint; else if (!endJoint && joint && joint->hitTest(endX, endY)) endJoint = joint; } } LineTrack* newLine = new LineTrack(Point2D(startX, startY), Point2D(endX, endY), startJoint, endJoint); newLine->setUuid(uuid); newLine->getLine()->setLineWidth(3); wit->second->addChild(newLine); widgets->insert(WidgetData(std::string(uuid), newLine)); // Tell the world newLine->toOutboundPacketStream(ps); broadcast(ps); } else {// orphan if we don't know about its pad yet newLine = new LineTrack(Point2D(startX, startY), Point2D(endX, endY), NULL, NULL); newLine->setUuid(uuid); m_orphans.insert(WidgetData(std::string(padUuid), newLine)); } } } }
void Network::handleObjectSpiralMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) { // Utility data structures char buffer[1024]; osc::OutboundPacketStream ps(buffer, 1024); // Parse OSC message osc::Symbol uuid, padUuid; float startAngle, startRadius, endAngle, endRadius; m.ArgumentStream() >> uuid >> padUuid >> startAngle >> startRadius >> endAngle >> endRadius >> osc::EndMessage; std::cerr << uuid << ", " << padUuid << ", " << startAngle << ", " << startRadius << ", " << endAngle << ", " << endRadius << std::endl; // Check for known arc, add & broadcast if unknown WidgetMap* widgets = Widget::getAll(); WidgetMap::iterator wit = widgets->find(std::string(uuid)); if (wit == widgets->end()) { wit = m_orphans.find(std::string(uuid)); if (wit == m_orphans.end()) { SpiralTrack* newSpiral = NULL; // Search for pad wit = widgets->find(std::string(padUuid)); if (wit != widgets->end()) { Point2D center = ((RoundPad*)wit->second)->getCenter(); Point2D startPoint = Spiral::getPointFromRadius(center, startRadius, startAngle); Point2D endPoint = Spiral::getPointFromRadius(center, endRadius, endAngle); Joint *endJoint = NULL, *startJoint = NULL; std::vector<Widget*>* children = wit->second->getChildren(); for (int i = children->size() - 1; i >= 0; i --) { Track *track = dynamic_cast<Track *>(children->at(i)); if (track) { Joint *joint = track->getJoint1(); if (!startJoint && joint && joint->hitTest(startPoint.x, startPoint.y)) startJoint = joint; else if (!endJoint && joint && joint->hitTest(endPoint.x, endPoint.y)) endJoint = joint; joint = track->getJoint2(); if (!startJoint && joint && joint->hitTest(startPoint.x, startPoint.y)) startJoint = joint; else if (!endJoint && joint && joint->hitTest(endPoint.x, endPoint.y)) endJoint = joint; } } newSpiral = new SpiralTrack(center, startAngle, startRadius, endAngle, endRadius, startJoint, endJoint); newSpiral->setUuid(uuid); newSpiral->getSpiral()->setLineWidth(3); newSpiral->getJoint1()->setParentRoundPad(((RoundPad*)wit->second)); newSpiral->getJoint2()->setParentRoundPad(((RoundPad*)wit->second)); wit->second->addChild(newSpiral); widgets->insert(WidgetData(std::string(uuid), newSpiral)); // Tell the world newSpiral->toOutboundPacketStream(ps); broadcast(ps); } else {// orphan if we don't know about its pad yet newSpiral = new SpiralTrack(Point2D(0, 0), startAngle, startRadius, endAngle, endRadius, NULL, NULL); newSpiral->setUuid(uuid); m_orphans.insert(WidgetData(std::string(padUuid), newSpiral)); } } } }