bool engineInitSystem() { engine_shutdown(); if (!engine_init()) { // } initMapData(); #if defined(ARM_LINUX) loadGrammar(); registerCallback(); #endif g_navDisplay->initContext(); g_navDisplay->initViewport(); g_navDisplay->initDisplay(SCREEN_WIDTH,SCREEN_HEIGHT); LatLongGrid_Init(&g_latLongGrid); LatLongGrid_SetStep(&g_latLongGrid, 100000, 100000); gps_init(); #if defined(ARM_LINUX) gps_setContext(NMEA_CONTEXT_GPS); #else gps_setContext(NMEA_CONTEXT_MANUAL); #endif }
void GameMap::initMap() { // init map data first initMapData(); // generate some default cell on map int len = 4; for (int i = 0; i < len; i++) { generateCell(); } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); _debugLabel = Label::createWithTTF("", "fonts/arial.ttf", 12); _debugLabel->setPosition(origin.x + visibleSize.width - 50, origin.y + visibleSize.height - 50); this->addChild(_debugLabel); // init event listener auto listener = EventListenerTouchOneByOne::create(); //listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(GameMap::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(GameMap::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(GameMap::onTouchEnded, this); this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); //Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); }
/* initAnchor: * Save current map values * Initialize fields in job->obj pertaining to anchors. * In particular, this also sets the output rectangle. * If there is something to do, close current anchor if * necessary, start the anchor and returns 1. * Otherwise, it returns 0. * * FIX: Should we provide a tooltip if none is set, as is done * for nodes, edges, etc. ? */ static int initAnchor (GVJ_t* job, htmlenv_t* env, htmldata_t* data, boxf b, htmlmap_data_t* save, int closePrev) { obj_state_t *obj = job->obj; int changed; char* id; static int anchorId; int internalId = 0; agxbuf xb; char intbuf[30]; /* hold 64-bit decimal integer */ unsigned char buf[SMALLBUF]; save->url = obj->url; save->tooltip = obj->tooltip; save->target = obj->target; save->id = obj->id; save->explicit_tooltip = obj->explicit_tooltip; id = data->id; if (!id || !*id) { /* no external id, so use the internal one */ agxbinit(&xb, SMALLBUF, buf); if (!env->objid) { env->objid = strdup (getObjId (job, obj->u.n, &xb)); env->objid_set = 1; } agxbput (&xb, env->objid); sprintf (intbuf, "_%d", anchorId++); agxbput (&xb, intbuf); id = agxbuse (&xb); internalId = 1; } changed = initMapData (job, NULL, data->href, data->title, data->target, id, obj->u.g); if (internalId) agxbfree (&xb); if (changed) { if (closePrev && (save->url || save->explicit_tooltip)) gvrender_end_anchor(job); if (obj->url || obj->explicit_tooltip) { emit_map_rect(job, b); gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target, obj->id); } } return changed; }
MapData *readMapDataTPED(string filename, int expected_loci, int expected_haps) { igzstream fin; cerr << "Opening " << filename << "...\n"; fin.open(filename.c_str()); if (fin.fail()) { cerr << "ERROR: Failed to open " << filename << " for reading.\n"; throw 0; } //int fileStart = fin.tellg(); string line; int nloci = 0; int num_cols = 4; int current_cols = 0; while (getline(fin, line)) { nloci++; current_cols = countFields(line); if (current_cols != num_cols + expected_haps) { cerr << "ERROR: line " << nloci << " of " << filename << " has " << current_cols << ", but expected " << num_cols + expected_haps << ".\n"; throw 0; } } if (nloci != expected_loci) { cerr << "ERROR: Expected " << expected_loci << " loci in map file but found " << nloci << ".\n"; throw 0; } fin.clear(); // clear error flags //fin.seekg(fileStart); fin.close(); fin.open(filename.c_str()); if (fin.fail()) { cerr << "ERROR: Failed to open " << filename << " for reading.\n"; throw 0; } cerr << "Loading map data for " << nloci << " loci\n"; MapData *data = initMapData(nloci); string chr; for (int locus = 0; locus < data->nloci; locus++) { fin >> data->chr; fin >> data->locusName[locus]; fin >> data->geneticPos[locus]; fin >> data->physicalPos[locus]; getline(fin, line); } fin.close(); return data; }
MapData *readMapDataVCF(string filename, int expected_loci) { igzstream fin; cerr << "Opening " << filename << "...\n"; fin.open(filename.c_str()); if (fin.fail()) { cerr << "ERROR: Failed to open " << filename << " for reading.\n"; throw 0; } string line; int nloci = 0; int numCommentedLines = 0; while (getline(fin, line)) { if (line[0] == '#') { numCommentedLines++; } else { nloci++; } } if (nloci != expected_loci) { cerr << "ERROR: Expected " << expected_loci << " loci in file but found " << nloci << ".\n"; throw 0; } fin.clear(); // clear error flags //fin.seekg(fileStart); fin.close(); fin.open(filename.c_str()); if (fin.fail()) { cerr << "ERROR: Failed to open " << filename << " for reading.\n"; throw 0; } cerr << "Loading map data for " << nloci << " loci\n"; for (int i = 0; i < numCommentedLines; i++) { getline(fin, line); } MapData *data = initMapData(nloci); string chr; for (int locus = 0; locus < data->nloci; locus++) { fin >> data->chr; fin >> data->physicalPos[locus]; fin >> data->locusName[locus]; getline(fin, line); data->geneticPos[locus] = MISSING; } fin.close(); return data; }