Revision 27685
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/behavior/PolylineBehavior3D.java | ||
---|---|---|
1 | 1 |
package org.gvsig.gvsig3dgui.behavior; |
2 | 2 |
|
3 |
import java.awt.Graphics; |
|
4 |
import java.awt.Rectangle; |
|
3 | 5 |
import java.awt.event.MouseEvent; |
4 | 6 |
import java.awt.geom.Point2D; |
7 |
import java.awt.geom.Rectangle2D; |
|
5 | 8 |
|
9 |
import org.apache.batik.ext.awt.geom.Polyline2D; |
|
6 | 10 |
import org.apache.log4j.Level; |
7 | 11 |
import org.apache.log4j.Logger; |
8 | 12 |
import org.gvsig.gvsig3d.map3d.GraphicLayer3D; |
... | ... | |
16 | 20 |
import org.gvsig.osgvp.util.Util; |
17 | 21 |
import org.gvsig.osgvp.viewer.Intersections; |
18 | 22 |
|
23 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
19 | 24 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
25 |
import com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent; |
|
20 | 26 |
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
21 | 27 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener; |
22 | 28 |
import com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener; |
... | ... | |
24 | 30 |
public class PolylineBehavior3D extends PolylineBehavior{ |
25 | 31 |
private Point2D m_FirstPoint; |
26 | 32 |
private Point2D m_LastPoint; |
27 |
private boolean _clicked; |
|
33 |
private boolean _clicked=false;
|
|
28 | 34 |
private PolylineListener listener; |
29 | 35 |
private InteractivePolyline ipol; |
30 | 36 |
private int height; |
31 | 37 |
private int width; |
32 |
private float _factor=0.1f;
|
|
38 |
private float _factor=1f; |
|
33 | 39 |
private static Logger logger = Logger.getLogger(GraphicLayer3D.class |
34 | 40 |
.getName()); |
35 | 41 |
|
... | ... | |
40 | 46 |
ipol = new InteractivePolyline(); |
41 | 47 |
} catch (OSGVPException e) { |
42 | 48 |
logger.error("Command: " |
43 |
+ "Error creating new selection rectangle.", e);
|
|
49 |
+ "Error creating new interactive polyline", e);
|
|
44 | 50 |
} |
45 | 51 |
} |
46 |
public void mousePressed(MouseEvent arg0) { |
|
52 |
@Override |
|
53 |
public void paintComponent(Graphics g) { |
|
47 | 54 |
// TODO Auto-generated method stub |
48 |
|
|
49 |
System.out.println("presed"); |
|
50 |
|
|
55 |
// super.paintComponent(g); |
|
51 | 56 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
52 |
|
|
53 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick(arg0.getX(), |
|
54 |
arg0.getY()); |
|
55 |
|
|
56 |
if (arg0.getButton() == MouseEvent.BUTTON3) { |
|
57 |
_clicked = true; |
|
58 |
Vec3 normal =hits.getFirstIntersection() |
|
59 |
.getIntersectionNormal(); |
|
60 |
normal.normalize(); |
|
61 |
ipol.setMouseCoords(hits.getFirstIntersection().getIntersectionPoint().sum(normal.escalarProduct(_factor))); |
|
62 |
|
|
63 |
|
|
64 |
} |
|
65 |
try { |
|
66 |
((PlanetViewer) mcontext.getCanvas3d().getOSGViewer()) |
|
67 |
.addNodeToHUD(ipol); |
|
68 |
ipol.update(); |
|
69 |
} catch (OSGVPException e) { |
|
70 |
// TODO Auto-generated catch block |
|
71 |
e.printStackTrace(); |
|
72 |
} |
|
73 |
ipol.setEnabledNode(true); |
|
74 |
|
|
57 |
mcontext.getCanvas3d().repaint(); |
|
75 | 58 |
} |
76 | 59 |
public void mouseMoved(MouseEvent arg0) { |
77 | 60 |
|
61 |
|
|
62 |
|
|
78 | 63 |
if (_clicked) { |
79 | 64 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
80 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick(arg0.getX(), |
|
65 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick(arg0.getX(),
|
|
81 | 66 |
arg0.getY()); |
82 | 67 |
Vec3 normal =hits.getFirstIntersection() |
83 | 68 |
.getIntersectionNormal(); |
... | ... | |
95 | 80 |
|
96 | 81 |
} |
97 | 82 |
} |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
public void mousePressed(MouseEvent arg0) { |
|
88 |
// TODO Auto-generated method stub |
|
89 |
|
|
90 |
|
|
91 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
|
92 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick(arg0.getX(), |
|
93 |
arg0.getY()); |
|
94 |
if (!_clicked){ |
|
95 |
try { |
|
96 |
((PlanetViewer) mcontext.getCanvas3d().getOSGViewer()) |
|
97 |
.addNodeToHUD(ipol); |
|
98 |
|
|
99 |
} catch (OSGVPException e) { |
|
100 |
// TODO Auto-generated catch block |
|
101 |
e.printStackTrace(); |
|
102 |
} |
|
103 |
if (arg0.getButton() == MouseEvent.BUTTON1) { |
|
104 |
_clicked = true; |
|
105 |
Vec3 normal =hits.getFirstIntersection() |
|
106 |
.getIntersectionNormal(); |
|
107 |
normal.normalize(); |
|
108 |
ipol.setMouseCoords(hits.getFirstIntersection().getIntersectionPoint().sum(normal.escalarProduct(_factor))); |
|
109 |
} |
|
110 |
try { |
|
111 |
ipol.update(); |
|
112 |
} catch (OSGVPException e) { |
|
113 |
// TODO Auto-generated catch block |
|
114 |
e.printStackTrace(); |
|
115 |
} |
|
116 |
ipol.setEnabledNode(true); |
|
117 |
} |
|
118 |
|
|
119 |
} |
|
120 |
|
|
98 | 121 |
public void mouseReleased(MouseEvent arg0) { |
99 | 122 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
100 | 123 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick(arg0.getX(), |
101 | 124 |
arg0.getY()); |
102 |
if (arg0.getButton() == MouseEvent.BUTTON3) {
|
|
125 |
if (arg0.getButton() == MouseEvent.BUTTON1) {
|
|
103 | 126 |
Vec3 normal =hits.getFirstIntersection() |
104 | 127 |
.getIntersectionNormal(); |
105 | 128 |
normal.normalize(); |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/view/View3D.java | ||
---|---|---|
26 | 26 |
import org.gvsig.gvsig3d.map3d.ViewPort3D; |
27 | 27 |
import org.gvsig.gvsig3d.navigation.NavigationMode; |
28 | 28 |
import org.gvsig.gvsig3dgui.ProjectView3D; |
29 |
import org.gvsig.gvsig3dgui.behavior.PolylineBehavior3D; |
|
29 | 30 |
import org.gvsig.gvsig3dgui.behavior.RectangleBehavior3D; |
30 | 31 |
import org.gvsig.gvsig3dgui.listener.PointSelectListerner3D; |
32 |
import org.gvsig.gvsig3dgui.listener.PolylineDrawListener3D; |
|
31 | 33 |
import org.gvsig.gvsig3dgui.listener.RectangleSelectListener3D; |
32 | 34 |
import org.gvsig.osgvp.planets.Planet; |
33 | 35 |
import org.gvsig.osgvp.planets.RequestLayerListener; |
... | ... | |
49 | 51 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
50 | 52 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
51 | 53 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
54 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener; |
|
52 | 55 |
import com.iver.cit.gvsig.project.documents.view.MapOverview; |
53 | 56 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
54 | 57 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC; |
... | ... | |
307 | 310 |
new Behavior[] { new RectangleBehavior3D(rsl) }); |
308 | 311 |
// |
309 | 312 |
// //Selecci�n por pol�gono |
313 |
PolylineDrawListener3D polylis = new PolylineDrawListener3D( |
|
314 |
m_MapControl); |
|
315 |
m_MapControl.addMapTool("interactivePolyline", |
|
316 |
new Behavior[] { new PolylineBehavior3D(polylis) }); |
|
317 |
|
|
318 |
|
|
319 |
|
|
310 | 320 |
// PolygonSelectListener poligSel = new |
311 | 321 |
// PolygonSelectListener(m_MapControl); |
312 | 322 |
// m_MapControl.addMapTool("polSelection", new Behavior[]{new |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/listener/PolylineDrawListener3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.listener; |
|
2 |
|
|
3 |
import java.awt.Cursor; |
|
4 |
|
|
5 |
import org.gvsig.gvsig3d.map3d.MapControl3D; |
|
6 |
|
|
7 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
8 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
9 |
import com.iver.cit.gvsig.fmap.tools.PolygonSelectionListener; |
|
10 |
import com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent; |
|
11 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener; |
|
12 |
|
|
13 |
public class PolylineDrawListener3D extends PolygonSelectionListener{ |
|
14 |
|
|
15 |
public PolylineDrawListener3D(MapControl mapCtrl) { |
|
16 |
super(mapCtrl); |
|
17 |
} |
|
18 |
public void pointFixed(MeasureEvent arg0) throws BehaviorException { |
|
19 |
// TODO Auto-generated method stub |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
public void points(MeasureEvent arg0) throws BehaviorException { |
|
24 |
// TODO Auto-generated method stub |
|
25 |
|
|
26 |
} |
|
27 |
|
|
28 |
public void polylineFinished(MeasureEvent arg0) throws BehaviorException { |
|
29 |
// TODO Auto-generated method stub |
|
30 |
|
|
31 |
} |
|
32 |
|
|
33 |
public boolean cancelDrawing() { |
|
34 |
// TODO Auto-generated method stub |
|
35 |
return false; |
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
} |
Also available in: Unified diff