World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 07-16-2012, 08:38 PM   #1
jscWaveLink
Junior Member
 
Join Date: Jul 2012
Posts: 8
jscWaveLink is on a distinguished road
Default Picking Terrain

I'm using WWJ 1.3 and the ApplicationTemplate.java class. The WorldMapLayer class indicates that the ClickAndGoSelectListener can be used to move the view to a selected location when that location is clicked within the layer's map. I have modifed the ApplicationTemplate.java and ClickAndGoSelectListener classes. ClickAndGoSelectListener will display the lat/lon coordinates of the terrain when a RIGHT_CLICK occurs. However, the listener never gets called on a RIGHT_CLICK. If the user clicks on a tactical symbol, though, the listener gets called and the coordinates are displayed.

In the code below, a right click on the terrain displays nothing, but a right click on a tactical symbol displays:
Quote:
RIGHT Click
RIGHT Lat 29.348377019510618 Lon -5.6307413529977115
In the AppPanel, I have
Code:
this.wwd = this.createWorldWindow(); // returns new WorldWindowGLCanvas();
this.wwd.addSelectListener(new SSFClickAndGoSelectListener(this.getWwd(), WorldMapLayer.class));
In the SSFClickAndGoSelectListener,
Code:
    public void selected(SelectEvent event)
    {
        if (event.isRightClick())
        {System.out.println(" RIGHT Click ");
        	PickedObjectList pol = event.getObjects();
        	if (event.hasObjects())
        	{
        	System.out.println(" RIGHT Lat "+pol.getTerrainObject().getPosition().getLatitude().getDegrees()+
        			" Lon "+event.getObjects().getTerrainObject().getPosition().getLongitude().getDegrees());
        	}
        	else
        	{
        		System.out.println(" RIGHT, but no objects");
        	}
        }
   ...
I've also tried checking the eventAction to be SelectEvent.RIGHT_CLICK, with the same results. I read on this forum about other issues with picking terrain in
Quote:
handling mouse events in WWJ
. But most posts seem to suggest that picking terrain is working. What else needs to be done to pick terrain? It seems like the RIGHT_CLICK is being consumed, but the docs indicate that all SelectListeners will be called and my listener doesn't check for isConsumed().

Finally, I'd like to remove the "fly-to" functionality of the LEFT_CLICK. If I comment out the call to view.goTo() in my ClickAndGoSelectListener, the LEFT_CLICK still pans to the location. Is there another class which the example ApplicationTemplate uses to implement the ClickAndGoSelectListener functions?

Thanks for your time and help.
jscWaveLink is offline   Reply With Quote
Old 07-21-2012, 06:01 AM   #2
pabercrombie
WW Dev. Team
 
Join Date: Sep 2010
Location: Boston, MA, USA
Posts: 325
pabercrombie is on a distinguished road
Default

You need to use a MouseListener to handle terrain selection (which I think you've already figured out, judging from this thread).

The "pan to location on left click" is handled by the default input handler, not the ClickAndGoSelectListener. An easy way to disable this feature is to add mouse listener that consumes clicks on terrain (the mouse listener will process clicks before the WW input handler, and the input handler will ignore any events that have already been consumed.)

Code:
wwd.getInputHandler().addMouseListener(new MouseAdapter()
    {
        @Override
        public void mouseClicked(MouseEvent e)
        {
            PickedObjectList objects = wwd.getObjectsAtCurrentPosition();
            boolean isTerrain = objects != null
                && objects.getTopPickedObject() != null
                && objects.getTopPickedObject().isTerrain();
            if (isTerrain)
            {
                e.consume(); // Prevents globe moving in response to click
            }
        }
    });
pabercrombie is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Terrain Picking Work in 1.4.0? jscWaveLink Development Help 5 07-21-2012 05:43 AM
Problem picking terrain with vertical exaggeration set to 0 NathanKronenfeld Development Help 3 01-21-2011 04:50 PM
Bug in the visualization for the terrain of CompoundElevationModel? mao Development Help 8 03-20-2009 05:12 AM
Problem with terrain and its modification bako Development Help 1 02-23-2009 05:35 PM


All times are GMT +1. The time now is 09:04 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.