/*************************************************************************** * Copyright (C) 2009 by Jack R * * lynx21.12.12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "ossimplanetgui.h" #include "ossimplanetviewer.h" #include #include #include #include #include #include #include #include #include #include #include #include OssimPlanetGui::OssimPlanetGui(QgisInterface *theQgisInterface, QWidget *parent, Qt::WindowFlags fl) : QWidget(parent, fl), mQGisIface(theQgisInterface) { QGLFormat format; if(format.swapInterval() >= 0) { format.setSwapInterval(1); } format.setOverlay(false); mGlobeViewer = new OssimPlanetQgisViewer(format, this); mGlobeViewer->setMouseTracking(false); mGlobeViewer->setFocusPolicy(Qt::StrongFocus); mPlanet = new ossimPlanet(); mPlanet->setupDefaults(); mManipulator = new ossimPlanetManipulator(); osg::ref_ptr keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; keyswitchManipulator->addMatrixManipulator('1', "Standard", mManipulator.get()); mGlobeViewer->setCameraManipulator(keyswitchManipulator.get()); mGlobeViewer->addEventHandler(new osgGA::StateSetManipulator(mGlobeViewer->getCamera()->getOrCreateStateSet())); mGlobeViewer->addEventHandler(new osgViewer::StatsHandler); mGlobeViewer->setSceneData(mPlanet.get()); mTextureLayers = new ossimPlanetTextureLayerGroup(); mTextureLayers->setName("Image Layers"); mTextureLayers->setDescription("Image layers used to populate the planetary viewer"); mPlanet->land()->referenceLayer()->addTop(mTextureLayers.get()); QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(mGlobeViewer.get()); setLayout(layout); } OssimPlanetGui::~OssimPlanetGui() { } void OssimPlanetGui::convertLayer() { } void OssimPlanetGui::uploadImages() { int layerCount = mQGisIface->mapCanvas()->layerCount(); for (int i = 0; i < layerCount; i++) { ossimString layerName; layerName = mQGisIface->mapCanvas()->layer(i)->source().toStdString(); osg::ref_ptr textureLayer = ossimPlanetTextureLayerRegistry::instance()->createLayer(layerName); if(textureLayer.valid()) { mTextureLayers->addTop(textureLayer.get()); } else { QMessageBox::information(this, tr("Error"), tr("Loaded format not supported.")); // mTextureLayers->addTop(convertLayer(sdgfd)); return; } if(!textureLayer->getLookAt().valid()) { textureLayer->resetLookAt(); } } } void OssimPlanetGui::lookAt(ossim_uint32 idx) { osg::ref_ptr textureLayer = layerGroup()->layer(idx); if (textureLayer.valid()) { const osg::ref_ptr lookAt = textureLayer->getLookAt(); if(lookAt.valid()) { ossimPlanetDestinationCommandAction(lookAt->toNavigationString()).execute(); } } else { QMessageBox::information(this, tr("Error"), tr("Unable to look at the selected raster.")); } }