Revision 32375

View differences:

branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/build.number
1
build.number=13
1
build.number=14
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/layer/properties/VectorialLayerListener3D.java
17 17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18 18
 */
19 19

  
20

  
21

  
22 20
package org.gvsig.gvsig3dgui.layer.properties;
23 21

  
24 22
import java.awt.geom.Rectangle2D;
......
35 33
import com.iver.cit.gvsig.fmap.layers.FLayer;
36 34

  
37 35
/**
38
* 
39
* @version 
40
* @author �ngel Fraile Gri��n.(angel.fraile@iver.es)
41
*/
36
 * 
37
 * @version
38
 * @author �ngel Fraile Gri��n.(angel.fraile@iver.es)
39
 */
42 40

  
43 41
public class VectorialLayerListener3D {
44 42

  
......
46 44
	private Layer3DProps props3D;
47 45
	private MapContext3D context;
48 46
	private FLayer flyr;
49
	private static Logger logger = Logger.getLogger(VectorialLayerListener3D.class
50
			.getName());
51
	
47
	private static Logger logger = Logger
48
			.getLogger(VectorialLayerListener3D.class.getName());
49

  
52 50
	public VectorialLayerListener3D(VectorialLayerPanel3D panel) {
53 51
		this.vectorialLayerPanel3D = panel;
54 52
	}
55
	
53

  
56 54
	/**
57 55
	 * Actions to execute when the accept option is pressed
58 56
	 */
59 57
	public void accept() {
60
		
58

  
61 59
		context = vectorialLayerPanel3D.getMapContext();
62 60
		props3D = vectorialLayerPanel3D.getLayer3DProps();
63 61
		flyr = vectorialLayerPanel3D.getLayer();
64
		
65
		//Rastering the layer
66
		if (vectorialLayerPanel3D.isRasterOptionSelected() && (props3D.getType()!=Layer3DProps.layer3DImage)) {
62

  
63
		// Rastering the layer
64
		if (vectorialLayerPanel3D.isRasterOptionSelected()
65
				&& (props3D.getType() != Layer3DProps.layer3DImage)) {
67 66
			context.removeLayerToTerrain(flyr);
68 67
			props3D.setType(Layer3DProps.layer3DImage);
69 68
			props3D.setCacheService(null);
70 69
			context.addLayerToTerrain(flyr, true);
71
		} else if ((!vectorialLayerPanel3D.isZValueSelected())&&(!vectorialLayerPanel3D.isRasterOptionSelected())) {
72
					int new_h = 0;
73
					int actual_h = 0;
74
					
75
					try {
76
						actual_h = (int)Double.parseDouble(vectorialLayerPanel3D.getMyHeight());
77
						new_h = (int)Double.parseDouble(vectorialLayerPanel3D.getJTextFieldHeight());
78
					} catch (NumberFormatException e) {
79
						logger.error("Command: "
80
								+ "Error getting maximun range layer elevation value.", e);
81
					}
82
					
83
					if ((new_h >= 0 && new_h!= actual_h) || (actual_h == vectorialLayerPanel3D.getDefaultElevation()) ) //aplicando una altura distinta, si es la misma no se hace nada
84
					{
85
						context.removeLayerToTerrain(flyr);
86
						props3D.setZEnable(false);
87
						props3D.setType(Layer3DProps.layer3DVector);
88
						props3D.setCacheService(null);
89
						props3D.setHeigth(new_h);
90
						context.addLayerToTerrain(flyr, true);
91
					}//if
92
			//else if		
93
			} else if(vectorialLayerPanel3D.isZValueSelected() && props3D.getType()!= Layer3DProps.layer3DVector){//Value Z associated to the layer
70
		} else if ((!vectorialLayerPanel3D.isZValueSelected())
71
				&& (!vectorialLayerPanel3D.isRasterOptionSelected())) {
72
			int new_h = 0;
73
			int actual_h = 0;
74

  
75
			try {
76
				actual_h = (int) Double.parseDouble(vectorialLayerPanel3D
77
						.getMyHeight());
78
				new_h = (int) Double.parseDouble(vectorialLayerPanel3D
79
						.getJTextFieldHeight());
80
			} catch (NumberFormatException e) {
81
				logger.error("Command: "
82
						+ "Error getting maximun range layer elevation value.",
83
						e);
84
			}
85

  
86
			if ((new_h >= 0 && new_h != actual_h)
87
					|| (actual_h == vectorialLayerPanel3D.getDefaultElevation())) // aplicando
88
																					// una
89
																					// altura
90
																					// distinta,
91
																					// si
92
																					// es
93
																					// la
94
																					// misma
95
																					// no
96
																					// se
97
																					// hace
98
																					// nada
99
			{
94 100
				context.removeLayerToTerrain(flyr);
101
				props3D.setZEnable(false);
95 102
				props3D.setType(Layer3DProps.layer3DVector);
96 103
				props3D.setCacheService(null);
97
				props3D.setZEnable(true);
98
				context.addLayerToTerrain(flyr,true);
99
				
100
			}//else 
101
				
102
			if(vectorialLayerPanel3D.isDetailOptionSelected()) {
103
				Extent planetExtent = null;
104
				Rectangle2D extentLayer = null;
105
				
106
				try {
107
					planetExtent = context.getTerrain().getExtent();
108
					extentLayer = flyr.getFullExtent();
109
				} catch (ExpansionFileReadException e) {
110
					e.printStackTrace();
111
				} catch (ReadDriverException e) {
112
					e.printStackTrace();
113
				}
114
				double extPW = planetExtent.xMax() - planetExtent.xMin(); // planet width 
115
				double extPH = planetExtent.yMax() - planetExtent.yMin();// planet hight
116
				double extW = extentLayer.getWidth();	// layer width
117
				double extH = extentLayer.getHeight();	// layer hight
118
				int depth = 0;
119
				
120
				while(extPW > extW && extPH > extH) {// Calculating level of depth (div x /(2 pow n))
121
					
122
					extPW = extPW/2;
123
					extPH = extPH/2;
124
					
125
					depth++;//level of depth
126
				}//while
127
				
104
				props3D.setHeigth(new_h);
105
				context.addLayerToTerrain(flyr, true);
106
			}// if
107
			// else if
108
		} else if (vectorialLayerPanel3D.isZValueSelected()
109
				/*&& props3D.getType() != Layer3DProps.layer3DVector*/) {// Value Z
110
																		// associated
111
																		// to
112
																		// the
113
																		// layer
114
			context.removeLayerToTerrain(flyr);
115
			props3D.setType(Layer3DProps.layer3DVector);
116
			props3D.setCacheService(null);
117
			props3D.setZEnable(true);
118
			context.addLayerToTerrain(flyr, true);
119

  
120
		}// else
121

  
122
		if (vectorialLayerPanel3D.isDetailOptionSelected()) {
123
			Extent planetExtent = null;
124
			Rectangle2D extentLayer = null;
125

  
126
			try {
127
				planetExtent = context.getTerrain().getExtent();
128
				extentLayer = flyr.getFullExtent();
129
			} catch (ExpansionFileReadException e) {
130
				e.printStackTrace();
131
			} catch (ReadDriverException e) {
132
				e.printStackTrace();
133
			}
134
			double extPW = planetExtent.xMax() - planetExtent.xMin(); // planet
135
																		// width
136
			double extPH = planetExtent.yMax() - planetExtent.yMin();// planet
137
																		// hight
138
			double extW = extentLayer.getWidth(); // layer width
139
			double extH = extentLayer.getHeight(); // layer hight
140
			int depth = 0;
141

  
142
			while (extPW > extW && extPH > extH) {// Calculating level of depth
143
													// (div x /(2 pow n))
144

  
145
				extPW = extPW / 2;
146
				extPH = extPH / 2;
147

  
148
				depth++;// level of depth
149
			}// while
150

  
151
			Layer layer = props3D.getTerrainLayer();
152
			if (layer != null) {
153
				layer.setMaxResolution(depth);
154
				context.getLayerManager().updateLayers();
155
			}
156
		}// if
157
		else {
158
			Layer layer = props3D.getTerrainLayer();
159
			if (layer != null) {
160
				layer.setMaxResolution(vectorialLayerPanel3D.getDefaultDepth());
161
				context.getLayerManager().updateLayers();
162
			}
163
		}
164

  
165
		if (vectorialLayerPanel3D.isRangeOptionSelected()) {
166

  
167
			int new_max = 0;
168
			int new_min = 0;
169

  
170
			try {
171
				new_max = (int) Double.parseDouble(vectorialLayerPanel3D
172
						.getJTextFieldRangeMax());
173
				new_min = (int) Double.parseDouble(vectorialLayerPanel3D
174
						.getJTextFieldRangeMin());
175
			} catch (NumberFormatException e) {
176
				logger.error("Command: " + "Number format must be a integer.",
177
						e);
178
			}
179

  
180
			if ((new_min > vectorialLayerPanel3D.getDefaultMinRange() || new_max < vectorialLayerPanel3D
181
					.getDefaultMaxRange())) // aplicando una altura distinta, si
182
											// es la misma no se hace nada
183
			{
128 184
				Layer layer = props3D.getTerrainLayer();
129
				if(layer != null) {
130
					layer.setMaxResolution(depth);
185
				if (layer != null) {
186
					layer.setMaxLevel(new_max);
187
					layer.setMinLevel(new_min);
131 188
					context.getLayerManager().updateLayers();
132 189
				}
133
 			}//if
134
			else {
135
				Layer layer = props3D.getTerrainLayer();
136
				if(layer != null) {
137
					layer.setMaxResolution(vectorialLayerPanel3D.getDefaultDepth());
138
					context.getLayerManager().updateLayers();
139
				}
140
			}	
141
			
142
			if(vectorialLayerPanel3D.isRangeOptionSelected()) {
143
				
144
				int new_max = 0;
145
				int new_min = 0;
146
				
147
				try {
148
					new_max = (int)Double.parseDouble(vectorialLayerPanel3D.getJTextFieldRangeMax());
149
					new_min = (int)Double.parseDouble(vectorialLayerPanel3D.getJTextFieldRangeMin());
150
				} catch (NumberFormatException e) {
151
					logger.error("Command: "
152
							+ "Number format must be a integer.", e);
153
				}
154
				
155
				if ((new_min > vectorialLayerPanel3D.getDefaultMinRange() || new_max < vectorialLayerPanel3D.getDefaultMaxRange())) //aplicando una altura distinta, si es la misma no se hace nada
156
				{
157
					Layer layer = props3D.getTerrainLayer();
158
					if(layer != null) {
159
						layer.setMaxLevel(new_max);
160
						layer.setMinLevel(new_min);
161
						context.getLayerManager().updateLayers();
162
					}
163
				}//if
164
				
165
			}//if
166
			else {
167
				Layer layer = props3D.getTerrainLayer();
168
				if(layer != null) {
169
					layer.setMaxLevel(vectorialLayerPanel3D.getDefaultMaxRange());
170
					layer.setMinLevel(vectorialLayerPanel3D.getDefaultMinRange());
171
					context.getLayerManager().updateLayers();
172
				}
173
			}//else
174
				
190
			}// if
191

  
192
		}// if
193
		else {
194
			Layer layer = props3D.getTerrainLayer();
195
			if (layer != null) {
196
				layer.setMaxLevel(vectorialLayerPanel3D.getDefaultMaxRange());
197
				layer.setMinLevel(vectorialLayerPanel3D.getDefaultMinRange());
198
				context.getLayerManager().updateLayers();
199
			}
200
		}// elseisZValueSelected
201

  
175 202
	}
176 203

  
177 204
	/**
178 205
	 * Actions to execute when the apply option is pressed
179 206
	 */
180
	
207

  
181 208
	public void apply() {
182
		
209

  
183 210
		accept();
184 211
	}
185 212

  
......
187 214
	 * Actions to execute when the cancel option is pressed
188 215
	 */
189 216
	public void cancel() {
190
		
217

  
191 218
	}
192
	
219

  
193 220
}
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/manipulator/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
}
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/import3D/ControlImport3D.java
366 366
					PluginServices.getText(this,"editable_layer_select"), JOptionPane.WARNING_MESSAGE);
367 367
			return;
368 368
		}
369
		
370
		_view3D.getCanvas3d().removeMouseListener(this);
369 371
		PluginServices.getMDIManager().closeWindow(this);
370 372
	}
371 373

  
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/config/text.properties
39 39
Elevacion=Elevaci\u00F3n
40 40
Elevation_layer_question=\u00BFDesea usar esta capa como elevaci\u00F3n (Si/No)?
41 41
enable_3d_edition=Activar edici\u00F3n 3D
42
enable_manipulator=Activar modo de edici\u00F3n
42 43
EscaladoX=EscaladoX\:
43 44
EscaladoY=EscaladoY\:
44 45
EscaladoZ=EscaladoZ\:
......
50 51
File=Fichero
51 52
Flat=Plana
52 53
FullScreen=Pantalla Completa
54
geometry_not_supported=Geometr\u00EDa no soportada
53 55
GL=No
54 56
HeadMounted=Casco Visor
55 57
Heigth_layer_question=Altura de los vectores (en metros)
......
154 156
X=X
155 157
Y=Y
156 158
Zoom_Navigation=Zoom
159
>>>>>>> .r32373
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/config/about.htm
16 16
  </tr>
17 17
</table>
18 18
  <h2>Plugin 3D para gvSIG</h2>	
19
		<p><b>Iver T.I y AI2</b> ha a?adido la <b>Extensi&oacute;n 3D</b>
19
		<p><b>Iver T.I y AI2</b> ha aadido la <b>Extensi&oacute;n 3D</b>
20 20
		 a GvSIG.</p>
21 21
		
22 22
		<p><b>Desarrollo:</b></p>
......
35 35
			<li>Angel Fraile,</li>
36 36
			<li>Jes&uacute;s Zarzoso</li>
37 37
		</ul>
38
  <p><b> Build Number: 6</b></p>
38
  <p><b> Build Number: 14</b></p>
39 39
  </body>
40 40
</html>
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/config/text_en.properties
39 39
Elevacion=Elevation
40 40
Elevation_layer_question=Use this layer as elevation layer(Yes/No)?
41 41
enable_3d_edition=Enable 3D edition
42
enable_manipulator=Enable edition mode
42 43
EscaladoX=ScaleX\:
43 44
EscaladoY=ScaleY\:
44 45
EscaladoZ=ScaleZ\:
......
50 51
File=File
51 52
Flat=Flat
52 53
FullScreen=Full screen
54
geometry_not_supported=Geometry not supported
53 55
GL=No
54 56
HeadMounted=Head mounted display
55 57
Heigth_layer_question=Vector height (in meters)
branches/gvSIG_19_ext3D_osgVP_2_2_0/extensions/ext3Dgui/config/config.xml
227 227
			description="Extensi?n encargada de la manipulaci?n de geometrias 3D."
228 228
			active="true" priority="40">
229 229
			<tool-bar name="Editing_tools" position="7">
230
				<selectable-tool icon="rotation_manipulator"
231
					action-command="ROTATION_MANIPULATOR" tooltip="rotation_manipulator"
230
				<action-tool icon="enable_manipulator" name="ENABLE_MANIP" 
231
					action-command="ENABLE_MANIPULATOR" tooltip="enable_manipulator"
232 232
					position="1" />
233
				<selectable-tool icon="tabbox_manipulator"
234
					action-command="TABBOX_MANIPULATOR" tooltip="tabbox_manipulator"
233
				<selectable-tool icon="rotation_manipulator" name="ROT_MANIP"
234
					action-command="ROTATION_MANIPULATOR" tooltip="rotation_manipulator"
235 235
					position="2" />
236
				<!--
237
					<selectable-tool icon="scale_manipulator"
238
					action-command="SCALE_MANIPULATOR" tooltip="scale_manipulator"
239
					position="3"/>
240
				-->
236
				<selectable-tool icon="tabbox_manipulator" name="TAB_MANIP"
237
					action-command="TABBOX_MANIPULATOR" tooltip="tabbox_manipulator"
238
					position="3" />
239
				
241 240
			</tool-bar>
242 241
		</extension>
243 242
		<extension class-name="org.gvsig.gvsig3dgui.AboutExtension3D"

Also available in: Unified diff