root / trunk / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / import3D / CreateNewLayerOSG.java @ 22675
History | View | Annotate | Download (2.53 KB)
1 |
package org.gvsig.gvsig3dgui.import3D; |
---|---|
2 |
|
3 |
import org.gvsig.gvsig3d.drivers.GvsigDriverOSG; |
4 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
5 |
import org.gvsig.gvsig3dgui.view.View3D; |
6 |
|
7 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
8 |
import com.iver.andami.PluginServices; |
9 |
import com.iver.andami.plugins.Extension; |
10 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
11 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
12 |
import com.iver.cit.gvsig.fmap.layers.VectorialDefaultAdapter; |
13 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
14 |
|
15 |
public class CreateNewLayerOSG extends Extension { |
16 |
private FLyrVect layerOSG;
|
17 |
|
18 |
public void execute(String actionCommand) { |
19 |
|
20 |
if (actionCommand.equals("CREARCAPA")) { |
21 |
com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices |
22 |
.getMDIManager().getActiveWindow(); |
23 |
|
24 |
if (activeWindow instanceof View3D) { |
25 |
GvsigDriverOSG d = new GvsigDriverOSG();
|
26 |
VectorialAdapter adapter = new VectorialDefaultAdapter();
|
27 |
adapter.setDriver(d); |
28 |
|
29 |
layerOSG = new FLyrVect();
|
30 |
View3D vista = (View3D) PluginServices.getMDIManager() |
31 |
.getActiveWindow(); |
32 |
IProjectView model = vista.getModel(); |
33 |
|
34 |
MapContext3D mapa = (MapContext3D) model.getMapContext(); |
35 |
layerOSG.setName("defaultLayerOSG");
|
36 |
layerOSG.setSource(adapter); |
37 |
|
38 |
// add 3D properties, mainly to keep track of hooked state
|
39 |
Layer3DProps props3D = new Layer3DProps();
|
40 |
props3D.setType(Layer3DProps.layer3DOSG); |
41 |
props3D.setChooseType(false);
|
42 |
props3D.setLayer(layerOSG); |
43 |
props3D.setNewLayerOSG(true);
|
44 |
|
45 |
layerOSG.setProperty("3DLayerExtension", props3D);
|
46 |
layerOSG.setProjection(mapa.getProjection()); |
47 |
mapa.getLayers().addLayer(layerOSG); |
48 |
} |
49 |
} |
50 |
} |
51 |
|
52 |
public void initialize() { |
53 |
PluginServices.getIconTheme().registerDefault( |
54 |
"create_new_layer_OSG",
|
55 |
this.getClass().getClassLoader().getResource(
|
56 |
"images/plugin_link.png"));
|
57 |
} |
58 |
|
59 |
public boolean isEnabled() { |
60 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
61 |
.getMDIManager().getActiveWindow(); |
62 |
|
63 |
if (f == null) { |
64 |
return false; |
65 |
} |
66 |
|
67 |
// Only isVisible = true, where the view has a view3D.
|
68 |
if (f instanceof View3D) { |
69 |
return true; |
70 |
} |
71 |
return false; |
72 |
|
73 |
} |
74 |
|
75 |
public boolean isVisible() { |
76 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
77 |
.getMDIManager().getActiveWindow(); |
78 |
|
79 |
if (f == null) { |
80 |
return false; |
81 |
} |
82 |
|
83 |
// Only isVisible = true, where the view has a view3D.
|
84 |
if (f instanceof View3D) { |
85 |
return true; |
86 |
} |
87 |
return false; |
88 |
|
89 |
} |
90 |
|
91 |
} |