Statistics
| Revision:

root / trunk / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / import3D / CreateNewLayerOSG.java @ 22628

History | View | Annotate | Download (2.36 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

    
16
public class CreateNewLayerOSG extends Extension  {
17
        private FLyrVect layerOSG;
18

    
19
        public void execute(String actionCommand) {
20
                
21
                if (actionCommand.equals("CREARCAPA")) {
22
                        com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices
23
                        .getMDIManager().getActiveWindow();
24

    
25
                        
26
                        if (activeWindow instanceof View3D) {
27
                                GvsigDriverOSG d = new GvsigDriverOSG();
28
                                VectorialAdapter adapter = new VectorialDefaultAdapter();
29
                                adapter.setDriver(d);
30
                                
31
                                layerOSG = new FLyrVect();
32
                                View3D vista = (View3D) PluginServices.getMDIManager().getActiveWindow();
33
                                IProjectView model = vista.getModel();
34
                                
35
                                MapContext3D mapa = (MapContext3D) model.getMapContext();
36
                                layerOSG.setName("defaultLayerOSG");
37
                                layerOSG.setSource(adapter);
38
                                
39
                                // add 3D properties, mainly to keep track of hooked state
40
                                Layer3DProps props3D = new Layer3DProps();
41
                                props3D.setLayer(layerOSG);
42
                                props3D.setNewLayerOSG(true);
43
                                props3D.setType(Layer3DProps.layer3DOSG);
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
                
54
        }
55

    
56
        public boolean isEnabled() {
57
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices
58
                .getMDIManager().getActiveWindow();
59

    
60
                if (f == null) {
61
                        return false;
62
                }
63
                
64
                // Only isVisible = true, where the view has a view3D.
65
                if (f instanceof View3D) {
66
                        return true;
67
                }
68
                return false;
69
                
70
        }
71

    
72
        public boolean isVisible() {
73
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices
74
                .getMDIManager().getActiveWindow();
75

    
76
                if (f == null) {
77
                        return false;
78
                }
79
                
80
                // Only isVisible = true, where the view has a view3D.
81
                if (f instanceof View3D) {
82
                        return true;
83
                }
84
                return false;
85
                
86
        }
87

    
88
}
89