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


C++ BaseNode::getConnectedNodes方法代码示例

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


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

示例1: removeObject

/*! Slot. Removes the currently selected node. If the node is
    an object, it also removes all connections connected to that
    node.
*/
void Document::removeObject() {
  assert(indexOfSelectedObject >= -1);
  assert(indexOfSelectedObject < static_cast<int>(nodes.size()));

  if (indexOfSelectedObject != -1) {
    BaseNode* obj = nodes.at(indexOfSelectedObject);
    if (obj->isConnector() == false) {
      // erase all the connected connectionnodes
      // get the list of connected nodes, which are all connections
      std::list<BaseNode*> objs;
      objs = obj->getConnectedNodes();

      // iterator through that list and delete the connection nodes
      // as well as remove the pointers to this node from all objects
      // that are connected to the connection node
      std::list<BaseNode*>::iterator it;
      for (it = objs.begin(); it != objs.end(); ++it) {
        // for each of the objects that are connected to this connection,
        std::list<BaseNode*> secondaryObject;
        std::list<BaseNode*>::iterator it2;
        for (it2 = secondaryObject.begin(); it2 != secondaryObject.end(); ++it) {  // NOLINT
          // remove the connection back to the connectionode we are deleting
          (*it2)->removeConnectedNode(*it);
        }

        // delete this connection node
        for (int i = 0; i < static_cast<int>(nodes.size()); i++) {
          if (nodes.at(i) == (*it)) {
            removeFromOrdering(i);
            nodes.erase(nodes.begin()+i);
          }
        }
      }
      // now actually erase the object
      removeFromOrdering(indexOfSelectedObject);
      nodes.erase(nodes.begin()+indexOfSelectedObject);
    } else {
      // get the list of connected objects (should only be two objects)
      std::list<BaseNode*> secondaryObjects;
      secondaryObjects = obj->getConnectedNodes();

      // iterate through the list and disconnect the connectionnode we
      // are deleting from the objects.
      std::list<BaseNode*>::iterator it;  // NOLINT
      for (it = secondaryObjects.begin(); it != secondaryObjects.end(); ++it) {
        (*it)->removeConnectedNode(obj);
      }

      // now delete the actual nodecount
      removeFromOrdering(indexOfSelectedObject);
      nodes.erase(nodes.begin()+indexOfSelectedObject);
    }
  }
  setModified(true);
  indexOfSelectedObject = -1;
  emit modelChanged();
}
开发者ID:hexfaker,项目名称:puml,代码行数:61,代码来源:document.cpp


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