Revision 29938 branches/v2_0_0_prep/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/listener/RectangleSelectListener3D.java
RectangleSelectListener3D.java | ||
---|---|---|
3 | 3 |
import java.awt.geom.Point2D; |
4 | 4 |
import java.awt.geom.Rectangle2D; |
5 | 5 |
|
6 |
import org.gvsig.andami.messages.NotificationManager; |
|
7 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
8 |
import org.gvsig.fmap.mapcontext.layers.FBitSet; |
|
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
10 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
11 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
12 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
13 |
import org.gvsig.fmap.mapcontrol.tools.RectangleSelectionListener; |
|
6 | 14 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
7 | 15 |
import org.gvsig.osgvp.core.osg.Vec3; |
8 | 16 |
import org.gvsig.osgvp.viewer.Intersections; |
9 | 17 |
|
10 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
11 |
import com.iver.andami.messages.NotificationManager; |
|
12 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
13 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
14 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
|
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
16 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
17 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
18 |
import com.iver.cit.gvsig.fmap.tools.RectangleSelectionListener; |
|
19 |
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
|
20 |
|
|
21 | 18 |
public class RectangleSelectListener3D extends RectangleSelectionListener { |
22 | 19 |
|
23 | 20 |
private MapControl mapControl; |
... | ... | |
28 | 25 |
mapControl = mc; |
29 | 26 |
} |
30 | 27 |
|
31 |
@Override |
|
32 |
public void rectangle(RectangleEvent event) throws BehaviorException { |
|
33 |
try { |
|
34 |
// mapCtrl.getMapContext().selectByRect(event.getWorldCoordRect()); |
|
35 |
Rectangle2D rect = event.getWorldCoordRect(); |
|
36 |
Point2D up = new Point2D.Double(); |
|
37 |
up.setLocation(rect.getX(), rect.getY()); |
|
38 |
Vec3 upLeft = coordinatesIntersection(up); |
|
39 |
// Point2D down = new Point2D.Double(); |
|
40 |
// down.setLocation(rect.getMaxX(), rect.getMaxY()); |
|
41 |
// Vec3 downRight = coordinatesIntersection(down); |
|
28 |
// TODO:COMENTADO PARA LA 2.0 |
|
29 |
// @Override |
|
30 |
// public void rectangle(RectangleEvent event) throws BehaviorException { |
|
31 |
// try { |
|
32 |
// |
|
33 |
// Rectangle2D rect = event.getWorldCoordRect(); |
|
34 |
// Point2D up = new Point2D.Double(); |
|
35 |
// up.setLocation(rect.getX(), rect.getY()); |
|
36 |
// Vec3 upLeft = coordinatesIntersection(up); |
|
37 |
// |
|
38 |
// |
|
39 |
// Rectangle2D newRect = new Rectangle2D.Double(upLeft.x(), |
|
40 |
// upLeft.y(), rect.getHeight(), rect.getWidth()); |
|
41 |
// |
|
42 |
// FLayer[] actives = mapControl.getMapContext().getLayers() |
|
43 |
// .getActives(); |
|
44 |
// for (int i = 0; i < actives.length; i++) { |
|
45 |
// if (actives[i] instanceof FLyrVect) { |
|
46 |
// FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
47 |
// FBitSet oldBitSet = lyrVect.getSource().getRecordset() |
|
48 |
// .getSelection(); |
|
49 |
// |
|
50 |
// FBitSet newBitSet = lyrVect.queryByRect(rect); |
|
51 |
// if (event.getEvent().isControlDown()) |
|
52 |
// newBitSet.xor(oldBitSet); |
|
53 |
// lyrVect.getRecordset().setSelection(newBitSet); |
|
54 |
// } |
|
55 |
// } |
|
56 |
// |
|
57 |
// } catch (ReadException e) { |
|
58 |
// throw new BehaviorException("No se pudo hacer la selecci�n"); |
|
59 |
// } catch (VisitorException e) { |
|
60 |
// throw new BehaviorException("No se pudo hacer la selecci�n"); |
|
61 |
// } |
|
62 |
// } |
|
42 | 63 |
|
43 |
Rectangle2D newRect = new Rectangle2D.Double(upLeft.x(), |
|
44 |
upLeft.y(), rect.getHeight(), rect.getWidth()); |
|
45 |
|
|
46 |
FLayer[] actives = mapControl.getMapContext().getLayers() |
|
47 |
.getActives(); |
|
48 |
for (int i = 0; i < actives.length; i++) { |
|
49 |
if (actives[i] instanceof FLyrVect) { |
|
50 |
FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
51 |
FBitSet oldBitSet = lyrVect.getSource().getRecordset() |
|
52 |
.getSelection(); |
|
53 |
// FBitSet newBitSet = lyrVect.queryByRect(newRect); |
|
54 |
FBitSet newBitSet = lyrVect.queryByRect(rect); |
|
55 |
if (event.getEvent().isControlDown()) |
|
56 |
newBitSet.xor(oldBitSet); |
|
57 |
lyrVect.getRecordset().setSelection(newBitSet); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
} catch (ReadDriverException e) { |
|
62 |
throw new BehaviorException("No se pudo hacer la selecci?n"); |
|
63 |
} catch (VisitorException e) { |
|
64 |
throw new BehaviorException("No se pudo hacer la selecci?n"); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 | 64 |
public Vec3 coordinatesIntersection(Point2D pScreen) { |
69 | 65 |
Vec3 intersection; |
70 | 66 |
|
Also available in: Unified diff