Revision 237

View differences:

2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/resources/config.xml
8 8
			description=""
9 9
			active="true"
10 10
			priority="1">
11
		</extension>		
11
		</extension>	
12
		<extension class-name="org.gvsig.gvsig3d.app.extension.AboutExtension3D"
13
			description="Extension to add about panel." 
14
			active="true" 
15
			priority="1">
16
		</extension>	
12 17
	</extensions>
13 18
</plugin-config>
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/resources/about.htm
1
<html>
2
  <head>
3
    <title>Extension 3D del programa GvSIG </title>
4
    <meta content="">
5
    <style></style>
6
  </head>
7
  <body>
8
<table width="60%" border="0">
9
  <tr>
10
    <td width="50%"><div align="right"><img src="images/logoIver.png" width="87" height="50"></div></td>
11
    <td width="50%"><img src="logo_ai2.jpg"></td>
12
  </tr>
13
  <tr>
14
    <td colspan="2"><font face="Arial, Helvetica, sans-serif">&copy; Copyright
15
      Generalitat Valenciana, IVER T.I and other contributors 2008.</font></td>
16
  </tr>
17
</table>
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>
20
		 a GvSIG.</p>
21
		
22
		<p><b>Desarrollo:</b></p>
23
		
24
		<p>Directores del proyecto:</p>
25
		<ul>
26
			<li>Salvador Bayarri</li>
27
			<li>Javier Lluch</li>
28
		</ul>
29
		<p>Equipo de desarrollo:</p>
30
		<ul>
31
			<li>Rafael Gait&aacute;n,</li>
32
			<li>Julio Campos,</li>
33
			<li>Jordi Torres,</li>
34
			<li>Mar&iacute;a Ten,</li>
35
			<li>Angel Fraile,</li>
36
			<li>Jes&uacute;s Zarzoso</li>
37
		</ul>
38
  <p><b> Build Number: 14</b></p>
39
  </body>
40
</html>
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/java/org/gvsig/gvsig3d/app/extension/Gvsig3DExtension.java
47 47

  
48 48
    @Override
49 49
    public void postInitialize() {
50
        // super.postInitialize();
50
         //super.postInitialize();
51 51
        // manager = Gvsig3DLocator.getManager();
52 52
        // // Asignamos el locator e iniciamos la instancia
53 53
        // swingManager = Gvsig3DSwingLocator.getSwingManager();
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/java/org/gvsig/gvsig3d/app/extension/DefaultView3DDocument.java
21 21
 */
22 22
package org.gvsig.gvsig3d.app.extension;
23 23

  
24
import java.awt.Color;
25
import java.util.prefs.Preferences;
26

  
24 27
import org.gvsig.app.ApplicationLocator;
25 28
import org.gvsig.app.project.ProjectPreferences;
26 29
import org.gvsig.app.project.documents.DocumentManager;
27 30
import org.gvsig.app.project.documents.view.BaseViewDocument;
28 31
import org.gvsig.fmap.mapcontext.MapContext;
29 32
import org.gvsig.fmap.mapcontext.ViewPort;
33
import org.gvsig.gvsig3d.Gvsig3DException;
34
import org.gvsig.gvsig3d.Gvsig3DLocator;
35
import org.gvsig.gvsig3d.map3d.MapContext3D;
36
import org.gvsig.osgvp.exceptions.node.NodeException;
37
import org.gvsig.osgvp.terrain.Extent;
38
import org.gvsig.osgvp.terrain.JavaDataDriver;
39
import org.gvsig.osgvp.terrain.LayerManager;
40
import org.gvsig.osgvp.terrain.Terrain;
41
import org.gvsig.osgvp.terrain.TerrainViewer;
42
import org.gvsig.osgvp.viewer.Camera;
43
import org.gvsig.osgvp.viewer.CanvasViewer;
44
import org.gvsig.osgvp.viewer.IViewerContainer;
45
import org.gvsig.osgvp.viewer.ViewerFactory;
46
import org.gvsig.osgvp.viewer.ViewerStateListener;
47
import org.gvsig.tools.locator.LocatorException;
30 48
import org.gvsig.tools.persistence.PersistentState;
31 49
import org.gvsig.tools.persistence.exception.PersistenceException;
50
import org.slf4j.Logger;
51
import org.slf4j.LoggerFactory;
32 52

  
33 53
/**
34 54
 * @author gvSIG Team
......
37 57
 */
38 58
public class DefaultView3DDocument extends BaseViewDocument {
39 59

  
40
    private static final long serialVersionUID = 676711512482344764L;
60
	private static final long serialVersionUID = 676711512482344764L;
41 61

  
42
    public static final String PERSISTENCE_DEFINITION_NAME =
43
        "DefaultView3DDocument";
62
	public static final String PERSISTENCE_DEFINITION_NAME = "DefaultView3DDocument";
44 63

  
45
    public DefaultView3DDocument() {
46
        this(null);
47
    }
64
	private IViewerContainer _canvas3d = null;
65
	private TerrainViewer _terrainViewer = null;
66
	private Terrain _terrain = null;
67
	// private ProjectCamera _projectCamera = null;
68
	private JavaDataDriver _terrainDataManager = null;
69
	private LayerManager _terrainLayerManager = null;
70
	private int _terrainType = Terrain.CoordinateSystemType.PROJECTED; // spheric
71
	// or
72
	// plane
73
	private Color _backgroundColor;
74
	private float _verticalExaggeration = 1;
75
	private DefaultView3DPanel _view = null;
76
	private static Preferences _prefs = Preferences.userRoot().node(
77
			"gvsig.configuration.3D");
78
	private boolean _prespectiveMode = true;
79
	private static Logger _logger = LoggerFactory
80
			.getLogger(DefaultView3DDocument.class.getName());
48 81

  
49
    public DefaultView3DDocument(DocumentManager factory) {
50
        super(factory);
82
	public DefaultView3DDocument() {
83
		this(null);
84
	}
51 85

  
52
        ProjectPreferences preferences =
53
            (ProjectPreferences) ApplicationLocator.getManager()
54
                .getPreferences("project");
55
        MapContext viewMapContext =
56
            new MapContext(new ViewPort(preferences.getDefaultProjection()));
57
        this.setMapContext(viewMapContext);
86
	public DefaultView3DDocument(DocumentManager factory) {
87
		super(factory);
58 88

  
59
    }
89
		ProjectPreferences preferences = (ProjectPreferences) ApplicationLocator
90
				.getManager().getPreferences("project");
91
		MapContext3D viewMapContext;
92
		ViewPort vp = new ViewPort();
93
		try {
94
			viewMapContext = Gvsig3DLocator.getManager()
95
					.createDefaultMapContext3DInstance(vp);
96
			this.setMapContext(viewMapContext);
97
		} catch (LocatorException e) {
98
			// TODO Auto-generated catch block
99
			e.printStackTrace();
100
		}
60 101

  
61
    public void saveToState(PersistentState state) throws PersistenceException {
62
        super.saveToState(state);
63
    }
102
	}
64 103

  
65
    public void loadFromState(PersistentState state)
66
        throws PersistenceException {
67
        super.loadFromState(state);
68
    }
104
	public void saveToState(PersistentState state) throws PersistenceException {
105
		super.saveToState(state);
106
	}
69 107

  
70
    public String exportDocumentAsText() {
71
        // FIXME: jjdc PersistentManager getStateAsText o similar
72
        // PersistenceManager manager = ToolsLocator.getPersistenceManager();
73
        // PersistentState state = manager.getState(this);
74
        // return manager.getStateAsText(state);
75
        return null;
76
    }
108
	public void loadFromState(PersistentState state)
109
			throws PersistenceException {
110
		super.loadFromState(state);
111
	}
77 112

  
78
    public void setStateFromText(String text) {
79
        // FIXME: jjdc PersistentManager getStateFromText o similar
80
        // PersistenceManager manager = ToolsLocator.getPersistenceManager();
81
        // PersistentState state = manager.getStateFromText(text);
82
        // this.loadFromState(state);
83
    }
113
	public String exportDocumentAsText() {
114
		// FIXME: jjdc PersistentManager getStateAsText o similar
115
		// PersistenceManager manager = ToolsLocator.getPersistenceManager();
116
		// PersistentState state = manager.getState(this);
117
		// return manager.getStateAsText(state);
118
		return null;
119
	}
84 120

  
121
	public void setStateFromText(String text) {
122
		// FIXME: jjdc PersistentManager getStateFromText o similar
123
		// PersistenceManager manager = ToolsLocator.getPersistenceManager();
124
		// PersistentState state = manager.getStateFromText(text);
125
		// this.loadFromState(state);
126
	}
127

  
128
	public int getTerrainType() {
129
		return _terrainType;
130
	}
131

  
132
	public void setTerrainType(int type) {
133
		_terrainType = type;
134
	}
135

  
136
	public float getVerticalExaggeration() {
137
		return _verticalExaggeration;
138
	}
139

  
140
	public void setVerticalExaggeration(float exaggeration) {
141
		_verticalExaggeration = exaggeration;
142
	}
143

  
144
	public Color getBackGroundColor() {
145
		return _backgroundColor;
146
	}
147

  
148
	public void setBackGroundColor(Color backGroundColor) {
149
		_backgroundColor = backGroundColor;
150
		if ((_backgroundColor != null) && (_terrainViewer != null)) {
151
			float r, g, b, a;
152
			r = ((float) _backgroundColor.getRed()) / 255.0f;
153
			g = ((float) _backgroundColor.getGreen()) / 255.0f;
154
			b = ((float) _backgroundColor.getBlue()) / 255.0f;
155
			a = ((float) _backgroundColor.getAlpha()) / 255.0f;
156

  
157
			_terrainViewer.setClearColor(r, g, b, a);
158
		}
159
	}
160

  
161
	public Terrain getTerrain() {
162
		return _terrain;
163
	}
164

  
165
	public void setTerrain(Terrain terrain) {
166
		_terrain = terrain;
167
	}
168

  
169
	public IViewerContainer getCanvas3d() {
170
		return _canvas3d;
171
	}
172

  
173
	public void setCanvas3d(CanvasViewer canvas3d) {
174
		_canvas3d = canvas3d;
175
	}
176

  
177
	// private void setVerticalEx(float exa) {
178
	//
179
	// SingleLayerIterator lyrIterator = new SingleLayerIterator(
180
	// (FLayers3D) getMapContext().getLayers());
181
	// while (lyrIterator.hasNext()) {
182
	// FLayer lyr = lyrIterator.next();
183
	//
184
	// Layer3DProps props = Layer3DProps.getLayer3DProps(lyr);
185
	// int type = props.getType();
186
	// if (exa != props.getVerticalEx()) {
187
	// if (type == Layer3DProps.layer3DElevation) {
188
	// props.setVerticalEx(exa);
189
	// HeightfieldLayer layer = (HeightfieldLayer)props.getTerrainLayer();
190
	// if(layer == null) return;
191
	// layer.setVerticalExaggeration(exa);
192
	// _view.getTerrain().getLayerManager().updateLayers();
193
	// } else if (type == Layer3DProps.layer3DVector) {
194
	// props.setVerticalEx(exa);
195
	// }
196
	// }
197
	//
198
	// }
199
	// }
200

  
201
	public boolean isPrespectiveModeActive() {
202
		return _prespectiveMode;
203
	}
204

  
205
	/**
206
	 * Active the prespective mode. If we disable the prespective mode, the
207
	 * ortho mode will be active
208
	 * 
209
	 * @param prespectiveMode
210
	 *            enable/disable
211
	 */
212
	public void setActivePrespectiveMode(boolean prespectiveMode) {
213
		_prespectiveMode = prespectiveMode;
214
	}
215

  
216
	private void configureProjectionViewMode() {
217
		if (_prespectiveMode) {
218
			System.out.println("Setting up prespective projection");
219
			// this.m_canvas3d.getOSGViewer().setProjectionMatrixAsPerspective(
220
			// arg0, arg1, arg2, arg3);
221
		} else {
222
			System.out.println("Setting up prespective projection");
223
			this._canvas3d.getOSGViewer().setProjectionMatrixAsOrtho(-10, 10,
224
					-10, 10, 1, 1000);
225
		}
226
	}
227

  
228
	public DefaultView3DPanel getView() {
229
		return _view;
230
	}
231

  
232
	public void setView(DefaultView3DPanel view) {
233
		_view = view;
234
	}
235

  
236
	public IViewerContainer getOrCreateCanvas3D() {
237

  
238
		if (_canvas3d == null) {
239
			try {
240
				_terrainViewer = new TerrainViewer();
241
			} catch (NodeException e1) {
242

  
243
			}
244

  
245
			// System.out.println("TerrainViewer is: " + _terrainViewer);
246

  
247
			_canvas3d = ViewerFactory.getInstance().createViewer(
248
					ViewerFactory.VIEWER_TYPE.CANVAS_VIEWER, _terrainViewer);
249

  
250
			if (_canvas3d == null)
251
				System.out.println("ERROR; CANVAS NULL");
252

  
253
			ViewerFactory.getInstance().startAnimator();
254

  
255
			try {
256

  
257
				_terrain = new Terrain();
258

  
259
				_terrainDataManager = new JavaDataDriver();
260
				_canvas3d.getOSGViewer()
261
						.addUpdateOperation(_terrainDataManager);
262

  
263
				_terrainLayerManager = new LayerManager();
264
				_terrain.setLayerManager(_terrainLayerManager);
265

  
266
				_terrainViewer.addTerrain(_terrain);
267

  
268
				_canvas3d.addKeyListener(new ViewerStateListener(_canvas3d
269
						.getOSGViewer()));
270

  
271
				if (_canvas3d.getOSGViewer().getCameraManipulator() != null)
272
					_canvas3d.getOSGViewer().getCameraManipulator()
273
							.computeHomePosition();
274

  
275
				Camera cam;
276
				cam = new Camera();
277

  
278
				if (_terrainType == Terrain.CoordinateSystemType.PROJECTED) {
279
					Extent extent = _terrain.getExtent();
280
					double width = extent.xMax() - extent.xMin();
281
					double length = extent.yMax() - extent.yMin();
282

  
283
					double height = Math.sqrt(width * width + length * length) * 10f;
284
					cam.setViewByLookAt((float) (extent.xMax() / 2.0),
285
							(float) (extent.yMax() / 2.0), (float) height,
286
							(float) (extent.xMax() / 2.0),
287
							(float) (extent.yMax() / 2.0), 0f, 0f, 1f, 0f);
288
					cam.setViewByLookAt(0, 0, 5000000 * 4.6, 0, 0, 0, 0, 1, 0);
289

  
290
					_terrainViewer.getTerrainCameraManipulator()
291
							.setMinimumDistance(10);
292
					_terrainViewer.getTerrainCameraManipulator()
293
							.setMaximumDistance(5000000 * 10);
294
				} else {
295
					cam.setViewByLookAt(_terrain.getRadiusEquatorial() * 8.0,
296
							0, 0, 0, 0, 0, 0, 0, 1);
297

  
298
					_terrainViewer.getTerrainCameraManipulator()
299
							.setMinimumDistance(100);
300
					_terrainViewer
301
							.getTerrainCameraManipulator()
302
							.setMaximumDistance(
303
									(float) (_terrain.getRadiusEquatorial() * 10.0));
304
				}
305

  
306
				_terrainViewer.setCamera(cam);
307

  
308
			} catch (NodeException e) {
309
			}
310

  
311
		}
312

  
313
		return _canvas3d;
314
	}
315

  
316
	public JavaDataDriver getTerrainDataManager() {
317

  
318
		return _terrainDataManager;
319

  
320
	}
321

  
322
	public LayerManager getTerrainLayerManager() {
323

  
324
		return _terrainLayerManager;
325

  
326
	}
327

  
85 328
}
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/java/org/gvsig/gvsig3d/app/extension/DefaultView3DPanel.java
22 22
package org.gvsig.gvsig3d.app.extension;
23 23

  
24 24
import java.awt.BorderLayout;
25
import java.awt.Color;
25 26
import java.awt.Component;
27
import java.awt.Cursor;
26 28
import java.awt.Dimension;
27
import java.awt.geom.Rectangle2D;
29
import java.awt.Image;
30
import java.awt.Point;
31
import java.awt.Toolkit;
32
import java.beans.PropertyChangeEvent;
33
import java.beans.PropertyChangeListener;
34
import java.net.URL;
28 35

  
36
import javax.swing.ImageIcon;
29 37
import javax.swing.JPanel;
30 38
import javax.swing.JSplitPane;
31 39

  
32 40
import org.cresques.cts.IProjection;
41
import org.gvsig.andami.PluginServices;
33 42
import org.gvsig.andami.ui.mdiManager.WindowInfo;
34 43
import org.gvsig.app.project.documents.Document;
44
import org.gvsig.app.project.documents.view.MapOverview;
35 45
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
36 46
import org.gvsig.app.project.documents.view.toc.gui.TOC;
47
import org.gvsig.app.project.documents.view.toolListeners.InfoListener;
37 48
import org.gvsig.fmap.crs.CRSFactory;
49
import org.gvsig.fmap.geom.primitive.Envelope;
50
import org.gvsig.fmap.geom.primitive.impl.Envelope2D;
38 51
import org.gvsig.fmap.mapcontext.MapContext;
52
import org.gvsig.fmap.mapcontext.ViewPort;
53
import org.gvsig.fmap.mapcontext.events.ColorEvent;
54
import org.gvsig.fmap.mapcontext.events.ExtentEvent;
55
import org.gvsig.fmap.mapcontext.events.ProjectionEvent;
56
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener;
57
import org.gvsig.fmap.mapcontrol.MapControl;
58
import org.gvsig.fmap.mapcontrol.MapControl.MapToolListener;
39 59
import org.gvsig.fmap.mapcontrol.MapControlLocator;
40 60
import org.gvsig.fmap.mapcontrol.MapControlManager;
41
import org.gvsig.gvsig3d.impl.map3d.Viewport3DImpl;
61
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
62
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
63
import org.gvsig.gvsig3d.Gvsig3DException;
64
import org.gvsig.gvsig3d.Gvsig3DLocator;
65
import org.gvsig.gvsig3d.Gvsig3DManager;
66
import org.gvsig.gvsig3d.app.listener.PointSelectListener3D;
67
import org.gvsig.gvsig3d.app.resources.ResourcesFactory;
68
import org.gvsig.gvsig3d.map3d.MapContext3D;
69
import org.gvsig.gvsig3d.map3d.ViewPort3D;
70
import org.gvsig.gvsig3d.navigation.NavigationMode;
42 71
import org.gvsig.osgvp.terrain.JavaDataDriver;
43 72
import org.gvsig.osgvp.terrain.LayerManager;
44 73
import org.gvsig.osgvp.terrain.Terrain;
45 74
import org.gvsig.osgvp.viewer.DisplaySettings;
46 75
import org.gvsig.osgvp.viewer.IViewerContainer;
47 76
import org.gvsig.osgvp.viewer.OSGViewer;
77
import org.gvsig.tools.locator.LocatorException;
48 78

  
49 79
/**
50 80
 * @author gvSIG Team
51 81
 * @version $Id$
52 82
 * 
53 83
 */
84

  
85
// WAS VIEW3D////////////////////////////////////////////
54 86
public class DefaultView3DPanel extends AbstractViewPanel {
55 87

  
56
    /**
88
	/**
57 89
     * 
58 90
     */
59
    private static final long serialVersionUID = -4044661453954786519L;
91
	private static final long serialVersionUID = -4044661453954786519L;
60 92

  
61
    private IViewerContainer _canvas3d = null;
62
    private Terrain _terrain = null;
63
    private JavaDataDriver _terrainDataManager = null;
64
    private LayerManager _terrainLayerManager = null;
65
    // private NavigationMode _navMode = null;
66
    private static MapControlManager mapControlManager =
67
        MapControlLocator.getMapControlManager();
93
	private IViewerContainer _canvas3d = null;
94
	private Terrain _terrain = null;
95
	private JavaDataDriver _terrainDataManager = null;
96
	private LayerManager _terrainLayerManager = null;
97
	private NavigationMode _navMode = null;
98
	private static MapControlManager mapControlManager = MapControlLocator
99
			.getMapControlManager();
68 100

  
69
    public DefaultView3DPanel() {
70
        super();
71
        this.setName("View3D");
72
    }
101
	private String buttonPath;
73 102

  
74
    public void initialize() {
75
        super.initialize();
76
        initComponents();
103
	public DefaultView3DPanel() {
104
		super();
105
		this.setName("View3D");
106
	}
77 107

  
108
	public void initialize() {
109
		super.initialize();
110
		initComponents();
78 111

  
79
    }
112
	}
80 113

  
81
    public Document getDocument() {
114
	public Document getDocument() {
82 115

  
83
        return this.modelo;
84
    }
116
		return this.modelo;
117
	}
85 118

  
86
    public void setDocument(Document document) {
87
        setModel((DefaultView3DDocument) document);
119
	public void setDocument(Document document) {
120
		setModel((DefaultView3DDocument) document);
88 121

  
122
	}
89 123

  
90
    }
124
	public void setModel(DefaultView3DDocument model) {
91 125

  
92
    public void setModel(DefaultView3DDocument model) {
126
		this.modelo = model;
93 127

  
94
        this.modelo = model;
128
		MapContext3D mContext3D = (MapContext3D) modelo.getMapContext();
95 129

  
96
        MapContext fmap = (MapContext) modelo.getMapContext();
130
		// set projection for 3D view
131
		IProjection projection = null;
132
		ViewPort3D vPort3D = null;
133
		Envelope extent;
134
		if (_terrain.getCoordinateSystemType() == Terrain.CoordinateSystemType.GEOCENTRIC) {
135
			projection = CRSFactory.getCRS("EPSG:4326");
136
			extent = new Envelope2D(-180.0, 90.0, 180.0, -90.0);
137
		} else {
138
			if ((mContext3D != null) && (mContext3D.getProjection() != null))
139
				projection = mContext3D.getProjection();
140
			else
141
				projection = CRSFactory.getCRS("EPSG:23030");
142
			extent = new Envelope2D(20000000.0, 10000000.0, -20000000.0,
143
					-10000000.0);
144
		}
145
		try {
146
			vPort3D = Gvsig3DLocator.getManager()
147
					.createtDefaultViewPort3DInstance(projection);
148
			vPort3D.setEnvelope(extent);
149
			mContext3D.setViewPort((ViewPort) vPort3D);
150
			vPort3D.setTerrain(_terrain);
151
		} catch (LocatorException e) {
152
			// TODO Auto-generated catch block
153
			e.printStackTrace();
154
		}
97 155

  
98
        // set projection for 3D view
99
        IProjection projection = null;
100
        Viewport3DImpl vp = null;
101
        Rectangle2D extend;
102
        if (_terrain.getCoordinateSystemType() == Terrain.CoordinateSystemType.GEOCENTRIC) {
103
            projection = CRSFactory.getCRS("EPSG:4326");
104
            extend = new Rectangle2D.Double(-180.0, 90.0, 180.0, -90.0);
105
        } else {
106
            if ((fmap != null) && (fmap.getProjection() != null))
107
                projection = fmap.getProjection();
108
            else
109
                projection = CRSFactory.getCRS("EPSG:23030");
110
            extend =
111
                new Rectangle2D.Double(20000000.0, 10000000.0, -20000000.0,
112
                    -10000000.0);
113
        }
114
        vp = new Viewport3DImpl();
115
        vp.setEnvelope(extend);
116
        fmap.setViewPort(vp);
117
        vp.setTerrain(_terrain);
156
		// Add ViewPort3D listener to canvas3D. to refresh locator.
157
		// _canvas3d.addMouseListener((ViewPort3D) vp);
118 158

  
119
        // Add ViewPort3D listener to canvas3D. to refresh locator.
120
        //_canvas3d.addMouseListener((Viewport3DImpl) vp);
159
		// Pass JOSG objects to MapContext3D
160
		mContext3D.setViewer(_canvas3d);
161
		mContext3D.setViewProjection(projection);
162
		mContext3D.setDataManager(_terrainDataManager);
163
		mContext3D.setLayerManager(_terrainLayerManager);
164
		mContext3D.setTerrain(_terrain);
121 165

  
122
        // Pass JOSG objects to MapContext3D
123
        // ((MapContext3DImpl) fmap).setViewer(_canvas3d);
124
        // ((MapContext3DImpl) fmap).setViewProjection(projection);
125
        // ((MapContext3DImpl) fmap).setDataManager(_terrainDataManager);
126
        // ((MapContext3DImpl) fmap).setLayerManager(_terrainLayerManager);
127
        // // this needs be later.
128
        // ((MapContext3DImpl) fmap).setTerrain(_terrain);
166
		// Se configura el mapControl
129 167

  
130
        // Se configura el mapControl
168
		MapToolListener mapToolListener = m_MapControl.getMapToolListener();
169
		_canvas3d.addMouseListener(mapToolListener);
170
		_canvas3d.addMouseMotionListener(mapToolListener);
171
		_canvas3d.addMouseWheelListener(mapToolListener);
172
		//
173
		m_MapControl.setMapContext((MapContext) mContext3D);
174
		m_TOC.setMapContext((MapContext) mContext3D);
175
		m_MapControl.setBackground(new Color(255, 255, 255));
176
		if (modelo.getMapOverViewContext() != null) {
177
			m_MapLoc.setModel(modelo.getMapOverViewContext());
178
		}
179
		model.addPropertyChangeListener(new PropertyChangeListener() {
131 180

  
132
        // canvasListener lis = new canvasListener();
133
        // lis.setTerrain(_terrain);
134
        // lis.setCanvas(_canvas3d);
135
        // _canvas3d.addKeyListener(lis);
136
        // _canvas3d.addMouseListener(lis);
181
			public void propertyChange(PropertyChangeEvent evt) {
182
				if (evt.getPropertyName().equals("name")) {
183
					PluginServices
184
							.getMDIManager()
185
							.getWindowInfo(DefaultView3DPanel.this)
186
							.setTitle(
187
									PluginServices.getText(this, "Vista3D")
188
											+ " : "
189
											+ (String) evt.getNewValue());
190
				}
191
			}
192
		});
193
		if (m_MapControl.getViewPort() != null) {
194
			m_MapControl.getViewPort().addViewPortListener(
195
					new ViewPortListener() {
137 196

  
138
        // MapToolListener mapToolListener = m_MapControl.getMapToolListener();
139
        // _canvas3d.addMouseListener(mapToolListener);
140
        // _canvas3d.addMouseMotionListener(mapToolListener);
141
        // _canvas3d.addMouseWheelListener(mapToolListener);
197
						public void extentChanged(ExtentEvent e) {
198
							/*
199
							 * if (PluginServices.getMainFrame() != null){
200
							 * PluginServices.getMainFrame().getStatusBar().
201
							 * setControlValue
202
							 * ("scale",String.valueOf(m_MapControl
203
							 * .getMapContext ().getScaleView()));
204
							 * 
205
							 * 
206
							 * 
207
							 * PluginServices.getMainFrame().getStatusBar().
208
							 * setMessage ("projection",
209
							 * 
210
							 * 
211
							 * 
212
							 * getMapControl().getViewPort().getProjection().
213
							 * getAbrev ()); }
214
							 */
215
						}
142 216

  
143
        // m_MapControl.setMapContext(fmap);
144
        m_TOC.setMapContext(fmap);
145
        // m_MapControl.setBackground(new Color(255, 255, 255));
146
        // if (modelo.getMapOverViewContext() != null) {
147
        // m_MapLoc.setModel(modelo.getMapOverViewContext());
148
        // }
149
        // model.addPropertyChangeListener(new PropertyChangeListener() {
150
        //
151
        // public void propertyChange(PropertyChangeEvent evt) {
152
        // if (evt.getPropertyName().equals("name")) {
153
        // PluginServices.getMDIManager().getWindowInfo(DefaultView3DPanel.this)
154
        // .setTitle(
155
        // PluginServices.getText(this, "Vista3D") + " : "
156
        // + (String) evt.getNewValue());
157
        // }
158
        // }
159
        // });
160
        // if (m_MapControl.getViewPort() != null) {
161
        // m_MapControl.getViewPort().addViewPortListener(
162
        // new ViewPortListener() {
163
        //
164
        // public void extentChanged(ExtentEvent e) {
165
        // /*
166
        // * if (PluginServices.getMainFrame() != null){
167
        // * PluginServices.getMainFrame().getStatusBar().
168
        // * setControlValue
169
        // * ("scale",String.valueOf(m_MapControl.getMapContext
170
        // * ().getScaleView()));
171
        // *
172
        // *
173
        // *
174
        // * PluginServices.getMainFrame().getStatusBar().setMessage
175
        // * ("projection",
176
        // *
177
        // *
178
        // *
179
        // * getMapControl().getViewPort().getProjection().getAbrev
180
        // * ()); }
181
        // */
182
        // }
183
        //
184
        // public void backColorChanged(ColorEvent e) {
185
        // }
186
        //
187
        // public void projectionChanged(ProjectionEvent e) {
188
        // m_MapLoc.setProjection(e.getNewProjection());
189
        // }
190
        // });
191
        // }
217
						public void backColorChanged(ColorEvent e) {
218
						}
192 219

  
193
    }
220
						public void projectionChanged(ProjectionEvent e) {
221
							m_MapLoc.setProjection(e.getNewProjection());
222
						}
223
					});
224
		}
194 225

  
195
    protected void initComponents() {
226
	}
196 227

  
197
        m_TOC = new TOC();
228
	protected void initComponents() {
198 229

  
199
        removeAll();
200
        tempMainSplit = new ViewSplitPane(JSplitPane.HORIZONTAL_SPLIT);
230
		Gvsig3DManager manager = Gvsig3DLocator.getManager();
201 231

  
202
        if (windowLayout == null) {
203
            tempMainSplit.setPreferredSize(new Dimension(500, 300));
204
        }
232
		try {
233
			m_MapControl = manager.createDefaultMapControl3DInstance();
234
			m_MapControl.addExceptionListener(mapControlExceptionListener);
235
			m_TOC = new TOC();
236
			m_MapLoc = new MapOverview(m_MapControl);
237
			m_MapLoc.setPreferredSize(new Dimension(150, 200));
205 238

  
206
        tempMainSplit.setLeftComponent(m_TOC);
239
			removeAll();
240
			tempMainSplit = new ViewSplitPane(JSplitPane.HORIZONTAL_SPLIT);
207 241

  
208
        m_TOC.setVisible(true);
242
			if (windowLayout == null) {
243
				tempMainSplit.setPreferredSize(new Dimension(500, 300));
244
			}
209 245

  
210
        JPanel panel = new JPanel();
211
        panel.setLayout(new BorderLayout());
212
        System.out.println(_canvas3d.getWidth() + " " + _canvas3d.getHeight());
213
        panel.add((Component) _canvas3d);
214
        panel.setMinimumSize(new Dimension(100, 100));
246
			tempMainSplit.setLeftComponent(m_TOC);
215 247

  
216
        tempMainSplit.setRightComponent(panel);
248
			m_TOC.setVisible(true);
217 249

  
218
        this.setLayout(new BorderLayout());
219
        this.add(tempMainSplit, BorderLayout.CENTER);
250
			JPanel panel = new JPanel();
251
			panel.setLayout(new BorderLayout());
252
			System.out.println(_canvas3d.getWidth() + " "
253
					+ _canvas3d.getHeight());
254
			panel.add((Component) _canvas3d);
255
			panel.setMinimumSize(new Dimension(100, 100));
220 256

  
221
    }
257
			tempMainSplit.setRightComponent(panel);
222 258

  
223
    public IViewerContainer getCanvas3d() {
224
        return _canvas3d;
225
    }
259
			this.setLayout(new BorderLayout());
260
			this.add(tempMainSplit, BorderLayout.CENTER);
226 261

  
227
    public void setCanvas3d(IViewerContainer canvas3d) {
228
        _canvas3d = canvas3d;
229
    }
262
			// default cursor
263
			String oldPath = ResourcesFactory.getExtPath();// Save the path.
264
			ResourcesFactory
265
					.setExtPath("/gvSIG/extensiones/org.gvsig.gvsig3d.app.extension/images/");// my
266
			// new
267
			// path
268
			buttonPath = ResourcesFactory.getResourcesPath();
269
			ResourcesFactory.setExtPath(oldPath);// Restore the old path.
230 270

  
231
    public DisplaySettings getDisplaySettings() {
271
			URL path;
272
			path = this.getClass().getClassLoader().getResource("images/");
273
			buttonPath = path.getPath();
232 274

  
233
        return ((OSGViewer) getCanvas3d().getOSGViewer()).getDisplaySettings();
275
			Image navCursorImage = new ImageIcon(buttonPath
276
					+ "/NavigationCursor.gif").getImage();
234 277

  
235
    }
278
			Cursor navCursor = Toolkit.getDefaultToolkit().createCustomCursor(
279
					navCursorImage, new Point(16, 16), "");
280
			((Component) _canvas3d).setCursor(navCursor);
236 281

  
237
    public Object getWindowProfile() {
238
        return WindowInfo.EDITOR_PROFILE;
239
    }
282
			// Seleccion por punto
283
			// PointSelectListener3D psl = new
284
			// PointSelectListener3D(m_MapControl);
285
			// m_MapControl.addBehavior("pointSelection", new Behavior[] { new
286
			// PointBehavior(psl) });
287
			// m_MapControl.setCurrentMapTool(new PointBehavior(psl));
288
			//
289
			// Info por punto
290
			InfoListener il = new InfoListener(m_MapControl);
291
			m_MapControl.addBehavior("info",
292
					new Behavior[] { new PointBehavior(il) });
293
			m_MapControl.setCurrentMapTool(new PointBehavior(il));
240 294

  
241
    public Terrain getTerrain() {
242
        return _terrain;
243
    }
295
			// // Selecci�n por rect�ngulo
296
			// RectangleSelectListener3D rsl = new
297
			// RectangleSelectListener3D(m_MapControl);
298
			// m_MapControl.addMapTool("rectSelection", new Behavior[] { new
299
			// RectangleBehavior3D(rsl) });
300
			//
244 301

  
245
    public void setTerrain(Terrain terrain) {
246
        if (_canvas3d == null)
247
            return;
248
        _terrain = terrain;
249
    }
302
		} catch (Gvsig3DException e) {
303
			// TODO Auto-generated catch block
304
			e.printStackTrace();
305
		}
250 306

  
251
    public JavaDataDriver getDataManager() {
252
        return _terrainDataManager;
253
    }
307
	}
254 308

  
255
    public void setDataManager(JavaDataDriver manager) {
256
        _terrainDataManager = manager;
257
    }
309
	public IViewerContainer getCanvas3d() {
310
		return _canvas3d;
311
	}
258 312

  
259
    public LayerManager getLayerManager() {
260
        return _terrainLayerManager;
261
    }
313
	public void setCanvas3d(IViewerContainer canvas3d) {
314
		_canvas3d = canvas3d;
315
	}
262 316

  
263
    public void setLayerManager(LayerManager manager) {
264
        _terrainLayerManager = manager;
265
    }
317
	public DisplaySettings getDisplaySettings() {
266 318

  
319
		return ((OSGViewer) getCanvas3d().getOSGViewer()).getDisplaySettings();
320

  
321
	}
322

  
323
	public Object getWindowProfile() {
324
		return WindowInfo.EDITOR_PROFILE;
325
	}
326

  
327
	public Terrain getTerrain() {
328
		return _terrain;
329
	}
330

  
331
	public void setTerrain(Terrain terrain) {
332
		if (_canvas3d == null)
333
			return;
334
		_terrain = terrain;
335
	}
336

  
337
	public JavaDataDriver getDataManager() {
338
		return _terrainDataManager;
339
	}
340

  
341
	public void setDataManager(JavaDataDriver manager) {
342
		_terrainDataManager = manager;
343
	}
344

  
345
	public LayerManager getLayerManager() {
346
		return _terrainLayerManager;
347
	}
348

  
349
	public void setLayerManager(LayerManager manager) {
350
		_terrainLayerManager = manager;
351
	}
352

  
353
	public NavigationMode getNavMode() {
354
		return _navMode;
355
	}
356

  
357
	public void setNavMode(NavigationMode navMode) {
358
		_navMode = navMode;
359
	}
360

  
267 361
}
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/java/org/gvsig/gvsig3d/app/extension/View3DManager.java
35 35
import org.gvsig.app.project.documents.gui.WindowLayout;
36 36
import org.gvsig.app.project.documents.view.DefaultViewDocument;
37 37
import org.gvsig.app.project.documents.view.gui.ViewProperties;
38
import org.gvsig.fmap.mapcontext.ViewPort;
39
import org.gvsig.fmap.mapcontext.layers.FLayers;
40
import org.gvsig.gvsig3d.Gvsig3DLocator;
41
import org.gvsig.gvsig3d.Gvsig3DManager;
38 42
import org.gvsig.osgvp.exceptions.node.NodeException;
39 43
import org.gvsig.osgvp.terrain.Extent;
40 44
import org.gvsig.osgvp.terrain.JavaDataDriver;
......
56 60
 */
57 61
public class View3DManager extends AbstractDocumentManager {
58 62

  
59
    private static final String PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME =
60
        "DefaultViewDocument";
61
    public static String TYPENAME = "project.document.view3d";
62
    private DynStruct persistenceDefinition;
63
	private static final String PERSISTENCE_VIEW3D_DOCUMENT_DEFINITION_NAME = "DefaultView3DDocument";
64
	public static String TYPENAME = "project.document.view3d";
65
	private DynStruct persistenceDefinition;
63 66

  
64
    private IViewerContainer _canvas3d = null;
65
    private TerrainViewer _terrainViewer = null;
67
	private IViewerContainer _canvas3d = null;
68
	private TerrainViewer _terrainViewer = null;
66 69

  
67
    private Terrain _terrain = null;
68
    private JavaDataDriver _terrainDataManager = null;
69
    private LayerManager _terrainLayerManager = null;
70
    private int _terrainType = Terrain.CoordinateSystemType.PROJECTED; // spheric
70
	private Terrain _terrain = null;
71
	private JavaDataDriver _terrainDataManager = null;
72
	private LayerManager _terrainLayerManager = null;
73
	private int _terrainType = Terrain.CoordinateSystemType.PROJECTED; // spheric
71 74

  
72
    // or
73
    // plane
75
	// or
76
	// plane
74 77

  
75
    // private Terrain _terrain = null;
76
    // //private ProjectCamera _projectCamera = null;
77
    // private JavaDataDriver _terrainDataManager = null;
78
    // private LayerManager _terrainLayerManager = null;
79
    // private int _terrainType = Terrain.CoordinateSystemType.PROJECTED; //
80
    // spheric
81
    // // or
82
    // // plane
78
	// private Terrain _terrain = null;
79
	// //private ProjectCamera _projectCamera = null;
80
	// private JavaDataDriver _terrainDataManager = null;
81
	// private LayerManager _terrainLayerManager = null;
82
	// private int _terrainType = Terrain.CoordinateSystemType.PROJECTED; //
83
	// spheric
84
	// // or
85
	// // plane
83 86

  
84
    public View3DManager() {
85
        // Do nothing
86
    }
87
	public View3DManager() {
88
		// Do nothing
89
	}
87 90

  
88
    public int getPriority() {
89
        return 0;
90
    }
91
	public int getPriority() {
92
		return 0;
93
	}
91 94

  
92
    public ImageIcon getIcon() {
93
        return PluginServices.getIconTheme().get("document-view3d-icon");
94
    }
95
	public ImageIcon getIcon() {
96
		return PluginServices.getIconTheme().get("document-view3d-icon");
97
	}
95 98

  
96
    public ImageIcon getIconSelected() {
97
        return PluginServices.getIconTheme().get("document-view3d-icon-sel");
98
    }
99
	public ImageIcon getIconSelected() {
100
		return PluginServices.getIconTheme().get("document-view3d-icon-sel");
101
	}
99 102

  
100
    public String getTitle() {
101
        return PluginServices.getText(this, "Vista3d");
102
    }
103
	public String getTitle() {
104
		return PluginServices.getText(this, "Vista3d");
105
	}
103 106

  
104
    public String getTypeName() {
105
        return TYPENAME;
106
    }
107
	public String getTypeName() {
108
		return TYPENAME;
109
	}
107 110

  
108
    public AbstractDocument createDocument() {
111
	public AbstractDocument createDocument() {
109 112

  
110
        return new DefaultView3DDocument(this);
111
    }
113
		String viewName = "";
114
		String aux = PluginServices.getText(this, "untitled");
115
//		int numViews = ((Integer) AbstractDocument.NUMS.get(_registerName))
116
//				.intValue();
117
//
118
//		viewName = aux + " - " + numViews++;
119
//
120
//		ProjectDocument.NUMS.put(_registerName, new Integer(numViews));
121
		
122
		DefaultView3DDocument viewDocument = new DefaultView3DDocument(this);
123
		
124
//		if(viewDocument != null)
125
//			viewDocument.setProject(project);
126
//		
127
		return viewDocument;
128
	}
112 129

  
113
    public IWindow getMainWindow(Document doc, WindowLayout layout) {
114
        DefaultView3DPanel view = new DefaultView3DPanel();
115
        view.setCanvas3d(getOrCreateCanvas3D());
130
	public IWindow getMainWindow(Document doc, WindowLayout layout) {
116 131

  
117
        view.setTerrain(_terrain);
118
        view.setDataManager(_terrainDataManager);
119
        view.setLayerManager(_terrainLayerManager);
132
		DefaultView3DPanel view = new DefaultView3DPanel();
133
		DefaultView3DDocument viewDoc = (DefaultView3DDocument) doc;
120 134

  
121
        if (layout != null) {
122
            view.setWindowLayout(layout);
123
        }
124
        view.initialize();
125
        view.setDocument(doc);
126
        ((AbstractDocument) doc).raiseEventCreateWindow(view);
127
        return view;
128
    }
135
		Gvsig3DManager manager = Gvsig3DLocator.getManager();
129 136

  
130
    public IWindow getPropertiesWindow(Document doc) {
131
        return new ViewProperties((DefaultViewDocument) doc);
132
    }
137
		ViewPort vp = new ViewPort();
138
		FLayers layers = manager.createDefaultFLayers3DInstance(vp);
133 139

  
134
    /**
135
     * Registers in the points of extension the Factory with alias.
136
     * 
137
     */
138
    public static void register() {
139
        View3DManager factory = new View3DManager();
140
        ProjectManager.getInstance().registerDocumentFactory(factory);
140
		viewDoc.setMapContext(layers.getMapContext());
141
		viewDoc.setMapOverViewContext(manager
142
				.createDefaultMapContext3DInstance());
141 143

  
142
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
143
        manager.registerFactory(factory);
144
		IViewerContainer canvas3d = viewDoc.getOrCreateCanvas3D();
145
		view.setCanvas3d(canvas3d);
144 146

  
145
        ProjectManager.getInstance().registerDocumentAction(TYPENAME,
146
            new CopyDocumentAction());
147
        ProjectManager.getInstance().registerDocumentAction(TYPENAME,
148
            new CutDocumentAction());
149
        ProjectManager.getInstance().registerDocumentAction(TYPENAME,
150
            new PasteDocumentAction());
147
		view.setTerrain(viewDoc.getTerrain());
148
		view.setDataManager(viewDoc.getTerrainDataManager());
149
		view.setLayerManager(viewDoc.getTerrainLayerManager());
151 150

  
152
        PluginServices.getIconTheme().registerDefault(
153
            "document-view3d-icon",
154
            View3DManager.class.getClassLoader().getResource(
155
                "images/ProjectView3D.png"));
156
        PluginServices.getIconTheme().registerDefault(
157
            "document-view3d-icon-sel",
158
            View3DManager.class.getClassLoader().getResource(
159
                "images/ProjectView3DSel.png"));
151
		if (layout != null) {
152
			view.setWindowLayout(layout);
153
		}
154
		view.initialize();
155
		view.setDocument(doc);
156
		((AbstractDocument) doc).raiseEventCreateWindow(view);
160 157

  
161
        // if (factory.persistenceDefinition == null) {
162
        // factory.persistenceDefinition =
163
        // manager.addDefinition(ViewDocument.class,
164
        // PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME,
165
        // "Default view document persistence definition", null, null);
166
        // factory.persistenceDefinition.extend(manager
167
        // .getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
168
        //
169
        // factory.persistenceDefinition.addDynFieldBoolean("useMapOverview")
170
        // .setMandatory(true);
171
        // factory.persistenceDefinition.addDynFieldObject("mainMapContext")
172
        // .setClassOfValue(MapContext.class).setMandatory(true);
173
        // factory.persistenceDefinition.addDynFieldObject(
174
        // "overviewMapContext").setClassOfValue(MapContext.class)
175
        // .setMandatory(false);
176
        //
177
        // }
158
		return view;
159
	}
178 160

  
179
    }
161
	public IWindow getPropertiesWindow(Document doc) {
162
		return new ViewProperties((DefaultViewDocument) doc);
163
	}
180 164

  
181
    @SuppressWarnings("rawtypes")
182
    public DynStruct getDefinition(String className) {
165
	/**
166
	 * Registers in the points of extension the Factory with alias.
167
	 * 
168
	 */
169
	public static void register() {
170
		View3DManager factory = new View3DManager();
171
		ProjectManager.getInstance().registerDocumentFactory(factory);
183 172

  
184
        // if (this.persistenceDefinition.getName().equalsIgnoreCase(className))
185
        // {
186
        // return this.persistenceDefinition;
187
        // }
188
        // if (this.persistenceDefinition.getFullName()
189
        // .equalsIgnoreCase(className)) {
190
        // return this.persistenceDefinition;
191
        // }
192
        // if (this.getDocumentClass().getName().equals(className)) {
193
        // return this.persistenceDefinition;
194
        // }
173
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
174
		manager.registerFactory(factory);
195 175

  
196
        // Class theClass;
197
        // try {
198
        // theClass = (Class) Class.forName(className);
199
        // } catch (ClassNotFoundException e) {
200
        // return null;
201
        // }
202
        // if ( this.manages(theClass)){
203
        // return this.persistenceDefinition;
204
        // }
205
        return null;
206
    }
176
		ProjectManager.getInstance().registerDocumentAction(TYPENAME,
177
				new CopyDocumentAction());
178
		ProjectManager.getInstance().registerDocumentAction(TYPENAME,
179
				new CutDocumentAction());
180
		ProjectManager.getInstance().registerDocumentAction(TYPENAME,
181
				new PasteDocumentAction());
207 182

  
208
    @SuppressWarnings("rawtypes")
209
    protected Class getDocumentClass() {
210
        return DefaultViewDocument.class;
211
    }
183
		PluginServices.getIconTheme().registerDefault(
184
				"document-view3d-icon",
185
				View3DManager.class.getClassLoader().getResource(
186
						"images/ProjectView3D.png"));
187
		PluginServices.getIconTheme().registerDefault(
188
				"document-view3d-icon-sel",
189
				View3DManager.class.getClassLoader().getResource(
190
						"images/ProjectView3DSel.png"));
212 191

  
213
    public IViewerContainer getOrCreateCanvas3D() {
192
//		if (factory.persistenceDefinition == null) {
193
//			factory.persistenceDefinition = manager.addDefinition(
194
//					ViewDocument.class,
195
//					PERSISTENCE_VIEW3D_DOCUMENT_DEFINITION_NAME,
196
//					"Default view 3D document persistence definition", null, null);
197
//			factory.persistenceDefinition
198
//					.extend(manager
199
//							.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
200
//
201
//			factory.persistenceDefinition.addDynFieldBoolean("useMapOverview")
202
//					.setMandatory(true);
203
//			factory.persistenceDefinition.addDynFieldObject("mainMapContext")
204
//					.setClassOfValue(MapContext.class).setMandatory(true);
205
//			factory.persistenceDefinition
206
//					.addDynFieldObject("overviewMapContext")
207
//					.setClassOfValue(MapContext.class).setMandatory(false);
208
//
209
//		}
214 210

  
215
        if (_canvas3d == null) {
216
            try {
217
                _terrainViewer = new TerrainViewer();
218
            } catch (NodeException e1) {
211
	}
219 212

  
220
            }
213
	@SuppressWarnings("rawtypes")
214
	public DynStruct getDefinition(String className) {
221 215

  
222
            // System.out.println("TerrainViewer is: " + _terrainViewer);
216
//		if (this.persistenceDefinition.getName().equalsIgnoreCase(className)) {
217
//			return this.persistenceDefinition;
218
//		}
219
//		if (this.persistenceDefinition.getFullName()
220
//				.equalsIgnoreCase(className)) {
221
//			return this.persistenceDefinition;
222
//		}
223
//		if (this.getDocumentClass().getName().equals(className)) {
224
//			return this.persistenceDefinition;
225
//		}
226
//
227
//		Class theClass;
228
//		try {
229
//			theClass = (Class) Class.forName(className);
230
//		} catch (ClassNotFoundException e) {
231
//			return null;
232
//		}
233
//		if (this.manages(theClass)) {
234
//			return this.persistenceDefinition;
235
//		}
223 236

  
224
            _canvas3d =
225
                ViewerFactory.getInstance().createViewer(
226
                    ViewerFactory.VIEWER_TYPE.CANVAS_VIEWER, _terrainViewer);
227
            
228
            if (_canvas3d == null)
229
                System.out.println("ERROR; CANVAS NULL");
230
            System.out.println("Canvas3d is" + _canvas3d);
237
		return null;
231 238

  
232
            ViewerFactory.getInstance().startAnimator();
239
	}
233 240

  
234
            try {
241
	@SuppressWarnings("rawtypes")
242
	protected Class getDocumentClass() {
243
		return DefaultViewDocument.class;
244
	}
235 245

  
236
                _terrain = new Terrain();
237 246

  
238
                _terrainDataManager = new JavaDataDriver();
239
                _canvas3d.getOSGViewer()
240
                    .addUpdateOperation(_terrainDataManager);
241

  
242
                _terrainLayerManager = new LayerManager();
243
                _terrain.setLayerManager(_terrainLayerManager);
244

  
245
                _terrainViewer.addTerrain(_terrain);
246

  
247
                _canvas3d.addKeyListener(new ViewerStateListener(_canvas3d
248
                    .getOSGViewer()));
249

  
250
                if (_canvas3d.getOSGViewer().getCameraManipulator() != null)
251
                    _canvas3d.getOSGViewer().getCameraManipulator()
252
                        .computeHomePosition();
253

  
254
                Camera cam;
255
                cam = new Camera();
256

  
257
                if (_terrainType == Terrain.CoordinateSystemType.PROJECTED) {
258
                    Extent extent = _terrain.getExtent();
259
                    double width = extent.xMax() - extent.xMin();
260
                    double length = extent.yMax() - extent.yMin();
261

  
262
                    double height =
263
                        Math.sqrt(width * width + length * length) * 10f;
264
                    cam.setViewByLookAt((float) (extent.xMax() / 2.0),
265
                        (float) (extent.yMax() / 2.0), (float) height,
266
                        (float) (extent.xMax() / 2.0),
267
                        (float) (extent.yMax() / 2.0), 0f, 0f, 1f, 0f);
268
                    cam.setViewByLookAt(0, 0, 5000000 * 4.6, 0, 0, 0, 0, 1, 0);
269

  
270
                    _terrainViewer.getTerrainCameraManipulator()
271
                        .setMinimumDistance(10);
272
                    _terrainViewer.getTerrainCameraManipulator()
273
                        .setMaximumDistance(5000000 * 10);
274
                } else {
275
                    cam.setViewByLookAt(_terrain.getRadiusEquatorial() * 8.0,
276
                        0, 0, 0, 0, 0, 0, 0, 1);
277

  
278
                    _terrainViewer.getTerrainCameraManipulator()
279
                        .setMinimumDistance(100);
280
                    _terrainViewer.getTerrainCameraManipulator()
281
                        .setMaximumDistance(
282
                            (float) (_terrain.getRadiusEquatorial() * 10.0));
283
                }
284

  
285
                _terrainViewer.setCamera(cam);
286

  
287
            } catch (NodeException e) {
288
            }
289

  
290
             // _canvas3d.addKeyListener(new Key3DListener(_terrain));
291
        }
292

  
293
        return _canvas3d;
294
    }
295 247
}
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/src/main/java/org/gvsig/gvsig3d/app/extension/AboutExtension3D.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.gvsig3d.app.extension;
23

  
24
import org.gvsig.about.AboutLocator;
25
import org.gvsig.about.AboutManager;
26
import org.gvsig.andami.plugins.Extension;
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 *
32
 */
33
public class AboutExtension3D extends Extension {
34

  
35
    public void postInitialize() {
36

  
37
        AboutManager manager = AboutLocator.getManager();
38

  
39
        manager.addDeveloper("AI2", this.getClass().getClassLoader()
40
            .getResource("about.html"), 1);
41

  
42
    }
43

  
44
    public void execute(String actionCommand) {
45

  
46
    }
47

  
48
    public void initialize() {
49
        // TODO Auto-generated method stub
50

  
51
    }
52

  
53
    public boolean isEnabled() {
54
        // TODO Auto-generated method stub
55
        return false;
56
    }
57

  
58
    public boolean isVisible() {
59
        // TODO Auto-generated method stub
60
        return false;
61
    }
62

  
63
}
2.0/trunk/org.gvsig.gvsig3d.app/org.gvsig.gvsig3d.app.extension/pom.xml
36 36
		<dependency>
37 37
			<groupId>org.gvsig</groupId>
38 38
			<artifactId>org.gvsig.gvsig3d.lib.impl</artifactId>
39
			<scope>runtime</scope>
40
			
39 41
		</dependency>
40 42
		<dependency>
41 43
			<groupId>org.gvsig</groupId>
2.0/trunk/org.gvsig.gvsig3d/org.gvsig.gvsig3d.lib/org.gvsig.gvsig3d.lib.api/src/main/java/org/gvsig/gvsig3d/Gvsig3DManager.java
21 21
 */
22 22
package org.gvsig.gvsig3d;
23 23

  
24
import org.cresques.cts.IProjection;
25
import org.gvsig.fmap.mapcontext.ViewPort;
26
import org.gvsig.gvsig3d.map3d.GraphicLayer3D;
27
import org.gvsig.gvsig3d.map3d.Layer3DProps;
24 28
import org.gvsig.gvsig3d.map3d.MapContext3D;
25 29
import org.gvsig.gvsig3d.map3d.MapControl3D;
30
import org.gvsig.gvsig3d.map3d.ViewPort3D;
31
import org.gvsig.gvsig3d.map3d.layers.FLayers3D;
32
import org.gvsig.osgvp.terrain.Terrain;
33
import org.gvsig.osgvp.terrain.TerrainViewer;
26 34
import org.gvsig.tools.service.Manager;
27 35

  
28 36
/**
......
36 44
 */
37 45
public interface Gvsig3DManager extends Manager {
38 46

  
39
    public void registerMapContext3D(String name, Class mapContext3DClass);
47
	public void registerDefaultMapContext3D(Class mapContext3DClass);
40 48

  
41
    public void registerDefaultMapContext3D(Class mapContext3DClass);
49
	public MapContext3D createMapContext3DInstance(String name)
50
			throws Gvsig3DException;
42 51

  
43
    public MapContext3D getMapContext3D(String name); // throws
44
                                                      // MapContext3DCreationException
52
	public MapContext3D createDefaultMapContext3DInstance();
45 53

  
46
    public MapContext3D getDefaultMapContext3D(); // throws
47
                                                  // MapContext3DCreationException
54
	public MapContext3D createDefaultMapContext3DInstance(ViewPort vp);
48 55

  
56
	public void registerDefaultMapControl3D(Class mapControl3DClass);
49 57

  
50
    public void registerMapControl3D(String name, Class mapControl3DClass);
58
	public MapControl3D createMapControl3DInstance(String name)
59
			throws Gvsig3DException;
51 60

  
52
    public void registerDefaultMapControl3D(Class mapControl3DClass);
61
	public MapControl3D createDefaultMapControl3DInstance()
62
			throws Gvsig3DException;
53 63

  
54
    public MapControl3D getMapControl3D(String name); // throws
55
                                                      // MapControl3DCreationException
64
	public FLayers3D createFLayers3DInstance(String name)
65
			throws Gvsig3DException;
56 66

  
57
    public MapControl3D getDefaultMapControl3D(); // throws
58
                                                  // MapControl3DCreationException
67
	public FLayers3D createDefaultFLayers3DInstance(ViewPort vp);
59 68

  
60
    public void registerViewPort3D(String name, Class viewPort3DClass);
69
	public void registerDefaultGraphicsLayer3D(Class graphicLayer3DClass);
61 70

  
62
    public void registerDefaultViewPort3D(Class viewPort3DClass);
71
	public GraphicLayer3D createGraphicsLayer3DInstance(String name)
72
			throws Gvsig3DException;
63 73

  
64
    public MapControl3D getViewPort3D(String name); // throws
74
	public GraphicLayer3D createDefaultGraphicsLayer3DInstance(
75
			TerrainViewer terrainViewer, Terrain terrain)
76
			throws Gvsig3DException;
65 77

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff