MapView* SampleLapViewer::createLapView(int refRace, int refLap) { QVector<QPointF> positions; QSqlQuery posQuery; posQuery.prepare("select longitude, latitude from POSITION where ref_lap_race = ? and ref_lap_num = ?"); posQuery.addBindValue(refRace); posQuery.addBindValue(refLap); if (posQuery.exec()) { while (posQuery.next()) { GeoCoordinate tmp; tmp.setLongitude(posQuery.value(0).toFloat()); tmp.setLatitude(posQuery.value(1).toFloat()); positions << tmp.projection(); } } MapScene* sc = new MapScene(50 * 1000, this); sc->addTrack(positions); MapView* view = new MapView(this); view->setDragMode(QGraphicsView::ScrollHandDrag); view->setScene(sc); connect(view, SIGNAL(zoomedAround(int,QPointF)), this, SLOT(zoomView(int))); return view; }
QPoint ApplicationUI::worldToPixel(QObject* mapObject, double latitude, double longitude) const { MapView* mapview = qobject_cast<MapView*>(mapObject); const Point worldCoordinates = Point(latitude, longitude); return mapview->worldToWindow(worldCoordinates); }
void PanTool::dragFinish() { MapView* view = mapWidget()->getMapView(); view->finishPanning(cur_pos - click_pos); cur_map_widget->setCursor(Qt::OpenHandCursor); }
QVariantList ApplicationUI::worldToPixelInvokable(QObject* mapObject, double latitude, double longitude) const { MapView* mapview = qobject_cast<MapView*>(mapObject); const Point worldCoordinates = Point(latitude, longitude); const QPoint pixels = mapview->worldToWindow(worldCoordinates); return QVariantList() << pixels.x() << pixels.y(); }
void DocumentManager::centerViewOn(qreal x, qreal y) { MapView *view = currentMapView(); if (!view) return; view->centerOn(currentDocument()->renderer()->tileToPixelCoords(x, y)); }
void PanTool::dragCanceled() { // finalize current panning MapView* view = mapWidget()->getMapView(); view->finishPanning(view->panOffset()); cur_map_widget->setCursor(Qt::OpenHandCursor); }
void ApplicationUI::addMarker(QObject* mapObject, double lat, double lon, QString nombre){ MapView* mapview = qobject_cast<MapView*>(mapObject); GeoLocation* loc = new GeoLocation(lat, lon, mapview); loc->setName(nombre); mapview->mapData()->clear(); mapview->mapData()->add(loc); }
void MainWindow::openLastFiles() { const QStringList files = recentFiles(); mSettings.beginGroup(QLatin1String("recentFiles")); int openCount = mSettings.value(QLatin1String("recentOpenedFiles"), 1).toInt(); QStringList mapScales = mSettings.value( QLatin1String("mapScale")).toStringList(); QStringList scrollX = mSettings.value( QLatin1String("scrollX")).toStringList(); QStringList scrollY = mSettings.value( QLatin1String("scrollY")).toStringList(); QStringList selectedLayer = mSettings.value( QLatin1String("selectedLayer")).toStringList(); for (int i = 0; i < openCount; i++) { if (!(i < files.size())) break; if (!(i < mapScales.size())) continue; if (!(i < scrollX.size())) continue; if (!(i < scrollY.size())) continue; if (!(i < selectedLayer.size())) continue; if (openFile(files.at(i))) { MapView *mapView = mDocumentManager->currentMapView(); // Restore camera to the previous position qreal scale = mapScales.at(i).toDouble(); if (scale > 0) mapView->zoomable()->setScale(scale); const int hor = scrollX.at(i).toInt(); const int ver = scrollY.at(i).toInt(); mapView->horizontalScrollBar()->setSliderPosition(hor); mapView->verticalScrollBar()->setSliderPosition(ver); int layer = selectedLayer.at(i).toInt(); if (layer > 0 && layer < mMapDocument->map()->layerCount()) mMapDocument->setCurrentLayerIndex(layer); } } QString lastActiveDocument = mSettings.value(QLatin1String("lastActive")).toString(); int documentIndex = mDocumentManager->findDocument(lastActiveDocument); if (documentIndex != -1) mDocumentManager->switchToDocument(documentIndex); mSettings.endGroup(); }
void PlaceToolInputState::OnDraw() { if( mUnitPlacementSprite ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); // Draw the Unit placement sprite. mUnitPlacementSprite->OnDraw( *mapView->GetCamera() ); } }
void MainWnd::OnToolsMapview() { if(theApp.cartridgeType == 0) { MapView *dlg = new MapView; dlg->Create(IDD_MAP_VIEW, this); dlg->ShowWindow(SW_SHOW); } else { GBMapView *dlg = new GBMapView; dlg->Create(IDD_GB_MAP_VIEW, this); dlg->ShowWindow(SW_SHOW); } }
bool PlaceToolInputState::OnPointerDown( const Pointer& pointer ) { // Make sure there is a valid UnitType and Faction selected. if( mSelectedUnitType && mSelectedFaction && pointer.IsActivePointer() ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); // If this is the active pointer, create a new Unit placement sprite under it. CreateUnitPlacementSprite( mapView->ScreenToWorldCoords( pointer.position ) ); } return false; //InputState::OnPointerDown( pointer ); }
MapView * MapView::create() { MapView *ret = new MapView; if (ret && ret->init()) { ret->autorelease(); } else { delete ret; ret = nullptr; } return ret; }
void SampleLapViewer::zoomView(int increment) { QMatrix scaling; MapView* currentView = dynamic_cast<MapView*>( this->ui->lapsViewStack->currentWidget()); if (currentView == NULL) return; this->_zoomLevel += increment; qreal scale = qPow(2, this->_zoomLevel / 10.0); scaling.scale(scale, scale); currentView->setMatrix(scaling); }
virtual void display() { map_view->update(); glClear(GL_COLOR_BUFFER_BIT); prog->enable(); prog->setProjectionMatrix(projection_matrix); prog->enableAttribs(); map_view->draw(prog,spect,projection_matrix); prog->disableAttribs(); prog->disable(); }
bool PlaceToolInputState::OnPointerMotion( const Pointer& activePointer, const PointersByID& pointersByID ) { bool wasHandled = false; //InputState::OnPointerMotion( activePointer, pointersByID ); if( !wasHandled && mUnitPlacementSprite && activePointer.isMoving ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); // Move the Unit placement Sprite to the position of the active pointer. MoveUnitPlacementSprite( mapView->ScreenToWorldCoords( activePointer.position ) ); wasHandled = true; } return wasHandled; }
void EraserToolInputState::DestroyUnitAtScreenCoords( const Vec2f& screenCoords ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); Map* map = owner->GetMap(); // Get the UnitSprite under the pointer (if any). UnitSprite* unitSprite = mapView->GetUnitSpriteAtScreenCoords( screenCoords ); if( unitSprite ) { // If there is a Unit under the pointer, destroy it. Unit* unit = unitSprite->GetUnit(); DebugPrintf( "Erasing UnitSprite at Tile (%d,%d)!", unit->GetTileX(), unit->GetTileY() ); map->DestroyUnit( unit ); } }
Unit* PlaceToolInputState::CreateUnitAtScreenCoords( const Vec2f& screenCoords ) { Unit* unit = nullptr; if( mSelectedUnitType ) { if( mSelectedFaction ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); Map* map = owner->GetMap(); // Get the Tile at the screen coords. Vec2f worldPos = mapView->ScreenToWorldCoords( screenCoords ); Vec2s tilePos = mapView->WorldToTileCoords( worldPos ); Map::Iterator tile = map->GetTile( tilePos ); if( tile.IsValid() && tile->IsEmpty() && mSelectedUnitType->CanMoveAcrossTerrain( tile->GetTerrainType() ) ) { // If the selected UnitType can be placed into the Tile, create a new Unit. DebugPrintf( "Placing Unit at tile (%d,%d)!", tilePos.x, tilePos.y ); unit = map->CreateUnit( mSelectedUnitType, mSelectedFaction, tilePos ); } else { WarnFail( "Cannot place Unit into tile (%d,%d)!", tilePos.x, tilePos.y ); } } else { WarnFail( "Cannot create Unit because no Faction was selected!" ); } } else { WarnFail( "Cannot create Unit because no UnitType was selected!" ); } return unit; }
int main(int argc, char *argv[]) { std::cerr << "Justina Robocar City Emulator, Copyright (C) 2015 András Mamenyák" << std::endl << "This program comes with ABSOLUTELY NO WARRANTY;" << std::endl << "This is free software, and you are welcome to redistribute it" << std::endl << "under certain conditions." << std::endl << std::endl; if (argc < 2) { std::cerr << "Usage: Monitor OSM_FILE\n"; exit(1); } QApplication app(argc, argv); MapView mapview; mapview.init(argv[1]); mapview.show(); return app.exec(); }
void DocumentManager::addDocument(MapDocument *mapDocument) { Q_ASSERT(mapDocument); Q_ASSERT(!mDocuments.contains(mapDocument)); mDocuments.append(mapDocument); mUndoGroup->addStack(mapDocument->undoStack()); MapView *view = new MapView(mTabWidget); MapScene *scene = new MapScene(view); // scene is owned by the view scene->setMapDocument(mapDocument); view->setScene(scene); const int documentIndex = mDocuments.size() - 1; mTabWidget->addTab(view, mapDocument->displayName()); mTabWidget->setTabToolTip(documentIndex, mapDocument->fileName()); connect(mapDocument, SIGNAL(fileNameChanged()), SLOT(updateDocumentTab())); connect(mapDocument, SIGNAL(modifiedChanged()), SLOT(updateDocumentTab())); switchToDocument(documentIndex); centerViewOn(0, 0); }
void ChunkGenerator::chunkGeneration(Map& map, Vec3i spectatorPos, MapView& mapView) { // chunkPos ist Position des Chunks, in dem der Spectator steht in Chunkkoordinaten Vec2i chunkPos = map.getChunkPos(spectatorPos); for(int x = chunkPos.x - 8; x <= chunkPos.x + 8; x++) { for(int z = chunkPos.y - 8; z <= chunkPos.y + 8; z++) { if(!map.exists({x * 16, 0, z * 16})) { map.addChunk({x, z}); Chunk chunk = map.getChunk({x, z}); double simpBiomeNoise = SimplexNoise::noise(0.01*x, 0.01*z, m_biome_seed); int biomeNoise = SimplexNoise::noiseInt(0, 126, simpBiomeNoise); if(0 <= biomeNoise && biomeNoise <= 44){ chunk.setBiomeType(BiomeType::Desert); } if(45 <= biomeNoise && biomeNoise <= 46){ chunk.setBiomeType(BiomeType::DesertPlain); } if(47 <= biomeNoise && biomeNoise <= 54){ chunk.setBiomeType(BiomeType::Plains); } if(55 <= biomeNoise && biomeNoise <= 56){ chunk.setBiomeType(BiomeType::PlainForest); } if(57 <= biomeNoise && biomeNoise <= 69){ chunk.setBiomeType(BiomeType::Forest); } // Biome ohne Wasser if(!m_setWater) { if(70 <= biomeNoise && biomeNoise <= 74){ chunk.setBiomeType(BiomeType::Hillside); } if(75 <= biomeNoise && biomeNoise <= 126){ chunk.setBiomeType(BiomeType::Mountains); } } else { if(70 <= biomeNoise && biomeNoise <= 74){ chunk.setBiomeType(BiomeType::WaterHillside); } if(75 <= biomeNoise && biomeNoise <= 126){ chunk.setBiomeType(BiomeType::WaterMountains); } } setBiomes(map, chunk, x, z, biomeNoise); Vec2i chuPos = Vec2i(x + 1, z); if(mapView.exists(chuPos)) { mapView.deleteChunkView(chuPos); } chuPos = Vec2i(x - 1, z); if(mapView.exists(chuPos)) { mapView.deleteChunkView(chuPos); } chuPos = Vec2i(x, z + 1); if(mapView.exists(chuPos)) { mapView.deleteChunkView(chuPos); } chuPos = Vec2i(x, z - 1); if(mapView.exists(chuPos)) { mapView.deleteChunkView(chuPos); } } } } }
void PanTool::dragMove() { MapView* view = mapWidget()->getMapView(); view->setPanOffset(cur_pos - click_pos); }