Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / manipulator / Manipulator3DExtension.java @ 29938

History | View | Annotate | Download (3.55 KB)

1
package org.gvsig.gvsig3dgui.manipulator;
2

    
3
import java.awt.Component;
4

    
5
import org.gvsig.andami.PluginServices;
6
import org.gvsig.andami.plugins.Extension;
7
import org.gvsig.andami.ui.mdiManager.IWindow;
8
import org.gvsig.app.project.documents.view.IProjectView;
9
import org.gvsig.fmap.mapcontext.MapContext;
10
import org.gvsig.fmap.mapcontext.layers.FLayer;
11
import org.gvsig.gvsig3d.cacheservices.OSGCacheService;
12
import org.gvsig.gvsig3d.navigation.NavigationMode;
13
import org.gvsig.gvsig3dgui.view.View3D;
14
import org.gvsig.osgvp.manipulator.EditionManager;
15
import org.gvsig.osgvp.manipulator.Manipulator.DraggerType;
16

    
17
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
18

    
19
public class Manipulator3DExtension extends Extension {
20

    
21
        private NavigationMode navMode;
22
        private EditionManager em;
23

    
24
        public void execute(String actionCommand) {
25

    
26
                // Getting view3
27
                IWindow view = PluginServices
28
                                .getMDIManager().getActiveWindow();
29
                if (!(view instanceof View3D))
30
                        return;
31
                // Casting to View3D
32
                View3D vista3D = (View3D) view;
33
                Component viewer = (Component) vista3D.getCanvas3d();
34

    
35
                // remove active tool in MapControl
36
                boolean resetCursor = true;
37

    
38

    
39
                IProjectView model = vista3D.getModel();
40
                MapContext mapa = model.getMapContext();
41
                FLayer[] activeLayers = mapa.getLayers().getActives();
42
                if (activeLayers.length > 0) {
43
                        FLayer layer = activeLayers[0];
44

    
45
                        Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer);
46
                        OSGCacheService osgCacheService = (OSGCacheService) props3D
47
                                        .getCacheService();
48

    
49
                        em = osgCacheService.getEditionManager();
50
                        if (actionCommand.equals("ROTATION_MANIPULATOR")) {
51
                                em.changeDragger(DraggerType.TABBOX_DRAGGER);
52
                        } else if (actionCommand.equals("TABBOX_MANIPULATOR")) {
53
                                em.changeDragger(DraggerType.TRACKBALL_DRAGGER);
54
                        } 
55
                }
56

    
57
        }
58

    
59
        public void initialize() {
60
                // TODO Auto-generated method stub
61
                
62
                //Registering icons.
63
                PluginServices.getIconTheme().registerDefault(
64
                                "tabbox_manipulator",
65
                                this.getClass().getClassLoader().getResource(
66
                                "images/rotation_manipulator.png"));
67
                
68
                PluginServices.getIconTheme().registerDefault(
69
                                "rotation_manipulator",
70
                                this.getClass().getClassLoader().getResource(
71
                                "images/tabbox_manipulator.gif"));
72

    
73
        }
74

    
75
        public boolean isEnabled() {
76
                boolean result = false;
77
                // Getting view3
78
                IWindow view = PluginServices
79
                .getMDIManager().getActiveWindow();
80
                if ((view instanceof View3D)){
81
                        // Casting to View3D
82
                        View3D vista3D = (View3D) view;
83
                        
84
                        IProjectView model = vista3D.getModel();
85
                        MapContext mapa = model.getMapContext();
86
                        FLayer[] activeLayers = mapa.getLayers().getActives();
87
                        if (activeLayers.length > 0) {
88
                                FLayer layer = activeLayers[0];
89
                                Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer);
90
                                if (props3D.getType() == Layer3DProps.layer3DOSG){
91
                                        result = true;
92
                                }
93
                        }
94
                }
95
                return result;
96
        }
97

    
98
        public boolean isVisible() {
99
                // Getting view3
100
                boolean result = false;
101
                // Getting view3
102
                IWindow view = PluginServices
103
                .getMDIManager().getActiveWindow();
104
                if ((view instanceof View3D)){
105
                        // Casting to View3D
106
                        View3D vista3D = (View3D) view;
107
                        
108
                        IProjectView model = vista3D.getModel();
109
                        MapContext mapa = model.getMapContext();
110
                        FLayer[] activeLayers = mapa.getLayers().getActives();
111
                        if (activeLayers.length > 0) {
112
                                FLayer layer = activeLayers[0];
113
                                Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer);
114
                                if (props3D.getType() == Layer3DProps.layer3DOSG){
115
                                        result = true;
116
                                }
117
                        }
118
                }
119
                return result;
120
        }
121

    
122
}