Пример #1
0
bool touchmind::view::path::impl::DefaultPathView::_CheckValidity()
{
    if (GetNodeModel().expired()) {
        return false;
    }
    std::shared_ptr<model::node::NodeModel> node = GetNodeModel().lock();
    std::shared_ptr<model::node::NodeModel> parent = node->GetParent();
    if (parent == nullptr) {
        return false;
    }
    if (parent->IsCollapsed() || parent->IsAncestorCollapsed()) {
        return false;
    }
    return true;
}
Пример #2
0
bool touchmind::view::path::impl::DefaultPathView::HitTest(
    touchmind::Context *pContext,
    ID2D1RenderTarget *pRenderTarget,
    D2D1_POINT_2F point)
{
    if (!_CheckValidity()) {
        return false;
    }
    CreateDeviceDependentResources(pContext, pRenderTarget);
    BOOL b;
    m_pathGeometry->StrokeContainsPoint(
        point,
        GetNodeModel().lock()->GetPathModel()->GetWidth() + 5.0f,
        nullptr,
        nullptr,
        &b);
    return (b == TRUE);
}
Пример #3
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;
}
Пример #4
0
void touchmind::view::path::impl::DefaultPathView::CreateDeviceDependentResources(
    touchmind::Context *pContext,
    ID2D1RenderTarget *pRenderTarget )
{
    if (!_CheckValidity()) {
        return;
    }
    auto node = GetNodeModel().lock();
    auto path = node->GetPathModel();
    if (path->IsRepaintRequired(GetRepaintCounter()) ||
            m_pathBrush == nullptr ||
            m_pathGeometry == nullptr ||
            m_pathStyle == nullptr) {
        _CreateDeviceDependentResources(pContext, pRenderTarget, node);
        if (path->IsSelected()) {
            _CreateTexture(pContext, pRenderTarget, node);
        } else {
            m_pBitmap = nullptr;
        }
        SetRepaintCounter(path);
    }
}
Пример #5
0
void touchmind::view::path::impl::DefaultPathView::Draw(
    touchmind::Context *pContext,
    ID2D1RenderTarget *pRenderTarget )
{
    if (!_CheckValidity()) {
        return;
    }
    auto node = GetNodeModel().lock();
    auto path = node->GetPathModel();

    CreateDeviceDependentResources(pContext, pRenderTarget);
    if (path->IsSelected()) {
        FLOAT shadowOffset = GetNodeViewManager()->GetGaussFilter()->GetOffset();
        D2D1_SIZE_F size = m_pBitmap->GetSize();
        FLOAT left = m_bounds.left -  shadowOffset;
        FLOAT top  = m_bounds.top - shadowOffset;
        pRenderTarget->DrawBitmap(m_pBitmap, D2D1::RectF(left, top, left + size.width, top + size.height));
    }
    pRenderTarget->DrawGeometry(
        m_pathGeometry,
        m_pathBrush,
        path->GetWidthAsValue(),
        m_pathStyle);
}