Revision 23304 trunk/libraries/lib3DMap/src/org/gvsig/gvsig3d/cacheservices/OSGCacheService.java
OSGCacheService.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.geom.Rectangle2D; |
4 | 4 |
import java.io.File; |
5 |
import java.io.FileNotFoundException; |
|
6 | 5 |
|
6 |
import javax.swing.JOptionPane; |
|
7 |
|
|
7 | 8 |
import org.apache.log4j.Logger; |
8 | 9 |
import org.cresques.cts.IProjection; |
9 | 10 |
import org.gvsig.cacheservice.CacheService; |
... | ... | |
13 | 14 |
import org.gvsig.geometries3D.MultiGeometry; |
14 | 15 |
import org.gvsig.geometries3D.MultiSolid; |
15 | 16 |
import org.gvsig.gvsig3d.drivers.GvsigDriverOSG; |
17 |
import org.gvsig.gvsig3d.listener.EditorListener; |
|
16 | 18 |
import org.gvsig.operations3D.Draw3DMultiSolid; |
17 | 19 |
import org.gvsig.operations3D.context.Draw3DContext; |
18 | 20 |
import org.gvsig.osgvp.Group; |
19 | 21 |
import org.gvsig.osgvp.Node; |
20 | 22 |
import org.gvsig.osgvp.PositionAttitudeTransform; |
21 | 23 |
import org.gvsig.osgvp.Vec3; |
22 |
import org.gvsig.osgvp.osgDB; |
|
23 | 24 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
25 |
import org.gvsig.osgvp.manipulator.EditionManager; |
|
26 |
import org.gvsig.osgvp.manipulator.ManipulatorHandler; |
|
27 |
import org.gvsig.osgvp.manipulator.RemoveAllSelectionCommand; |
|
28 |
import org.gvsig.osgvp.manipulator.Manipulator.DraggerType; |
|
24 | 29 |
import org.gvsig.osgvp.planets.Planet; |
25 | 30 |
import org.gvsig.osgvp.planets.PlanetViewer; |
26 | 31 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
... | ... | |
43 | 48 |
|
44 | 49 |
// vector caching for libJOSG |
45 | 50 |
private Group _layerNode; |
46 |
|
|
51 |
|
|
47 | 52 |
private boolean newLayerOSG = false; |
48 | 53 |
|
54 |
private EditionManager editionManager; |
|
55 |
|
|
56 |
private RemoveAllSelectionCommand command; |
|
57 |
|
|
49 | 58 |
private static Logger logger = Logger.getLogger(OSGCacheService.class |
50 | 59 |
.getName()); |
51 | 60 |
|
... | ... | |
62 | 71 |
_layer = layer; |
63 | 72 |
_layerNode = new Group(); |
64 | 73 |
_layerNode.setNodeName("layer3DOSG"); |
65 |
|
|
74 |
|
|
66 | 75 |
try { |
67 | 76 |
_planetViewer.addSpecialNode(_layerNode); |
68 | 77 |
} catch (NodeException e1) { |
... | ... | |
88 | 97 |
} |
89 | 98 |
|
90 | 99 |
} |
91 |
|
|
100 |
|
|
92 | 101 |
public Group getLayerNode() { |
93 | 102 |
return _layerNode; |
94 | 103 |
} |
95 |
|
|
96 | 104 |
|
97 | 105 |
// uses a strategy to get all features from layer and their symbols |
98 | 106 |
// and add them to the planet |
... | ... | |
100 | 108 |
public void AddFeaturesToPlanet() { |
101 | 109 |
|
102 | 110 |
boolean newLayer = Layer3DProps.getLayer3DProps(_layer).isNewLayerOSG(); |
103 |
|
|
104 |
if(!newLayer) |
|
105 |
{ |
|
106 |
GvsigDriverOSG osgD = (GvsigDriverOSG) ((FLyrVect) _layer).getSource() |
|
107 |
.getDriver(); |
|
111 |
|
|
112 |
if (!newLayer) { |
|
113 |
GvsigDriverOSG osgD = (GvsigDriverOSG) ((FLyrVect) _layer) |
|
114 |
.getSource().getDriver(); |
|
108 | 115 |
try { |
109 | 116 |
File file = osgD.getFile(); |
110 |
Node n = null; |
|
111 |
|
|
112 |
|
|
113 |
try { |
|
114 |
n = osgDB.readNodeFile(file.getAbsolutePath()); |
|
115 |
} catch (FileNotFoundException e) { |
|
116 |
// TODO Auto-generated catch block |
|
117 |
e.printStackTrace(); |
|
118 |
} |
|
117 |
Node n = null; |
|
118 |
|
|
119 |
// try { |
|
120 |
// n = osgDB.readNodeFile(file.getAbsolutePath()); |
|
121 |
// } catch (FileNotFoundException e) { |
|
122 |
// // TODO Auto-generated catch block |
|
123 |
// e.printStackTrace(); |
|
124 |
// } |
|
119 | 125 |
MultiGeometry root = osgD.getOSGDriver().getRootFeature(); |
120 | 126 |
// Insert the geometry in the root node of the graph. |
121 | 127 |
Group g = new Group(); |
122 |
// buildGeometry(root, g);
|
|
123 |
g.addChild(n); |
|
128 |
buildGeometry(root, g); |
|
129 |
// g.addChild(n);
|
|
124 | 130 |
_layerNode.addChild(g); |
125 | 131 |
} catch (NodeException e) { |
126 | 132 |
// TODO Auto-generated catch block |
... | ... | |
155 | 161 |
posAttTrasn = new PositionAttitudeTransform(); |
156 | 162 |
posAttTrasn.setPosition(position); |
157 | 163 |
posAttTrasn.setScale(scale); |
158 |
posAttTrasn.setAttitude((float) rotation.x(), new Vec3(1,0,0)); |
|
159 |
posAttTrasn.setAttitude((float) rotation.y(), new Vec3(0,1,0)); |
|
160 |
posAttTrasn.setAttitude((float) rotation.z(), new Vec3(0,0,1)); |
|
164 |
// posAttTrasn.setAttitude((float) rotation.x(), new Vec3(1,0,0));
|
|
165 |
// posAttTrasn.setAttitude((float) rotation.y(), new Vec3(0,1,0));
|
|
166 |
// posAttTrasn.setAttitude((float) rotation.z(), new Vec3(0,0,1));
|
|
161 | 167 |
buildGeometry(multiGeometry, group); |
162 | 168 |
posAttTrasn.addChild(group); |
163 | 169 |
_layerNode.addChild(posAttTrasn); |
170 |
// _layerNode.addChild(group); |
|
164 | 171 |
} catch (NodeException e1) { |
165 | 172 |
// TODO Auto-generated catch block |
166 | 173 |
e1.printStackTrace(); |
167 | 174 |
} |
168 | 175 |
|
169 |
|
|
170 | 176 |
} |
171 | 177 |
|
172 | 178 |
private void buildGeometry(AbstractPrimitive geom, Group group) |
... | ... | |
206 | 212 |
|
207 | 213 |
} |
208 | 214 |
|
215 |
public void startEditing() { |
|
209 | 216 |
|
217 |
try { |
|
218 |
Layer3DProps props3D = Layer3DProps.getLayer3DProps(this._layer); |
|
219 |
if ((props3D.getType() == Layer3DProps.layer3DOSG) |
|
220 |
&& (!props3D.isEditing())) { |
|
221 |
props3D.setEditing(true); |
|
222 |
JOptionPane.showMessageDialog(null, |
|
223 |
"la capa ha sido puesta en edicion automaticamente"); |
|
224 |
editionManager = new EditionManager(); |
|
225 |
editionManager.setScene(_layerNode); |
|
226 |
Group parent = _layerNode.getParent(0); |
|
227 |
parent.removeChild(_layerNode); |
|
228 |
parent.addChild(editionManager); |
|
229 |
|
|
230 |
ManipulatorHandler manipulatorHandler = new ManipulatorHandler(); |
|
231 |
manipulatorHandler.setActive(true); |
|
232 |
|
|
233 |
EditorListener editionListener = new EditorListener( |
|
234 |
editionManager, manipulatorHandler, _canvas3D); |
|
235 |
|
|
236 |
_canvas3D.getOSGViewer().addEventHandler(manipulatorHandler); |
|
237 |
|
|
238 |
// public void changeDragger(String draggerType) |
|
239 |
//editionManager.changeDragger(DraggerType.ROTATE_SPHERE_DRAGGER |
|
240 |
// ); |
|
241 |
// editionManager.changeDragger(DraggerType.TABBOX_DRAGGER); |
|
242 |
//editionManager.changeDragger(DraggerType.TRANSLATE_AXIS_DRAGGER |
|
243 |
// ); |
|
244 |
|
|
245 |
} |
|
246 |
} catch (NodeException e) { |
|
247 |
// TODO Auto-generated catch block |
|
248 |
e.printStackTrace(); |
|
249 |
} |
|
250 |
} |
|
251 |
|
|
252 |
public void endEditing() { |
|
253 |
|
|
254 |
try { |
|
255 |
Layer3DProps props3D = Layer3DProps.getLayer3DProps(this._layer); |
|
256 |
if ((props3D.getType() == Layer3DProps.layer3DOSG) |
|
257 |
&& (props3D.isEditing())) { |
|
258 |
props3D.setEditing(false); |
|
259 |
|
|
260 |
command = new RemoveAllSelectionCommand(editionManager); |
|
261 |
command.execute(); |
|
262 |
|
|
263 |
Group scene = editionManager.getTransformedScene(); |
|
264 |
Group parent = _layerNode.getParent(0); |
|
265 |
parent.removeChild(_layerNode); |
|
266 |
parent.addChild(scene); |
|
267 |
|
|
268 |
// public void changeDragger(String draggerType) |
|
269 |
//editionManager.changeDragger(DraggerType.ROTATE_SPHERE_DRAGGER |
|
270 |
// ); |
|
271 |
// editionManager.changeDragger(DraggerType.TABBOX_DRAGGER); |
|
272 |
//editionManager.changeDragger(DraggerType.TRANSLATE_AXIS_DRAGGER |
|
273 |
// ); |
|
274 |
|
|
275 |
} |
|
276 |
} catch (NodeException e) { |
|
277 |
// TODO Auto-generated catch block |
|
278 |
e.printStackTrace(); |
|
279 |
} |
|
280 |
|
|
281 |
} |
|
282 |
public EditionManager getEditionManager() { |
|
283 |
return editionManager; |
|
284 |
} |
|
285 |
|
|
286 |
public void setEditionManager(EditionManager editionManager) { |
|
287 |
this.editionManager = editionManager; |
|
288 |
} |
|
289 |
|
|
290 |
|
|
210 | 291 |
} |
Also available in: Unified diff