Skip to content

Commit ab9bc85

Browse files
Marco Bernasocchipka
authored andcommittedJul 5, 2011
fixed sync handler fixed refresh handler added home handler code formatting
1 parent 573b803 commit ab9bc85

File tree

1 file changed

+204
-205
lines changed

1 file changed

+204
-205
lines changed
 

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 204 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
6464

6565
//constructor
6666
GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
67-
: QgisPlugin( sName, sDescription, sPluginVersion, sPluginType ),
67+
: QgisPlugin( sName, sDescription, sPluginVersion, sPluginType ),
6868
mQGisIface( theQgisInterface ),
6969
mQActionPointer( NULL ),
7070
mQActionSettingsPointer( NULL ),
@@ -102,16 +102,16 @@ void GlobePlugin::initGui()
102102
mQDockWidget.setWidget( &viewer );
103103

104104
connect( mQGisIface->mapCanvas() , SIGNAL( extentsChanged() ),
105-
this, SLOT( extentsChanged() ) );
105+
this, SLOT( extentsChanged() ) );
106106
connect( mQGisIface->mapCanvas(), SIGNAL( layersChanged() ),
107-
this, SLOT( layersChanged() ) );
107+
this, SLOT( layersChanged() ) );
108108
}
109109

110110

111111
void GlobePlugin::run()
112112
{
113113
#ifdef QGISDEBUG
114-
if ( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
114+
if( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
115115
#endif
116116

117117
mQGisIface->addDockWidget( Qt::RightDockWidgetArea, &mQDockWidget );
@@ -158,10 +158,10 @@ void GlobePlugin::run()
158158

159159
void GlobePlugin::settings()
160160
{
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+
}
165165
}
166166

167167
void GlobePlugin::setupMap()
@@ -170,10 +170,10 @@ void GlobePlugin::setupMap()
170170
QString earthFileName = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/globe.earth" );
171171
EarthFile earthFile;
172172
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+
}
177177

178178
QTextStream in( &earthFileTemplate );
179179
QString earthxml = in.readAll();
@@ -183,16 +183,16 @@ void GlobePlugin::setupMap()
183183
earthxml.replace( "/usr/share/osgearth/data", QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe" ) );
184184

185185
//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+
}
190190

191191
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+
}
196196

197197
osg::ref_ptr<Map> map = earthFile.getMap();
198198

@@ -223,13 +223,13 @@ void GlobePlugin::setupMap()
223223
osg::TessellationHints* hints = new osg::TessellationHints();
224224
hints->setDetailRatio( 0.1 );
225225

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 );
227227
osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable( cylinder, hints );
228228
cylinderDrawable->setColor( osg::Vec4( 0.5, 0.25, 0.125, 1.0 ) );
229229
osg::Geode* cylinderGeode = new osg::Geode();
230230
cylinderGeode->addDrawable( cylinderDrawable );
231231

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 );
233233
osg::ShapeDrawable* coneDrawable = new osg::ShapeDrawable( cone, hints );
234234
coneDrawable->setColor( osg::Vec4( 0.0, 0.5, 0.0, 1.0 ) );
235235
osg::Geode* coneGeode = new osg::Geode();
@@ -244,20 +244,20 @@ void GlobePlugin::setupMap()
244244
double lat = 47.1786;
245245
double lon = 10.111;
246246
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++ )
248250
{
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 );
255254
}
255+
}
256256
#endif
257257
}
258258

259259
struct PanControlHandler : public NavigationControlHandler
260-
{
260+
{
261261
PanControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
262262
virtual void onMouseDown( Control* control, int mouseButtonMask )
263263
{
@@ -267,78 +267,82 @@ struct PanControlHandler : public NavigationControlHandler
267267
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
268268
double _dx;
269269
double _dy;
270-
};
270+
};
271271

272272
struct RotateControlHandler : public NavigationControlHandler
273-
{
273+
{
274274
RotateControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
275275
virtual void onMouseDown( Control* control, int mouseButtonMask )
276276
{
277-
if ( 0 == _dx && 0 == _dy)
277+
if( 0 == _dx && 0 == _dy )
278278
{
279-
_manip->setRotation( osg::Quat() );
279+
_manip->setRotation( osg::Quat() );
280280
}
281281
else
282282
{
283-
_manip->rotate( _dx, _dy );
283+
_manip->rotate( _dx, _dy );
284284
}
285285
}
286286
private:
287287
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
288288
double _dx;
289289
double _dy;
290-
};
290+
};
291291

292292
struct ZoomControlHandler : public NavigationControlHandler
293-
{
293+
{
294294
ZoomControlHandler( osgEarthUtil::EarthManipulator* manip, double dx, double dy ) : _manip( manip ), _dx( dx ), _dy( dy ) { }
295295
virtual void onMouseDown( Control* control, int mouseButtonMask )
296296
{
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 );
308298
}
309299
private:
310300
osg::observer_ptr<osgEarthUtil::EarthManipulator> _manip;
311301
double _dx;
312302
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+
315319
struct RefreshControlHandler : public ControlEventHandler
316320
{
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;
326330
};
327331

328332
struct SyncExtentControlHandler : public ControlEventHandler
329333
{
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;
337341
};
338342

339343
bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
340344
{
341-
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '1' )
345+
if( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '1' )
342346
{
343347
mGlobe->syncExtent();
344348
}
@@ -349,25 +353,20 @@ void GlobePlugin::syncExtent()
349353
{
350354
osgEarthUtil::EarthManipulator* manip = dynamic_cast<osgEarthUtil::EarthManipulator*>( viewer.getCameraManipulator() );
351355
//rotate earth to north and perpendicular to camera
352-
manip->setRotation(osg::Quat());
356+
manip->setRotation( osg::Quat() );
353357

354358
//get actual mapCanvas->extent().height in meters
355359
QgsRectangle extent = mQGisIface->mapCanvas()->extent();
356360
//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 );
359363
QgsRectangle projectedExtent = trans->transformBoundingBox( extent );
360364

361365
double viewAngle = 30;
362366
double height = projectedExtent.height();
363367
double distance = height / tan( viewAngle * osg::PI / 180 ); //c = b*cotan(B(rad))
364368

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;
371370

372371
osgEarthUtil::Viewpoint viewpoint( osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 ), 0.0, -90.0, distance );
373372
manip->setViewpoint( viewpoint, 4.0 );
@@ -388,7 +387,7 @@ void GlobePlugin::setupControls()
388387
moveHControls->setVertAlign( Control::ALIGN_CENTER );
389388
moveHControls->setHorizAlign( Control::ALIGN_CENTER );
390389
moveHControls->setPosition( 20, 26 );
391-
moveHControls->setPadding(3);
390+
moveHControls->setPadding( 3 );
392391

393392
osgEarthUtil::EarthManipulator* manip = dynamic_cast<osgEarthUtil::EarthManipulator*>( viewer.getCameraManipulator() );
394393
//Move Left
@@ -410,7 +409,7 @@ void GlobePlugin::setupControls()
410409
moveVControls->setVertAlign( Control::ALIGN_CENTER );
411410
moveVControls->setHorizAlign( Control::ALIGN_CENTER );
412411
moveVControls->setPosition( 40, 5 );
413-
moveVControls->setPadding(3);
412+
moveVControls->setPadding( 3 );
414413

415414
//Move Up
416415
osg::Image* moveUpImg = osgDB::readImageFile( imgDir + "/move-up.png" );
@@ -440,7 +439,7 @@ void GlobePlugin::setupControls()
440439
rotateControls->setVertAlign( Control::ALIGN_CENTER );
441440
rotateControls->setHorizAlign( Control::ALIGN_CENTER );
442441
rotateControls->setPosition( 5, 120 );
443-
rotateControls->setPadding(3);
442+
rotateControls->setPadding( 3 );
444443

445444
//Rotate CCW
446445
osg::Image* rotateCCWImg = osgDB::readImageFile( imgDir + "/rotate-ccw.png" );
@@ -474,7 +473,7 @@ void GlobePlugin::setupControls()
474473
tiltControls->setVertAlign( Control::ALIGN_CENTER );
475474
tiltControls->setHorizAlign( Control::ALIGN_CENTER );
476475
tiltControls->setPosition( 40, 90 );
477-
tiltControls->setPadding(3);
476+
tiltControls->setPadding( 3 );
478477

479478
//tilt Up
480479
osg::Image* tiltUpImg = osgDB::readImageFile( imgDir + "/tilt-up.png" );
@@ -502,7 +501,7 @@ void GlobePlugin::setupControls()
502501
zoomControls->setVertAlign( Control::ALIGN_CENTER );
503502
zoomControls->setHorizAlign( Control::ALIGN_CENTER );
504503
zoomControls->setPosition( 40, 180 );
505-
zoomControls->setPadding(3);
504+
zoomControls->setPadding( 3 );
506505

507506
//Zoom In
508507
osg::Image* zoomInImg = osgDB::readImageFile( imgDir + "/zoom-in.png" );
@@ -519,7 +518,7 @@ void GlobePlugin::setupControls()
519518
zoomControls->addControl( zoomOut );
520519

521520
//END ZOOM CONTROLS
522-
521+
523522
//EXTRA CONTROLS
524523
//Horizontal container
525524
HBox* extraControls = new HBox();
@@ -530,18 +529,18 @@ void GlobePlugin::setupControls()
530529
extraControls->setVertAlign( Control::ALIGN_CENTER );
531530
extraControls->setHorizAlign( Control::ALIGN_CENTER );
532531
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+
540534
//Sync Extent
541535
osg::Image* extraSyncImg = osgDB::readImageFile( imgDir + "/sync-extent.png" );
542536
ImageControl* extraSync = new NavigationControl( extraSyncImg );
543537
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+
545544
//refresh layers
546545
osg::Image* extraRefreshImg = osgDB::readImageFile( imgDir + "/refresh-view.png" );
547546
ImageControl* extraRefresh = new NavigationControl( extraRefreshImg );
@@ -568,19 +567,19 @@ void GlobePlugin::setupProxy()
568567
{
569568
QSettings settings;
570569
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() )
572575
{
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 );
583578
}
579+
//TODO: settings.value("/proxyType")
580+
//TODO: URL exlusions
581+
HTTPClient::setProxySettings( proxySettings );
582+
}
584583
settings.endGroup();
585584
}
586585

@@ -594,32 +593,32 @@ typedef std::list< osg::ref_ptr<VersionedTile> > TileList;
594593
void GlobePlugin::layersChanged()
595594
{
596595
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() );
622606
}
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+
}
623622
}
624623

625624
void GlobePlugin::unload()
@@ -653,56 +652,56 @@ void GlobePlugin::placeNode( osg::Node* node, double lat, double lon, double alt
653652
void GlobePlugin::copyFolder( QString sourceFolder, QString destFolder )
654653
{
655654
QDir sourceDir( sourceFolder );
656-
if ( !sourceDir.exists() )
655+
if( !sourceDir.exists() )
657656
return;
658657
QDir destDir( destFolder );
659-
if ( !destDir.exists() )
660-
{
661-
destDir.mkpath( destFolder );
662-
}
658+
if( !destDir.exists() )
659+
{
660+
destDir.mkpath( destFolder );
661+
}
663662
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+
}
670669
files.clear();
671670
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+
}
678677
}
679678

680679
bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
681680
{
682-
switch ( ea.getEventType() )
683-
{
681+
switch( ea.getEventType() )
682+
{
684683
case osgGA::GUIEventAdapter::PUSH:
685684
_mouse_down_event = &ea;
686685
break;
687686
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+
}
692691
break;
693692
case osgGA::GUIEventAdapter::RELEASE:
694693
_mouse_down_event = NULL;
695694
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 )
698700
{
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() );
705703
}
704+
}
706705
return Control::handle( ea, aa, cx );
707706
}
708707

@@ -751,65 +750,65 @@ bool KeyboardControlHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GU
751750
752751
*/
753752

754-
switch ( ea.getEventType() )
755-
{
756-
case ( osgGA::GUIEventAdapter::KEYDOWN ) :
753+
switch( ea.getEventType() )
754+
{
755+
case( osgGA::GUIEventAdapter::KEYDOWN ) :
757756
{
758757
//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+
}
775774
//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+
}
784783
//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+
}
793792
//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+
}
802801
//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+
}
807806
break;
808807
}
809808

810809
default:
811810
break;
812-
}
811+
}
813812
return false;
814813
}
815814

0 commit comments

Comments
 (0)
Please sign in to comment.