Revision 32375 branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/manipulator/Manipulator3DExtension.java

View differences:

Manipulator3DExtension.java
1 1
package org.gvsig.gvsig3dgui.manipulator;
2 2

  
3 3
import java.awt.Component;
4
import java.io.File;
4 5

  
6
import javax.swing.Icon;
7
import javax.swing.ImageIcon;
8

  
5 9
import org.gvsig.gvsig3d.cacheservices.OSGCacheService;
6 10
import org.gvsig.gvsig3d.navigation.NavigationMode;
7 11
import org.gvsig.gvsig3dgui.view.View3D;
8 12
import org.gvsig.osgvp.manipulator.EditionManager;
13
import org.gvsig.osgvp.manipulator.ManipulatorHandler;
9 14
import org.gvsig.osgvp.manipulator.Manipulator.DraggerType;
10
import org.gvsig.symbology.fmap.rendering.ProportionalSymbolsLegend;
11 15

  
12 16
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
13 17
import com.iver.andami.PluginServices;
14 18
import com.iver.andami.plugins.Extension;
19
import com.iver.andami.ui.mdiFrame.JToolBarButton;
15 20
import com.iver.cit.gvsig.fmap.MapContext;
16 21
import com.iver.cit.gvsig.fmap.layers.FLayer;
17 22
import com.iver.cit.gvsig.project.documents.view.IProjectView;
......
20 25

  
21 26
	private NavigationMode navMode;
22 27
	private EditionManager em;
28
	private ManipulatorHandler mh;
29
	private boolean _active = false;
30
	JToolBarButton myButton = null;
31
	Icon iconAct = null;
23 32

  
33
	Icon iconDes = null;
34

  
24 35
	public void execute(String actionCommand) {
25 36

  
26 37
		// Getting view3
......
35 46
		// remove active tool in MapControl
36 47
		boolean resetCursor = true;
37 48

  
38
//		navMode = vista3D.getNavMode();
39
//		navMode.removeAllModes();
49
		// navMode = vista3D.getNavMode();
50
		// navMode.removeAllModes();
40 51

  
41 52
		IProjectView model = vista3D.getModel();
42 53
		MapContext mapa = model.getMapContext();
......
49 60
					.getCacheService();
50 61

  
51 62
			em = osgCacheService.getEditionManager();
63
			mh = osgCacheService.getManipulatorHandler();
64

  
52 65
			if (actionCommand.equals("ROTATION_MANIPULATOR")) {
53
//				em.changeDragger(DraggerType.ROTATE_SPHERE_DRAGGER);
66
				// em.changeDragger(DraggerType.ROTATE_SPHERE_DRAGGER);
54 67
				em.changeDragger(DraggerType.TABBOX_DRAGGER);
55 68
			} else if (actionCommand.equals("TABBOX_MANIPULATOR")) {
56 69
				em.changeDragger(DraggerType.TRACKBALL_DRAGGER);
57
			} 
70
			} else if (actionCommand.equals("ENABLE_MANIPULATOR")) {
71

  
72
				JToolBarButton b = (JToolBarButton) PluginServices
73
						.getMainFrame().getComponentByName("ENABLE_MANIP");
74

  
75
				if (_active) {
76

  
77
					osgCacheService.disableEditionListener();
78
					b.setIcon(iconAct);
79

  
80
				} else {
81

  
82
					osgCacheService.enableEditionListener();
83
					b.setIcon(iconDes);
84

  
85
				}
86

  
87
				_active = !_active;
88

  
89
			}
58 90
		}
59 91

  
60 92
	}
61 93

  
62 94
	public void initialize() {
63 95
		// TODO Auto-generated method stub
64
		
65
		//Registering icons.
96

  
97
		// Registering icons.
66 98
		PluginServices.getIconTheme().registerDefault(
67 99
				"tabbox_manipulator",
68 100
				this.getClass().getClassLoader().getResource(
69
				"images/rotation_manipulator.png"));
70
		
101
						"images/rotation_manipulator.png"));
102

  
71 103
		PluginServices.getIconTheme().registerDefault(
72 104
				"rotation_manipulator",
73 105
				this.getClass().getClassLoader().getResource(
74
				"images/tabbox_manipulator.gif"));
106
						"images/tabbox_manipulator.gif"));
75 107

  
108
		PluginServices.getIconTheme().registerDefault(
109
				"enable_manipulator",
110
				this.getClass().getClassLoader()
111
						.getResource("images/pick2.png"));
112

  
76 113
	}
77 114

  
78
	public boolean isEnabled() {
115
	public boolean osgLayerActive() {
116

  
79 117
		boolean result = false;
80 118
		// Getting view3
81 119
		com.iver.andami.ui.mdiManager.IWindow view = PluginServices
82
		.getMDIManager().getActiveWindow();
83
		if ((view instanceof View3D)){
120
				.getMDIManager().getActiveWindow();
121
		if ((view instanceof View3D)) {
84 122
			// Casting to View3D
85 123
			View3D vista3D = (View3D) view;
86
			
124

  
87 125
			IProjectView model = vista3D.getModel();
88 126
			MapContext mapa = model.getMapContext();
89 127
			FLayer[] activeLayers = mapa.getLayers().getActives();
90 128
			if (activeLayers.length > 0) {
91 129
				FLayer layer = activeLayers[0];
92 130
				Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer);
93
				if (props3D != null&&props3D.getType() == Layer3DProps.layer3DOSG){
131
				if (props3D != null
132
						&& props3D.getType() == Layer3DProps.layer3DOSG) {
94 133
					result = true;
95 134
				}
96 135
			}
97 136
		}
137

  
98 138
		return result;
139

  
99 140
	}
100 141

  
142
	public boolean isEnabled() {
143

  
144
		return osgLayerActive();
145
	}
146

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

  
149
		return osgLayerActive();
124 150
	}
125 151

  
152
	public void postInitialize() {
153

  
154
		File file = new File(this.getClass().getClassLoader().getResource(
155
				"images").getFile());
156
		String path1 = file.getPath() + "/pick2.png";
157
		String path2 = file.getPath() + "/nopick2.png";
158

  
159
		iconAct = new ImageIcon(path1);
160
		iconDes = new ImageIcon(path2);
161

  
162
	}
163

  
126 164
}

Also available in: Unified diff