/*! Set the length of the backbone. The length doesn't include the space needed for overlapping labels. \param length Length of the backbone \sa move(), minLabelDist() */ void QwtScaleDraw::setLength( double length ) { #if 1 if ( length >= 0 && length < 10 ) length = 10; // why should we accept negative lengths ??? if ( length < 0 && length > -10 ) length = -10; #else length = qMax( length, 10 ); #endif d_data->len = length; updateMap(); }
MapWidget::MapWidget(QWidget *parent) : QWidget(parent), m_center(55.755831, 37.617673), m_zoom(10), m_online(true), m_lockWheel(false) { m_tiles = new TilesMap(m_center, m_zoom, m_online, this); connect(m_tiles, SIGNAL(updated(QRect)), SLOT(updateMap(QRect))); connect(m_tiles, SIGNAL(tilesLoading(int)), SIGNAL(tilesLoading(int))); connect(m_tiles, SIGNAL(zoomChanged(int)), SIGNAL(zoomChanged(int))); m_overlays = new Overlays(m_center, m_zoom, this); m_pointDialog = new PointDialog(this); connect(m_pointDialog, SIGNAL(accepted()), SLOT(pointDialogAccepted())); QShortcut *sc; sc = new QShortcut(QKeySequence("Left"), this); connect(sc, SIGNAL(activated()), SLOT(panLeft())); sc = new QShortcut(QKeySequence("Right"), this); connect(sc, SIGNAL(activated()), SLOT(panRight())); sc = new QShortcut(QKeySequence("Down"), this); connect(sc, SIGNAL(activated()), SLOT(panDown())); sc = new QShortcut(QKeySequence("Up"), this); connect(sc, SIGNAL(activated()), SLOT(panUp())); sc = new QShortcut(QKeySequence("PgUp"), this); connect(sc, SIGNAL(activated()), SLOT(zoomIn())); sc = new QShortcut(QKeySequence("PgDown"), this); connect(sc, SIGNAL(activated()), SLOT(zoomOut())); sc = new QShortcut(QKeySequence("Escape"), this); connect(sc, SIGNAL(activated()), SLOT(hideAll())); sc = new QShortcut(QKeySequence("Shift+Insert"), this); connect(sc, SIGNAL(activated()), SLOT(openAddPointDialog())); sc = new QShortcut(QKeySequence("E"), this); connect(sc, SIGNAL(activated()), SLOT(openEditPointDialog())); sc = new QShortcut(QKeySequence("Delete"), this); connect(sc, SIGNAL(activated()), SLOT(openDeletePointDialog())); sc = new QShortcut(QKeySequence("Alt+I"), this); connect(sc, SIGNAL(activated()), SLOT(switchOnline())); sc = new QShortcut(QKeySequence("Alt+O, Alt+O"), this); connect(sc, SIGNAL(activated()), SLOT(openInOSM())); sc = new QShortcut(QKeySequence("Alt+O, Alt+G"), this); connect(sc, SIGNAL(activated()), SLOT(openInGoogleMaps())); sc = new QShortcut(QKeySequence("Alt+O, Alt+Y"), this); connect(sc, SIGNAL(activated()), SLOT(openInYandexMaps())); }
int LightMaps::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: toggleNightMode(); break; case 1: setZoom_p(); break; case 2: setZoom_m(); break; case 3: updateMap((*reinterpret_cast< const QRect(*)>(_a[1]))); break; default: ; } _id -= 4; } return _id; }
void HCluster::clusterNames(){ try { ///cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(clusterArray[smallRow].smallChild) << '\t' << list->get(clusterArray[smallCol].smallChild); if (mapWanted) { updateMap(); } list->set(clusterArray[smallCol].smallChild, list->get(clusterArray[smallRow].smallChild)+','+list->get(clusterArray[smallCol].smallChild)); list->set(clusterArray[smallRow].smallChild, ""); list->setLabel(toString(smallDist)); //cout << '\t' << list->get(clusterArray[smallRow].smallChild) << '\t' << list->get(clusterArray[smallCol].smallChild) << endl; } catch(exception& e) { m->errorOut(e, "HCluster", "clusterNames"); exit(1); } }
bool BinaryConnection::updateMaps() { // Save map count unsigned int count = (unsigned int)mDatabase->getMaps().size(); mFile.write((char*)&count, sizeof(count)); // Save maps MapList::const_iterator i = mDatabase->getMaps().begin(); for (; i != mDatabase->getMaps().end(); ++i) { if (updateMap(i->second) == false) { return false; } } return true; }
void SlamGMapping::laserCallback(const sensor_msgs::LaserScan::ConstPtr& scan) { laser_count_++; if ((laser_count_ % throttle_scans_) != 0) return; static ros::Time last_map_update(0,0); // We can't initialize the mapper until we've got the first scan if(!got_first_scan_) { if(!initMapper(*scan)) return; got_first_scan_ = true; } GMapping::OrientedPoint odom_pose; if(addScan(*scan, odom_pose)) { ROS_DEBUG("scan processed"); GMapping::OrientedPoint mpose = gsp_->getParticles()[gsp_->getBestParticleIndex()].pose; ROS_DEBUG("new best pose: %.3f %.3f %.3f", mpose.x, mpose.y, mpose.theta); ROS_DEBUG("odom pose: %.3f %.3f %.3f", odom_pose.x, odom_pose.y, odom_pose.theta); ROS_DEBUG("correction: %.3f %.3f %.3f", mpose.x - odom_pose.x, mpose.y - odom_pose.y, mpose.theta - odom_pose.theta); tf::Transform laser_to_map = tf::Transform(tf::createQuaternionFromRPY(0, 0, mpose.theta), tf::Vector3(mpose.x, mpose.y, 0.0)).inverse(); tf::Transform odom_to_laser = tf::Transform(tf::createQuaternionFromRPY(0, 0, odom_pose.theta), tf::Vector3(odom_pose.x, odom_pose.y, 0.0)); map_to_odom_mutex_.lock(); map_to_odom_ = (odom_to_laser * laser_to_map).inverse(); map_to_odom_mutex_.unlock(); if(!got_map_ || (scan->header.stamp - last_map_update) > map_update_interval_) { updateMap(*scan); last_map_update = scan->header.stamp; ROS_DEBUG("Updated the map"); } } }
void SlamKarto::laserCallback(const sensor_msgs::LaserScan::ConstPtr& scan) { laser_count_++; if ((laser_count_ % throttle_scans_) != 0) return; static ros::Time last_map_update(0,0); // Check whether we know about this laser yet karto::LaserRangeFinder* laser = getLaser(scan); if(!laser) { ROS_WARN("Failed to create laser device for %s; discarding scan", scan->header.frame_id.c_str()); return; } karto::Pose2 odom_pose; if(addScan(laser, scan, odom_pose)) { ROS_DEBUG("added scan at pose: %.3f %.3f %.3f", odom_pose.GetX(), odom_pose.GetY(), odom_pose.GetHeading()); publishGraphVisualization(); if(!got_map_ || (scan->header.stamp - last_map_update) > map_update_interval_) { if(updateMap()) { last_map_update = scan->header.stamp; got_map_ = true; ROS_DEBUG("Updated the map"); } } } }
MarksWidget::MarksWidget(QSharedPointer<User> user, WContainerWidget *parent) : WTabWidget(parent) { m_user = user; marksTable = new WTableView(); marksTable->setMinimumSize(WLength(100), WLength(400)); marksMapWidget = new WGoogleMap(); marksMapWidget->setMinimumSize(WLength(300), WLength(400)); marksMapWidget->setMaximumSize(WLength(500), WLength(400)); marksMapWidget->setCenter(Wt::WGoogleMap::Coordinate(60, 30)); marksMapWidget->enableScrollWheelZoom(); marksModel = new MarksModel(m_user, marksTable->parent()); marksTable->setModel(marksModel); marksTable->setSelectable(true); /* Setting up tab widget */ this->addTab(marksTable, "Table"); this->addTab(marksMapWidget, "Map"); updateMap(); }
void THIS::processMessage ( Message* newMessage ) { PainterPlugin::processMessage ( newMessage ); switch ( newMessage->getType() ) { case MessageTypes::MAP_DATA_M: { MapDataM* message = Message::castTo<MapDataM> ( newMessage ); if ( message ) { updateMap ( message->getMapPointer() ); requestRedraw(); } break; } default: break; } }
void* ThreadRecv() { ENetEvent event; /* Wait up to 1000 milliseconds for an event. */ while(1) { CCLOG("begin recv"); while (enet_host_service (server, & event, 1000000) > 0) { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: CCLOG("A new client connected from %x:%u.\n", event.peer -> address.host, event.peer -> address.port); /* Store any relevant client information here. */ char temp[50]; strcat(temp, "Client information"); event.peer -> data = temp; //channel = 1; break; case ENET_EVENT_TYPE_RECEIVE: CCLOG("A packet of length %u containing %s was received on channel %u.\n", event.packet -> dataLength, event.packet -> data, event.channelID); updateMap(viewLayer, event.packet -> data); CCLOG("update finish"); enet_packet_destroy (event.packet); CCLOG("packet destroyed"); break; case ENET_EVENT_TYPE_DISCONNECT: CCLOG("%s disconected.\n", event.peer -> data); /* Reset the peer's client information. */ event.peer -> data = NULL; } } } enet_host_destroy(server); return NULL; }
void LocalBackEnd::consumeSingleEvent(GameEvent* event) { switch(event->type) { case RawData: Debug("Received raw data from server"); unpackRaws((RawDataEvent*)event); break; case AreaData: Debug("Area data received from server"); _world.processWorldEvent(event); changeArea(); break; case TileData: //Debug("Tile data received from server"); _world.processWorldEvent(event); updateMap((TileDataEvent*)event); break; case ObjectData: updateObject((ObjectDataEvent*)event); break; case CharacterReady: Debug("Character is ready"); changeArea(); _characterID = ((CharacterReadyEvent*)event)->ID; break; case CharacterNotReady: Debug("Character not ready - " << ((CharacterNotReadyEvent*)event)->reason); break; case ThingMoved: moveObject((ThingMovedEvent*)event); break; case MoveFailed: Debug("Failed to move - " << ((MoveFailedEvent*)event)->reason); break; default: Warn("Unhandled game event type " << event->type); break; } }
/** * @details This creates a `mapObj` primed for use with a `mapservObj`. */ mapObj* Map::LoadMap(mapservObj *mapserv, mapObj *src) { mapObj* map = msNewMapObj(); if (!map) { return NULL; } // updating alters the state of the map, so work on a copy if (msCopyMap(map, src) != MS_SUCCESS) { msFreeMap(map); return NULL; } mapserv->map = map; // delegate to the helper function if (updateMap(mapserv, map) != MS_SUCCESS) { msFreeMap(map); mapserv->map = NULL; return NULL; } return map; }
//Display Function void display(void) { if(!paused) { if(counter >= timer) { updateMap(); counter = 0; } counter++; } glClearColor(0.0,0.0,0.0,0.0); for (int i = 0; i < 30; i++ ) { for (int j = 0; j < 30; j++ ) { //Set Color as White if alive. if(currentMap[i][j] == 1) { glColor3f(1.0f, 1.0f, 1.0f); } //Set Color as Black if dead. else { glColor3f(0, 0, 0); } //Draw Cell. glBegin(GL_POLYGON); glVertex2f(i * tileSize, j * tileSize); glVertex2f(i * tileSize + tileSize, j * tileSize); glVertex2f(i * tileSize + tileSize, j * tileSize + tileSize); glVertex2f(i * tileSize, j * tileSize + tileSize); glEnd(); } } glutSwapBuffers(); }
// update button void MapPlanning::on_updateTableButton_clicked() { updateMap(); }
// - button void MapPlanning::on_deleteButton_clicked() { QModelIndexList indexes = ui->tableView->selectionModel()->selectedIndexes(); model->removeRows(indexes); updateMap(); }
void QgsValueMapConfigDlg::loadFromCSVButtonPushed() { QString fileName = QFileDialog::getOpenFileName( 0, tr( "Select a file" ) ); if ( fileName.isNull() ) return; QFile f( fileName ); if ( !f.open( QIODevice::ReadOnly ) ) { QMessageBox::information( NULL, tr( "Error" ), tr( "Could not open file %1\nError was:%2" ).arg( fileName, f.errorString() ), QMessageBox::Cancel ); return; } QTextStream s( &f ); s.setAutoDetectUnicode( true ); QRegExp re0( "^([^;]*);(.*)$" ); re0.setMinimal( true ); QRegExp re1( "^([^,]*),(.*)$" ); re1.setMinimal( true ); QMap<QString, QVariant> map; s.readLine(); while ( !s.atEnd() ) { QString l = s.readLine().trimmed(); QString key, val; if ( re0.indexIn( l ) >= 0 && re0.captureCount() == 2 ) { key = re0.cap( 1 ).trimmed(); val = re0.cap( 2 ).trimmed(); } else if ( re1.indexIn( l ) >= 0 && re1.captureCount() == 2 ) { key = re1.cap( 1 ).trimmed(); val = re1.cap( 2 ).trimmed(); } else continue; if (( key.startsWith( "\"" ) && key.endsWith( "\"" ) ) || ( key.startsWith( "'" ) && key.endsWith( "'" ) ) ) { key = key.mid( 1, key.length() - 2 ); } if (( val.startsWith( "\"" ) && val.endsWith( "\"" ) ) || ( val.startsWith( "'" ) && val.endsWith( "'" ) ) ) { val = val.mid( 1, val.length() - 2 ); } map[ key ] = val; } updateMap( map, false ); }
void sdlMapBoucle(sdlMap *sdMap) { int continuGame = 1; int resultMenu; int i, num; char c; Menu menu; sdlMenuInit(&menu, getSdlMapEcran(sdMap)); //Lancement du menu resultMenu = sdlMenuBoucle(&menu); SDL_Event event; /* Horloges (en secondes) */ float currentClock, prevClock; /* Intervalle de temps (en secondes) entre deux Èvolutions du jeu */ float intervalClock = 0.1f; int rafraichissement; sdlMapAff(sdMap); assert(SDL_Flip(getSdlMapEcran(sdMap))!=-1); // RÈcupËre l'horloge actuelle et la convertit en secondes // clock() retourne le nombre de tops horloge depuis le lancement du programme prevClock = (float)clock()/(float)CLOCKS_PER_SEC; // Tant que ce n'est pas la fin ... while (continuGame == 1) { switch (resultMenu) { case 0: continuGame = 0; resultMenu = 1; break; case 2: num = getMapNum(getSdlMap(sdMap)); num++; if(num > 4) num = 1; setMapNum(getSdlMap(sdMap), num); setSdlMap(sdMap,newMap(15, 15, num)); setSdlMapMode(sdMap, 0); setSdlMapSpeed(sdMap, 0); continuGame = 1; resultMenu = 1; break; default: break; } rafraichissement = 0; // RÈcupËre l'horloge actuelle et la convertit en secondes currentClock = (float)clock()/(float)CLOCKS_PER_SEC; //printf("\n %f \n %f \n %f \n %f \n", horloge_precedente, horloge_courante, (horloge_courante - horloge_precedente), intervalle_horloge); // Si suffisamment de temps s'est ÈcoulÈ depuis la derniËre prise d'horloge if ((currentClock - prevClock) >= intervalClock) { if (getSdlMapSpeed(sdMap)) { for (i=0; i<10; i++) { updateMap(getSdlMap(sdMap)); } } else { for (i=0; i<5; i++) { updateMap(sdMap->map); } } updateInterface(getSdlMapInterface(sdMap), getSdlMap(sdMap)); rafraichissement = 1; prevClock = currentClock; if(getSdlMap(sdMap)->life <= 0) { resultMenu = sdlMenuBoucle(&menu); } if(getSdlMapMode(sdMap) && isWaveEnd(getSdlMap(sdMap))) { newWave(getSdlMap(sdMap)); } } // tant qu'il y a des evenements ‡ traiter : cette boucle n'est pas bloquante while (SDL_PollEvent(&event)) { // Si l'utilisateur a cliquÈ sur la croix de fermeture if ( event.type == SDL_QUIT ) continuGame = 0; // Si l'utilisateur a appuyÈ sur une touche if (event.type == SDL_KEYDOWN) { rafraichissement = 1; Map *map = getSdlMap(sdMap); Interface *interface = getSdlMapInterface(sdMap); Cursor *cursor = getInterfaceCursor(interface); switch (event.key.keysym.sym) { //Quiter (esc) case SDLK_ESCAPE: resultMenu = sdlMenuBoucle(&menu); break; //Deplacement curseur droite (left) case SDLK_LEFT: moveCursorLeft(cursor); break; //Deplacement curseur gauche (right) case SDLK_RIGHT: moveCursorRight(cursor); break; //Deplacement curseur haut (up) case SDLK_UP: moveCursorUp(cursor); break; //Deplacement curseur bas (down) case SDLK_DOWN: moveCursorDown(cursor); break; //Nouvelle vague (w) case SDLK_w: if(isWaveEnd(map)){ newWave(map); } break; //Nouvelle tours type archer (a) case SDLK_a: buyInterfaceTower('A', &(cursor->position), sdMap->map); break; //Nouvelle tours type knight (k) case SDLK_k: buyInterfaceTower('K', &(cursor->position), sdMap->map); break; //Nouvelle tours type mage (m) case SDLK_m: buyInterfaceTower('M', &(cursor->position), sdMap->map); break; case SDLK_c: buyInterfaceTower('C', &(cursor->position), sdMap->map); break; case SDLK_e: if(isCursorOnTower(cursor, getSdlMap(sdMap))) { evolveTower(interface->tower, &map->gold); } break; case SDLK_v: sellInterfaceTower(getSdlMap(sdMap), &(cursor->position), getInterfaceTower(interface)); break; case SDLK_s: if (getSdlMapSpeed(sdMap)) { setSdlMapSpeed(sdMap,0); } else { setSdlMapSpeed(sdMap,1); } break; case SDLK_i: if(getSdlMapMode(sdMap)){ setSdlMapMode(sdMap,0); } else { setSdlMapMode(sdMap,1); } break; default: break; } } } if (rafraichissement==1) { // on affiche le jeu sur le buffer caché sdlMapAff(sdMap); // on permute les deux buffers (cette fonction ne doit se faire qu'une seule fois dans a boucle) SDL_Flip( getSdlMapEcran(sdMap) ); } } sdlMenuLibere(&menu); }
void SlamGMapping::laserCallback(const sensor_msgs::LaserScan::ConstPtr& scan) { //BOOKMARK: write scan to file #ifdef LOGTOFILE writeLaserMsgtoFile(*scan); #endif laser_count_++; if ((laser_count_ % throttle_scans_) != 0) return; static ros::Time last_map_update(0,0); // We can't initialize the mapper until we've got the first scan if(!got_first_scan_) { if(!initMapper(*scan)) return; got_first_scan_ = true; } GMapping::OrientedPoint odom_pose; if(addScan(*scan, odom_pose)) { ROS_DEBUG("scan processed"); GMapping::OrientedPoint mpose = gsp_->getParticles()[gsp_->getBestParticleIndex()].pose; ROS_DEBUG("new best pose: %.3f %.3f %.3f", mpose.x, mpose.y, mpose.theta); ROS_DEBUG("odom pose: %.3f %.3f %.3f", odom_pose.x, odom_pose.y, odom_pose.theta); ROS_DEBUG("correction: %.3f %.3f %.3f", mpose.x - odom_pose.x, mpose.y - odom_pose.y, mpose.theta - odom_pose.theta); tf::Stamped<tf::Pose> odom_to_map; try { tf_.transformPose(odom_frame_,tf::Stamped<tf::Pose> (tf::Transform(tf::createQuaternionFromRPY(0, 0, mpose.theta), tf::Vector3(mpose.x, mpose.y, 0.0)).inverse(), scan->header.stamp, base_frame_),odom_to_map); } catch(tf::TransformException e){ ROS_ERROR("Transform from base_link to odom failed\n"); odom_to_map.setIdentity(); } #ifdef LOGTOFILE writePoseStamped(odom_to_map); #endif map_to_odom_mutex_.lock(); map_to_odom_ = tf::Transform(tf::Quaternion( odom_to_map.getRotation() ), tf::Point( odom_to_map.getOrigin() ) ).inverse(); map_to_odom_mutex_.unlock(); if(!got_map_ || (scan->header.stamp - last_map_update) > map_update_interval_) { updateMap(*scan); last_map_update = scan->header.stamp; ROS_DEBUG("Updated the map"); } } }
void * jouer_radio_IA(void * rdy_p) { char *coup; void ** rdy = (void **)rdy_p; int * desc_pipe_write = (int *)rdy[0]; int * desc_pipe_read = (int *)rdy[1]; struct coup * pere; char joueur; int i; int pipeDes_write[2]; pipe(pipeDes_write); int pipeDes_read[2]; pipe(pipeDes_read); /* close(pipeDes[0]); */ pion ** grille; initMap(); joueur = 'A'; grille = initGrille(); coup = malloc(sizeof(char) * 13); for (i = 0; i < 13; i++) { coup[i] = 0; } int mode = 2; int difficulter = 1; int type = 0; * desc_pipe_write = pipeDes_write[1]; * desc_pipe_read = pipeDes_read[0]; free(rdy_p); updateMap(grille); while (!victoire) { ready_to_play = 0; if (joueur == 'A') { /* updateMap(grille); */ //affiche(); pere = malloc(sizeof(struct coup)); pere->proto = NULL; pere->coupSuivant = NULL; pere = coupsPossibles(grille, 'A', pere); /* updateMap(grille); */ do { write(pipeDes_read[1], "ready", strlen("ready")); interaction(coup, grille, &joueur, mode, pere); if (action(grille, coup, pere, 1) != -1)break; /* updateMap(grille); */ write(pipeDes_read[1], "bad_coup_in", strlen("bad_coup_in_")); } while (42); freeCoup(pere, 1); joueur = 'B'; } if (joueur == 'B') { /* updateMap(grille); */ //affiche(); if (!victoire) { jouerCoupIA(grille, 'B', difficulter, 0, 0, type, coup); joueur = 'A'; updateMap(grille); write(pipeDes_read[1], coup, strlen(coup)); } } } freeMap(); free(grille); free(coup); close(pipeDes_write[1]); close(pipeDes_write[0]); close(pipeDes_read[1]); close(pipeDes_read[0]); return NULL; }
/** * Main ingame loop. */ void gameLoop() { BYTE xdist, ydist; UBYTE cx, cy; // Init player pposx = 80; pposy = 64; pdir = DIR_DOWN; alive = 1; // Set game variables score = 0; nextUpdate = 0; switch_delay = START_DELAY; // Load game map BG tiles DISPLAY_OFF; // Load tile data sets LCDC_REG = B8(01000011); set_sprite_data(0, sprite_dataLen, sprite_data); set_bkg_data(0, game_dataLen, game_data); set_bkg_tiles(0, 0, 20, 18, map_tiles); // Score counter set_sprite_tile(5, 64); move_sprite(5, 15, 148); set_sprite_tile(6, 65); set_sprite_tile(7, 65); move_sprite(6, 26, 148); move_sprite(7, 35, 148); set_sprite_tile(4, 64); clearMap(); addBox(); DISPLAY_ON; // Game loop while(alive) { wait_vbl_done(); time++; nextUpdate++; if(nextUpdate >= switch_delay) { nextUpdate = 0; updateMap(); spawnCells(); } updatePlayer(); // Check if player has picked up box xdist = pposx - boxx; ydist = pposy - boxy; if(xdist > -COLDISTX && xdist < COLDISTX && ydist > -COLDISTY && ydist < COLDISTY) { score++; updateScore(); addBox(); switch_delay--; } // Check if player is on black hole cx = pposx/16 - 1; cy = pposy/16 - 1; if(map[cx + cy*MAPW] >= CELL_BLACK) { alive = 0; } } }
MainWindow::MainWindow() : filename_(), default_extent_(-20037508.3428,-20037508.3428,20037508.3428,20037508.3428) { mapWidget_ = new MapWidget(this); QSplitter *splitter = new QSplitter(this); QTabWidget *tabWidget=new QTabWidget; layerTab_ = new LayerTab; layerTab_->setFocusPolicy(Qt::NoFocus); layerTab_->setIconSize(QSize(16,16)); //LayerDelegate *delegate = new LayerDelegate(this); //layerTab_->setItemDelegate(delegate); //layerTab_->setItemDelegate(new QItemDelegate(this)); //layerTab_->setViewMode(QListView::IconMode); layerTab_->setFlow(QListView::TopToBottom); tabWidget->addTab(layerTab_,tr("Layers")); // Styles tab styleTab_ = new StyleTab; tabWidget->addTab(styleTab_,tr("Styles")); splitter->addWidget(tabWidget); splitter->addWidget(mapWidget_); QList<int> list; list.push_back(200); list.push_back(600); splitter->setSizes(list); mapWidget_->setFocusPolicy(Qt::StrongFocus); mapWidget_->setFocus(); //setCentralWidget(mapWidget_); setCentralWidget(splitter); createActions(); createMenus(); createToolBars(); createContextMenu(); setWindowTitle(tr("Mapnik Viewer")); status=new QStatusBar(this); status->showMessage(tr("")); setStatusBar(status); resize(800,600); //connect mapview to layerlist connect(mapWidget_, SIGNAL(mapViewChanged()),layerTab_, SLOT(update())); // slider connect(slider_,SIGNAL(valueChanged(int)),mapWidget_,SLOT(zoomToLevel(int))); // renderer selector connect(renderer_selector_,SIGNAL(currentIndexChanged(QString const&)), mapWidget_, SLOT(updateRenderer(QString const&))); // scale factor connect(scale_factor_,SIGNAL(valueChanged(double)), mapWidget_, SLOT(updateScaleFactor(double))); // connect(layerTab_,SIGNAL(update_mapwidget()),mapWidget_,SLOT(updateMap())); connect(layerTab_,SIGNAL(layerSelected(int)), mapWidget_,SLOT(layerSelected(int))); }
/*! Set the length of the backbone. The length doesn't include the space needed for overlapping labels. \sa move(), minLabelDist() */ void QwtScaleDraw::setLength(int length) { d_data->len = qwtMax(length, 10); updateMap(); }
void GameState::update(int worldTime) { # ifndef NDEBUG dbgLockObjects = true; # endif // Update game state (update AI, etc.) const MapManager::Maps &maps = MapManager::getMaps(); for (MapManager::Maps::const_iterator m = maps.begin(), m_end = maps.end(); m != m_end; ++m) { MapComposite *map = m->second; if (!map->isActive()) { continue; } updateMap(map); for (CharacterIterator p(map->getWholeMapIterator()); p; ++p) { informPlayer(map, *p); /* sending the whole character is overhead for the database, it should be replaced by a syncbuffer. see: game-server/accountconnection: AccountConnection::syncChanges() if (worldTime % 2000 == 0) { accountHandler->sendCharacterData(*p); } */ } for (ActorIterator i(map->getWholeMapIterator()); i; ++i) { Actor *a = *i; a->clearUpdateFlags(); if (a->canFight()) { static_cast< Being * >(a)->clearHitsTaken(); } } } # ifndef NDEBUG dbgLockObjects = false; # endif // Take care of events that were delayed because of their side effects. for (DelayedEvents::iterator i = delayedEvents.begin(), i_end = delayedEvents.end(); i != i_end; ++i) { const DelayedEvent &e = i->second; Actor *o = i->first; switch (e.type) { case EVENT_REMOVE: remove(o); if (o->getType() == OBJECT_CHARACTER) { Character *ch = static_cast< Character * >(o); ch->disconnected(); gameHandler->kill(ch); } delete o; break; case EVENT_INSERT: insertSafe(o); break; case EVENT_WARP: assert(o->getType() == OBJECT_CHARACTER); warp(static_cast< Character * >(o), e.map, e.x, e.y); break; } } delayedEvents.clear(); }
void MiniMap::sceneRectChanged(const QRectF & /*rect*/) { updateMap(); }
void EnMapView::setupMapView() { // get the screen size unsigned int windowwidth = 600; unsigned int windowheight = 800; yaf3d::Application::get()->getScreenSize( windowwidth, windowheight ); _screenSize = osg::Vec2f( static_cast< float >( windowwidth ), static_cast< float >( windowheight ) ); // calculate internal variables _factor = osg::Vec2f( ( 1.0f / _levelDimensions.x() ) * _stretch.x(), ( 1.0f / _levelDimensions.y() ) * _stretch.y() ); _halfSize = osg::Vec2f( _size * 0.5f ); try { // calculate position of view map osg::Vec2 position = calcPosition( _align, _size, _screenSize ); _snapPoints = calcSnapPoints( _size, _screenSize ); _p_wnd = CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", MAPVIEW_WND "mainWnd" ); _p_wnd->setMetricsMode( CEGUI::Absolute ); _p_wnd->setSize( CEGUI::Size( _size.x(), _size.y() ) ); _p_wnd->setPosition( CEGUI::Point( position.x(), position.y() ) ); _p_wnd->setAlpha( _alpha ); _p_wnd->setAlwaysOnTop( true ); _p_wnd->subscribeEvent( CEGUI::Window::EventMouseButtonDown, CEGUI::Event::Subscriber( &vrc::EnMapView::onMouseDown, this ) ); _p_wnd->subscribeEvent( CEGUI::Window::EventMouseButtonUp, CEGUI::Event::Subscriber( &vrc::EnMapView::onMouseUp, this ) ); _p_wnd->subscribeEvent( CEGUI::Window::EventMouseMove, CEGUI::Event::Subscriber( &vrc::EnMapView::onMouseMove, this ) ); // put the map picture into a static image element CEGUI::StaticImage* p_staticimg = static_cast< CEGUI::StaticImage* >( CEGUI::WindowManager::getSingleton().createWindow( "TaharezLook/StaticImage", MAPVIEW_WND "image" ) ); p_staticimg->setSize( CEGUI::Size( 1.0f, 1.0f ) ); p_staticimg->setPosition( CEGUI::Point( 0.0f, 0.0f ) ); p_staticimg->setBackgroundEnabled( false ); p_staticimg->setFrameEnabled( false ); p_staticimg->setAlpha( _alpha ); // create a new imageset for map picture { CEGUI::Texture* p_texture = yaf3d::GuiManager::get()->getGuiRenderer()->createTexture( _minMapFile, std::string( MAPVIEW_WND ) + _minMapFile ); CEGUI::Imageset* p_imageSet = CEGUI::ImagesetManager::getSingleton().createImageset( std::string( MAPVIEW_WND ) + _minMapFile, p_texture ); if ( !p_imageSet->isImageDefined( _minMapFile ) ) p_imageSet->defineImage( std::string( MAPVIEW_WND ) + _minMapFile, CEGUI::Point( 0.0f, 0.0f ), CEGUI::Size( p_texture->getWidth(), p_texture->getHeight() ), CEGUI::Point( 0.0f,0.0f ) ); CEGUI::Image* p_image = &const_cast< CEGUI::Image& >( p_imageSet->getImage( std::string( MAPVIEW_WND ) + _minMapFile ) ); p_staticimg->setImage( p_image ); _p_wnd->addChildWindow( p_staticimg ); } // create a static text for displaying player name when mouse is over its point on map { _nameDisplay = static_cast< CEGUI::StaticText* >( CEGUI::WindowManager::getSingleton().createWindow( "TaharezLook/StaticText", MAPVIEW_WND "playername" ) ); _nameDisplay->setMetricsMode( CEGUI::Absolute ); _nameDisplay->setFrameEnabled( false ); _nameDisplay->setBackgroundEnabled( false ); _nameDisplay->setFont( YAF3D_GUI_FONT8 ); _nameDisplay->setTextColours( CEGUI::colour( _nameDisplayColor.x(), _nameDisplayColor.y(), _nameDisplayColor.z() ) ); _nameDisplay->setPosition( CEGUI::Point( _nameDisplayPos.x(), _nameDisplayPos.y() ) ); _nameDisplay->setSize( CEGUI::Size( _nameDisplaySize.x(), _nameDisplaySize.y() ) ); _nameDisplay->setAlwaysOnTop( true ); _p_wnd->addChildWindow( _nameDisplay ); } // image for marking a player on map _p_imgPlayerMarker = vrc::gameutils::GuiUtils::get()->getCustomImage( IMAGE_NAME_CROSSHAIR ); vrc::gameutils::GuiUtils::get()->getMainGuiWindow()->addChildWindow( _p_wnd ); // update the map updatePlayerList(); updateMap(); } catch ( const CEGUI::Exception& e ) { log_error << "EnMapView: problem creating gui" << std::endl; log_out << " reason: " << e.getMessage().c_str() << std::endl; } }
void * jouer_radio_VS(void * rdy_p) { extern sem_t * mutex_play_a; extern char coup_jouer[13]; char *coup; struct coup * pere; char joueur; int i; /* close(pipeDes[0]); */ pion ** grille; initMap(); joueur = 'A'; grille = initGrille(); coup = malloc(sizeof(char) * 13); for (i = 0; i < 13; i++) { coup[i] = 0; } int mode = 2; int difficulter = 1; int type = 0; updateMap(grille); sem_post(mutex_play_a); while (!victoire) { ready_to_play = 0; if (joueur == 'A') { /* updateMap(grille); */ //affiche() pere = malloc(sizeof(struct coup)); pere->proto = NULL; pere->coupSuivant = NULL; pere = coupsPossibles(grille, 'A', pere); /* write(pipeDes_read[1],"ready",strlen("ready")); */ printf("UNLOCK1\n"); fflush(stdout); sem_post(mutex_play_a); interaction(coup, grille, &joueur, mode, pere); if (action(grille, coup, pere, 1) == -1) jouerCoupIA(grille, 'A', difficulter, 0, 0, type, coup); copy_str(coup_jouer, coup); printf("UNLOCK2\n"); fflush(stdout); sem_post(mutex_play_a); freeCoup(pere, 1); joueur = 'B'; } if (joueur == 'B') { updateMap(grille); //affiche(); if (!victoire) { //affiche() pere = malloc(sizeof(struct coup)); pere->proto = NULL; pere->coupSuivant = NULL; pere = coupsPossibles(grille, 'B', pere); /* write(pipeDes_read[1],"ready",strlen("ready")); */ printf("UNLOCK3\n"); fflush(stdout); sem_post(mutex_play_a); interaction(coup, grille, &joueur, mode, pere); if (action(grille, coup, pere, 1) == -1) jouerCoupIA(grille, 'B', difficulter, 0, 0, type, coup); copy_str(coup_jouer, coup); printf("UNLOCK4\n"); fflush(stdout); sem_post(mutex_play_a); freeCoup(pere, 1); joueur = 'A'; } } } freeMap(); free(grille); free(coup); return NULL; }
/*! \brief Move the position of the scale The meaning of the parameter pos depends on the alignment: <dl> <dt>QwtScaleDraw::LeftScale <dd>The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the left of the backbone. <dt>QwtScaleDraw::RightScale <dd>The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the right of the backbone. <dt>QwtScaleDraw::TopScale <dd>The origin is the leftmost point of the backbone. The backbone is a horizontal line. Scale marks and labels are drawn above the backbone. <dt>QwtScaleDraw::BottomScale <dd>The origin is the leftmost point of the backbone. The backbone is a horizontal line Scale marks and labels are drawn below the backbone. </dl> \param pos Origin of the scale \sa pos(), setLength() */ void QwtScaleDraw::move(const QPoint &pos) { d_data->pos = pos; updateMap(); }
void MiniMap::visibleRectChanged() { visibleRect = parent->visibleRect(); updateMap(); }
int main(int argc, char **argv) { ros::init(argc, argv, "mcl_node"); ros::NodeHandle n("/mcl_node");; n.param<std::string>("map_frame", mapFrame, "map"); n.param<std::string>("robot_base_link", baseFrame, "base_link"); n.param<double>("map_offset_x", coords.x0, 0.0); n.param<double>("map_offset_y", coords.y0, 0.0); n.param<int>("map_occupied_min_threshold", minOccupied, 10); double odom_a1, odom_a2, odom_a3, odom_a4; n.param<std::string>("odometry_frame", odomFrame, "odom"); n.param<double>("odometry_model_a1", odom_a1, 0.05); n.param<double>("odometry_model_a2", odom_a2, 0.01); n.param<double>("odometry_model_a3", odom_a3, 0.02); n.param<double>("odometry_model_a4", odom_a4, 0.01); //TODO: setup these IR constants more properly. double irZhit, irZrm; n.param<double>("ir_model_sigma_hit", irSigma, 0.1); n.param<double>("ir_model_z_hit", irZhit, 0.95); n.param<double>("ir_model_z_random_over_z_max", irZrm, 0.05); int nParticles, mcl_rate; double minDelta, aslow, afast; double crashRadius, crashYaw, stdXY, stdYaw, locStdXY, locStdYaw; n.param<int>("mcl_particles", nParticles, 200); n.param<int>("mcl_rate", mcl_rate, 5); n.param<double>("mcl_init_cone_radius", initConeRadius, 0.2); n.param<double>("mcl_init_yaw_variance", initYawVar, 0.3); n.param<double>("mcl_min_position_delta", minDelta, 0.001); n.param<double>("mcl_aslow", aslow, 0.01); n.param<double>("mcl_afast", afast, 0.2); n.param<double>("mcl_crash_radius", crashRadius, 0.1); n.param<double>("mcl_crash_yaw", crashYaw, 0.2); n.param<double>("mcl_good_std_xy", stdXY, 0.05); n.param<double>("mcl_good_std_yaw", stdYaw, 0.6); n.param<double>("mcl_localized_std_xy", locStdXY, 0.05); n.param<double>("mcl_localized_std_yaw", locStdYaw, 0.6); tf::TransformBroadcaster broadcaster_obj; tf_broadcaster = &broadcaster_obj; tf::TransformListener listener_obj; tf_listener = &listener_obj; odom2map = new tf::Stamped<tf::Pose>; message_filters::Subscriber<nav_msgs::Odometry> odom_sub(n, "/odom", 1); message_filters::Subscriber<ir_sensors::RangeArray> range_sub(n,"/ir_publish/sensors", 1); message_filters::Synchronizer<SyncPolicy> sync(SyncPolicy(10), odom_sub, range_sub); sync.registerCallback(boost::bind(&odomRangeUpdate, _1, _2)); ros::Subscriber map_version_sub = n.subscribe<std_msgs::Int32>("/map_node/version", 2, mapVersionCB); ros::Publisher particle_pub_obj = n.advertise<geometry_msgs::PoseArray>("/mcl/particles", 5); ros::Publisher localized_pub = n.advertise<std_msgs::Bool>("/mcl/is_localized", 5); geometry_msgs::PoseArray poseArray; poseArray.header.frame_id = mapFrame; //Wait 8 s for the map service. if(!ros::service::waitForService("/map_node/get_map", 8000)) { ROS_ERROR("Map service unreachable."); return -1; } mapInflated = new nav_msgs::OccupancyGrid(); mapDistance = new nav_msgs::OccupancyGrid(); ros::ServiceClient map_client_obj = n.serviceClient<map_tools::GetMap>("/map_node/get_map"); map_client = &map_client_obj; if(!updateMap()) { return -1; } struct PoseState pose, goodStd, locStd; goodStd.set(stdXY); goodStd.yaw = stdYaw; locStd.set(locStdXY); locStd.yaw = locStdYaw; pose.set(0.0); pose.x += coords.x0; pose.y += coords.y0; om = new OdometryModel(odom_a1, odom_a2, odom_a3, odom_a4); mclEnabled = false; coords.x = coords.x0; coords.y = coords.y0; coords.th = 0.0; mc = new MonteCarlo(om, &isPointFree, nParticles, minDelta, aslow, afast, crashRadius, crashYaw, goodStd); irm = new RangeModel(&getDist, irZhit, irZrm); mc->addSensor(irm); double csz = mapInflated->info.resolution; double wc = ((double)mapInflated->info.width); double hc = ((double)mapInflated->info.height); assert(csz > 0.00001); mc->init(pose, initConeRadius, initYawVar, wc*csz, hc*csz); //mc->init(wc*csz, hc*csz); mclEnabled = true; current_time = ros::Time::now(); int rate = 40, counter = 0; ros::Rate loop_rate(rate); if(!updateMap()) return -1; *odom2map = mclTransform(); struct PoseState odom0; bool firstMcl = true; double dx = 0, dy = 0, dyaw = 0, dx1 = 0, dy1 = 0, dyaw1 = 0; std_msgs::Bool isLocalizedMsg; isLocalizedMsg.data = isLocalized; ros::Subscriber init_mcl_sub = n.subscribe<geometry_msgs::Pose>("/mcl/initial_pose", 2, initMcl); while (ros::ok()) { if(!firstMcl) { dx = odomState.x - odom0.x; dy = odomState.y - odom0.y; dyaw = odomState.yaw - odom0.yaw; dx1 = dx; dy1 = dy; dyaw1 = dyaw; } if(counter % (rate/mcl_rate) == 0) { if(mclEnabled) { if(firstMcl) { odom0 = odomState; firstMcl = false; } odom0 = odomState; if(runMonteCarlo()) { dx = 0; dy = 0; dyaw = 0; } particles2PoseArray(mc->getParticles(), poseArray); particle_pub_obj.publish(poseArray); struct PoseState std = mc->getStd(); if(std.x > locStd.x || std.y > locStd.y || std.yaw > locStd.yaw) { isLocalized = false; } else { isLocalized = true; } } isLocalizedMsg.data = isLocalized; localized_pub.publish(isLocalizedMsg); counter = 0; } counter++; if(!firstMcl) { struct PoseState avg = mc->getState(); coords.x = avg.x + dx; coords.y = avg.y + dy; coords.th = avg.yaw + dyaw; //Do not update transform when rotating quickly on spot. if((std::sqrt(dx1*dx1 + dy1*dy1) > 0.03/(double)mcl_rate) && isLocalized) *odom2map = mclTransform(); } publishTransform(*odom2map); ros::spinOnce(); loop_rate.sleep(); ros::Duration last_update = ros::Time::now() - current_time; if(last_update > ros::Duration(1.2/(double)rate)) current_time = ros::Time::now(); } return 0; }
void digBlock(int x, int y, tileshape newshape) { updateMap( x, y, newshape); }