Rect HierarchyTreeControlNode::GetRect() const { Rect rect; if (uiObject && dynamic_cast<UIScrollView*>(uiObject)) { // We are Scroll View, and our child controls should not be taken into account // while calculating the rect. See pls DF-1844 and DF-2704. UIScrollView* scrollView = dynamic_cast<UIScrollView*>(uiObject); return Rect(scrollView->GetPosition(true), scrollView->GetSize()); } if (uiObject) rect = uiObject->GetRect(true); const HIERARCHYTREENODESLIST& childs = GetChildNodes(); for (HIERARCHYTREENODESLIST::const_iterator iter = childs.begin(); iter != childs.end(); ++iter) { const HierarchyTreeControlNode* control = dynamic_cast<const HierarchyTreeControlNode*>(*iter); if (!control) continue; Rect controlRect = control->GetRect(); rect = rect.Combine(controlRect); } return rect; }
std::vector<Metawall::IMWMetadataElementPtr> ElementRatings::GetMetaDataElementsFromRating(const CStdString& sXML, const CStdString& sRating) { Metawall::IMWMetadataElementsPtr pElements; HRESULT hRes = pElements.CreateInstance(__uuidof(Metawall::CMetadataElements)); if (FAILED(hRes)) ThrowComException(_T("Failed to create a Metadata Elements object"), hRes); pElements->SelectNoElements(); LogMetadataElements(pElements, _T("Logging all elements")); std::vector<CStdString> vElements = GetChildNodes(sXML, sRating); std::vector<CStdString>::iterator itCurrent = vElements.begin(); std::vector<Metawall::IMWMetadataElementPtr> vMetaDataElements; while (itCurrent != vElements.end()) { CStdString sElement = GetMWElementFromXML(*itCurrent); vMetaDataElements.push_back(pElements->Item[sElement.c_str()]); itCurrent++; } LogMetadataElements(pElements, _T("Logging elements after enabling for selected rating")); return vMetaDataElements; }
bool HierarchyTreePlatformNode::Save(YamlNode* node) { YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP); platform->Set(WIDTH_NODE, GetWidth()); platform->Set(HEIGHT_NODE, GetHeight()); Map<String, YamlNode*> &platformsMap = node->AsMap(); platformsMap[GetName().toStdString()] = platform; ActivatePlatform(); Map<String, YamlNode*> &platformMap = platform->AsMap(); YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY); platformMap[SCREENS_NODE] = screens; // Add the Localization info - specific for each Platform. SaveLocalization(platform); QString projectFolder = GetResourceFolder(); projectFolder += "UI"; QDir dir; dir.mkpath(projectFolder); bool result = true; for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin(); iter != GetChildNodes().end(); ++iter) { HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter); if (!screenNode) continue; QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(screenNode->GetName()); result &= screenNode->Save(screenPath); screens->AddValueToArray(screenNode->GetName().toStdString()); } return result; }
void HierarchyTreeScreenNode::CombineRectWithChild(Rect& rect) const { const HIERARCHYTREENODESLIST& childs = GetChildNodes(); for (HIERARCHYTREENODESLIST::const_iterator iter = childs.begin(); iter != childs.end(); ++iter) { const HierarchyTreeControlNode* control = dynamic_cast<const HierarchyTreeControlNode*>(*iter); if (!control) continue; Rect controlRect = control->GetRect(); rect = rect.Combine(controlRect); } }
void cisim::nodes::NorNode::Run() { if (!HasAllInputBits()) throw std::runtime_error("Not every input bit has been set"); outputBit = (inputBit1 == Bit::BITSTATE_LOW && inputBit2 == Bit::BITSTATE_LOW) ? Bit::BITSTATE_HIGH : Bit::BITSTATE_LOW; // Set the child nodes next input bit. for (auto& node: GetChildNodes()) node.second->SetNextInputBit(outputBit); // Call the on run event. // cisim::events::OnRunEvent event(this, outputBit); // CallEvent(event); }
Rect HierarchyTreeControlNode::GetRect() const { Rect rect; if (uiObject) rect = uiObject->GetRect(true); const HIERARCHYTREENODESLIST& childs = GetChildNodes(); for (HIERARCHYTREENODESLIST::const_iterator iter = childs.begin(); iter != childs.end(); ++iter) { const HierarchyTreeControlNode* control = dynamic_cast<const HierarchyTreeControlNode*>(*iter); if (!control) continue; Rect controlRect = control->GetRect(); rect = rect.Combine(controlRect); } return rect; }
List<GuidesManager::StickedRect> HierarchyTreeScreenNode::GetControlRectsList(bool includeScreenBounds) const { List<GuidesManager::StickedRect> rectsList; const HierarchyTreeNode::HIERARCHYTREENODESLIST& children = GetChildNodes(); for (HierarchyTreeNode::HIERARCHYTREENODESCONSTITER iter = children.begin(); iter != children.end(); iter ++) { const HierarchyTreeControlNode* controlNode = static_cast<const HierarchyTreeControlNode*>(*iter); GetControlRectsListRecursive(controlNode, rectsList); } if (includeScreenBounds) { // Screen/platform bounds are always forced to be sticked. rectsList.push_back(GuidesManager::StickedRect(GetOwnRect(), true)); } return rectsList; }
void CEngSemStructure::GetChildNodes(int iNode,vector<long> &nodes) const { vector<long> outRels; GetOutcomingRelations(iNode,outRels); if( outRels.size() < 1 ) return; for( int i=0; i<outRels.size(); i++ ) { if( m_Nodes[m_Relations[outRels[i]].m_SourceNodeNo].m_ClauseNo != m_Nodes[m_Relations[outRels[i]].m_TargetNodeNo].m_ClauseNo ) continue; nodes.push_back(m_Relations[outRels[i]].m_TargetNodeNo); GetChildNodes(m_Relations[outRels[i]].m_TargetNodeNo,nodes); } sort(nodes.begin(),nodes.end()); vector<long>::iterator it = unique(nodes.begin(),nodes.end()); int bad = nodes.size() - ( it-nodes.begin() ); for( int i=0; i<bad; i++ ) nodes.pop_back(); }
void BaseEntity::Deserialize(SerializableNodeObject* parentNode, EngineContext* engineContext) { if (!parentNode) { LOG("Cannot deserialize Entity: Node is null."); return; } // Position. /*SerializableProperty* positionProp = (SerializableProperty*)parentNode->FindNodeByName("position"); if (positionProp) this->SetPosition(positionProp->Value.toVec3f()); // Pose. SerializableProperty* poseProp = (SerializableProperty*)parentNode->FindNodeByName("pose"); if (poseProp) this->SetPose(poseProp->Value.toMat4f()); // Direction. SerializableProperty* directionProp = (SerializableProperty*)parentNode->FindNodeByName("direction"); if (directionProp) this->SetDirection(directionProp->Value.toVec3f()); // Scale. SerializableProperty* scaleProp = (SerializableProperty*)parentNode->FindNodeByName("scale"); if (scaleProp) this->SetScale(scaleProp->Value.toVec3f());*/ auto nbNodes = parentNode->GetChildNodesCount(); auto nodes = parentNode->GetChildNodes(); for (size_t i = 0; i < nbNodes; ++i) { auto node = nodes[i]; if (node->GetType() == SerializableNodeType::ARRAY && node->Name.toLower() == "properties") { auto nbProperties = node->GetChildNodesCount(); auto properties = node->GetChildNodes(); for (size_t p = 0; p < nbProperties; ++p) { if (properties[p]->GetType() != SerializableNodeType::OBJECT) continue; PropertyDescriptor pDesc; pDesc.Deserialize((SerializableNodeObject*)properties[p], engineContext); Property* prop = this->AddProperty(pDesc); // Look for the value node. SerializableProperty* valueNode = (SerializableProperty*)properties[p]->FindNodeByName("value"); if (valueNode) prop->Set(valueNode->Value); } } else if (node->GetType() == SerializableNodeType::ARRAY && node->Name.toLower() == "components") { auto nbComponents = node->GetChildNodesCount(); auto components = node->GetChildNodes(); for (size_t c = 0; c < nbComponents; ++c) { if (components[c]->GetType() != SerializableNodeType::OBJECT) continue; SerializableNodeObject* nodeInfo = (SerializableNodeObject*)components[c]; BaseComponent* component = BaseComponent::DeserializeComponent(nodeInfo, engineContext, this); if (!component) { LOG("Unable to deserialize component. Skipping."); continue; } this->AddComponent(component); //component->Deserialize(nodeInfo); } } else if (node->GetType() == SerializableNodeType::PROPERTY) { if (node->Name.toLower() == "class") { this->SetClass(node->Value.c_str()); } } } }
_di_IXMLLotteryPosType __fastcall TXMLTerminalType::Get_LotteryPos() { return (_di_IXMLLotteryPosType) GetChildNodes()->Nodes[System::UnicodeString("LotteryPos")]; };
_di_IXMLCategoryReportType __fastcall TXMLTerminalType::Get_CategoryReport() { return (_di_IXMLCategoryReportType) GetChildNodes()->Nodes[System::UnicodeString("CategoryReport")]; };
_di_IXMLKeyboardType __fastcall TXMLTerminalType::Get_Keyboard() { return (_di_IXMLKeyboardType) GetChildNodes()->Nodes[System::UnicodeString("Keyboard")]; };
void CEngSemStructure::ApplyTwoNegationsRule(int iEngNode) { if( m_Nodes[iEngNode].m_MainWordNo==-1 ) return; int iRusNode = m_Nodes[iEngNode].RusNode; if( iRusNode == -1 ) return; int iSemMainWord = RusStr.GetNode(iRusNode).m_MainWordNo; if( iSemMainWord == -1 ) return; if( !m_Nodes[iEngNode].HasRelOperator("НЕ") ) return; // vector<long> outChilds; GetChildNodes(iEngNode,outChilds); if( outChilds.size() < 1 ) return; // vector<long> negChilds; for( int i=0; i<outChilds.size(); i++ ) { if( HasNeg(m_Nodes[outChilds[i]].GetUnitNo(),m_Nodes[outChilds[i]].GetType()) ) negChilds.push_back(outChilds[i]); } if( negChilds.size() < 1 ) return; // m_Nodes[iEngNode].DelRelOperator("НЕ"); if( negChilds.size() == 1 ) return; // vector<long> rusNodes; for( int i=0; i<negChilds.size(); i++ ) { if( m_Nodes[negChilds[i]].RusNode != -1 ) rusNodes.push_back(m_Nodes[negChilds[i]].RusNode); } sort(rusNodes.begin(),rusNodes.end(),IsLessByMinWordNo(&RusStr)); int iFirst = rusNodes[0]; for( int i=0; i<negChilds.size(); i++ ) { if( m_Nodes[negChilds[i]].RusNode == iFirst ) continue; // весь следующий код на тему "ничего и никого" bool bCaseMNA = false; vector<long> inRels; GetIncomingRelations(negChilds[i],inRels,false); if( inRels.size() == 1 ) { int iParent = m_Relations[inRels[0]].m_SourceNodeNo; int iParRus = m_Nodes[iParent].RusNode; if( iParRus != -1 ) { const CSemNode& rusNode = RusStr.GetNode(iParRus); if( RusStr.GetNode(iParRus).m_NodeType == MNA ) bCaseMNA = true; } } if( !bCaseMNA ) { ChangeNegWord( negChilds[i] ); continue; } int iNodeMNA = m_Relations[inRels[0]].m_SourceNodeNo; vector<long> outMna; GetOutcomingRelations(iNodeMNA,outMna); bool bInFirstMNA = false; for( int j=0; j<outMna.size(); j++ ) { if( m_Nodes[m_Relations[outMna[j]].m_TargetNodeNo].RusNode == iFirst ) { bInFirstMNA = true; break; } } if( bInFirstMNA ) continue; ChangeNegWord( negChilds[i] ); } }
mxArray* ParseChildNodes(pugi::xml_node& node) { mxArray *children = NULL; pugi::xml_attribute tempAttr = node.first_attribute(); if (HasChildNodes(node) || tempAttr != NULL) { mxArray *attributes = ParseAttributes(node); std::vector<std::string> distinctNames; std::vector<std::string> allChildNodeNames; std::vector<pugi::xml_node> childNodes; std::size_t numChildNodes; childNodes = GetChildNodes(node); numChildNodes = childNodes.size(); for (int i = 0; i < numChildNodes; i++) { allChildNodeNames.push_back(childNodes.at(i).name()); } distinctNames = GetDistinctNodeNames(allChildNodeNames); /* Patch for bypassing the variable-length arrays problems of modern C++ compilers */ std::vector<const char*> distinctChildNodeNames; std::transform(distinctNames.begin(), distinctNames.end(), std::back_inserter(distinctChildNodeNames), [](const std::string & str) { // initialize empty char array char *output = new char[str.size()+1]; std::strcpy(output, str.c_str()); return output; }); std::vector<std::string> processedNames; children = mxCreateStructMatrix(1, 1, (int)distinctNames.size(), &distinctChildNodeNames[0]); for (int idx = 0; idx < childNodes.size(); idx++) { pugi::xml_node theChild = childNodes.at(idx); std::string type = node_types[theChild.type()]; std::string temp = theChild.name(); std::string val = theChild.value(); const char *namey[1] = {}; namey[0] = temp.c_str(); mxArray *glhf = mxGetField(children, 0, namey[0]); int indexOfMatchingItem = mxGetFieldNumber(children, namey[0]); if (!(strcmp(type.c_str(), "pcdata") == 0) && !(strcmp(type.c_str(), "comment") == 0) && !(strcmp(type.c_str(), "cdata") == 0)) { //XML allows the same elements to be defined multiple times, put each in a different cell if (std::find(processedNames.begin(), processedNames.end(), temp) != processedNames.end()) { if ( glhf != NULL ) { if (!mxIsCell(glhf)) { mxArray *temp = glhf; glhf = mxCreateCellMatrix(1, 2); mxSetCell(glhf, 0, temp); mxSetCell(glhf, 1, ParseChildNodes(theChild)); mxSetCell(children, indexOfMatchingItem, glhf); } else { std::size_t numberItemsInCell = mxGetN(glhf); mxArray *temp = glhf; glhf = mxCreateCellMatrix(1, numberItemsInCell + 1); for (int i = 0; i < numberItemsInCell; i++) { mxSetCell(glhf, i, mxGetCell(temp, i)); } mxSetCell(glhf, numberItemsInCell, ParseChildNodes(theChild)); mxSetCell(children, indexOfMatchingItem, glhf); } } } //add previously unknown (new) element to the structure else { mxSetCell(children, indexOfMatchingItem, ParseChildNodes(theChild)); } processedNames.push_back(temp); } else { const char *typeFieldNames[1] = {"Text"}; std::string value = theChild.value(); mxArray *matValue = mxCreateString(value.c_str()); if (strcmp(type.c_str(), "cdata") == 0) { typeFieldNames[0] = "CDATA"; } else if (strcmp(type.c_str(), "comment") == 0) { typeFieldNames[0] = "Comment"; } children = mxCreateStructMatrix(1, 1, 1, typeFieldNames); mxSetFieldByNumber(children, 0, 0, matValue); processedNames.push_back(temp); } } if (attributes != NULL) { const char *attrFieldName = "Attributes"; mxAddField(children, attrFieldName); mxSetField(children, 0, attrFieldName, attributes); } } return children; }
bool HierarchyTreePlatformNode::Save(YamlNode* node, bool saveAll) { YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP); platform->Set(WIDTH_NODE, GetWidth()); platform->Set(HEIGHT_NODE, GetHeight()); MultiMap<String, YamlNode*> &platformsMap = node->AsMap(); platformsMap.erase(GetName().toStdString()); platformsMap.insert(std::pair<String, YamlNode*>(GetName().toStdString(), platform)); ActivatePlatform(); MultiMap<String, YamlNode*> &platformMap = platform->AsMap(); YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY); platformMap.erase(SCREENS_NODE); platformMap.insert(std::pair<String, YamlNode*>(SCREENS_NODE, screens)); YamlNode* aggregators = new YamlNode(YamlNode::TYPE_MAP); platformMap.erase(AGGREGATORS_NODE); platformMap.insert(std::pair<String, YamlNode*>(AGGREGATORS_NODE, aggregators)); // Add the Localization info - specific for each Platform. SaveLocalization(platform); QString platformFolder = GetPlatformFolder(); QDir dir; dir.mkpath(platformFolder); bool result = true; //save aggregators node before save screens for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin(); iter != GetChildNodes().end(); ++iter) { HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter); if (!node) continue; QString path = QString(SCREEN_PATH).arg(platformFolder).arg(node->GetName()); MultiMap<String, YamlNode*> &aggregatorsMap = aggregators->AsMap(); YamlNode* aggregator = new YamlNode(YamlNode::TYPE_MAP); result &= node->Save(aggregator, path, saveAll); aggregatorsMap.erase(node->GetName().toStdString()); aggregatorsMap.insert(std::pair<String, YamlNode*>(node->GetName().toStdString(), aggregator)); } for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin(); iter != GetChildNodes().end(); ++iter) { HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter); if (node) continue; //skip aggregators HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter); if (!screenNode) continue; QString screenPath = QString(SCREEN_PATH).arg(platformFolder).arg(screenNode->GetName()); result &= screenNode->Save(screenPath, saveAll); screens->AddValueToArray(screenNode->GetName().toStdString()); } return result; }