当前位置: 首页>>代码示例>>C++>>正文


C++ Joint::hitTest方法代码示例

本文整理汇总了C++中Joint::hitTest方法的典型用法代码示例。如果您正苦于以下问题:C++ Joint::hitTest方法的具体用法?C++ Joint::hitTest怎么用?C++ Joint::hitTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Joint的用法示例。


在下文中一共展示了Joint::hitTest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleObjectLineMessage

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));
      }
    }
  }
}
开发者ID:emarschner,项目名称:playround,代码行数:63,代码来源:Network.cpp

示例2: handleObjectSpiralMessage

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));
      }
    }
  }
}
开发者ID:emarschner,项目名称:playround,代码行数:72,代码来源:Network.cpp


注:本文中的Joint::hitTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。