As picture shown above,We use osgEarth::Annotation::PlaceNode to present the label of a aircraft,such as PAD001,PAD002.Then we attach a osgEarth::Util::AnnotationEventCallback to each PlaceNode,code like:
osg::ref_ptr<osgEarth::Util::AnnotationEventCallback> cb = new osgEarth::Util::AnnotationEventCallback();
cb->addHandler( new CBattleObjectEventHandler());
CBattleObjectEventHandler is a custom AnnotationEventHandler which handle mouse event attched with the PlaceNode ,such as right click the PlaceNode to popup a menu.
It works well so far. Until we decide to add a second view as a "follow center dialog" which to follow a certain aircraft as the picture above.
The "follow center dialog" viewer and the main viewer are both under a same CompositeViewer,and share
a same SceneData.
Then the problem is ,all AnnotationEventCallback seems failed to the main viewer,but worked to the "follow center dialog" viewer!Means We can right click the PlaceNode to popup a menu but only in the "follow center dialog" viewer not in the main viewer!Or more specific ,any PlaceNode appeard in the "follow center dialog" viewer are lose the fuction of its CBattleObjectEventHandler!
Our needs is the AnnotationEventHandler of PlaceNode must functional in the main viewer.Functional in the "follow center dialog" viewer is only optional.
We dig a little up source code in \src\osgEarthUtil\AnnotationEvents.cpp