View Javadoc
1 /***************************************************************************** 2 * Virtual Mockup for Machine Vision 3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr., 4 * Carlos S. Santos. 5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP 6 * 7 * Permission is granted to redistribute and/or modify this 8 * software under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This software is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html) 16 * for more details. 17 * 18 *****************************************************************************/ 19 20 package camera3d.gui; 21 22 import java.util.Vector; 23 import camera3d.*; 24 import camera3d.event.SelectionChangedEvent; 25 import java.awt.*; 26 import javax.swing.*; 27 import java.util.*; 28 29 // Needed for some debugging done inside setSelectedOBject (it was actually used to debug 30 // transformation manipulators) at 16-6-2002 31 import javax.vecmath.*; 32 33 /*** 34 * A pane for editing properties of scene graph objects. It implements the 35 * camera3d.SelectionChangeListener interface, so it get informed of which objects 36 * are selected. Based on the type of object selected it defines which sub-panes 37 * must be shown, so we can edit parameters specific to each type of object. 38 * 39 * @author Fábio Roberto de Miranda 40 * @version 1.0 41 */ 42 class EditionPane extends JPanel implements SelectionChangeListener{ 43 44 private GUIControl guiControl; 45 46 private SelectionList list; 47 private Vector selectionList = new Vector(30, 6); 48 private BorderLayout borderLayout1 = new BorderLayout(); 49 private JScrollPane jScrollPane = new JScrollPane(); 50 private Box box; 51 52 private VcObjectEditionPane objectPane; 53 private VcViewEditionPane viewPane; 54 private VcContentEditionPane contentPane; 55 private VcLightEditionPane lightPane; 56 private VcPointLightEditionPane pointPane; 57 private VcSpotLightEditionPane spotPane; 58 private DistanceMeasurerPane distancePane; 59 //VcHelperPointEditionPane helperPtPane; 60 private VcLaserArrayEditionPane arrayPane; 61 62 63 private EmptyPanel emptyPanel; // Shown when there's no object selected 64 65 public EditionPane(GUIControl guiControl) { 66 this(); 67 this.guiControl = guiControl; 68 } 69 70 public void selectionChanged(SelectionChangedEvent event){ 71 /* as the multi-object selection has not been implemented, it will 72 suffice for now just using the newly added objects. */ 73 java.util.List list = event.getAddedObjects(); 74 //System.out.println("editionPane: "+list.size()+" objects added"); 75 Vector v = new Vector(list.size()); 76 v.addAll(list); 77 this.setSelectedObjects(v); 78 } 79 80 81 void setSelectionList(SelectionList list){ 82 this.list = list; 83 list.addSelectionChangeListener(this); 84 } 85 86 87 /* 88 * The inner selectionList of this class gets a reference to 89 * each object in the original selList Vector 90 */ 91 void setSelectedObjects(Vector selList){ 92 93 box.removeAll(); 94 Iterator iter = selList.iterator(); 95 selectionList.removeAllElements(); 96 while (iter.hasNext()){ 97 Object obj = iter.next(); 98 selectionList.addElement(obj); 99 } 100 101 if (selectionList.size() > 1){ 102 // Multiple objects selected: 103 // TODO: find the more specific class common to all selected objects and 104 // trigger proper edition pane. 105 } 106 if (selectionList.size() == 1){ 107 // One object selected: add edition panes along the hierarchy for 108 // this object 109 Object obj = selectionList.elementAt(0); 110 VcObject vcObj; 111 VcView vcView; 112 VcLight vcLight; 113 VcPointLight vcPointLight; 114 VcSpotLight vcSpotLight; 115 VcContent vcContent; 116 //VcHelperPoint helperPoint; 117 if (obj instanceof VcObject){ 118 vcObj = (VcObject)obj; 119 if (box == null){ 120 debugln("Box is null"); 121 } else if (objectPane == null) { 122 debugln("objectPane is null"); 123 } 124 box.add(objectPane); 125 objectPane.setVcObject(vcObj); 126 127 ///// Added 16/06/2002 for debugging purposes solely 128 129 /* 130 int tmode = VcObject.RELATIVE_MODE; 131 132 Vector3d[] vec3d = new Vector3d[6]; 133 Vector4d[] plane = new Vector4d[6]; 134 Point3d[] point = new Point3d[6]; 135 for (int i = 0; i < vec3d.length; i++) { 136 vec3d[i] = new Vector3d(); 137 plane[i] = new Vector4d(); 138 point[i] = new Point3d(); 139 } 140 vcObj.getLine(point[0], vec3d[0], tmode, VcObject.X); 141 vcObj.getLine(point[1], vec3d[1], tmode, VcObject.Y); 142 vcObj.getLine(point[2], vec3d[2], tmode, VcObject.Z); 143 */ 144 // Comparing both plane styles 145 /* 146 vcObj.getPlane(point[3], vec3d[3], tmode, VcObject.XY); 147 vcObj.getPlane(point[4], vec3d[4], tmode, VcObject.YZ); 148 vcObj.getPlane(point[5], vec3d[5], tmode, VcObject.ZX); 149 */ 150 // Just printing output 151 /* 152 System.out.println(" Line Parameters"); 153 for (int i = 0; i < 3; i++) { 154 System.out.println("Line "+vec3d[i]+", Point "+point[i]); 155 } 156 System.out.println("Plane parameters"); 157 for (int i = 3; i < point.length; i++) { 158 System.out.println("Line "+vec3d[i]+", Point "+point[i]); 159 } 160 161 vcObj.getPlane(plane[0], tmode, VcObject.XY); 162 vcObj.getPlane(plane[1], tmode, VcObject.YZ); 163 vcObj.getPlane(plane[2], tmode, VcObject.ZX); 164 165 System.out.println("Plane (Vector4d) parameters:"); 166 for (int i = 0; i < 4; i++) { 167 System.out.println("Plane parameters: "+plane[i]); 168 } 169 170 */ 171 /* 172 173 guiControl.addLine(point[0], vec3d[0]); 174 guiControl.addLine(point[1], vec3d[1]); 175 guiControl.addLine(point[2], vec3d[2]); 176 177 178 guiControl.addPlane(plane[0]); 179 guiControl.addPlane(plane[1]); 180 guiControl.addPlane(plane[2]); 181 182 183 guiControl.addPlane(point[3], vec3d[3]); 184 guiControl.addPlane(point[4], vec3d[4]); 185 guiControl.addPlane(point[5], vec3d[5]); 186 */ 187 188 /// End of added segment 189 } 190 if (obj instanceof VcView){ 191 vcView = (VcView)obj; 192 box.add(viewPane); 193 viewPane.setVcView(vcView); 194 } 195 if (obj instanceof VcLight){ 196 vcLight = (VcLight)obj; 197 box.add(lightPane); 198 lightPane.setVcLight(vcLight); 199 // proper "set" missing 200 } 201 if (obj instanceof VcPointLight){ 202 vcPointLight = (VcPointLight)obj; 203 box.add(pointPane); 204 pointPane.setVcPointLight(vcPointLight); 205 // proper "set" missing 206 } 207 if (obj instanceof VcSpotLight){ 208 vcSpotLight = (VcSpotLight)obj; 209 box.add(spotPane); 210 spotPane.setVcSpotLight(vcSpotLight); 211 // proper "set" missing 212 } 213 214 if (obj instanceof DistanceMeasurer){ 215 DistanceMeasurer measurer= (DistanceMeasurer)obj; 216 box.add(distancePane); 217 distancePane.setDistanceMeasurer(measurer); 218 //box.add(helperPtPane); 219 } 220 221 if (obj instanceof VcLaserArray){ 222 VcLaserArray array= (VcLaserArray)obj; 223 box.add(arrayPane); 224 arrayPane.setLaserArray(array); 225 } 226 227 this.validate(); 228 this.getParent().validate(); 229 } 230 231 if (selectionList.isEmpty()){ 232 debugln("editionPane: Selection list empty"); 233 box.add(emptyPanel); 234 this.validate(); 235 this.getParent().validate(); 236 } 237 } 238 239 public static void main(String[] args) { 240 EditionPane editionPane1 = new EditionPane(); 241 } 242 243 public EditionPane() { 244 objectPane = new VcObjectEditionPane(); 245 viewPane = new VcViewEditionPane(); 246 lightPane = new VcLightEditionPane(); 247 emptyPanel = new EmptyPanel(); 248 spotPane = new VcSpotLightEditionPane(); 249 pointPane = new VcPointLightEditionPane(); 250 distancePane = new DistanceMeasurerPane(); 251 //helperPtPane = new VcHelperPointEditionPane(); 252 arrayPane = new VcLaserArrayEditionPane(); 253 254 try { 255 jbInit(); 256 } 257 catch(Exception e) { 258 e.printStackTrace(); 259 } 260 } 261 private void jbInit() throws Exception { 262 box = Box.createVerticalBox(); 263 this.setLayout(borderLayout1); 264 jScrollPane.setAutoscrolls(true); 265 this.setEnabled(true); 266 this.add(jScrollPane, BorderLayout.CENTER); 267 jScrollPane.getViewport().add(box, null); 268 } 269 270 void debugln(String s){ 271 if (GUIControl.debugflag){ 272 System.out.println(s); 273 } 274 } 275 276 void setGUIControl(GUIControl guiControl){ 277 this.guiControl = guiControl; 278 viewPane.setGUIControl(guiControl); 279 lightPane.setGUIControl(guiControl); 280 objectPane.setGUIControl(guiControl); 281 pointPane.setGUIControl(guiControl); 282 spotPane.setGUIControl(guiControl); 283 distancePane.setGUIControl(guiControl); 284 //helperPtPane.setGUIControl(guiControl); 285 arrayPane.setGUIControl(guiControl); 286 } 287 288 }

This page was automatically generated by Maven