MainWindow::MainWindow(const SettingsRef& settings, DBThread *dbThread) : settings(settings), dbThread(dbThread)/*, map(new MapWidget(NULL, dbThread))*/ { setSource(QUrl::fromLocalFile("qml/main.qml")); setTitle("OSMScout"); connect(dbThread, SIGNAL(InitialisationFinished(DatabaseLoadedResponse)), this, SLOT(InitialisationFinished(DatabaseLoadedResponse))); }
MapWidget::MapWidget(QQuickItem* parent) : QQuickPaintedItem(parent), center(0.0,0.0), angle(0.0), magnification(64), requestNewMap(true) { setOpaquePainting(true); setAcceptedMouseButtons(Qt::LeftButton); DBThread *dbThread=DBThread::GetInstance(); //setFocusPolicy(Qt::StrongFocus); connect(dbThread,SIGNAL(InitialisationFinished(DatabaseLoadedResponse)), this,SLOT(initialisationFinished(DatabaseLoadedResponse))); connect(this,SIGNAL(TriggerMapRenderingSignal()), dbThread,SLOT(TriggerMapRendering())); connect(dbThread,SIGNAL(HandleMapRenderingResult()), this,SLOT(redraw())); connect(dbThread,SIGNAL(Redraw()), this,SLOT(redraw())); }
void DBThread::Initialize() { QStringList cmdLineArgs = QApplication::arguments(); QString databaseDirectory = cmdLineArgs.size() > 1 ? cmdLineArgs.at(1) : QDir::currentPath(); stylesheetFilename = cmdLineArgs.size() > 2 ? cmdLineArgs.at(2) : databaseDirectory + QDir::separator() + "standard.oss"; iconDirectory = cmdLineArgs.size() > 3 ? cmdLineArgs.at(3) : databaseDirectory + QDir::separator() + "icons" + QDir::separator(); emit stylesheetFilenameChanged(); if (database->Open(databaseDirectory.toLocal8Bit().data())) { osmscout::TypeConfigRef typeConfig=database->GetTypeConfig(); if (typeConfig) { styleConfig=std::make_shared<osmscout::StyleConfig>(typeConfig); delete painter; painter=NULL; if (styleConfig->Load(stylesheetFilename.toLocal8Bit().data())) { painter=new osmscout::MapPainterQt(styleConfig); } else { qDebug() << "Cannot load style sheet!"; styleConfig=NULL; /* if (database->GetTypeConfig()) { if(painter) { delete painter; painter = NULL; } styleConfig=std::make_shared<osmscout::StyleConfig>(database->GetTypeConfig()); if (!styleConfig->Load(m_stylesheetFilename.toLocal8Bit().data())) { styleConfig=NULL; } else { painter=new osmscout::MapPainterQt(styleConfig); */ } } else { qDebug() << "TypeConfig invalid!"; styleConfig=NULL; } } else { qDebug() << "Cannot open database!"; return; } DatabaseLoadedResponse response; if (!database->GetBoundingBox(response.boundingBox)) { qDebug() << "Cannot read initial bounding box"; return; } emit InitialisationFinished(response); }
void DBThread::Initialize() { QSettings settings;//(QSettings::UserScope, "osmscout.fransschreuder", "osmscout"); std::cout<<"Settings.status: "<<settings.status()<<std::endl; int selectedMap = settings.value("selectedmap", 0).toInt(); settings.setValue("selectedmap", selectedMap); std::cout<<"Settings filename "<<settings.fileName().toLocal8Bit().data()<<std::endl; QStringList mapDirs = findValidMapDirs(); if(mapDirs.size()<=0) { std::cout<<"Could not find valid map dir"<<std::endl; return; } if(selectedMap>=mapDirs.size()) { selectedMap = 0; } QString databaseDirectory = mapDirs[selectedMap]; QString stylesheetFilename=databaseDirectory+"/standard.oss"; if (database->Open(databaseDirectory.toLocal8Bit().data())) { osmscout::TypeConfigRef typeConfig=database->GetTypeConfig(); if (typeConfig) { styleConfig=new osmscout::StyleConfig(typeConfig); delete painter; painter=NULL; if (styleConfig->Load(stylesheetFilename.toLocal8Bit().data())) { painter=new osmscout::MapPainterQt(styleConfig); } else { //qDebug() << "Cannot load style sheet!"; styleConfig=NULL; } } else { //qDebug() << "TypeConfig invalid!"; styleConfig=NULL; } } else { //qDebug() << "Cannot open database!"; return; } DatabaseLoadedResponse response; if (!database->GetBoundingBox(response.boundingBox)) { //qDebug() << "Cannot read initial bounding box"; return; } emit InitialisationFinished(response); }
void DBThread::Initialize() { QStringList cmdLineArgs = QApplication::arguments(); QString databaseDirectory = cmdLineArgs.size() > 1 ? cmdLineArgs.at(1) : QDir::currentPath(); m_stylesheetFilename = cmdLineArgs.size() > 2 ? cmdLineArgs.at(2) : databaseDirectory + QDir::separator() + "standard.oss"; iconDirectory = cmdLineArgs.size() > 3 ? cmdLineArgs.at(3) : databaseDirectory + QDir::separator() + "icons" + QDir::separator(); emit stylesheetFilenameChanged(); if (database->Open(databaseDirectory.toLocal8Bit().data())) { if (database->GetTypeConfig()) { styleConfig=new osmscout::StyleConfig(database->GetTypeConfig()); if (!osmscout::LoadStyleConfig(m_stylesheetFilename.toLocal8Bit().data(), *styleConfig)) { delete styleConfig; styleConfig=NULL; } } else { styleConfig=NULL; } } else { std::cerr << "Cannot open database!" << std::endl; return; } DatabaseLoadedResponse response; if (!database->GetBoundingBox(response.minLat, response.minLon, response.maxLat, response.maxLon)) { std::cerr << "Cannot read initial bounding box" << std::endl; return; } std::cout << "Initial bounding box ["; std::cout << response.minLat <<"," << response.minLon << " - " << response.maxLat << "," << response.maxLon << "]" << std::endl; emit InitialisationFinished(response); }
void DBThread::Initialize() { #ifdef __ANDROID__ QStringList docPaths=QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); QString databaseDirectory; // look for standard.oss in each directory for(int i=0; i < docPaths.size(); i++) { QStringList list_filters; list_filters << "osmscout"; QDir path(docPaths[i]); QStringList list_files = path.entryList(list_filters,QDir::NoDotAndDotDot | QDir::Dirs); if(!(list_files.size() == 1)) { continue; } databaseDirectory=path.canonicalPath()+"/osmscout"; } if(databaseDirectory.length() == 0) { qDebug() << "ERROR: map database directory not found"; } else { qDebug() << "Loading database from " << databaseDirectory; } stylesheetFilename=databaseDirectory+"/standard.oss"; qDebug() << "Loading style sheet from " << stylesheetFilename; #else QStringList cmdLineArgs = QApplication::arguments(); QString databaseDirectory = cmdLineArgs.size() > 1 ? cmdLineArgs.at(1) : QDir::currentPath(); stylesheetFilename = cmdLineArgs.size() > 2 ? cmdLineArgs.at(2) : databaseDirectory + QDir::separator() + "standard.oss"; iconDirectory = cmdLineArgs.size() > 3 ? cmdLineArgs.at(3) : databaseDirectory + QDir::separator() + "icons"; #endif emit stylesheetFilenameChanged(); if (database->Open(databaseDirectory.toLocal8Bit().data())) { osmscout::TypeConfigRef typeConfig=database->GetTypeConfig(); if (typeConfig) { styleConfig=std::make_shared<osmscout::StyleConfig>(typeConfig); delete painter; painter=NULL; if (styleConfig->Load(stylesheetFilename.toLocal8Bit().data())) { painter=new osmscout::MapPainterQt(styleConfig); } else { qDebug() << "Cannot load style sheet!"; styleConfig=NULL; } } else { qDebug() << "TypeConfig invalid!"; styleConfig=NULL; } } else { qDebug() << "Cannot open database!"; return; } DatabaseLoadedResponse response; if (!database->GetBoundingBox(response.boundingBox)) { qDebug() << "Cannot read initial bounding box"; return; } lastRendering=QTime::currentTime(); emit InitialisationFinished(response); }