bool _DeepCompare(const std::shared_ptr<touchmind::model::node::NodeModel> &node1, const std::shared_ptr<touchmind::model::node::NodeModel> &node2) { if (node1->GetActualChildrenCount() != node2->GetActualChildrenCount()) { return false; } for (size_t i = 0; i < node1->GetActualChildrenCount(); ++i) { auto node1Child = node1->GetChild(i); auto node2Child = node2->GetChild(i); if (!node1Child->Compare(node2Child)) { return false; } _DeepCompare(node1Child, node2Child); } return true; }
void touchmind::print::XPSPrint::_PrintChildrenPaths(const std::shared_ptr<touchmind::model::node::NodeModel> &node) { PATH_DIRECTION linkDirection; touchmind::NODE_SIDE nodePosition = node->GetAncestorPosition(); switch (nodePosition) { case touchmind::NODE_SIDE_RIGHT: linkDirection = PATH_DIRECTION_RIGHT; break; case touchmind::NODE_SIDE_LEFT: linkDirection = PATH_DIRECTION_LEFT; break; case touchmind::NODE_SIDE_UNDEFINED: linkDirection = PATH_DIRECTION_AUTO; break; default: linkDirection = PATH_DIRECTION_AUTO; } for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) { std::shared_ptr<touchmind::model::node::NodeModel> child = node->GetChild(i); touchmind::model::CurvePoints curvePoints; view::GeometryBuilder::CalculatePath( node, child, linkDirection, touchmind::NODE_JUSTIFICATION_TOP, m_pConfiguration->GetLevelSeparation(), curvePoints); _PrintPath(child, curvePoints); } }
static void populateJsonWithSmilSeq(stringstream &stream, std::shared_ptr<const ePub3::SMILData::Sequence> seqq){ //TODO do we need this? //printf("CHECK SMIL DATA TREE TEXTREF FRAGID %s\n", seqq->_textref_fragmentID.c_str()); if(nullptr == seqq){ stream << "!! NULL SMIL SEQQ" << endl; return; } stream << "{" << endl; stream << "\"textref\": \"" << seqq->TextRefFile() << "\" ," << endl; stream << "\"epubtype\": \"" << seqq->Type() << "\" ," << endl; stream << "\"nodeType\": \"" << seqq->Name() << "\" ," << endl; stream << "\"children\": [" << endl; auto childrenCount = seqq->GetChildrenCount(); for (int i = 0; i < childrenCount; ++i){ std::shared_ptr<const ePub3::SMILData::TimeContainer> container = seqq->GetChild(i); if(nullptr == container){ stream << "!! NULL SMIL CONTAINER" << endl; continue; } //const ePub3::SMILData::Sequence *seq = dynamic_cast<const ePub3::SMILData::Sequence *>(container); //if (nullptr != seq){ if (container->IsSequence()){ auto seq = std::dynamic_pointer_cast<const ePub3::SMILData::Sequence>(container); populateJsonWithSmilSeq(stream, seq); //continue; } //const ePub3::SMILData::Parallel *par = dynamic_cast<const ePub3::SMILData::Parallel *>(container); //if (nullptr != par){ else if (container->IsParallel()){ auto par = std::dynamic_pointer_cast<const ePub3::SMILData::Parallel>(container); populateJsonWithSmilPar(stream, par); //continue; } else{ stream << "!! SMIL CONTAINER TYPE???" << endl; } if(i != childrenCount-1){ stream << ','; } } stream << ']' << endl; stream << '}' << endl; }
void touchmind::model::node::NodeModel::_Dump(std::wostream &out, int indent, const std::shared_ptr<touchmind::model::node::NodeModel> &node) { _Indent(out, indent); node->Dump(out); out << std::endl; for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) { auto child = node->GetChild(i); _Dump(out, indent + 1, child); } }
void _DeepCopy(std::shared_ptr<touchmind::model::node::NodeModel> srcParent, std::shared_ptr<touchmind::model::node::NodeModel> destParent) { for (size_t i = 0; i < srcParent->GetActualChildrenCount(); ++i) { auto srcChild = srcParent->GetChild(i); auto destChild = touchmind::model::node::NodeModel::Create(*srcChild.get()); destChild->RemoveAllChildren(); destParent->AddChild(destChild); _DeepCopy(srcChild, destChild); } }
void touchmind::layout::LayoutManager::_CalculateSize(const std::shared_ptr<touchmind::model::node::NodeModel> &node) { FLOAT width, height; m_pTextSizeProvider->Calculate(node, &width, &height); node->SetWidth(width + m_configuration->GetInsets().left + m_configuration->GetInsets().right); node->SetHeight(height + m_configuration->GetInsets().top + m_configuration->GetInsets().bottom); if (node != nullptr) { for (size_t i = 0; i < node->GetChildrenCount(); ++i) { std::shared_ptr<touchmind::model::node::NodeModel> child = node->GetChild(i); _CalculateSize(child); } } }
std::shared_ptr<touchmind::model::node::NodeModel> touchmind::model::node::NodeModel::_FindByNodeId(const std::shared_ptr<touchmind::model::node::NodeModel> &node, touchmind::NODE_ID nodeId) { if (nodeId == node->GetId()) { return node; } for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) { auto child = node->GetChild(i); auto result = _FindByNodeId(child, nodeId); if (result != nullptr) { return result; } } return nullptr; }
void touchmind::layout::LayoutManager::FirstWalk( const std::shared_ptr<touchmind::model::node::NodeModel> &tree, const std::shared_ptr<touchmind::model::node::NodeModel> &node, int level) { std::shared_ptr<touchmind::model::node::NodeModel> pLeftSibling = nullptr; node->SetX(0.0f); node->SetY(0.0f); LayoutWorkData* pTempDataOfNode = _GetLayoutWorkData(node); pTempDataOfNode->prelim = 0.0f; pTempDataOfNode->modifier = 0.0f; pTempDataOfNode->pLeftNeighbor = nullptr; pTempDataOfNode->pRightNeighbor = nullptr; SetLevelHeight(node, level); SetLevelWidth(node, level); SetNeighbors(node, level); if (node->GetChildrenCount() == 0 || level == m_configuration->GetMaxDepth()) { pLeftSibling = node->GetLeftSibling(); if (pLeftSibling != nullptr) { LayoutWorkData* pTempDataOfLeftSibling = _GetLayoutWorkData(pLeftSibling); pTempDataOfNode->prelim = pTempDataOfLeftSibling->prelim + GetNodeSize(pLeftSibling) + m_configuration->GetSiblingSeparation(); } else { pTempDataOfNode->prelim = 0.0f; } } else { for (size_t i = 0; i < node->GetChildrenCount(); ++i) { std::shared_ptr<touchmind::model::node::NodeModel> pChild = node->GetChild(i); FirstWalk(tree, pChild, level + 1); } FLOAT midPoint = GetChildrenCenter(node); midPoint -= GetNodeSize(node) / 2; pLeftSibling = node->GetLeftSibling(); if (pLeftSibling != nullptr) { LayoutWorkData* pTempDataOfLeftSibling = _GetLayoutWorkData(pLeftSibling); pTempDataOfNode->prelim = pTempDataOfLeftSibling->prelim + GetNodeSize(pLeftSibling) + m_configuration->GetSiblingSeparation(); pTempDataOfNode->modifier = pTempDataOfNode->prelim - midPoint; Apportion(tree, node, level); } else { pTempDataOfNode->prelim = midPoint; } } }
std::shared_ptr<touchmind::model::node::NodeModel> touchmind::layout::LayoutManager::GetLeftMost( const std::shared_ptr<touchmind::model::node::NodeModel> &node, int level, int maxLevel) const { if (level >= maxLevel) { return node; } if (node->GetChildrenCount() == 0) { return nullptr; } size_t n = node->GetChildrenCount(); for (size_t i = 0; i < n; ++i) { std::shared_ptr<touchmind::model::node::NodeModel> child = node->GetChild(i); std::shared_ptr<touchmind::model::node::NodeModel> leftmostDescendant = GetLeftMost(child, level + 1, maxLevel); if (leftmostDescendant != nullptr) { return leftmostDescendant; } } return nullptr; }
void touchmind::view::node::NodeViewManager::DrawNodePaths(touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget, std::shared_ptr<model::node::NodeModel> node) { PATH_DIRECTION pathDirection; touchmind::NODE_SIDE nodePosition = node->GetAncestorPosition(); switch (nodePosition) { case touchmind::NODE_SIDE_RIGHT: pathDirection = PATH_DIRECTION_RIGHT; break; case touchmind::NODE_SIDE_LEFT: pathDirection = PATH_DIRECTION_LEFT; break; case touchmind::NODE_SIDE_UNDEFINED: pathDirection = PATH_DIRECTION_AUTO; break; default: pathDirection = PATH_DIRECTION_AUTO; } for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) { std::shared_ptr<touchmind::model::node::NodeModel> child = node->GetChild(i); DrawPath(pContext, pRenderTarget, child); } }