Revision 26964
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/build.number | ||
---|---|---|
1 |
build.number=7 |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/InitialWarningExtension3D.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: InitialWarningExtension.java 15921 2007-11-05 16:14:10Z vcaballero $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.4 2006-10-02 13:52:34 jaume |
|
47 |
* organize impots |
|
48 |
* |
|
49 |
* Revision 1.3 2006/08/29 07:56:27 cesar |
|
50 |
* Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc) |
|
51 |
* |
|
52 |
* Revision 1.2 2006/08/29 07:13:53 cesar |
|
53 |
* Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow |
|
54 |
* |
|
55 |
* Revision 1.1 2006/05/25 16:27:21 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
package org.gvsig.gvsig3dgui; |
|
61 |
|
|
62 |
import java.awt.Color; |
|
63 |
import java.awt.Component; |
|
64 |
import java.awt.Window; |
|
65 |
import java.util.prefs.Preferences; |
|
66 |
|
|
67 |
import javax.swing.JButton; |
|
68 |
import javax.swing.JCheckBox; |
|
69 |
import javax.swing.JLabel; |
|
70 |
import javax.swing.JPanel; |
|
71 |
import javax.swing.JWindow; |
|
72 |
import javax.swing.border.TitledBorder; |
|
73 |
|
|
74 |
import com.iver.andami.PluginServices; |
|
75 |
import com.iver.andami.plugins.Extension; |
|
76 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
77 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
78 |
import com.iver.utiles.XMLEntity; |
|
79 |
|
|
80 |
public class InitialWarningExtension3D extends Extension { |
|
81 |
// public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.initial_warkning" ); |
|
82 |
// private boolean show = fPrefs.getBoolean( "show_panel", true); |
|
83 |
private DlgWaring dlgWarning; |
|
84 |
|
|
85 |
private boolean compatibilitySwing; |
|
86 |
|
|
87 |
private boolean showDialog; |
|
88 |
|
|
89 |
private String message; |
|
90 |
|
|
91 |
private static Preferences prefs = Preferences.userRoot().node( "gvsig.configuration.3D" ); |
|
92 |
/** |
|
93 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
94 |
*/ |
|
95 |
public boolean isEnabled() { |
|
96 |
return true; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible() |
|
101 |
*/ |
|
102 |
public boolean isVisible() { |
|
103 |
return true; |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
108 |
*/ |
|
109 |
public void initialize() { |
|
110 |
|
|
111 |
showDialog = false; |
|
112 |
message = PluginServices.getText(this, "initial_warning_3D"); |
|
113 |
|
|
114 |
String skinName = ""; |
|
115 |
PluginServices ps = PluginServices.getPluginServices("com.iver.core"); |
|
116 |
if(ps == null) return; |
|
117 |
XMLEntity xml = ps.getPersistentXML(); |
|
118 |
if (xml.contains("Skin-Selected")) { |
|
119 |
skinName = xml.getStringProperty("Skin-Selected"); |
|
120 |
} |
|
121 |
|
|
122 |
if (skinName.equals("com.iver.core.mdiManager.NewSkin")) { |
|
123 |
message += PluginServices.getText(this, "initial_skin_warning"); |
|
124 |
showDialog = true; |
|
125 |
} |
|
126 |
|
|
127 |
if (!skinName.equals("org.gvsig.mdiManager.DockingManager")){ |
|
128 |
compatibilitySwing = prefs.getBoolean("compatibilitySwing", compatibilitySwing); |
|
129 |
|
|
130 |
if (!compatibilitySwing){ |
|
131 |
message += PluginServices.getText(this, "initial_canvas_warning"); |
|
132 |
showDialog = true; |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
// if (showDialog){ |
|
137 |
// dlgWarning = new DlgWaring(); |
|
138 |
// dlgWarning.setText(message); |
|
139 |
// dlgWarning.setVisible(true); |
|
140 |
// } |
|
141 |
|
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
146 |
*/ |
|
147 |
public void execute(String actionCommand) { |
|
148 |
|
|
149 |
} |
|
150 |
|
|
151 |
private class DlgWaring extends JWindow{ |
|
152 |
|
|
153 |
private JButton btnOk = null; |
|
154 |
private JCheckBox chkBoxShowAgain = null; |
|
155 |
private JLabel lblText = null; |
|
156 |
private JPanel panel=null; |
|
157 |
private JPanel panel2; |
|
158 |
/** |
|
159 |
* This is the default constructor |
|
160 |
*/ |
|
161 |
public DlgWaring() { |
|
162 |
super((Window)PluginServices.getMainFrame()); |
|
163 |
Window window=(Window)PluginServices.getMainFrame(); |
|
164 |
setLocation(window.getWidth()/2+window.getX()-150,window.getHeight()/2+window.getY()-150); |
|
165 |
initialize(); |
|
166 |
this.setAlwaysOnTop(true); |
|
167 |
} |
|
168 |
|
|
169 |
public void setText(String string) { |
|
170 |
lblText.setText(string); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* This method initializes this |
|
175 |
* |
|
176 |
* @return void |
|
177 |
*/ |
|
178 |
private void initialize() { |
|
179 |
panel=new JPanel(); |
|
180 |
panel.setBackground(Color.black); |
|
181 |
panel.setLayout(null); |
|
182 |
panel.setBounds(0,0,300,300); |
|
183 |
panel2=new JPanel(); |
|
184 |
panel2.setLayout(null); |
|
185 |
panel2.setBounds(2,2,298,298); |
|
186 |
lblText = new JLabel(); |
|
187 |
lblText.setBounds(15, 15, 271, 200); |
|
188 |
lblText.setText("JLabel"); |
|
189 |
lblText.setBorder(new TitledBorder(PluginServices.getText(this, "warning"))); |
|
190 |
panel2.add(lblText); |
|
191 |
panel2.setSize((int)(panel.getSize().getWidth()-4),(int)(panel.getSize().getHeight()-4)); |
|
192 |
panel.add(panel2); |
|
193 |
this.setLayout(null); |
|
194 |
this.setSize(300, 300); |
|
195 |
this.add(getBtnOk(), null); |
|
196 |
// this.add(getChkBoxShowAgain(), null); |
|
197 |
this.add(panel, null); |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* This method initializes btnOk |
|
202 |
* |
|
203 |
* @return javax.swing.JButton |
|
204 |
*/ |
|
205 |
private JButton getBtnOk() { |
|
206 |
if (btnOk == null) { |
|
207 |
btnOk = new JButton(); |
|
208 |
btnOk.setBounds(100, 250, 100, 20); |
|
209 |
btnOk.setText(PluginServices.getText(this, "aceptar")); |
|
210 |
btnOk.addActionListener(new java.awt.event.ActionListener() { |
|
211 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
212 |
dlgWarning.setVisible(false); |
|
213 |
dlgWarning.dispose(); |
|
214 |
// PluginServices.getMDIManager().closeWindow(dlgWarning); |
|
215 |
} |
|
216 |
}); |
|
217 |
} |
|
218 |
return btnOk; |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* This method initializes chkBoxShowAgain |
|
223 |
* |
|
224 |
* @return javax.swing.JCheckBox |
|
225 |
*/ |
|
226 |
// private JCheckBox getChkBoxShowAgain() { |
|
227 |
// if (chkBoxShowAgain == null) { |
|
228 |
// chkBoxShowAgain = new JCheckBox(); |
|
229 |
// chkBoxShowAgain.setBounds(44, 116, 241, 21); |
|
230 |
// chkBoxShowAgain.setSelected(true); |
|
231 |
// chkBoxShowAgain.setText(PluginServices.getText(this, "show_this_dialog_next_startup")); |
|
232 |
// } |
|
233 |
// return chkBoxShowAgain; |
|
234 |
// } |
|
235 |
|
|
236 |
public WindowInfo getWindowInfo() { |
|
237 |
WindowInfo vi = new WindowInfo(WindowInfo.MODALDIALOG); |
|
238 |
vi.setWidth(300+8); |
|
239 |
vi.setHeight(250); |
|
240 |
vi.setTitle(PluginServices.getText(this, "warning")); |
|
241 |
return vi; |
|
242 |
} |
|
243 |
|
|
244 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
245 |
|
|
246 |
@Override |
|
247 |
public void postInitialize() { |
|
248 |
// TODO Auto-generated method stub |
|
249 |
super.postInitialize(); |
|
250 |
if (showDialog){ |
|
251 |
dlgWarning = new DlgWaring(); |
|
252 |
dlgWarning.setText(message); |
|
253 |
dlgWarning.setVisible(true); |
|
254 |
} |
|
255 |
|
|
256 |
} |
|
257 |
|
|
258 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/Extension3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui; |
|
2 |
|
|
3 |
import javax.swing.JPopupMenu; |
|
4 |
|
|
5 |
import org.gvsig.gvsig3dgui.preferences.View3DPreferences; |
|
6 |
import org.gvsig.gvsig3dgui.tocMenu.TocEditingLayer; |
|
7 |
import org.gvsig.gvsig3dgui.tocMenu.TocRefreshLayer; |
|
8 |
import org.gvsig.gvsig3dgui.tocMenu.TocTransparencyPanel; |
|
9 |
|
|
10 |
import com.iver.andami.PluginServices; |
|
11 |
import com.iver.andami.plugins.Extension; |
|
12 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
13 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
14 |
|
|
15 |
|
|
16 |
public class Extension3D extends Extension { |
|
17 |
|
|
18 |
public void execute(String actionCommand) { |
|
19 |
} |
|
20 |
|
|
21 |
public void initialize() { |
|
22 |
JPopupMenu.setDefaultLightWeightPopupEnabled(false); |
|
23 |
ProjectView3DFactory.register(); |
|
24 |
|
|
25 |
// TODO: registrar aki las opciones del menu contestual del toc |
|
26 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
27 |
extensionPoints.add("View_TocActions",PluginServices.getText(this, "Transparency"),new TocTransparencyPanel()); |
|
28 |
extensionPoints.add("View_TocActions",PluginServices.getText(this, "Layer_Refresh"),new TocRefreshLayer()); |
|
29 |
extensionPoints.add("View_TocActions",PluginServices.getText(this, "Editing_layer"),new TocEditingLayer()); |
|
30 |
|
|
31 |
// Registering preferences dialog |
|
32 |
extensionPoints.add("AplicationPreferences","View3DPreferences", new View3DPreferences()); |
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
public void postInitialize() { |
|
38 |
super.postInitialize(); |
|
39 |
} |
|
40 |
|
|
41 |
public boolean isEnabled() { |
|
42 |
return true; |
|
43 |
} |
|
44 |
|
|
45 |
public boolean isVisible() { |
|
46 |
return false; |
|
47 |
} |
|
48 |
|
|
49 |
public void terminate() { |
|
50 |
super.terminate(); |
|
51 |
} |
|
52 |
|
|
53 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/listener/PointSelectListerner3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.listener; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
|
|
5 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
|
6 |
import org.gvsig.osgvp.Vec3; |
|
7 |
import org.gvsig.osgvp.viewer.Intersections; |
|
8 |
|
|
9 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
10 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
|
11 |
import com.iver.andami.messages.NotificationManager; |
|
12 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
13 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
14 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
|
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
16 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
17 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
18 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
|
19 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.PointSelectListener; |
|
20 |
|
|
21 |
public class PointSelectListerner3D extends PointSelectListener { |
|
22 |
|
|
23 |
public PointSelectListerner3D(MapControl mapCtrl) { |
|
24 |
super(mapCtrl); |
|
25 |
// TODO Auto-generated constructor stub |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
public void point(PointEvent event) throws BehaviorException { |
|
31 |
// TODO Auto-generated method stub |
|
32 |
// super.point(event); |
|
33 |
// MapControl3D mapControl3D = (MapControl3D) this.mapCtrl; |
|
34 |
MapContext3D mapContext = (MapContext3D) mapCtrl.getMapContext(); |
|
35 |
|
|
36 |
try { |
|
37 |
// mapCtrl.getMapContext().selectByPoint(event.getPoint(), 1); |
|
38 |
Point2D p = event.getPoint(); |
|
39 |
Vec3 mapPoint = coordinatesIntersection(p); |
|
40 |
|
|
41 |
// Tolerancia de 3 pixels |
|
42 |
// double tol = mapCtrl.getViewPort().toMapDistance(3); |
|
43 |
double tol = 0.20; |
|
44 |
FLayer[] actives = mapCtrl.getMapContext().getLayers().getActives(); |
|
45 |
for (int i = 0; i < actives.length; i++) { |
|
46 |
if (actives[i] instanceof FLyrVect) { |
|
47 |
FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
48 |
Layer3DProps props = Layer3DProps.getLayer3DProps(lyrVect); |
|
49 |
float heigth = props.getHeigth(); |
|
50 |
if (Math.abs(heigth - mapPoint.z()) <= 3000){ |
|
51 |
FBitSet oldBitSet = lyrVect.getSource().getRecordset() |
|
52 |
.getSelection(); |
|
53 |
Point2D pointInter = new Point2D.Double(); |
|
54 |
pointInter.setLocation(mapPoint.x(), mapPoint.y()); |
|
55 |
FBitSet newBitSet = lyrVect.queryByPoint(pointInter, tol); |
|
56 |
// FBitSet newBitSet = lyrVect.queryByPoint(p, tol); |
|
57 |
if (event.getEvent().isControlDown()) |
|
58 |
newBitSet.xor(oldBitSet); |
|
59 |
lyrVect.getRecordset().setSelection(newBitSet); |
|
60 |
} |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
} catch (ReadDriverException e) { |
|
65 |
throw new BehaviorException("No se pudo hacer la selecci?n"); |
|
66 |
} catch (VisitorException e) { |
|
67 |
throw new BehaviorException("No se pudo hacer la selecci?n"); |
|
68 |
} |
|
69 |
// mapContext.selectionChanged(new SelectionEvent()); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public void pointDoubleClick(PointEvent event) throws BehaviorException { |
|
74 |
// TODO Auto-generated method stub |
|
75 |
// super.pointDoubleClick(event); |
|
76 |
} |
|
77 |
|
|
78 |
public Vec3 coordinatesIntersection(Point2D pScreen) { |
|
79 |
Vec3 intersection; |
|
80 |
|
|
81 |
// System.err.println("Coordenadas de pantalla " + pScreen.getX() + ","+ |
|
82 |
// pScreen.getY()); |
|
83 |
MapContext3D mcontext = (MapContext3D) this.mapCtrl.getMapContext(); |
|
84 |
int heigth = mcontext.getCanvas3d().getHeight(); |
|
85 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick( |
|
86 |
(int) pScreen.getX(),(int) pScreen.getY()); |
|
87 |
Point2D pWorld = new Point2D.Double(); |
|
88 |
if (hits.containsIntersections()) { |
|
89 |
// get XYZ coordinates on planet |
|
90 |
Vec3 hit = hits.getFirstIntersection().getIntersectionPoint(); |
|
91 |
// convert to geo coordinates |
|
92 |
|
|
93 |
// System.err.println("Interseccion de osg " + hit.x() + ","+ |
|
94 |
// hit.y()); |
|
95 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase("EPSG:4326") == 0) { |
|
96 |
Vec3 geoPt = mcontext.getPlanet().convertXYZToLatLongHeight(hit); |
|
97 |
// Swap the coordinates X and Y, because they are invert. |
|
98 |
intersection = new Vec3(geoPt.y(),geoPt.x(),geoPt.z()); |
|
99 |
// intersection = geoPt; |
|
100 |
} else { |
|
101 |
intersection = hit; |
|
102 |
} |
|
103 |
} else { |
|
104 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase("EPSG:4326") == 0) { |
|
105 |
pWorld.setLocation(360, 120); |
|
106 |
intersection = new Vec3(360,120,0); |
|
107 |
} else{ |
|
108 |
intersection = new Vec3(1e100,1e100,0); |
|
109 |
// pWorld.setLocation(1e100, 1e100); |
|
110 |
} |
|
111 |
} |
|
112 |
NotificationManager.addInfo("Obteniendo punto de informacion "+ intersection.x() + " , " + intersection.y() +" , "+ intersection.z()); |
|
113 |
return intersection; |
|
114 |
} |
|
115 |
|
|
116 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/listener/RectangleSelectListener3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.listener; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.awt.geom.Rectangle2D; |
|
5 |
|
|
6 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
|
7 |
import org.gvsig.osgvp.Vec3; |
|
8 |
import org.gvsig.osgvp.viewer.Intersections; |
|
9 |
|
|
10 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
11 |
import com.iver.andami.messages.NotificationManager; |
|
12 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
13 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
14 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
|
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
16 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
17 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
18 |
import com.iver.cit.gvsig.fmap.tools.RectangleSelectionListener; |
|
19 |
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
|
20 |
|
|
21 |
public class RectangleSelectListener3D extends RectangleSelectionListener { |
|
22 |
|
|
23 |
private MapControl mapControl; |
|
24 |
|
|
25 |
public RectangleSelectListener3D(MapControl mc) { |
|
26 |
super(mc); |
|
27 |
// TODO Auto-generated constructor stub |
|
28 |
mapControl = mc; |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public void rectangle(RectangleEvent event) throws BehaviorException { |
|
33 |
try { |
|
34 |
// mapCtrl.getMapContext().selectByRect(event.getWorldCoordRect()); |
|
35 |
Rectangle2D rect = event.getWorldCoordRect(); |
|
36 |
Point2D up = new Point2D.Double(); |
|
37 |
up.setLocation(rect.getX(), rect.getY()); |
|
38 |
Vec3 upLeft = coordinatesIntersection(up); |
|
39 |
// Point2D down = new Point2D.Double(); |
|
40 |
// down.setLocation(rect.getMaxX(), rect.getMaxY()); |
|
41 |
// Vec3 downRight = coordinatesIntersection(down); |
|
42 |
|
|
43 |
Rectangle2D newRect = new Rectangle2D.Double(upLeft.x(), |
|
44 |
upLeft.y(), rect.getHeight(), rect.getWidth()); |
|
45 |
|
|
46 |
FLayer[] actives = mapControl.getMapContext().getLayers() |
|
47 |
.getActives(); |
|
48 |
for (int i = 0; i < actives.length; i++) { |
|
49 |
if (actives[i] instanceof FLyrVect) { |
|
50 |
FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
51 |
FBitSet oldBitSet = lyrVect.getSource().getRecordset() |
|
52 |
.getSelection(); |
|
53 |
// FBitSet newBitSet = lyrVect.queryByRect(newRect); |
|
54 |
FBitSet newBitSet = lyrVect.queryByRect(rect); |
|
55 |
if (event.getEvent().isControlDown()) |
|
56 |
newBitSet.xor(oldBitSet); |
|
57 |
lyrVect.getRecordset().setSelection(newBitSet); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
} catch (ReadDriverException e) { |
|
62 |
throw new BehaviorException("No se pudo hacer la selecci?n"); |
|
63 |
} catch (VisitorException e) { |
|
64 |
throw new BehaviorException("No se pudo hacer la selecci?n"); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
public Vec3 coordinatesIntersection(Point2D pScreen) { |
|
69 |
Vec3 intersection; |
|
70 |
|
|
71 |
// System.err.println("Coordenadas de pantalla " + pScreen.getX() + ","+ |
|
72 |
// pScreen.getY()); |
|
73 |
MapContext3D mcontext = (MapContext3D) this.mapControl.getMapContext(); |
|
74 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick( |
|
75 |
(int) pScreen.getX(), (int) pScreen.getY()); |
|
76 |
Point2D pWorld = new Point2D.Double(); |
|
77 |
if (hits.containsIntersections()) { |
|
78 |
// get XYZ coordinates on planet |
|
79 |
Vec3 hit = hits.getFirstIntersection().getIntersectionPoint(); |
|
80 |
// convert to geo coordinates |
|
81 |
|
|
82 |
// System.err.println("Interseccion de osg " + hit.x() + ","+ |
|
83 |
// hit.y()); |
|
84 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase( |
|
85 |
"EPSG:4326") == 0) { |
|
86 |
Vec3 geoPt = mcontext.getPlanet() |
|
87 |
.convertXYZToLatLongHeight(hit); |
|
88 |
intersection = geoPt; |
|
89 |
} else { |
|
90 |
intersection = hit; |
|
91 |
} |
|
92 |
} else { |
|
93 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase( |
|
94 |
"EPSG:4326") == 0) { |
|
95 |
pWorld.setLocation(360, 120); |
|
96 |
intersection = new Vec3(360, 120, 0); |
|
97 |
} else { |
|
98 |
intersection = new Vec3(1e100, 1e100, 0); |
|
99 |
// pWorld.setLocation(1e100, 1e100); |
|
100 |
} |
|
101 |
} |
|
102 |
NotificationManager.addInfo("Obteniendo punto de informacion " |
|
103 |
+ intersection.x() + " , " + intersection.y() + " , " |
|
104 |
+ intersection.z()); |
|
105 |
return intersection; |
|
106 |
} |
|
107 |
|
|
108 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/camera/Menu3D.java | ||
---|---|---|
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 org.gvsig.gvsig3dgui.camera; |
|
42 |
|
|
43 |
import org.gvsig.gvsig3dgui.view.InsertPosition; |
|
44 |
import org.gvsig.gvsig3dgui.view.View3D; |
|
45 |
|
|
46 |
import com.iver.andami.PluginServices; |
|
47 |
import com.iver.andami.plugins.Extension; |
|
48 |
import com.iver.cit.gvsig.ProjectExtension; |
|
49 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
50 |
import com.iver.cit.gvsig.project.Project; |
|
51 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
52 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
|
53 |
import com.iver.cit.gvsig.project.documents.view.gui.FPanelExtentSelector; |
|
54 |
|
|
55 |
public class Menu3D extends Extension { |
|
56 |
|
|
57 |
|
|
58 |
private boolean activa = true; |
|
59 |
|
|
60 |
public void execute(String actionCommand) { |
|
61 |
// System.out.println("EXECUTE"); |
|
62 |
|
|
63 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices.getMDIManager().getActiveWindow(); |
|
64 |
if (!(view instanceof View3D)) |
|
65 |
return; |
|
66 |
// System.out.println("RECUPERADA LA VISTA 3D"); |
|
67 |
View3D vista3D =(View3D)view; |
|
68 |
|
|
69 |
if (actionCommand.equals("ENCUADRE")) { |
|
70 |
// System.out.println("DEBUG: Mostrando herramienta de encuadre"); |
|
71 |
// create and show the modal fopen dialog |
|
72 |
|
|
73 |
FPanelExtentSelector l = new FPanelExtentSelector(); |
|
74 |
|
|
75 |
ProjectExtension p = (ProjectExtension) PluginServices.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
|
76 |
Project project = p.getProject(); |
|
77 |
ExtentListSelectorModel3D modelo = new ExtentListSelectorModel3D(project); |
|
78 |
project.addPropertyChangeListener(modelo); |
|
79 |
l.setModel(modelo); |
|
80 |
l.addSelectionListener(new Encuadrator3D(project, null, vista3D)); |
|
81 |
// l.addSelectionListener(new Encuadrator(project, mapa, vista)); |
|
82 |
PluginServices.getMDIManager().addWindow(l); |
|
83 |
|
|
84 |
// GUI g = new GUI(); |
|
85 |
// //g.setVisible(true); |
|
86 |
// PluginServices.getMDIManager().addWindow((IWindow) g); |
|
87 |
} else if (actionCommand.equals("POINT3D")) { |
|
88 |
InsertPosition insertPosition = new InsertPosition(vista3D.getModel()); |
|
89 |
PluginServices.getMDIManager().addWindow(insertPosition); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
public void initialize() { |
|
94 |
// Register new icons |
|
95 |
// extent manegement |
|
96 |
PluginServices.getIconTheme().registerDefault( |
|
97 |
"encuadrator-icon", |
|
98 |
this.getClass().getClassLoader().getResource( |
|
99 |
"images/encuadre.png")); |
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
this.setActiva(true); |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
public boolean isEnabled() { |
|
108 |
return true; |
|
109 |
} |
|
110 |
|
|
111 |
public boolean isVisible() { |
|
112 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
|
113 |
.getMDIManager().getActiveWindow(); |
|
114 |
|
|
115 |
if (f == null) { |
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
if (f instanceof View3D) { |
|
120 |
BaseView vista = (BaseView) f; |
|
121 |
IProjectView model = vista.getModel(); |
|
122 |
MapContext mapa = model.getMapContext(); |
|
123 |
|
|
124 |
return mapa.getLayers().getLayersCount() > 0; |
|
125 |
} |
|
126 |
return false; |
|
127 |
} |
|
128 |
|
|
129 |
public void terminate() { |
|
130 |
super.terminate(); |
|
131 |
} |
|
132 |
|
|
133 |
public boolean isActiva() { |
|
134 |
return activa; |
|
135 |
} |
|
136 |
|
|
137 |
public void setActiva(boolean activa) { |
|
138 |
this.activa = activa; |
|
139 |
} |
|
140 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/camera/ExtentListSelectorModel3D.java | ||
---|---|---|
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 org.gvsig.gvsig3dgui.camera; |
|
42 |
|
|
43 |
import java.beans.PropertyChangeEvent; |
|
44 |
import java.beans.PropertyChangeListener; |
|
45 |
import java.util.ArrayList; |
|
46 |
|
|
47 |
import javax.swing.ListModel; |
|
48 |
import javax.swing.event.ListDataEvent; |
|
49 |
import javax.swing.event.ListDataListener; |
|
50 |
|
|
51 |
import com.iver.cit.gvsig.project.Project; |
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
public class ExtentListSelectorModel3D implements ListModel, PropertyChangeListener { |
|
56 |
|
|
57 |
private Project project; |
|
58 |
private ArrayList listeners = new ArrayList(); |
|
59 |
|
|
60 |
public ExtentListSelectorModel3D(Project p){ |
|
61 |
project = p; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* @see javax.swing.ListModel#getSize() |
|
66 |
*/ |
|
67 |
public int getSize() { |
|
68 |
return this.project.getCameras().length; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* @see javax.swing.ListModel#getElementAt(int) |
|
73 |
*/ |
|
74 |
public Object getElementAt(int arg0) { |
|
75 |
return this.project.getCameras()[arg0]; |
|
76 |
} |
|
77 |
|
|
78 |
/* (non-Javadoc) |
|
79 |
* @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener) |
|
80 |
*/ |
|
81 |
public void addListDataListener(ListDataListener arg0) { |
|
82 |
listeners.add(arg0); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener) |
|
87 |
*/ |
|
88 |
public void removeListDataListener(ListDataListener arg0) { |
|
89 |
listeners.remove(arg0); |
|
90 |
} |
|
91 |
|
|
92 |
/* (non-Javadoc) |
|
93 |
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) |
|
94 |
*/ |
|
95 |
public void propertyChange(PropertyChangeEvent change) { |
|
96 |
if (change.getPropertyName().equals("addCamera")){ |
|
97 |
ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, 0, getSize()); |
|
98 |
for (int i = 0; i < listeners.size(); i++){ |
|
99 |
((ListDataListener) listeners.get(i)).intervalAdded(event); |
|
100 |
} |
|
101 |
}else{ |
|
102 |
ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, 0, getSize()); |
|
103 |
for (int i = 0; i < listeners.size(); i++){ |
|
104 |
((ListDataListener) listeners.get(i)).intervalRemoved(event); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/camera/Encuadrator3D.java | ||
---|---|---|
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 org.gvsig.gvsig3dgui.camera; |
|
42 |
|
|
43 |
import org.gvsig.gvsig3dgui.view.View3D; |
|
44 |
import org.gvsig.osgvp.viewer.Camera; |
|
45 |
|
|
46 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
|
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 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/manipulator/Manipulator3DExtension.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.manipulator; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
|
|
5 |
import org.gvsig.gvsig3d.cacheservices.OSGCacheService; |
|
6 |
import org.gvsig.gvsig3d.navigation.NavigationMode; |
|
7 |
import org.gvsig.gvsig3dgui.view.View3D; |
|
8 |
import org.gvsig.osgvp.manipulator.EditionManager; |
|
9 |
import org.gvsig.osgvp.manipulator.Manipulator.DraggerType; |
|
10 |
|
|
11 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
|
12 |
import com.iver.andami.PluginServices; |
|
13 |
import com.iver.andami.plugins.Extension; |
|
14 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
16 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
17 |
|
|
18 |
public class Manipulator3DExtension extends Extension { |
|
19 |
|
|
20 |
private NavigationMode navMode; |
|
21 |
private EditionManager em; |
|
22 |
|
|
23 |
public void execute(String actionCommand) { |
|
24 |
|
|
25 |
// Getting view3 |
|
26 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices |
|
27 |
.getMDIManager().getActiveWindow(); |
|
28 |
if (!(view instanceof View3D)) |
|
29 |
return; |
|
30 |
// Casting to View3D |
|
31 |
View3D vista3D = (View3D) view; |
|
32 |
Component viewer = (Component) vista3D.getCanvas3d(); |
|
33 |
|
|
34 |
// remove active tool in MapControl |
|
35 |
boolean resetCursor = true; |
|
36 |
|
|
37 |
// navMode = vista3D.getNavMode(); |
|
38 |
// navMode.removeAllModes(); |
|
39 |
|
|
40 |
IProjectView model = vista3D.getModel(); |
|
41 |
MapContext mapa = model.getMapContext(); |
|
42 |
FLayer[] activeLayers = mapa.getLayers().getActives(); |
|
43 |
if (activeLayers.length > 0) { |
|
44 |
FLayer layer = activeLayers[0]; |
|
45 |
|
|
46 |
Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer); |
|
47 |
OSGCacheService osgCacheService = (OSGCacheService) props3D |
|
48 |
.getCacheService(); |
|
49 |
|
|
50 |
em = osgCacheService.getEditionManager(); |
|
51 |
if (actionCommand.equals("ROTATION_MANIPULATOR")) { |
|
52 |
// em.changeDragger(DraggerType.ROTATE_SPHERE_DRAGGER); |
|
53 |
em.changeDragger(DraggerType.TABBOX_DRAGGER); |
|
54 |
} else if (actionCommand.equals("TABBOX_MANIPULATOR")) { |
|
55 |
em.changeDragger(DraggerType.TRACKBALL_DRAGGER); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
public void initialize() { |
|
62 |
// TODO Auto-generated method stub |
|
63 |
|
|
64 |
//Registering icons. |
|
65 |
PluginServices.getIconTheme().registerDefault( |
|
66 |
"tabbox_manipulator", |
|
67 |
this.getClass().getClassLoader().getResource( |
|
68 |
"images/rotation_manipulator.png")); |
|
69 |
|
|
70 |
PluginServices.getIconTheme().registerDefault( |
|
71 |
"rotation_manipulator", |
|
72 |
this.getClass().getClassLoader().getResource( |
|
73 |
"images/tabbox_manipulator.gif")); |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
public boolean isEnabled() { |
|
78 |
boolean result = false; |
|
79 |
// Getting view3 |
|
80 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices |
|
81 |
.getMDIManager().getActiveWindow(); |
|
82 |
if ((view instanceof View3D)){ |
|
83 |
// Casting to View3D |
|
84 |
View3D vista3D = (View3D) view; |
|
85 |
|
|
86 |
IProjectView model = vista3D.getModel(); |
|
87 |
MapContext mapa = model.getMapContext(); |
|
88 |
FLayer[] activeLayers = mapa.getLayers().getActives(); |
|
89 |
if (activeLayers.length > 0) { |
|
90 |
FLayer layer = activeLayers[0]; |
|
91 |
Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer); |
|
92 |
if (props3D.getType() == Layer3DProps.layer3DOSG){ |
|
93 |
result = true; |
|
94 |
} |
|
95 |
} |
|
96 |
} |
|
97 |
return result; |
|
98 |
} |
|
99 |
|
|
100 |
public boolean isVisible() { |
|
101 |
// Getting view3 |
|
102 |
boolean result = false; |
|
103 |
// Getting view3 |
|
104 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices |
|
105 |
.getMDIManager().getActiveWindow(); |
|
106 |
if ((view instanceof View3D)){ |
|
107 |
// Casting to View3D |
|
108 |
View3D vista3D = (View3D) view; |
|
109 |
|
|
110 |
IProjectView model = vista3D.getModel(); |
|
111 |
MapContext mapa = model.getMapContext(); |
|
112 |
FLayer[] activeLayers = mapa.getLayers().getActives(); |
|
113 |
if (activeLayers.length > 0) { |
|
114 |
FLayer layer = activeLayers[0]; |
|
115 |
Layer3DProps props3D = Layer3DProps.getLayer3DProps(layer); |
|
116 |
if (props3D.getType() == Layer3DProps.layer3DOSG){ |
|
117 |
result = true; |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
return result; |
|
122 |
} |
|
123 |
|
|
124 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/legend/Legend3DExtension.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.legend; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import org.gvsig.baseclasses.IOperator; |
|
6 |
|
|
7 |
import com.iver.ai2.gvsig3d.legend.extrusion.ExtrusionLegendPanel; |
|
8 |
import com.iver.ai2.gvsig3d.legend.symbols.Object3DMarker; |
|
9 |
import com.iver.andami.plugins.Extension; |
|
10 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
11 |
import com.iver.cit.gvsig.gui.styling.SymbolEditor; |
|
12 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.LegendManager; |
|
13 |
|
|
14 |
|
|
15 |
public class Legend3DExtension extends Extension{ |
|
16 |
private static ArrayList<IOperator> operators=new ArrayList<IOperator>(); |
|
17 |
|
|
18 |
public void execute(String actionCommand) { |
|
19 |
|
|
20 |
// com.iver.andami.ui.mdiManager.IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
21 |
// Table table = (Table)window; |
|
22 |
// if (operators.isEmpty()) { |
|
23 |
// PluginServices.cancelableBackgroundExecution(new EvalOperatorsTask()); |
|
24 |
// }else{ |
|
25 |
// EvalExpressionDialog eed=new EvalExpressionDialog(table,EvalOperatorsTask.interpreter,operators); |
|
26 |
// PluginServices.getMDIManager().addWindow(eed); |
|
27 |
// } |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
public void initialize() { |
|
32 |
// TODO Auto-generated method stub |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
@Override |
|
39 |
public void postInitialize() { |
|
40 |
// TODO Auto-generated method stub |
|
41 |
|
|
42 |
//LegendManager.addLegendPage(ExtrusionProve.class); |
|
43 |
LegendManager.addLegendPage(ExtrusionLegendPanel.class); |
|
44 |
// LegendManager.addLegendPage(SingleSymbolLegend3D.class); |
|
45 |
SymbolEditor.addSymbolEditorPanel(Object3DMarker.class, FShape.POINT); |
|
46 |
|
|
47 |
// Register operation of expresion |
|
48 |
// Prove.registerOperations(); |
|
49 |
|
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
public boolean isEnabled() { |
|
54 |
// TODO Auto-generated method stub |
|
55 |
return true; |
|
56 |
} |
|
57 |
|
|
58 |
public boolean isVisible() { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
return true; |
|
61 |
} |
|
62 |
|
|
63 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/behavior/RectangleBehavior3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.behavior; |
|
2 |
|
|
3 |
import java.awt.Graphics; |
|
4 |
import java.awt.Point; |
|
5 |
import java.awt.Rectangle; |
|
6 |
import java.awt.event.MouseEvent; |
|
7 |
import java.awt.geom.Point2D; |
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
|
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.gvsig.gvsig3d.map3d.GraphicLayer3D; |
|
12 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
|
13 |
import org.gvsig.osgvp.Vec3; |
|
14 |
import org.gvsig.osgvp.exceptions.OSGVPException; |
|
15 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
16 |
import org.gvsig.osgvp.features.SelectionRectangle; |
|
17 |
import org.gvsig.osgvp.features.Polygon.PolygonType; |
|
18 |
import org.gvsig.osgvp.planets.PlanetViewer; |
|
19 |
import org.gvsig.osgvp.viewer.Intersections; |
|
20 |
|
|
21 |
import com.iver.andami.messages.NotificationManager; |
|
22 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
23 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
|
24 |
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent; |
|
25 |
import com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener; |
|
26 |
|
|
27 |
public class RectangleBehavior3D extends RectangleBehavior { |
|
28 |
|
|
29 |
private Point2D m_FirstPoint; |
|
30 |
private Point2D m_LastPoint; |
|
31 |
private RectangleListener listener; |
|
32 |
private SelectionRectangle rectangle; |
|
33 |
private int height; |
|
34 |
private int width; |
|
35 |
|
|
36 |
private static Logger logger = Logger.getLogger(GraphicLayer3D.class |
|
37 |
.getName()); |
|
38 |
|
|
39 |
public RectangleBehavior3D(RectangleListener zili) { |
|
40 |
super(zili); |
|
41 |
// TODO Auto-generated constructor stub |
|
42 |
listener = zili; |
|
43 |
try { |
|
44 |
rectangle = new SelectionRectangle(); |
|
45 |
} catch (OSGVPException e) { |
|
46 |
logger.error("Command: " |
|
47 |
+ "Error creating new selection rectangle.", e); |
|
48 |
} |
|
49 |
|
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public void mouseDragged(MouseEvent e) { |
|
54 |
// TODO Auto-generated method stub |
|
55 |
// super.mouseDragged(e); |
|
56 |
// Painting |
|
57 |
rectangle.setMouseCoords((int) e.getPoint().getX(), height |
|
58 |
- (int) e.getPoint().getY()); |
|
59 |
try { |
|
60 |
rectangle.update(); |
|
61 |
} catch (OSGVPException e1) { |
|
62 |
logger.error("Command: " + "Error updating rectangle selection.", |
|
63 |
e1); |
|
64 |
} |
|
65 |
|
|
66 |
rectangle.setType(PolygonType.FILLED_POLYGON); |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void mousePressed(MouseEvent e) { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
|
74 |
try { |
|
75 |
((PlanetViewer) mcontext.getCanvas3d().getOSGViewer()) |
|
76 |
.addNodeToHUD(rectangle); |
|
77 |
} catch (NodeException e1) { |
|
78 |
logger.error("Command: " |
|
79 |
+ "Error adding the rectangle selecton to the hud node.", |
|
80 |
e1); |
|
81 |
} |
|
82 |
height = mcontext.getCanvas3d().getHeight(); |
|
83 |
width = mcontext.getCanvas3d().getWidth(); |
|
84 |
|
|
85 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
86 |
m_FirstPoint = e.getPoint(); |
|
87 |
// Put here the code to star drawing the rectangle |
|
88 |
rectangle.setFirstPoint((int) m_FirstPoint.getX(), height |
|
89 |
- (int) m_FirstPoint.getY()); |
|
90 |
rectangle.setMouseCoords((int) m_FirstPoint.getX(), height |
|
91 |
- (int) m_FirstPoint.getY()); |
|
92 |
|
|
93 |
try { |
|
94 |
rectangle.update(); |
|
95 |
} catch (OSGVPException e1) { |
|
96 |
logger.error("Command: " |
|
97 |
+ "Error updating rectangle selection.", e1); |
|
98 |
} |
|
99 |
rectangle.setType(PolygonType.EMPTY_POLYGON); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
105 |
|
|
106 |
if (m_FirstPoint == null) |
|
107 |
return; |
|
108 |
Point2D p1 = new Point2D.Double(); |
|
109 |
Point2D p2 = new Point2D.Double(); |
|
110 |
Point pScreen = e.getPoint(); |
|
111 |
|
|
112 |
// ViewPort vp = getMapControl().getMapContext().getViewPort(); |
|
113 |
|
|
114 |
// p1 = vp.toMapPoint(m_FirstPoint); |
|
115 |
// p2 = vp.toMapPoint(pScreen); |
|
116 |
Vec3 p1Vec = coordinatesIntersection(m_FirstPoint); |
|
117 |
p1.setLocation(p1Vec.x(), p1Vec.y()); |
|
118 |
Vec3 p2Vec = coordinatesIntersection(pScreen); |
|
119 |
p2.setLocation(p2Vec.x(), p2Vec.y()); |
|
120 |
|
|
121 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
122 |
// Fijamos el nuevo extent |
|
123 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
124 |
r.setFrameFromDiagonal(p1, p2); |
|
125 |
|
|
126 |
Rectangle2D rectPixel = new Rectangle(); |
|
127 |
rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen); |
|
128 |
|
|
129 |
RectangleEvent event = new RectangleEvent(r, e, rectPixel); |
|
130 |
listener.rectangle(event); |
|
131 |
|
|
132 |
} |
|
133 |
|
|
134 |
// Deleted rectangle |
|
135 |
rectangle.setMouseCoords((int) m_FirstPoint.getX(), height |
|
136 |
- (int) m_FirstPoint.getY()); |
|
137 |
try { |
|
138 |
rectangle.update(); |
|
139 |
} catch (OSGVPException e1) { |
|
140 |
logger.error("Command: " + "Error updating rectangle selection.", |
|
141 |
e1); |
|
142 |
} |
|
143 |
rectangle.setType(PolygonType.EMPTY_POLYGON); |
|
144 |
|
|
145 |
m_FirstPoint = null; |
|
146 |
m_LastPoint = null; |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public void paintComponent(Graphics g) { |
|
151 |
// TODO Auto-generated method stub |
|
152 |
// super.paintComponent(g); |
|
153 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
|
154 |
mcontext.getCanvas3d().repaint(); |
|
155 |
} |
|
156 |
|
|
157 |
public Vec3 coordinatesIntersection(Point2D pScreen) { |
|
158 |
Vec3 intersection; |
|
159 |
|
|
160 |
// System.err.println("Coordenadas de pantalla " + pScreen.getX() + ","+ |
|
161 |
// pScreen.getY()); |
|
162 |
MapContext3D mcontext = (MapContext3D) getMapControl().getMapContext(); |
|
163 |
Intersections hits = mcontext.getCanvas3d().getOSGViewer().rayPick( |
|
164 |
(int) pScreen.getX(), (int) pScreen.getY()); |
|
165 |
Point2D pWorld = new Point2D.Double(); |
|
166 |
if (hits.containsIntersections()) { |
|
167 |
// get XYZ coordinates on planet |
|
168 |
Vec3 hit = hits.getFirstIntersection().getIntersectionPoint(); |
|
169 |
// convert to geo coordinates |
|
170 |
|
|
171 |
// System.err.println("Interseccion de osg " + hit.x() + ","+ |
|
172 |
// hit.y()); |
|
173 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase( |
|
174 |
"EPSG:4326") == 0) { |
|
175 |
Vec3 geoPt = mcontext.getPlanet() |
|
176 |
.convertXYZToLatLongHeight(hit); |
|
177 |
// Swap the coordinates X and Y, because they are invert. |
|
178 |
intersection = new Vec3(geoPt.y(), geoPt.x(), geoPt.z()); |
|
179 |
} else { |
|
180 |
intersection = hit; |
|
181 |
} |
|
182 |
} else { |
|
183 |
if (mcontext.getProjection().getAbrev().compareToIgnoreCase( |
|
184 |
"EPSG:4326") == 0) { |
|
185 |
pWorld.setLocation(360, 120); |
|
186 |
intersection = new Vec3(360, 120, 0); |
|
187 |
} else { |
|
188 |
intersection = new Vec3(1e100, 1e100, 0); |
|
189 |
// pWorld.setLocation(1e100, 1e100); |
|
190 |
} |
|
191 |
} |
|
192 |
NotificationManager.addInfo("Obteniendo punto de informacion " |
|
193 |
+ intersection.x() + " , " + intersection.y() + " , " |
|
194 |
+ intersection.z()); |
|
195 |
return intersection; |
|
196 |
} |
|
197 |
|
|
198 |
} |
branches/3D_Animation_prepto_osgvp_2_2_0/extensions/ext3Dgui/src/org/gvsig/gvsig3dgui/navigation/NavigationMenu3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3dgui.navigation; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
import java.awt.Cursor; |
|
5 |
import java.awt.Image; |
|
6 |
import java.awt.Point; |
|
7 |
import java.awt.Toolkit; |
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
import java.io.File; |
|
10 |
import java.net.URL; |
|
11 |
|
|
12 |
import javax.swing.Icon; |
|
13 |
import javax.swing.ImageIcon; |
|
14 |
import javax.swing.JOptionPane; |
|
15 |
|
|
16 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
|
17 |
import org.gvsig.gvsig3d.navigation.NavigationMode; |
|
18 |
import org.gvsig.gvsig3dgui.view.View3D; |
|
19 |
import org.gvsig.osgvp.planets.CustomTerrainManipulator; |
|
20 |
import org.gvsig.osgvp.planets.Planet; |
|
21 |
import org.gvsig.osgvp.planets.PlanetViewer; |
|
22 |
import org.gvsig.osgvp.viewer.Camera; |
|
23 |
import org.gvsig.osgvp.viewer.OSGViewer; |
|
24 |
|
|
25 |
import com.iver.ai2.gvsig3d.resources.ResourcesFactory; |
|
26 |
import com.iver.andami.PluginServices; |
|
27 |
import com.iver.andami.plugins.Extension; |
|
28 |
import com.iver.andami.ui.mdiFrame.JMenuItem; |
|
29 |
import com.iver.andami.ui.mdiFrame.JToolBarButton; |
|
30 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
31 |
import com.iver.cit.gvsig.project.documents.view.gui.FPanelLocConfig; |
|
32 |
|
|
33 |
public class NavigationMenu3D extends Extension { |
|
34 |
|
|
35 |
private boolean activa = true; |
|
36 |
|
|
37 |
private NavigationMode navMode; |
|
38 |
|
|
39 |
private boolean wireAct = false; |
|
40 |
|
|
41 |
JMenuItem myMenu = null; |
|
42 |
|
|
43 |
Icon iconVis = null; |
|
44 |
|
|
45 |
Icon iconNoVis = null; |
|
46 |
|
|
47 |
private ImageIcon iconButtonVis; |
|
48 |
|
|
49 |
private ImageIcon iconButtonNoVis; |
|
50 |
|
|
51 |
// cursors |
|
52 |
private Cursor navCursor; |
|
53 |
|
|
54 |
private Cursor zoomCursor; |
|
55 |
|
|
56 |
private Cursor panCursor; |
|
57 |
|
|
58 |
private Cursor azimCursor; |
|
59 |
|
|
60 |
private String buttonPath; |
|
61 |
|
|
62 |
private String imagesPath; |
|
63 |
|
|
64 |
public void execute(String actionCommand) { |
|
65 |
// System.out.println("EXECUTE"); |
|
66 |
|
|
67 |
// Getting view3 |
|
68 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices |
|
69 |
.getMDIManager().getActiveWindow(); |
|
70 |
if (!(view instanceof View3D)) |
|
71 |
return; |
|
72 |
// Casting to View3D |
|
73 |
View3D vista3D = (View3D) view; |
|
74 |
Component viewer = (Component) vista3D.getCanvas3d(); |
|
75 |
|
|
76 |
// remove active tool in MapControl |
|
77 |
boolean resetCursor = true; |
|
78 |
|
|
79 |
navMode = vista3D.getNavMode(); |
|
80 |
|
|
81 |
// Action for ZOOM_SELECT |
|
82 |
if (actionCommand.equals("PAN_SELECT")) { |
|
83 |
if (navMode != null) { |
|
84 |
viewer.setCursor(panCursor); |
|
85 |
navMode.SetRollMode(); |
|
86 |
} |
|
87 |
} else if (actionCommand.equals("ZOOM_SELECT")) { |
|
88 |
if (navMode != null) { |
|
89 |
viewer.setCursor(zoomCursor); |
|
90 |
navMode.SetZoomMode(); |
|
91 |
} |
|
92 |
} else if (actionCommand.equals("AZIMUT_SELECT")) { |
|
93 |
if (navMode != null) { |
|
94 |
viewer.setCursor(azimCursor); |
|
95 |
navMode.SetAzimutMode(); |
|
96 |
} |
|
97 |
} else if (actionCommand.equals("DEFAULT_SELECT")) { |
|
98 |
if (navMode != null) { |
|
99 |
viewer.setCursor(navCursor); |
|
100 |
navMode.SetDefaultMode(); |
|
101 |
} |
|
102 |
} else if (actionCommand.equals("WIRE_FRAME")) { |
|
103 |
resetCursor = false; |
|
104 |
wireAct = !wireAct; |
|
105 |
if (wireAct) |
|
106 |
vista3D.getCanvas3d().getOSGViewer().setPolygonMode( |
|
107 |
OSGViewer.PolygonModeType.GL_LINE); |
|
108 |
else |
|
109 |
vista3D.getCanvas3d().getOSGViewer().setPolygonMode( |
|
110 |
OSGViewer.PolygonModeType.GL_FILL); |
|
111 |
vista3D.getCanvas3d().repaint(); |
|
112 |
} else if (actionCommand.equals("RESET_VIEW")) { |
|
113 |
resetCursor = false; |
|
114 |
MapContext3D map3D = (MapContext3D) vista3D.getMapControl() |
|
115 |
.getMapContext(); |
|
116 |
FLayers layers = map3D.getLayers(); |
Also available in: Unified diff