root / trunk / extensions / ext3Dgui / src / com / iver / ai2 / gvsig3dgui / camera / Encuadrator3D.java @ 20900
History | View | Annotate | Download (4.86 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.ai2.gvsig3dgui.camera; |
42 |
|
43 |
import org.gvsig.osgvp.viewer.Camera; |
44 |
|
45 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
46 |
import com.iver.ai2.gvsig3dgui.view.View3D; |
47 |
import com.iver.cit.gvsig.fmap.MapContext; |
48 |
import com.iver.cit.gvsig.project.Project; |
49 |
import com.iver.cit.gvsig.project.documents.view.ListSelectorListener; |
50 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
51 |
|
52 |
public class Encuadrator3D implements ListSelectorListener { |
53 |
|
54 |
private Project project;
|
55 |
|
56 |
private BaseView vista;
|
57 |
|
58 |
private MapContext mapa;
|
59 |
|
60 |
public Encuadrator3D(Project project, MapContext map, View3D vista) {
|
61 |
this.project = project;
|
62 |
this.vista = vista;
|
63 |
mapa = map; |
64 |
} |
65 |
|
66 |
/**
|
67 |
* @see com.iver.utiles.ListSelectorListener#indexesSelected(int[])
|
68 |
*/
|
69 |
public void indexesSelected(int[] indices) { |
70 |
// mapa.getViewPort().setExtent(project.getExtents()[indices[0]].getExtent());
|
71 |
|
72 |
View3D vi = (View3D) this.vista;
|
73 |
Object[] l = project.getCameras(); |
74 |
|
75 |
Camera ca = (Camera) ((ProjectCamera) l[indices[0]]).getCamera();
|
76 |
|
77 |
vi.setCamera(ca); |
78 |
vi.getCanvas3d().repaint(); |
79 |
|
80 |
|
81 |
// ca = null;
|
82 |
// ca = vi.getCamera();
|
83 |
// System.out.println("******************************************");
|
84 |
// System.out.println("INFORMACION DE LA CAMARA");
|
85 |
// System.out.println("Centro::X " + ca.getCenter().x() + ";Y "
|
86 |
// + ca.getCenter().y() + ";Z " + ca.getCenter().z());
|
87 |
// System.out.println("Ojo::X " + ca.getEye().x() + ";Y " + ca.getEye().y()
|
88 |
// + ";Z " + ca.getEye().z());
|
89 |
// System.out.println("Up::X " + ca.getUp().x() + ";Y " + ca.getUp().y()
|
90 |
// + ";Z " + ca.getUp().z());
|
91 |
// System.out.println("******************************************");
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* @see com.iver.utiles.ListSelectorListener#indexesRemoved(int[])
|
96 |
*/
|
97 |
public void indexesRemoved(int[] indices) { |
98 |
// System.out
|
99 |
// .println("!!!!!!!!!!!!!!!!!!!!!ENTANDO EN LA FUNCION BORRAR INDICE!!!!");
|
100 |
for (int i = 0; i < indices.length; i++) { |
101 |
this.project.removeCamera(indices[i]);
|
102 |
} |
103 |
} |
104 |
|
105 |
/*
|
106 |
* (non-Javadoc)
|
107 |
*
|
108 |
* @see com.iver.utiles.ListSelectorListener#newElement(java.lang.String)
|
109 |
*/
|
110 |
public void newElement(String name) { |
111 |
// System.out
|
112 |
// .println("!!!!!!!!!!!!!!!!!!!!!ENTANDO EN LA FUNCION NUEVO ELEMENTO!!!!");
|
113 |
// System.out.println("nombre del encuadre ---->" + name);
|
114 |
|
115 |
View3D vi = (View3D) this.vista;
|
116 |
Camera ca = vi.getCamera(); |
117 |
|
118 |
ProjectCamera camera = new ProjectCamera();
|
119 |
camera.setDescription(name); |
120 |
camera.setCamera(ca); |
121 |
Object[] l = project.getCameras(); |
122 |
|
123 |
boolean exits = false; |
124 |
for (int i = 0; i < l.length; i++) { |
125 |
ProjectCamera cam = (ProjectCamera) l[i]; |
126 |
if (cam.getDescription().equals(camera.getDescription())){
|
127 |
exits = true;
|
128 |
} |
129 |
} |
130 |
|
131 |
if (!exits){
|
132 |
project.addCamera(camera); |
133 |
} |
134 |
|
135 |
|
136 |
// System.out.println("******************************************");
|
137 |
// System.out.println("INFORMACION DE LA CAMARA");
|
138 |
// System.out.println("Centro.... " + ca.getCenter());
|
139 |
// System.out.println("X " + ca.getCenter().x() + ";Y "
|
140 |
// + ca.getCenter().y() + ";Z " + ca.getCenter().z());
|
141 |
// System.out.println("Ojo....... " + ca.getEye());
|
142 |
// System.out.println("X " + ca.getEye().x() + ";Y " + ca.getEye().y()
|
143 |
// + ";Z " + ca.getEye().z());
|
144 |
// System.out.println("Up........ " + ca.getUp());
|
145 |
// System.out.println("X " + ca.getUp().x() + ";Y " + ca.getUp().y()
|
146 |
// + ";Z " + ca.getUp().z());
|
147 |
// System.out.println("******************************************");
|
148 |
|
149 |
// ProjectExtent extent = ProjectFactory.createExtent();
|
150 |
// extent.setDescription(name);
|
151 |
// // extent.setExtent(mapa.getViewPort().getExtent());
|
152 |
// project.addExtent(extent);
|
153 |
} |
154 |
|
155 |
} |