Exemplo n.º 1
0
void touchmind::view::node::NodeViewManager::DrawNodes(touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget,
                                                       std::shared_ptr<model::node::NodeModel> edittingNode) {
  CreateSharedDeviceResources(pContext, pRenderTarget);
  auto root = m_pMapModel->GetRootNodeModel();

  // if (root->IsDescendantRepaintRequired()) {
  SynchronizeWithModel();
  //}

  // Draw all paths
  root->ApplyVisitor([&](std::shared_ptr<model::node::NodeModel> node) -> touchmind::VISITOR_RESULT {
    DrawNodePaths(pContext, pRenderTarget, node);
    return touchmind::VISITOR_RESULT_CONTINUE;
  });

  // Draw all nodes
  root->ApplyVisitor([&](std::shared_ptr<model::node::NodeModel> node) -> touchmind::VISITOR_RESULT {
    if (edittingNode != node) {
      DrawNode(pContext, pRenderTarget, node);
    }
    return touchmind::VISITOR_RESULT_CONTINUE;
  });

  // root->ClearDescendantRepaintRequired();
}
Exemplo n.º 2
0
HRESULT touchmind::view::node::NodeViewManager::SynchronizeWithModel() {
  auto root = m_pMapModel->GetRootNodeModel();
  // set all wasHandled flags to false
  for (auto &kv : m_nodeIdToViewMap) {
    auto nodeView = kv.second;
    nodeView->ClearHandled();
  }
  // synchronize view resource with model
  SynchronizeViewAfterArrangingVisitor visitor(this, m_nodeIdToViewMap, m_pEditControlManager,
                                               m_pConfiguration->GetInsets());
  root->ApplyVisitor(visitor);

  // if wasHandled flag is false, remove its view resource
  std::vector<touchmind::NODE_ID> prepareRemove;
  for (auto &kv : m_nodeIdToViewMap) {
    auto nodeView = kv.second;
    if (!nodeView->IsHandled()) {
      m_pEditControlManager->DestroyDWLightEditControl(nodeView->GetEditControlIndex());
      prepareRemove.push_back(kv.first);
    }
  }
  // remove view resources
  for (auto &nodeId : prepareRemove) {
    m_nodeIdToViewMap.erase(nodeId);
    m_nodeIdToPathView.erase(nodeId);
  }
  return S_OK;
}
Exemplo n.º 3
0
void touchmind::win::CanvasPanel::CalculateScrolls(FLOAT width, FLOAT height) {
    auto root = GetRootNodeModel();
    touchmind::layout::TreeRectVisitor treeRectVisitor;
    root->ApplyVisitor(treeRectVisitor);

    FLOAT marginX = width / 4;
    FLOAT marginY = height / 4;
    m_pScrollBarHelper->SetModelRect(treeRectVisitor.treeRect.x1 - marginX, treeRectVisitor.treeRect.y1 - marginY,
                                     treeRectVisitor.treeRect.GetWidth() + marginX * 2,
                                     treeRectVisitor.treeRect.GetHeight() + marginY * 2);
    m_pScrollBarHelper->SetWindowSize((UINT)width, (UINT)height);
}
Exemplo n.º 4
0
std::shared_ptr<touchmind::model::path::PathModel>
touchmind::view::node::NodeViewManager::PathHitTest(touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget,
                                                    D2D1_POINT_2F point) {
  std::shared_ptr<touchmind::model::path::PathModel> result;
  auto root = m_pMapModel->GetRootNodeModel();
  root->ApplyVisitor([&](std::shared_ptr<touchmind::model::node::NodeModel> &node) -> VISITOR_RESULT {
    if (((!node->IsCollapsed() && !node->IsAncestorCollapsed())
         || (node->IsCollapsed() && !node->IsAncestorCollapsed()))) {
      if (m_nodeIdToPathView.count(node->GetId()) > 0) {
        auto pathView = m_nodeIdToPathView[node->GetId()];
        if (pathView->HitTest(pContext, pRenderTarget, point)) {
          result = pathView->GetNodeModel().lock()->GetPathModel();
          return touchmind::VISITOR_RESULT_STOP;
        }
      }
    }
    return touchmind::VISITOR_RESULT_CONTINUE;
  });
  return result;
}
Exemplo n.º 5
0
std::shared_ptr<touchmind::model::node::NodeModel>
touchmind::view::node::NodeViewManager::NodeHitTest(touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget,
                                                    D2D1_POINT_2F point) {
  UNREFERENCED_PARAMETER(pContext);
  UNREFERENCED_PARAMETER(pRenderTarget);

  FLOAT margin = 5.0f;
  std::shared_ptr<touchmind::model::node::NodeModel> result;
  auto root = m_pMapModel->GetRootNodeModel();
  root->ApplyVisitor([&](std::shared_ptr<touchmind::model::node::NodeModel> &node) -> VISITOR_RESULT {
    if (((!node->IsCollapsed() && !node->IsAncestorCollapsed())
         || (node->IsCollapsed() && !node->IsAncestorCollapsed()))
        && (node->GetX() - margin) <= point.x && point.x <= (node->GetX() + node->GetWidth() + margin)
        && (node->GetY() - margin) <= point.y && point.y <= (node->GetY() + node->GetHeight() + margin)) {
      result = node;
      return touchmind::VISITOR_RESULT_STOP;
    }
    return touchmind::VISITOR_RESULT_CONTINUE;
  });
  return result;
}
Exemplo n.º 6
0
HRESULT touchmind::view::node::NodeViewManager::SynchronizeViewBeforeArrange() {
  auto pRootNode = m_pMapModel->GetRootNodeModel();
  SynchronizeViewBeforeArrangingVisitor visitor(this, m_nodeIdToViewMap, m_pEditControlManager);
  pRootNode->ApplyVisitor(visitor);
  return S_OK;
}
Exemplo n.º 7
0
void CompositeDataItem::traverse( ItemVisitor& iv ) {
  std::for_each( begin(), end(), ApplyVisitor( iv ) );
}