int main() { int i,j; char lockName[10]; int money; TestMe(33,0); TestMe(55,1); TestMe(66,2); TestMe(44,0); TestMe(77,0); TestMe(88,1); TestMe(99,1); TestMe(11,1); TestMe(22,1); TestMe(33,1); TestMe(40,1); i = CreateLock("TestLock",8); WriteNum(i);Write("\n",1,1); for(i=0;i<29;i++) { Concatenate("TestLock",sizeof("testlock"),i,lockName); j = CreateLock(lockName, sizeof(lockName)); WriteNum(j);Write("\n",1,1); } /* AcquireLock(i-1); ReleaseLock(i-1); money = CreateSharedInt("money",5,10); SetSharedInt(money,5,1); SetSharedInt(money,3,1); SetSharedInt(money,8,10); i = ArraySearch(money,3,1); WriteNum(i);Write("\n",1,1); i = ArraySearch(money,99,10); WriteNum(i);Write("\n",1,1); */ }
void ribi::cmap::QtConceptMap::BuildQtConceptMap() { CleanMe(); assert(m_concept_map); assert(m_concept_map->IsValid()); assert(this->scene()); //This std::vector keeps the QtNodes in the same order as the nodes in the concept map //You cannot rely on Collect<QtConceptMapNodeConcept*>(scene), as this shuffles the order std::vector<QtNode*> qtnodes; assert(Collect<QtNode>(scene()).empty()); //Add the nodes to the scene, if there are any if (!m_concept_map->GetNodes().empty()) { //Add the main question as the first node const boost::shared_ptr<Node> node = m_concept_map->GetFocalNode(); QtNode * qtnode = nullptr; if (IsCenterNode(node)) { const boost::shared_ptr<CenterNode> centernode = boost::dynamic_pointer_cast<CenterNode>(node); qtnode = new QtCenterNode(centernode); } else { qtnode = new QtNode(node,this->GetDisplayStrategy(node->GetConcept())); } assert(qtnode); //Let the center node respond to mouse clicks qtnode->m_signal_request_scene_update.connect( boost::bind(&ribi::cmap::QtConceptMap::OnRequestSceneUpdate,this)); qtnode->m_signal_item_has_updated.connect( boost::bind(&ribi::cmap::QtConceptMap::OnItemRequestsUpdate,this,boost::lambda::_1)); //Add the center node to scene assert(!qtnode->scene()); this->scene()->addItem(qtnode); qtnodes.push_back(qtnode); assert(Collect<QtNode>(scene()).size() == 1); //Add the regular nodes to the scene const std::vector<boost::shared_ptr<ribi::cmap::Node> > nodes = m_concept_map->GetNodes(); const std::size_t n_nodes = nodes.size(); assert(n_nodes >= 1); for (std::size_t i=1; i!=n_nodes; ++i) //+1 to skip focal node { assert(Collect<QtNode>(scene()).size() == i && "Node not yet added to scene"); assert(i < nodes.size()); boost::shared_ptr<Node> node = nodes[i]; assert(node); assert( (IsCenterNode(node) || !IsCenterNode(node)) && "focal node != center node"); QtNode * const qtnode = AddNode(node); qtnodes.push_back(qtnode); assert(Collect<QtNode>(scene()).size() == i + 1 && "Node is added to scene"); } } #ifndef NDEBUG { //Check the number of const auto qtnodes = Collect<QtNode>(scene()); const auto n_qtnodes = qtnodes.size(); const auto nodes = m_concept_map->GetNodes(); const auto n_nodes = nodes.size(); assert(n_qtnodes == n_nodes && "There must as much nodes in the scene as there were in the concept map"); } #endif //Add the Concepts on the Edges { const std::vector<boost::shared_ptr<ribi::cmap::Edge> > edges = m_concept_map->GetEdges(); std::for_each(edges.begin(),edges.end(), [this,qtnodes](const boost::shared_ptr<Edge> edge) { assert(edge->GetFrom()); assert(edge->GetTo()); assert(edge->GetFrom() != edge->GetTo()); this->AddEdge(edge); } ); } #ifndef NDEBUG { //Check the number of edges const auto qtedges = Collect<QtEdge>(scene()); const auto n_qtedges = qtedges.size(); const auto edges = m_concept_map->GetEdges(); const auto n_edges = edges.size(); assert(n_qtedges == n_edges && "There must as much edges in the scene as there were in the concept map"); } #endif //Put the nodes around the focal question in an initial position if (MustReposition(AddConst(m_concept_map->GetNodes()))) { RepositionItems(); } #ifndef NDEBUG assert(m_concept_map->IsValid()); const auto nodes = m_concept_map->GetNodes(); const auto items = Collect<QtNode>(this->scene()); const std::size_t n_items = items.size(); const std::size_t n_nodes = nodes.size(); if (n_items != n_nodes) { TRACE(m_concept_map->GetNodes().size()); TRACE(n_items); TRACE(n_nodes); } assert(n_items == n_nodes && "GUI and non-GUI concept map must match"); TestMe(m_concept_map); #endif }