root / trunk / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / import3D / MenuImport3D.java @ 22628
History | View | Annotate | Download (2.88 KB)
1 |
package org.gvsig.gvsig3dgui.import3D; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
|
5 |
import org.gvsig.GeometryFactory3D; |
6 |
import org.gvsig.fmap.geom.GeometryManager; |
7 |
import org.gvsig.gvsig3d.cacheservices.OSGCacheService; |
8 |
import org.gvsig.gvsig3d.drivers.GvsigDriverOSG; |
9 |
import org.gvsig.gvsig3dgui.view.View3D; |
10 |
|
11 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
12 |
import com.iver.andami.PluginServices; |
13 |
import com.iver.andami.plugins.Extension; |
14 |
import com.iver.cit.gvsig.fmap.MapContext; |
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
16 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
17 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
18 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
19 |
|
20 |
|
21 |
/**
|
22 |
* DOCUMENT ME!
|
23 |
*
|
24 |
* @author
|
25 |
*/
|
26 |
|
27 |
public class MenuImport3D extends Extension{ |
28 |
|
29 |
|
30 |
private ControlImport3D controlImport;
|
31 |
|
32 |
|
33 |
public void execute(String actionCommand) { |
34 |
int tipoObjeto = 0; |
35 |
|
36 |
if (actionCommand.equals("OBJECT_NO_GIS")) |
37 |
tipoObjeto = 0;
|
38 |
else if( actionCommand.equals("OBJECT_GIS_VECTORIAL") ) |
39 |
tipoObjeto = 1;
|
40 |
|
41 |
|
42 |
|
43 |
View3D vista = (View3D) PluginServices.getMDIManager().getActiveWindow(); |
44 |
|
45 |
this.controlImport = new ControlImport3D(tipoObjeto,vista); |
46 |
|
47 |
PluginServices.getMDIManager().addWindow(controlImport); |
48 |
|
49 |
} |
50 |
|
51 |
public void initialize() { |
52 |
// TODO Auto-generated method stub
|
53 |
|
54 |
} |
55 |
|
56 |
public void postInitialize() { |
57 |
LayerFactory.getDM().addDriver(new File(this.getClass().getResource( |
58 |
"/lib").getFile()),"gvSIG OSG Driver",GvsigDriverOSG.class); |
59 |
|
60 |
// Inicializing the geometry factory 3D
|
61 |
GeometryManager.getInstance().registerGeometryFactory(new GeometryFactory3D());
|
62 |
} |
63 |
|
64 |
|
65 |
public boolean isEnabled() { |
66 |
|
67 |
// com.iver.andami.ui.mdiManager.IWindow f = PluginServices
|
68 |
// .getMDIManager().getActiveWindow();
|
69 |
//
|
70 |
// if (f == null) {
|
71 |
// return false;
|
72 |
// }
|
73 |
//
|
74 |
// // Only isEnable = true, where the view has a view3D.
|
75 |
// if (f instanceof View3D) {
|
76 |
// return true;
|
77 |
// }
|
78 |
// return false;
|
79 |
View3D vista = (View3D) PluginServices.getMDIManager().getActiveWindow(); |
80 |
IProjectView model = vista.getModel(); |
81 |
MapContext mapContext = model.getMapContext(); |
82 |
FLayers layers = mapContext.getLayers(); |
83 |
FLayer[] actives = layers.getActives();
|
84 |
//Layer3DProps props3D = Layer3DProps.getLayer3DProps(actives[0]);
|
85 |
if (actives.length == 1 |
86 |
&& Layer3DProps.getLayer3DProps(actives[0]).getType() == Layer3DProps.layer3DOSG) {
|
87 |
OSGCacheService osgCache = (OSGCacheService) Layer3DProps.getLayer3DProps(actives[0]).getCacheService();
|
88 |
return true; |
89 |
}else
|
90 |
return false; |
91 |
|
92 |
|
93 |
|
94 |
} |
95 |
|
96 |
public boolean isVisible() { |
97 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
98 |
.getMDIManager().getActiveWindow(); |
99 |
|
100 |
if (f == null) { |
101 |
return false; |
102 |
} |
103 |
|
104 |
// Only isVisible = true, where the view has a view3D.
|
105 |
if (f instanceof View3D) { |
106 |
return true; |
107 |
} |
108 |
return false; |
109 |
} |
110 |
} |
111 |
|
112 |
|