@@ -64,7 +64,7 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
64
64
65
65
// constructor
66
66
GlobePlugin::GlobePlugin ( QgisInterface* theQgisInterface )
67
- : QgisPlugin( sName , sDescription , sPluginVersion , sPluginType ),
67
+ : QgisPlugin( sName , sDescription , sPluginVersion , sPluginType ),
68
68
mQGisIface( theQgisInterface ),
69
69
mQActionPointer( NULL ),
70
70
mQActionSettingsPointer( NULL ),
@@ -102,16 +102,16 @@ void GlobePlugin::initGui()
102
102
mQDockWidget .setWidget ( &viewer );
103
103
104
104
connect ( mQGisIface ->mapCanvas () , SIGNAL ( extentsChanged () ),
105
- this , SLOT ( extentsChanged () ) );
105
+ this , SLOT ( extentsChanged () ) );
106
106
connect ( mQGisIface ->mapCanvas (), SIGNAL ( layersChanged () ),
107
- this , SLOT ( layersChanged () ) );
107
+ this , SLOT ( layersChanged () ) );
108
108
}
109
109
110
110
111
111
void GlobePlugin::run ()
112
112
{
113
113
#ifdef QGISDEBUG
114
- if ( !getenv ( " OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel ( osg::DEBUG_INFO );
114
+ if ( !getenv ( " OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel ( osg::DEBUG_INFO );
115
115
#endif
116
116
117
117
mQGisIface ->addDockWidget ( Qt::RightDockWidgetArea, &mQDockWidget );
@@ -158,10 +158,10 @@ void GlobePlugin::run()
158
158
159
159
void GlobePlugin::settings ()
160
160
{
161
- if ( mSettingsDialog .exec () )
162
- {
163
- // viewer stereo settings set by mSettingsDialog and stored in QSettings
164
- }
161
+ if ( mSettingsDialog .exec () )
162
+ {
163
+ // viewer stereo settings set by mSettingsDialog and stored in QSettings
164
+ }
165
165
}
166
166
167
167
void GlobePlugin::setupMap ()
@@ -170,10 +170,10 @@ void GlobePlugin::setupMap()
170
170
QString earthFileName = QDir::cleanPath ( QgsApplication::pkgDataPath () + " /globe/globe.earth" );
171
171
EarthFile earthFile;
172
172
QFile earthFileTemplate ( earthFileName );
173
- if ( !earthFileTemplate.open ( QIODevice::ReadOnly | QIODevice::Text ) )
174
- {
175
- return ;
176
- }
173
+ if ( !earthFileTemplate.open ( QIODevice::ReadOnly | QIODevice::Text ) )
174
+ {
175
+ return ;
176
+ }
177
177
178
178
QTextStream in ( &earthFileTemplate );
179
179
QString earthxml = in.readAll ();
@@ -183,16 +183,16 @@ void GlobePlugin::setupMap()
183
183
earthxml.replace ( " /usr/share/osgearth/data" , QDir::cleanPath ( QgsApplication::pkgDataPath () + " /globe" ) );
184
184
185
185
// prefill cache
186
- if ( !QFile::exists ( cacheDirectory + " /worldwind_srtm" ) )
187
- {
188
- copyFolder ( QgsApplication::pkgDataPath () + " /globe/data/worldwind_srtm" , cacheDirectory + " /globe/worldwind_srtm" );
189
- }
186
+ if ( !QFile::exists ( cacheDirectory + " /worldwind_srtm" ) )
187
+ {
188
+ copyFolder ( QgsApplication::pkgDataPath () + " /globe/data/worldwind_srtm" , cacheDirectory + " /globe/worldwind_srtm" );
189
+ }
190
190
191
191
std::istringstream istream ( earthxml.toStdString () );
192
- if ( !earthFile.readXML ( istream, earthFileName.toStdString () ) )
193
- {
194
- return ;
195
- }
192
+ if ( !earthFile.readXML ( istream, earthFileName.toStdString () ) )
193
+ {
194
+ return ;
195
+ }
196
196
197
197
osg::ref_ptr<Map> map = earthFile.getMap ();
198
198
@@ -223,13 +223,13 @@ void GlobePlugin::setupMap()
223
223
osg::TessellationHints* hints = new osg::TessellationHints();
224
224
hints->setDetailRatio( 0.1 );
225
225
226
- osg::Cylinder* cylinder = new osg::Cylinder( osg::Vec3( 0 ,0, 5 ), 0.5, 10 );
226
+ osg::Cylinder* cylinder = new osg::Cylinder( osg::Vec3( 0 , 0, 5 ), 0.5, 10 );
227
227
osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable( cylinder, hints );
228
228
cylinderDrawable->setColor( osg::Vec4( 0.5, 0.25, 0.125, 1.0 ) );
229
229
osg::Geode* cylinderGeode = new osg::Geode();
230
230
cylinderGeode->addDrawable( cylinderDrawable );
231
231
232
- osg::Cone* cone = new osg::Cone( osg::Vec3( 0 ,0, 10 ), 4, 10 );
232
+ osg::Cone* cone = new osg::Cone( osg::Vec3( 0 , 0, 10 ), 4, 10 );
233
233
osg::ShapeDrawable* coneDrawable = new osg::ShapeDrawable( cone, hints );
234
234
coneDrawable->setColor( osg::Vec4( 0.0, 0.5, 0.0, 1.0 ) );
235
235
osg::Geode* coneGeode = new osg::Geode();
@@ -244,20 +244,20 @@ void GlobePlugin::setupMap()
244
244
double lat = 47.1786;
245
245
double lon = 10.111;
246
246
double gridSize = 0.001;
247
- for ( int i=0; i<10; i++ )
247
+ for( int i = 0; i < 10; i++ )
248
+ {
249
+ for( int j = 0; j < 10; j++ )
248
250
{
249
- for ( int j=0; j<10; j++ )
250
- {
251
- double dx = gridSize * ( rand() / ( ( double ) RAND_MAX + 1.0 ) - 0.5 );
252
- double dy = gridSize * ( rand() / ( ( double ) RAND_MAX + 1.0 ) - 0.5 );
253
- placeNode( model, lat + i * gridSize + dx, lon + j * gridSize + dy );
254
- }
251
+ double dx = gridSize * ( rand() / (( double ) RAND_MAX + 1.0 ) - 0.5 );
252
+ double dy = gridSize * ( rand() / (( double ) RAND_MAX + 1.0 ) - 0.5 );
253
+ placeNode( model, lat + i * gridSize + dx, lon + j * gridSize + dy );
255
254
}
255
+ }
256
256
#endif
257
257
}
258
258
259
259
struct PanControlHandler : public NavigationControlHandler
260
- {
260
+ {
261
261
PanControlHandler ( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
262
262
virtual void onMouseDown ( Control* control, int mouseButtonMask )
263
263
{
@@ -267,78 +267,82 @@ struct PanControlHandler : public NavigationControlHandler
267
267
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
268
268
double _dx;
269
269
double _dy;
270
- };
270
+ };
271
271
272
272
struct RotateControlHandler : public NavigationControlHandler
273
- {
273
+ {
274
274
RotateControlHandler ( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
275
275
virtual void onMouseDown ( Control* control, int mouseButtonMask )
276
276
{
277
- if ( 0 == _dx && 0 == _dy)
277
+ if ( 0 == _dx && 0 == _dy )
278
278
{
279
- _manip->setRotation ( osg::Quat () );
279
+ _manip->setRotation ( osg::Quat () );
280
280
}
281
281
else
282
282
{
283
- _manip->rotate ( _dx, _dy );
283
+ _manip->rotate ( _dx, _dy );
284
284
}
285
285
}
286
286
private:
287
287
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
288
288
double _dx;
289
289
double _dy;
290
- };
290
+ };
291
291
292
292
struct ZoomControlHandler : public NavigationControlHandler
293
- {
293
+ {
294
294
ZoomControlHandler ( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
295
295
virtual void onMouseDown ( Control* control, int mouseButtonMask )
296
296
{
297
- if ( 0 == _dx && 0 == _dy)
298
- {
299
- _manip->setRotation ( osg::Quat () );
300
- // FIXME: instead of next 2 lines use _manip->home( control->ea, control->aa );
301
- osgEarthUtil::Viewpoint viewpoint ( osg::Vec3d ( -90 , 0 , 0.0 ), 0.0 , -90.0 , 3e7 );
302
- _manip->setViewpoint ( viewpoint, 4.0 );
303
- }
304
- else
305
- {
306
- _manip->zoom ( _dx, _dy );
307
- }
297
+ _manip->zoom ( _dx, _dy );
308
298
}
309
299
private:
310
300
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
311
301
double _dx;
312
302
double _dy;
313
- };
314
-
303
+ };
304
+
305
+ struct HomeControlHandler : public ControlEventHandler
306
+ {
307
+ HomeControlHandler ( osgEarthUtil::EarthManipulator* manip ) : _manip( manip ) { }
308
+ virtual void onClick ( Control* control, int mouseButtonMask )
309
+ {
310
+ _manip->setRotation ( osg::Quat () );
311
+ // FIXME: instead of next 2 lines use _manip->home( control->ea, control->aa );
312
+ osgEarthUtil::Viewpoint viewpoint ( osg::Vec3d ( -90 , 0 , 0.0 ), 0.0 , -90.0 , 3e7 );
313
+ _manip->setViewpoint ( viewpoint, 4.0 );
314
+ }
315
+ private:
316
+ osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
317
+ };
318
+
315
319
struct RefreshControlHandler : public ControlEventHandler
316
320
{
317
- RefreshControlHandler ( osgEarthUtil::EarthManipulator* manip, QgisInterface* mQGisIface ) : _manip( manip ), _mQGisIface( mQGisIface ) { }
318
- virtual void onMouseDown ( Control* control, int mouseButtonMask )
319
- {
320
- // TODO
321
- OE_NOTICE << " refresh layers" << std::endl;
322
- }
323
- private:
324
- osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
325
- QgisInterface* _mQGisIface;
321
+ RefreshControlHandler ( osgEarthUtil::EarthManipulator* manip, QgisInterface* mQGisIface ) : _manip( manip ), _mQGisIface( mQGisIface ) { }
322
+ virtual void onClick ( Control* control, int mouseButtonMask )
323
+ {
324
+ // TODO
325
+ OE_NOTICE << " refresh layers" << std::endl;
326
+ }
327
+ private:
328
+ osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
329
+ QgisInterface* _mQGisIface;
326
330
};
327
331
328
332
struct SyncExtentControlHandler : public ControlEventHandler
329
333
{
330
- SyncExtentControlHandler ( GlobePlugin* globe ) : mGlobe ( globe ) { }
331
- virtual void onMouseDown ( Control* control, int mouseButtonMask )
332
- {
333
- mGlobe ->syncExtent ();
334
- }
335
- private:
336
- GlobePlugin* mGlobe ;
334
+ SyncExtentControlHandler ( GlobePlugin* globe ) : mGlobe ( globe ) { }
335
+ virtual void onClick ( Control* control, int mouseButtonMask )
336
+ {
337
+ mGlobe ->syncExtent ();
338
+ }
339
+ private:
340
+ GlobePlugin* mGlobe ;
337
341
};
338
342
339
343
bool FlyToExtentHandler::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
340
344
{
341
- if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' 1' )
345
+ if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' 1' )
342
346
{
343
347
mGlobe ->syncExtent ();
344
348
}
@@ -349,25 +353,20 @@ void GlobePlugin::syncExtent()
349
353
{
350
354
osgEarthUtil::EarthManipulator* manip = dynamic_cast <osgEarthUtil::EarthManipulator*>( viewer.getCameraManipulator () );
351
355
// rotate earth to north and perpendicular to camera
352
- manip->setRotation (osg::Quat ());
356
+ manip->setRotation ( osg::Quat () );
353
357
354
358
// get actual mapCanvas->extent().height in meters
355
359
QgsRectangle extent = mQGisIface ->mapCanvas ()->extent ();
356
360
// TODO: implement a stronger solution ev look at http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm
357
- QgsCoordinateReferenceSystem* destSrs = new QgsCoordinateReferenceSystem (31254 , QgsCoordinateReferenceSystem::EpsgCrsId );
358
- QgsCoordinateTransform* trans = new QgsCoordinateTransform ( mQGisIface ->mapCanvas ()->mapRenderer ()->destinationSrs (), *destSrs);
361
+ QgsCoordinateReferenceSystem* destSrs = new QgsCoordinateReferenceSystem ( 31254 , QgsCoordinateReferenceSystem::EpsgCrsId );
362
+ QgsCoordinateTransform* trans = new QgsCoordinateTransform ( mQGisIface ->mapCanvas ()->mapRenderer ()->destinationSrs (), *destSrs );
359
363
QgsRectangle projectedExtent = trans->transformBoundingBox ( extent );
360
364
361
365
double viewAngle = 30 ;
362
366
double height = projectedExtent.height ();
363
367
double distance = height / tan ( viewAngle * osg::PI / 180 ); // c = b*cotan(B(rad))
364
368
365
- // QString md, me;
366
- // md.setNum(height);
367
- // me.setNum(distance);
368
- // QMessageBox msgBox;
369
- // msgBox.setText(md + " " + me );
370
- // msgBox.exec();
369
+ OE_NOTICE << " map extent: " << height << " camera distance: " << distance << std::endl;
371
370
372
371
osgEarthUtil::Viewpoint viewpoint ( osg::Vec3d ( extent.center ().x (), extent.center ().y (), 0.0 ), 0.0 , -90.0 , distance );
373
372
manip->setViewpoint ( viewpoint, 4.0 );
@@ -388,7 +387,7 @@ void GlobePlugin::setupControls()
388
387
moveHControls->setVertAlign ( Control::ALIGN_CENTER );
389
388
moveHControls->setHorizAlign ( Control::ALIGN_CENTER );
390
389
moveHControls->setPosition ( 20 , 26 );
391
- moveHControls->setPadding (3 );
390
+ moveHControls->setPadding ( 3 );
392
391
393
392
osgEarthUtil::EarthManipulator* manip = dynamic_cast <osgEarthUtil::EarthManipulator*>( viewer.getCameraManipulator () );
394
393
// Move Left
@@ -410,7 +409,7 @@ void GlobePlugin::setupControls()
410
409
moveVControls->setVertAlign ( Control::ALIGN_CENTER );
411
410
moveVControls->setHorizAlign ( Control::ALIGN_CENTER );
412
411
moveVControls->setPosition ( 40 , 5 );
413
- moveVControls->setPadding (3 );
412
+ moveVControls->setPadding ( 3 );
414
413
415
414
// Move Up
416
415
osg::Image* moveUpImg = osgDB::readImageFile ( imgDir + " /move-up.png" );
@@ -440,7 +439,7 @@ void GlobePlugin::setupControls()
440
439
rotateControls->setVertAlign ( Control::ALIGN_CENTER );
441
440
rotateControls->setHorizAlign ( Control::ALIGN_CENTER );
442
441
rotateControls->setPosition ( 5 , 120 );
443
- rotateControls->setPadding (3 );
442
+ rotateControls->setPadding ( 3 );
444
443
445
444
// Rotate CCW
446
445
osg::Image* rotateCCWImg = osgDB::readImageFile ( imgDir + " /rotate-ccw.png" );
@@ -474,7 +473,7 @@ void GlobePlugin::setupControls()
474
473
tiltControls->setVertAlign ( Control::ALIGN_CENTER );
475
474
tiltControls->setHorizAlign ( Control::ALIGN_CENTER );
476
475
tiltControls->setPosition ( 40 , 90 );
477
- tiltControls->setPadding (3 );
476
+ tiltControls->setPadding ( 3 );
478
477
479
478
// tilt Up
480
479
osg::Image* tiltUpImg = osgDB::readImageFile ( imgDir + " /tilt-up.png" );
@@ -502,7 +501,7 @@ void GlobePlugin::setupControls()
502
501
zoomControls->setVertAlign ( Control::ALIGN_CENTER );
503
502
zoomControls->setHorizAlign ( Control::ALIGN_CENTER );
504
503
zoomControls->setPosition ( 40 , 180 );
505
- zoomControls->setPadding (3 );
504
+ zoomControls->setPadding ( 3 );
506
505
507
506
// Zoom In
508
507
osg::Image* zoomInImg = osgDB::readImageFile ( imgDir + " /zoom-in.png" );
@@ -519,7 +518,7 @@ void GlobePlugin::setupControls()
519
518
zoomControls->addControl ( zoomOut );
520
519
521
520
// END ZOOM CONTROLS
522
-
521
+
523
522
// EXTRA CONTROLS
524
523
// Horizontal container
525
524
HBox* extraControls = new HBox ();
@@ -530,18 +529,18 @@ void GlobePlugin::setupControls()
530
529
extraControls->setVertAlign ( Control::ALIGN_CENTER );
531
530
extraControls->setHorizAlign ( Control::ALIGN_CENTER );
532
531
extraControls->setPosition ( 5 , 240 );
533
- extraControls->setPadding (3 );
534
-
535
- // Zoom Reset
536
- osg::Image* extraHomeImg = osgDB::readImageFile ( imgDir + " /zoom-home.png" );
537
- ImageControl* extraHome = new NavigationControl ( extraHomeImg );
538
- extraHome->addEventHandler ( new ZoomControlHandler ( manip, 0 , 0 ) );
539
-
532
+ extraControls->setPadding ( 3 );
533
+
540
534
// Sync Extent
541
535
osg::Image* extraSyncImg = osgDB::readImageFile ( imgDir + " /sync-extent.png" );
542
536
ImageControl* extraSync = new NavigationControl ( extraSyncImg );
543
537
extraSync->addEventHandler ( new SyncExtentControlHandler ( this ) );
544
-
538
+
539
+ // Zoom Reset
540
+ osg::Image* extraHomeImg = osgDB::readImageFile ( imgDir + " /zoom-home.png" );
541
+ ImageControl* extraHome = new NavigationControl ( extraHomeImg );
542
+ extraHome->addEventHandler ( new HomeControlHandler ( manip ) );
543
+
545
544
// refresh layers
546
545
osg::Image* extraRefreshImg = osgDB::readImageFile ( imgDir + " /refresh-view.png" );
547
546
ImageControl* extraRefresh = new NavigationControl ( extraRefreshImg );
@@ -568,19 +567,19 @@ void GlobePlugin::setupProxy()
568
567
{
569
568
QSettings settings;
570
569
settings.beginGroup ( " proxy" );
571
- if ( settings.value ( " /proxyEnabled" ).toBool () )
570
+ if ( settings.value ( " /proxyEnabled" ).toBool () )
571
+ {
572
+ ProxySettings proxySettings ( settings.value ( " /proxyHost" ).toString ().toStdString (),
573
+ settings.value ( " /proxyPort" ).toInt () );
574
+ if ( !settings.value ( " /proxyUser" ).toString ().isEmpty () )
572
575
{
573
- ProxySettings proxySettings ( settings.value ( " /proxyHost" ).toString ().toStdString (),
574
- settings.value ( " /proxyPort" ).toInt () );
575
- if ( !settings.value ( " /proxyUser" ).toString ().isEmpty () )
576
- {
577
- QString auth = settings.value ( " /proxyUser" ).toString () + " :" + settings.value ( " /proxyPassword" ).toString ();
578
- setenv ( " OSGEARTH_CURL_PROXYAUTH" , auth.toStdString ().c_str (), 0 );
579
- }
580
- // TODO: settings.value("/proxyType")
581
- // TODO: URL exlusions
582
- HTTPClient::setProxySettings ( proxySettings );
576
+ QString auth = settings.value ( " /proxyUser" ).toString () + " :" + settings.value ( " /proxyPassword" ).toString ();
577
+ setenv ( " OSGEARTH_CURL_PROXYAUTH" , auth.toStdString ().c_str (), 0 );
583
578
}
579
+ // TODO: settings.value("/proxyType")
580
+ // TODO: URL exlusions
581
+ HTTPClient::setProxySettings ( proxySettings );
582
+ }
584
583
settings.endGroup ();
585
584
}
586
585
@@ -594,32 +593,32 @@ typedef std::list< osg::ref_ptr<VersionedTile> > TileList;
594
593
void GlobePlugin::layersChanged ()
595
594
{
596
595
QgsDebugMsg ( " layersChanged" );
597
- if ( mTileSource )
598
- {
599
- /*
600
- //viewer.getDatabasePager()->clear();
601
- //mMapNode->getTerrain()->incrementRevision();
602
- TileList tiles;
603
- mMapNode->getTerrain()->getVersionedTiles( tiles );
604
- for( TileList::iterator i = tiles.begin(); i != tiles.end(); i++ ) {
605
- //i->get()->markTileForRegeneration();
606
- i->get()->updateImagery( mQgisMapLayer->getId(), mMapNode->getMap(), mMapNode->getEngine() );
607
- }
608
- */
609
- }
610
- if ( mTileSource && mMapNode ->getMap ()->getImageMapLayers ().size () > 1 )
611
- {
612
- QgsDebugMsg ( " removeMapLayer" );
613
- QgsDebugMsg ( QString ( " getImageMapLayers().size = %1" ).arg ( mMapNode ->getMap ()->getImageMapLayers ().size () ) );
614
- mMapNode ->getMap ()->removeMapLayer ( mQgisMapLayer );
615
- QgsDebugMsg ( QString ( " getImageMapLayers().size = %1" ).arg ( mMapNode ->getMap ()->getImageMapLayers ().size () ) );
616
- QgsDebugMsg ( " addMapLayer" );
617
- mTileSource = new QgsOsgEarthTileSource ( mQGisIface );
618
- mTileSource ->initialize ( " " , 0 );
619
- mQgisMapLayer = new ImageMapLayer ( " QGIS" , mTileSource );
620
- mMapNode ->getMap ()->addMapLayer ( mQgisMapLayer );
621
- QgsDebugMsg ( QString ( " getImageMapLayers().size = %1" ).arg ( mMapNode ->getMap ()->getImageMapLayers ().size () ) );
596
+ if ( mTileSource )
597
+ {
598
+ /*
599
+ //viewer.getDatabasePager()->clear();
600
+ //mMapNode->getTerrain()->incrementRevision();
601
+ TileList tiles;
602
+ mMapNode->getTerrain()->getVersionedTiles( tiles );
603
+ for( TileList::iterator i = tiles.begin(); i != tiles.end(); i++ ) {
604
+ //i->get()->markTileForRegeneration();
605
+ i->get()->updateImagery( mQgisMapLayer->getId(), mMapNode->getMap(), mMapNode->getEngine() );
622
606
}
607
+ */
608
+ }
609
+ if ( mTileSource && mMapNode ->getMap ()->getImageMapLayers ().size () > 1 )
610
+ {
611
+ QgsDebugMsg ( " removeMapLayer" );
612
+ QgsDebugMsg ( QString ( " getImageMapLayers().size = %1" ).arg ( mMapNode ->getMap ()->getImageMapLayers ().size () ) );
613
+ mMapNode ->getMap ()->removeMapLayer ( mQgisMapLayer );
614
+ QgsDebugMsg ( QString ( " getImageMapLayers().size = %1" ).arg ( mMapNode ->getMap ()->getImageMapLayers ().size () ) );
615
+ QgsDebugMsg ( " addMapLayer" );
616
+ mTileSource = new QgsOsgEarthTileSource ( mQGisIface );
617
+ mTileSource ->initialize ( " " , 0 );
618
+ mQgisMapLayer = new ImageMapLayer ( " QGIS" , mTileSource );
619
+ mMapNode ->getMap ()->addMapLayer ( mQgisMapLayer );
620
+ QgsDebugMsg ( QString ( " getImageMapLayers().size = %1" ).arg ( mMapNode ->getMap ()->getImageMapLayers ().size () ) );
621
+ }
623
622
}
624
623
625
624
void GlobePlugin::unload ()
@@ -653,56 +652,56 @@ void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt
653
652
void GlobePlugin::copyFolder ( QString sourceFolder, QString destFolder )
654
653
{
655
654
QDir sourceDir ( sourceFolder );
656
- if ( !sourceDir.exists () )
655
+ if ( !sourceDir.exists () )
657
656
return ;
658
657
QDir destDir ( destFolder );
659
- if ( !destDir.exists () )
660
- {
661
- destDir.mkpath ( destFolder );
662
- }
658
+ if ( !destDir.exists () )
659
+ {
660
+ destDir.mkpath ( destFolder );
661
+ }
663
662
QStringList files = sourceDir.entryList ( QDir::Files );
664
- for ( int i = 0 ; i< files.count (); i++ )
665
- {
666
- QString srcName = sourceFolder + " /" + files[i];
667
- QString destName = destFolder + " /" + files[i];
668
- QFile::copy ( srcName, destName );
669
- }
663
+ for ( int i = 0 ; i < files.count (); i++ )
664
+ {
665
+ QString srcName = sourceFolder + " /" + files[i];
666
+ QString destName = destFolder + " /" + files[i];
667
+ QFile::copy ( srcName, destName );
668
+ }
670
669
files.clear ();
671
670
files = sourceDir.entryList ( QDir::AllDirs | QDir::NoDotAndDotDot );
672
- for ( int i = 0 ; i< files.count (); i++ )
673
- {
674
- QString srcName = sourceFolder + " /" + files[i];
675
- QString destName = destFolder + " /" + files[i];
676
- copyFolder ( srcName, destName );
677
- }
671
+ for ( int i = 0 ; i < files.count (); i++ )
672
+ {
673
+ QString srcName = sourceFolder + " /" + files[i];
674
+ QString destName = destFolder + " /" + files[i];
675
+ copyFolder ( srcName, destName );
676
+ }
678
677
}
679
678
680
679
bool NavigationControl::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
681
680
{
682
- switch ( ea.getEventType () )
683
- {
681
+ switch ( ea.getEventType () )
682
+ {
684
683
case osgGA::GUIEventAdapter::PUSH:
685
684
_mouse_down_event = &ea;
686
685
break ;
687
686
case osgGA::GUIEventAdapter::FRAME:
688
- if ( _mouse_down_event )
689
- {
690
- _mouse_down_event = &ea;
691
- }
687
+ if ( _mouse_down_event )
688
+ {
689
+ _mouse_down_event = &ea;
690
+ }
692
691
break ;
693
692
case osgGA::GUIEventAdapter::RELEASE:
694
693
_mouse_down_event = NULL ;
695
694
break ;
696
- }
697
- if ( _mouse_down_event )
695
+ }
696
+ if ( _mouse_down_event )
697
+ {
698
+ // OE_NOTICE << "NavigationControl::handle getEventType " << ea.getEventType() << std::endl;
699
+ for ( ControlEventHandlerList::const_iterator i = _eventHandlers.begin (); i != _eventHandlers.end (); ++i )
698
700
{
699
- // OE_NOTICE << "NavigationControl::handle getEventType " << ea.getEventType() << std::endl;
700
- for ( ControlEventHandlerList::const_iterator i = _eventHandlers.begin (); i != _eventHandlers.end (); ++i )
701
- {
702
- NavigationControlHandler* handler = dynamic_cast <NavigationControlHandler*>( i->get () );
703
- if ( handler ) handler->onMouseDown ( this , ea.getButtonMask () );
704
- }
701
+ NavigationControlHandler* handler = dynamic_cast <NavigationControlHandler*>( i->get () );
702
+ if ( handler ) handler->onMouseDown ( this , ea.getButtonMask () );
705
703
}
704
+ }
706
705
return Control::handle ( ea, aa, cx );
707
706
}
708
707
@@ -751,65 +750,65 @@ bool KeyboardControlHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GU
751
750
752
751
*/
753
752
754
- switch ( ea.getEventType () )
755
- {
756
- case ( osgGA::GUIEventAdapter::KEYDOWN ) :
753
+ switch ( ea.getEventType () )
754
+ {
755
+ case ( osgGA::GUIEventAdapter::KEYDOWN ) :
757
756
{
758
757
// move map
759
- if ( ea.getKey () == ' 4' )
760
- {
761
- _manip->pan ( -MOVE_OFFSET, 0 );
762
- }
763
- if ( ea.getKey () == ' 6' )
764
- {
765
- _manip->pan ( MOVE_OFFSET, 0 );
766
- }
767
- if ( ea.getKey () == ' 2' )
768
- {
769
- _manip->pan ( 0 , MOVE_OFFSET );
770
- }
771
- if ( ea.getKey () == ' 8' )
772
- {
773
- _manip->pan ( 0 , -MOVE_OFFSET );
774
- }
758
+ if ( ea.getKey () == ' 4' )
759
+ {
760
+ _manip->pan ( -MOVE_OFFSET, 0 );
761
+ }
762
+ if ( ea.getKey () == ' 6' )
763
+ {
764
+ _manip->pan ( MOVE_OFFSET, 0 );
765
+ }
766
+ if ( ea.getKey () == ' 2' )
767
+ {
768
+ _manip->pan ( 0 , MOVE_OFFSET );
769
+ }
770
+ if ( ea.getKey () == ' 8' )
771
+ {
772
+ _manip->pan ( 0 , -MOVE_OFFSET );
773
+ }
775
774
// rotate
776
- if ( ea.getKey () == ' /' )
777
- {
778
- _manip->rotate ( MOVE_OFFSET, 0 );
779
- }
780
- if ( ea.getKey () == ' *' )
781
- {
782
- _manip->rotate ( -MOVE_OFFSET, 0 );
783
- }
775
+ if ( ea.getKey () == ' /' )
776
+ {
777
+ _manip->rotate ( MOVE_OFFSET, 0 );
778
+ }
779
+ if ( ea.getKey () == ' *' )
780
+ {
781
+ _manip->rotate ( -MOVE_OFFSET, 0 );
782
+ }
784
783
// tilt
785
- if ( ea.getKey () == ' 9' )
786
- {
787
- _manip->rotate ( 0 , MOVE_OFFSET );
788
- }
789
- if ( ea.getKey () == ' 3' )
790
- {
791
- _manip->rotate ( 0 , -MOVE_OFFSET );
792
- }
784
+ if ( ea.getKey () == ' 9' )
785
+ {
786
+ _manip->rotate ( 0 , MOVE_OFFSET );
787
+ }
788
+ if ( ea.getKey () == ' 3' )
789
+ {
790
+ _manip->rotate ( 0 , -MOVE_OFFSET );
791
+ }
793
792
// zoom
794
- if ( ea.getKey () == ' -' )
795
- {
796
- _manip->zoom ( 0 , MOVE_OFFSET );
797
- }
798
- if ( ea.getKey () == ' +' )
799
- {
800
- _manip->zoom ( 0 , -MOVE_OFFSET );
801
- }
793
+ if ( ea.getKey () == ' -' )
794
+ {
795
+ _manip->zoom ( 0 , MOVE_OFFSET );
796
+ }
797
+ if ( ea.getKey () == ' +' )
798
+ {
799
+ _manip->zoom ( 0 , -MOVE_OFFSET );
800
+ }
802
801
// reset
803
- if ( ea.getKey () == ' 5' )
804
- {
805
- // _manip->zoom( 0, 0 );
806
- }
802
+ if ( ea.getKey () == ' 5' )
803
+ {
804
+ // _manip->zoom( 0, 0 );
805
+ }
807
806
break ;
808
807
}
809
808
810
809
default :
811
810
break ;
812
- }
811
+ }
813
812
return false ;
814
813
}
815
814
0 commit comments