00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 package com.generalrobotix.ui.view;
00020
00021 import java.awt.BorderLayout;
00022 import java.awt.Color;
00023 import java.awt.Component;
00024 import java.awt.Dimension;
00025 import java.awt.Font;
00026 import java.awt.Frame;
00027 import java.awt.GraphicsConfiguration;
00028 import java.awt.GridLayout;
00029 import java.awt.MenuItem;
00030 import java.awt.Panel;
00031 import java.awt.PopupMenu;
00032 import java.awt.TextField;
00033 import java.awt.event.ActionEvent;
00034 import java.awt.event.ActionListener;
00035 import java.awt.event.KeyAdapter;
00036 import java.awt.event.KeyEvent;
00037 import java.awt.event.MouseEvent;
00038 import java.awt.event.MouseListener;
00039 import java.awt.image.BufferedImage;
00040 import java.io.File;
00041 import java.io.IOException;
00042 import java.net.MalformedURLException;
00043 import java.net.URL;
00044 import java.util.ArrayList;
00045 import java.util.Iterator;
00046 import java.util.List;
00047 import java.util.Map;
00048 import java.util.Vector;
00049
00050 import javax.swing.*;
00051 import javax.media.j3d.*;
00052 import javax.vecmath.*;
00053
00054 import org.eclipse.swt.SWT;
00055 import org.eclipse.swt.awt.SWT_AWT;
00056 import org.eclipse.swt.events.ControlEvent;
00057 import org.eclipse.swt.events.ControlListener;
00058 import org.eclipse.swt.graphics.RGB;
00059 import org.eclipse.swt.widgets.ColorDialog;
00060 import org.eclipse.swt.widgets.Composite;
00061 import org.eclipse.swt.widgets.Display;
00062 import org.eclipse.swt.widgets.FileDialog;
00063 import org.omg.CosNaming.NameComponent;
00064 import org.omg.CosNaming.NamingContext;
00065
00066
00067 import org.omg.PortableServer.POAPackage.ServantNotActive;
00068 import org.omg.PortableServer.POAPackage.WrongPolicy;
00069 import org.eclipse.jface.dialogs.MessageDialog;
00070
00071
00072 import com.sun.j3d.utils.universe.SimpleUniverse;
00073
00074 import jp.go.aist.hrp.simulator.*;
00075 import jp.go.aist.hrp.simulator.OnlineViewerPackage.OnlineViewerException;
00076
00077 import com.generalrobotix.ui.*;
00078 import com.generalrobotix.ui.util.*;
00079 import com.generalrobotix.ui.util.AxisAngle4d;
00080 import com.generalrobotix.ui.item.GrxCollisionPairItem;
00081 import com.generalrobotix.ui.item.GrxLinkItem;
00082 import com.generalrobotix.ui.item.GrxModelItem;
00083 import com.generalrobotix.ui.item.GrxSensorItem;
00084 import com.generalrobotix.ui.item.GrxSimulationItem;
00085 import com.generalrobotix.ui.item.GrxWorldStateItem;
00086 import com.generalrobotix.ui.item.GrxWorldStateItem.CharacterStateEx;
00087 import com.generalrobotix.ui.item.GrxWorldStateItem.WorldStateEx;
00088 import com.generalrobotix.ui.view.tdview.*;
00089 import com.generalrobotix.ui.view.vsensor.Camera_impl;
00090
00091 @SuppressWarnings("serial")
00092 public class Grx3DView
00093 extends GrxBaseView
00094 implements ThreeDDrawable
00095 {
00096 public static final String TITLE = "3DView";
00097
00098 public static final GraphicsConfiguration graphicsConfiguration = SimpleUniverse.getPreferredConfiguration();
00099
00100 private GrxWorldStateItem currentWorld_ = null;
00101 private List<GrxModelItem> currentModels_ = new ArrayList<GrxModelItem>();
00102 private List<GrxCollisionPairItem> currentCollisionPairs_ = new ArrayList<GrxCollisionPairItem>();
00103 private WorldStateEx currentState_ = null;
00104 private GrxSimulationItem simItem_ = null;
00105 private final static int VIEW=0;
00106 private final static int EDIT=1;
00107 private final static int SIMULATION = 2;
00108 private int viewMode_ = VIEW;
00109 private double dAngle_ = Math.toRadians(0.1);
00110
00111
00112 private static VirtualUniverse universe_;
00113 private javax.media.j3d.Locale locale_;
00114 private BranchGroup bgRoot_;
00115 private BranchGroup unclickableBgRoot_;
00116
00117 private BranchGroup rulerBg_;
00118 private float LineWidth_ = 1.0f;
00119 private float colprop = 10.0f;
00120 private float coldiff = 0.1f;
00121
00122
00123 private Canvas3D canvas_;
00124 private Canvas3D offscreen_;
00125 private View view_;
00126 private TransformGroup tgView_;
00127 private Transform3D t3dViewHome_ = new Transform3D();
00128 private ViewInfo info_;
00129 private BehaviorManager behaviorManager_ = new BehaviorManager(manager_);
00130 private Background backGround_ = new Background(0.0f, 0.0f, 0.0f);
00131 private double[] default_eye = new double[]{2.0, 2.0, 0.8};
00132 private double[] default_lookat = new double[]{0.0, 0.0, 0.8};
00133 private double[] default_upward = new double[]{0.0, 0.0, 1.0};
00134
00135
00136 private RecordingManager recordingMgr_;
00137 private String lastMovieFileName;
00138
00139
00140 private ObjectToolBar objectToolBar_ = new ObjectToolBar();
00141 private ViewToolBar viewToolBar_ = new ViewToolBar(this);
00142 private JButton btnHomePos_ = new JButton(new ImageIcon(getClass().getResource("/resources/images/home.png")));
00143 private JToggleButton btnFloor_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/floor.png")));
00144 private JToggleButton btnCollision_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/collision.png")));
00145 private JToggleButton btnDistance_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/distance.png")));
00146 private JToggleButton btnIntersection_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/proximity.png")));
00147 private JToggleButton btnCoM_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/com.png")));
00148 private JToggleButton btnCoMonFloor_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/com_z0.png")));
00149 private JToggleButton btnRec_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/record.png")));
00150 private JButton btnPlayer_ = new JButton(new ImageIcon(getClass().getResource("/resources/images/movie_player.png")));
00151 private JButton btnRestore_ = new JButton(new ImageIcon(getClass().getResource("/resources/images/undo.png")));
00152 private JToggleButton btnBBdisp_ = new JToggleButton(new ImageIcon(getClass().getResource("/resources/images/AABB.png")));
00153
00154 private JLabel lblMode_ = new JLabel(MessageBundle.get("Grx3DView.label.view"));
00155 private JLabel lblTarget_ = new JLabel("");
00156 private JLabel lblValue_ = new JLabel("");
00157
00158 private Shape3D collision_;
00159 private Shape3D distance_;
00160 private Vector<GrxLinkItem> intersectingLinks_;
00161
00162 private boolean showActualState_ = true;
00163
00164
00165 Frame frame_;
00166 Composite comp;
00167
00168 public Grx3DView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent)
00169 {
00170 super(name, manager, vp, parent);
00171 isScrollable_ = false;
00172
00173
00174
00175
00176
00177 comp = new Composite( getComposite(), SWT.EMBEDDED);
00178 frame_ = SWT_AWT.new_Frame( comp );
00179
00180 comp.addControlListener( new ControlListener() {
00181 public void controlMoved(ControlEvent e) {}
00182 public void controlResized(ControlEvent e) {
00183 frame_.setBounds(0, 0, comp.getSize().x, comp.getSize().y );
00184 }
00185 });
00186
00187
00188
00189
00190
00191
00192
00193 Panel contentPane = new Panel();
00194
00195
00196
00197 frame_.add(contentPane);
00198
00199 contentPane.setLayout(new BorderLayout());
00200 contentPane.setBackground(Color.lightGray);
00201
00202
00203 lblMode_.setForeground(Color.black);
00204 lblMode_.setFont(new Font("Monospaced", Font.BOLD, 12));
00205 lblMode_.setPreferredSize(new Dimension(300, 20));
00206
00207 lblTarget_.setForeground(Color.white);
00208 lblTarget_.setFont(new Font("Monospaced", Font.BOLD, 12));
00209 lblTarget_.setPreferredSize(new Dimension(500, 20));
00210
00211 lblValue_.setForeground(Color.white);
00212 lblValue_.setFont(new Font("Monospaced", Font.BOLD, 12));
00213 lblValue_.setPreferredSize(new Dimension(300, 20));
00214
00215 JPanel southPanel = new JPanel();
00216 southPanel.setLayout(new GridLayout(1,0));
00217 southPanel.add( lblMode_ );
00218 Box clipPanel = Box.createHorizontalBox();
00219 JLabel clipDistLabel0 = new JLabel(MessageBundle.get("Grx3DView.label.clipDistance0"));
00220 JLabel clipDistLabel1 = new JLabel(MessageBundle.get("Grx3DView.label.clipDistance1"));
00221 final TextField frontText = new TextField(6);
00222 final TextField backText = new TextField(6);
00223 frontText.addActionListener(new ActionListener(){
00224 public void actionPerformed(ActionEvent arg0) {
00225 String str = frontText.getText();
00226 try{
00227 info_.frontClipDistance=Double.parseDouble(str);
00228 view_.setFrontClipDistance(info_.frontClipDistance);
00229 }catch(NumberFormatException e){
00230 frontText.setText(String.valueOf(info_.frontClipDistance));
00231 }
00232 }
00233 });
00234 backText.addActionListener(new ActionListener(){
00235 public void actionPerformed(ActionEvent arg0) {
00236 String str = backText.getText();
00237 try{
00238 info_.backClipDistance=Double.parseDouble(str);
00239 view_.setBackClipDistance(info_.backClipDistance);
00240 }catch(NumberFormatException e){
00241 backText.setText(String.valueOf(info_.backClipDistance));
00242 }
00243 }
00244 });
00245
00246 clipPanel.add(clipDistLabel0);
00247 clipPanel.add(frontText);
00248 clipPanel.add(clipDistLabel1);
00249 clipPanel.add(backText);
00250 southPanel.add(clipPanel);
00251
00252 canvas_ = new Canvas3D(graphicsConfiguration);
00253 canvas_.setDoubleBufferEnable(true);
00254 canvas_.addKeyListener(new ModelEditKeyAdapter());
00255 _setupSceneGraph();
00256
00257 frontText.setText(String.valueOf(info_.frontClipDistance));
00258 backText.setText(String.valueOf(info_.backClipDistance));
00259 JPanel mainPane = new JPanel(new BorderLayout());
00260 mainPane.setBackground(Color.black);
00261 contentPane.add(southPanel, BorderLayout.SOUTH);
00262 mainPane.add(canvas_, BorderLayout.CENTER);
00263 contentPane.add(mainPane, BorderLayout.CENTER);
00264
00265 _setupToolBars();
00266 contentPane.add(objectToolBar_, BorderLayout.WEST);
00267 contentPane.add(viewToolBar_, BorderLayout.NORTH);
00268
00269 collision_ = new Shape3D();
00270 collision_.setPickable(false);
00271 collision_.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
00272 try {
00273 Appearance app = new Appearance();
00274 LineAttributes latt = new LineAttributes();
00275 latt.setLineWidth(LineWidth_);
00276 app.setLineAttributes(latt);
00277 collision_.setAppearance(app);
00278 } catch (Exception ex) {
00279 ex.printStackTrace();
00280 }
00281 BranchGroup bg = new BranchGroup();
00282 bg.addChild(collision_);
00283 bgRoot_.addChild(bg);
00284
00285 distance_ = new Shape3D();
00286 distance_.setPickable(false);
00287 distance_.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
00288 try {
00289 Appearance app = new Appearance();
00290 LineAttributes latt = new LineAttributes();
00291 latt.setLineWidth(LineWidth_);
00292 app.setLineAttributes(latt);
00293 distance_.setAppearance(app);
00294 } catch (Exception ex) {
00295 ex.printStackTrace();
00296 }
00297 BranchGroup bgDistance = new BranchGroup();
00298 bgDistance.addChild(distance_);
00299 bgRoot_.addChild(bgDistance);
00300
00301 intersectingLinks_ = new Vector<GrxLinkItem>();
00302
00303 setScrollMinSize(SWT.DEFAULT,SWT.DEFAULT);
00304
00305
00306 behaviorManager_.setThreeDViewer(this);
00307 behaviorManager_.setViewIndicator(viewToolBar_);
00308 behaviorManager_.setItem(currentModels_, currentCollisionPairs_);
00309 behaviorManager_.initDynamicsSimulator();
00310 behaviorManager_.setOperationMode(BehaviorManager.OPERATION_MODE_NONE);
00311 behaviorManager_.setViewMode(BehaviorManager.ROOM_VIEW_MODE);
00312 behaviorManager_.setViewHandlerMode("button_mode_rotation");
00313 behaviorManager_.replaceWorld(null);
00314 viewToolBar_.setMode(ViewToolBar.ROOM_MODE);
00315 viewToolBar_.setOperation(ViewToolBar.ROTATE);
00316
00317 registerCORBA();
00318
00319 setUp();
00320 manager_.registerItemChangeListener(this, GrxModelItem.class);
00321 manager_.registerItemChangeListener(this, GrxWorldStateItem.class);
00322 manager_.registerItemChangeListener(this, GrxCollisionPairItem.class);
00323 manager_.registerItemChangeListener(this, GrxSimulationItem.class);
00324
00325 }
00326
00327 public void setUp(){
00328 Iterator<GrxModelItem> it = currentModels_.iterator();
00329 while(it.hasNext()) {
00330 GrxModelItem model = it.next();
00331 if(model.bgRoot_.isLive())
00332 model.bgRoot_.detach();
00333 model.deleteObserver(this);
00334 }
00335 currentModels_ = manager_.<GrxModelItem>getSelectedItemList(GrxModelItem.class);
00336 currentCollisionPairs_ = manager_.<GrxCollisionPairItem>getSelectedItemList(GrxCollisionPairItem.class);
00337 behaviorManager_.setItem(currentModels_, currentCollisionPairs_);
00338 it = currentModels_.iterator();
00339 boolean modelModified = false;
00340 while(it.hasNext()) {
00341 GrxModelItem model = it.next();
00342 bgRoot_.addChild(model.bgRoot_);
00343 model.setWireFrame(viewToolBar_.isWireFrameSelected());
00344 modelModified |= model.isModified();
00345 model.addObserver(this);
00346 }
00347 if(modelModified)
00348 optionButtonEnable(false);
00349 else
00350 optionButtonEnable(true);
00351 if(btnBBdisp_.isSelected()){
00352 btnBBdisp_.doClick();
00353 }
00354
00355 if(currentWorld_ != null){
00356 currentWorld_.deleteObserver(this);
00357 currentWorld_.deletePosObserver(this);
00358 }
00359 currentWorld_ = manager_.<GrxWorldStateItem>getSelectedItem(GrxWorldStateItem.class, null);
00360 if(currentWorld_!=null){
00361 currentState_ = currentWorld_.getValue(currentWorld_.getPosition());
00362 currentWorld_.addObserver(this);
00363 currentWorld_.addPosObserver(this);
00364 }else
00365 currentState_ = null;
00366 if(currentState_ == null)
00367 updateViewSimulator(0);
00368 else
00369 updatePosition(currentWorld_, currentWorld_.getPosition());
00370 showOption();
00371
00372 if(simItem_ != null)
00373 simItem_.deleteObserver(this);
00374 simItem_ = manager_.<GrxSimulationItem>getSelectedItem(GrxSimulationItem.class, null);
00375 if(simItem_!=null){
00376 simItem_.addObserver(this);
00377 if(simItem_.isSimulating())
00378 viewMode_ = SIMULATION;
00379 }
00380 if(viewMode_==SIMULATION){
00381 disableButton();
00382 objectToolBar_.setMode(ObjectToolBar.DISABLE_MODE);
00383 }
00384 }
00385
00386 private void _setupSceneGraph() {
00387 universe_ = new VirtualUniverse();
00388 locale_ = new javax.media.j3d.Locale(universe_);
00389 bgRoot_ = new BranchGroup();
00390
00391 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
00392 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
00393 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
00394
00395
00396 bgRoot_.addChild(_createLights());
00397 bgRoot_.addChild(_createView());
00398 bgRoot_.compile();
00399 locale_.addBranchGraph(bgRoot_);
00400
00401 unclickableBgRoot_ = new BranchGroup();
00402 unclickableBgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
00403 unclickableBgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
00404 unclickableBgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
00405
00406 locale_.addBranchGraph( unclickableBgRoot_ );
00407 }
00408
00409 private BranchGroup _createView() {
00410 BranchGroup bg = new BranchGroup();
00411 ViewPlatform platform = new ViewPlatform();
00412 info_ = new ViewInfo(ViewInfo.VIEW_MODE_ROOM | ViewInfo.FRONT_VIEW, 3.0 );
00413 view_ = new View();
00414 view_.setScreenScalePolicy(View.SCALE_EXPLICIT);
00415 view_.setScreenScale(0.1);
00416 tgView_ = new TransformGroup();
00417
00418 view_.setPhysicalBody(new PhysicalBody());
00419 view_.setPhysicalEnvironment(new PhysicalEnvironment());
00420 view_.setFrontClipPolicy(View.VIRTUAL_EYE);
00421 view_.setBackClipPolicy(View.VIRTUAL_EYE);
00422 view_.setFrontClipDistance(info_.frontClipDistance);
00423 view_.setBackClipDistance(info_.backClipDistance);
00424 view_.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
00425 view_.setFieldOfView(Math.PI/4);
00426 view_.addCanvas3D(canvas_);
00427
00428 tgView_.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
00429 tgView_.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
00430 tgView_.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
00431 tgView_.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
00432 tgView_.setCapability(TransformGroup.ALLOW_LOCAL_TO_VWORLD_READ);
00433
00434 view_.attachViewPlatform(platform);
00435 tgView_.addChild(platform);
00436 bg.addChild(tgView_);
00437
00438 _setViewHomePosition();
00439
00440 return bg;
00441 }
00442
00443 private BranchGroup _createLights() {
00444 BranchGroup bg = new BranchGroup();
00445 DirectionalLight[] light = new DirectionalLight[4];
00446 TransformGroup[] tg = new TransformGroup[4];
00447 BoundingSphere bounds =
00448 new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
00449
00450
00451
00452
00453
00454 light[0] = new DirectionalLight(true,
00455 new Color3f(0.7f, 0.7f, 0.7f),
00456 new Vector3f(0.0f, 0.0f, -1.0f)
00457 );
00458
00459 light[1] = new DirectionalLight(true,
00460 new Color3f(0.4f, 0.4f, 0.4f),
00461 new Vector3f(0.0f, 0.0f, -1.0f)
00462 );
00463
00464 light[2] = new DirectionalLight(true,
00465 new Color3f(0.7f, 0.7f, 0.7f),
00466 new Vector3f(0.0f, 0.0f, -1.0f)
00467 );
00468
00469 light[3] = new DirectionalLight(true,
00470 new Color3f(0.4f, 0.4f, 0.4f),
00471 new Vector3f(0.0f, 0.0f, -1.0f)
00472 );
00473
00474 for (int i = 0; i < 4; i ++) {
00475 light[i].setInfluencingBounds(bounds);
00476 tg[i] = new TransformGroup();
00477 bg.addChild(tg[i]);
00478 tg[i].addChild(light[i]);
00479 }
00480
00481 Transform3D transform = new Transform3D();
00482 Vector3d pos = new Vector3d();
00483 AxisAngle4d rot = new AxisAngle4d();
00484
00485 pos.set(10.0, 10.0, 5.0);
00486 transform.set(pos);
00487 rot.set(-0.5, 0.5, 0.0, 1.2);
00488 transform.set(rot);
00489 tg[0].setTransform(transform);
00490
00491 pos.set(10.0, -10.0, -5.0);
00492 transform.set(pos);
00493 rot.set(0.5, 0.5, 0.0, 3.14 - 1.2);
00494 transform.set(rot);
00495 tg[1].setTransform(transform);
00496
00497 pos.set(-10.0, -10.0, 5.0);
00498 transform.set(pos);
00499 rot.set(0.5, -0.5, 0.0, 1.2);
00500 transform.set(rot);
00501 tg[2].setTransform(transform);
00502
00503 pos.set(-10.0, 10.0, -5.0);
00504 transform.set(pos);
00505 rot.set(-0.5, -0.5, 0.0, 3.14 - 1.2);
00506 transform.set(rot);
00507 tg[3].setTransform(transform);
00508
00509
00510 AmbientLight alight = new AmbientLight(new Color3f(1.0f, 1.0f, 1.0f));
00511 alight.setInfluencingBounds(bounds);
00512 tg[0].addChild(alight);
00513
00514
00515 backGround_.setCapability(Background.ALLOW_COLOR_READ);
00516 backGround_.setCapability(Background.ALLOW_COLOR_WRITE);
00517 backGround_.setApplicationBounds(bounds);
00518 bg.addChild(backGround_);
00519
00520 return bg;
00521 }
00522
00523 private void _setupToolBars() {
00524 btnHomePos_.setToolTipText(MessageBundle.get("Grx3DView.text.goHomeEyePos"));
00525 btnHomePos_.addActionListener(new ActionListener() {
00526 public void actionPerformed(ActionEvent arg0) {
00527 tgView_.setTransform(t3dViewHome_);
00528 }
00529 });
00530 btnHomePos_.addMouseListener(new MouseListener(){
00531 public void mouseClicked(MouseEvent arg0) {
00532 }
00533 public void mouseEntered(MouseEvent arg0) {
00534 }
00535 public void mouseExited(MouseEvent arg0) {
00536 }
00537 public void mousePressed(MouseEvent arg0) {
00538 if(arg0.getButton()==MouseEvent.BUTTON2 || arg0.getButton()==MouseEvent.BUTTON3){
00539 PopupMenu popupMenu = new PopupMenu();
00540 final MenuItem menu0 = new MenuItem(MessageBundle.get("Grx3DView.popupmenu.setHomeEyePos"));
00541 menu0.addActionListener(new ActionListener(){
00542 public void actionPerformed(ActionEvent arg0) {
00543 if(arg0.getSource()==menu0){
00544 tgView_.getTransform(t3dViewHome_);
00545 final double[] eyeHomePosition = new double[16];
00546 t3dViewHome_.get(eyeHomePosition);
00547 syncExec(new Runnable(){
00548 public void run(){
00549 setDblAry("eyeHomePosition", eyeHomePosition, 5);
00550 }
00551 });
00552 }
00553 }
00554 });
00555 final MenuItem menu1 = new MenuItem(MessageBundle.get("Grx3DView.popupmenu.restoreDefault"));
00556 menu1.addActionListener(new ActionListener(){
00557 public void actionPerformed(ActionEvent arg0) {
00558 if(arg0.getSource()==menu1){
00559 _setViewHomePosition();
00560 final double[] eyeHomePosition = new double[16];
00561 t3dViewHome_.get(eyeHomePosition);
00562 syncExec(new Runnable(){
00563 public void run(){
00564 setDblAry("eyeHomePosition", eyeHomePosition, 5);
00565 }
00566 });
00567 }
00568 }
00569 });
00570 popupMenu.add(menu0);
00571 popupMenu.add(menu1);
00572 btnHomePos_.add(popupMenu);
00573 popupMenu.show(btnHomePos_, arg0.getX(), arg0.getY());
00574 }
00575 }
00576 public void mouseReleased(MouseEvent arg0) {
00577 }
00578 });
00579
00580 btnFloor_.setToolTipText(MessageBundle.get("Grx3DView.text,showZPlane"));
00581 btnFloor_.setSelected(false);
00582 btnFloor_.addActionListener(new ActionListener() {
00583 public void actionPerformed(ActionEvent arg0) {
00584 if (btnFloor_.isSelected()) {
00585 btnFloor_.setToolTipText(MessageBundle.get("Grx3DView.text.hideZPlane"));
00586 syncExec(new Runnable(){
00587 public void run(){
00588 setProperty("showScale", "true");
00589 }
00590 });
00591 if (bgRoot_.indexOfChild(getRuler()) == -1)
00592 bgRoot_.addChild(getRuler());
00593 } else {
00594 btnFloor_.setToolTipText(MessageBundle.get("Grx3DView.text.showZPlane"));
00595 syncExec(new Runnable(){
00596 public void run(){
00597 setProperty("showScale", "false");
00598 }
00599 });
00600 if (bgRoot_.indexOfChild(getRuler()) != -1)
00601 getRuler().detach();
00602 }
00603 }
00604 });
00605
00606 btnCollision_.setToolTipText(MessageBundle.get("Grx3DView.text.showCollision"));
00607 btnCollision_.setSelected(false);
00608 btnCollision_.addActionListener(new ActionListener() {
00609 public void actionPerformed(ActionEvent arg0) {
00610 if (btnCollision_.isSelected()){
00611 btnCollision_.setToolTipText(MessageBundle.get("Grx3DView.text.hideCollision"));
00612 syncExec(new Runnable(){
00613 public void run(){
00614 setProperty("showCollision", "true");
00615 }
00616 });
00617 if (viewMode_ == SIMULATION || ( viewMode_ == VIEW && currentState_ != null))
00618 _showCollision(currentState_.collisions);
00619 else
00620 _showCollision(behaviorManager_.getCollision());
00621 }else{
00622 btnCollision_.setToolTipText(MessageBundle.get("Grx3DView.text.showCollision"));
00623 syncExec(new Runnable(){
00624 public void run(){
00625 setProperty("showCollision", "false");
00626 }
00627 });
00628 _showCollision(null);
00629 }
00630 }
00631 });
00632
00633 btnDistance_.setToolTipText(MessageBundle.get("Grx3DView.text.showDistance"));
00634 btnDistance_.setSelected(false);
00635 btnDistance_.addActionListener(new ActionListener() {
00636 public void actionPerformed(ActionEvent arg0) {
00637 if (btnDistance_.isSelected()){
00638 btnDistance_.setToolTipText(MessageBundle.get("Grx3DView.text.hideDistance"));
00639 syncExec(new Runnable(){
00640 public void run(){
00641 setProperty("showDistance", "true");
00642 }
00643 });
00644 if (viewMode_ != SIMULATION)
00645 _showDistance(behaviorManager_.getDistance());
00646 }else {
00647 btnDistance_.setToolTipText(MessageBundle.get("Grx3DView.text.showDistance"));
00648 syncExec(new Runnable(){
00649 public void run(){
00650 setProperty("showDistance", "false");
00651 }
00652 });
00653 _showDistance(null);
00654 }
00655 }
00656 });
00657
00658 btnIntersection_.setToolTipText(MessageBundle.get("Grx3DView.text.checkIntersection"));
00659 btnIntersection_.setSelected(false);
00660 btnIntersection_.addActionListener(new ActionListener() {
00661 public void actionPerformed(ActionEvent arg0) {
00662 if (btnIntersection_.isSelected()){
00663 btnIntersection_.setToolTipText(MessageBundle.get("Grx3DView.text.nocheckIntersection"));
00664 syncExec(new Runnable(){
00665 public void run(){
00666 setProperty("showIntersection", "true");
00667 }
00668 });
00669 if (viewMode_ != SIMULATION)
00670 _showIntersection(behaviorManager_.getIntersection());
00671 }else{
00672 btnIntersection_.setToolTipText(MessageBundle.get("Grx3DView.text.checkIntersection"));
00673 syncExec(new Runnable(){
00674 public void run(){
00675 setProperty("showIntersection", "false");
00676 }
00677 });
00678 _showIntersection(null);
00679 }
00680 }
00681 });
00682
00683 btnCoM_.setToolTipText(MessageBundle.get("Grx3DView.text.showCom"));
00684 btnCoM_.setSelected(false);
00685 btnCoM_.addActionListener(new ActionListener() {
00686 public void actionPerformed(ActionEvent arg0) {
00687 boolean b = btnCoM_.isSelected();
00688 for (int i=0; i<currentModels_.size(); i++)
00689 currentModels_.get(i).setVisibleCoM(b);
00690 if(b)
00691 syncExec(new Runnable(){
00692 public void run(){
00693 setProperty("showCoM", "true");
00694 }
00695 });
00696 else
00697 syncExec(new Runnable(){
00698 public void run(){
00699 setProperty("showCoM", "false");
00700 }
00701 });
00702 };
00703 });
00704
00705 btnCoMonFloor_.setToolTipText(MessageBundle.get("Grx3DView.text.showcomFloor"));
00706 btnCoMonFloor_.setSelected(false);
00707 btnCoMonFloor_.addActionListener(new ActionListener() {
00708 public void actionPerformed(ActionEvent arg0) {
00709 boolean b = btnCoMonFloor_.isSelected();
00710 for (int i=0; i<currentModels_.size(); i++)
00711 currentModels_.get(i).setVisibleCoMonFloor(b);
00712 if(b)
00713 syncExec(new Runnable(){
00714 public void run(){
00715 setProperty("showCoMonFloor", "true");
00716 }
00717 });
00718 else
00719 syncExec(new Runnable(){
00720 public void run(){
00721 setProperty("showCoMonFloor", "false");
00722 }
00723 });
00724 };
00725 });
00726
00727 btnRec_.setToolTipText(MessageBundle.get("Grx3DView.text.record"));
00728 btnRec_.addActionListener(new ActionListener() {
00729 public void actionPerformed(ActionEvent e) {
00730 if (btnRec_.isSelected()) {
00731 if (currentWorld_ != null && currentWorld_.getLogSize() > 0)
00732 rec();
00733 else
00734 btnRec_.setSelected(false);
00735 } else {
00736 btnRec_.setSelected(false);
00737 }
00738 }
00739 });
00740
00741 btnPlayer_.setToolTipText(MessageBundle.get("Grx3DView.text.moviePlayer"));
00742 btnPlayer_.addActionListener(new ActionListener() {
00743 public void actionPerformed(ActionEvent e) {
00744 Display.getDefault().syncExec( new Runnable(){
00745 public void run(){
00746 new SWTMoviePlayer( getParent().getShell(), lastMovieFileName );
00747 }
00748 });
00749
00750 }
00751 });
00752
00753
00754 final JButton btnCamera = new JButton("C");
00755 btnCamera.addActionListener(new ActionListener(){
00756 public void actionPerformed(ActionEvent e) {
00757 for (int i=0; i<currentModels_.size(); i++) {
00758 List<Camera_impl> l = currentModels_.get(i).getCameraSequence();
00759 for (int j=0; j<l.size(); j++) {
00760 Camera_impl c = l.get(j);
00761 c.setVisible(!c.isVisible());
00762 }
00763 }
00764 }
00765 });
00766
00767 btnBBdisp_.addActionListener(new ActionListener() {
00768 public void actionPerformed(ActionEvent e) {
00769 boolean b = btnBBdisp_.isSelected();
00770 if(b){
00771 List<GrxModelItem> visibleModels = setNumOfAABB();
00772 Iterator<GrxModelItem> it = visibleModels.iterator();
00773 while(it.hasNext())
00774 it.next().setVisibleAABB(b);
00775 if(visibleModels.isEmpty())
00776 btnBBdisp_.setSelected(false);
00777 }else
00778 for (int i=0; i<currentModels_.size(); i++)
00779 currentModels_.get(i).setVisibleAABB(b);
00780 }
00781 });
00782
00783 viewToolBar_.add(btnHomePos_,0);
00784 viewToolBar_.add(btnFloor_, 8);
00785 viewToolBar_.add(btnCollision_, 9);
00786 viewToolBar_.add(btnDistance_, 10);
00787 viewToolBar_.add(btnIntersection_, 11);
00788 viewToolBar_.add(btnCoM_, 12);
00789 viewToolBar_.add(btnCoMonFloor_, 13);
00790 viewToolBar_.add(btnRec_);
00791 viewToolBar_.add(btnPlayer_);
00792 viewToolBar_.add(btnCamera);
00793 viewToolBar_.add(btnBBdisp_);
00794
00795 btnRestore_.setToolTipText(MessageBundle.get("Grx3DView.text.restoreModel"));
00796 btnRestore_.addActionListener(new ActionListener() {
00797 public void actionPerformed(ActionEvent e) {
00798 for (int i=0; i<currentModels_.size(); i++) {
00799 final GrxModelItem item = currentModels_.get(i);
00800 syncExec(new Runnable(){
00801 public void run(){
00802 item.restoreProperties();
00803 }
00804 });
00805
00806 }
00807 showOption();
00808 }
00809 });
00810
00811 objectToolBar_.add(btnRestore_, 0);
00812 objectToolBar_.setOrientation(JToolBar.VERTICAL);
00813
00814 JToolBar bars[] = new JToolBar[]{viewToolBar_, objectToolBar_};
00815 for (int i=0; i<bars.length; i++) {
00816 JToolBar bar = bars[i];
00817 bar.setFloatable(false);
00818 for (int j=0; j<bar.getComponentCount(); j++) {
00819 Component c = bar.getComponent(j);
00820 if (c instanceof AbstractButton) {
00821 AbstractButton b = (AbstractButton)c;
00822 b.setPreferredSize(GrxBaseView.getDefaultButtonSize());
00823 b.setMaximumSize(GrxBaseView.getDefaultButtonSize());
00824 }
00825 }
00826 }
00827
00828 _registerAction();
00829 }
00830
00831 public Canvas3D getCanvas3D() {
00832 return canvas_;
00833 }
00834
00835 public BranchGroup getBranchGroupRoot() {
00836 return bgRoot_;
00837 }
00838
00839 private void _setViewHomePosition() {
00840 t3dViewHome_.lookAt(
00841 new Point3d(default_eye),
00842 new Point3d(default_lookat),
00843 new Vector3d(default_upward));
00844 t3dViewHome_.invert();
00845 tgView_.setTransform(t3dViewHome_);
00846 }
00847
00848 public void restoreProperties(){
00849 super.restoreProperties();
00850 if(getStr("showScale")==null) propertyChanged("showScale", "true");
00851 if(getStr("showCollision")==null) propertyChanged("showCollision", "true");
00852 if(getStr("showDistance")==null) propertyChanged("showDistance", "false");
00853 if(getStr("showIntersection")==null) propertyChanged("showIntersection", "false");
00854 if(getStr("showCoM")==null) propertyChanged("showCoM", "false");
00855 if(getStr("showCoMonFloor")==null) propertyChanged("showCoMonFloor", "false");
00856 if(getStr("view.mode")==null) propertyChanged("view.mode", ViewToolBar.COMBO_SELECT_ROOM);
00857 if(getStr("showActualState")==null) propertyChanged("showActualState", "true");
00858 if(getStr("eyeHomePosition")==null){
00859 final double[] eyeHomePosition = new double[16];
00860 _setViewHomePosition();
00861 t3dViewHome_.get(eyeHomePosition);
00862 syncExec(new Runnable(){
00863 public void run(){
00864 setDblAry("eyeHomePosition", eyeHomePosition, 5);
00865 }
00866 });
00867 propertyChanged("eyeHomePosiotion", getProperty("eyeHomePosition"));
00868 }
00869 }
00870
00871 public void registerItemChange(GrxBaseItem item, int event){
00872 if(item instanceof GrxModelItem){
00873 GrxModelItem modelItem = (GrxModelItem) item;
00874 switch(event){
00875 case GrxPluginManager.SELECTED_ITEM:
00876 if(!modelItem.bgRoot_.isLive()){
00877 modelItem.setWireFrame(viewToolBar_.isWireFrameSelected());
00878 bgRoot_.addChild(modelItem.bgRoot_);
00879 currentModels_.add(modelItem);
00880 behaviorManager_.setItem(currentModels_, currentCollisionPairs_);
00881 if(viewMode_ == VIEW && currentState_!=null){
00882 updateModels(currentState_);
00883 updateViewSimulator(currentState_.time);
00884 }else
00885 updateViewSimulator(0);
00886 if(modelItem.isModified())
00887 optionButtonEnable(false);
00888 showOption();
00889 if(btnBBdisp_.isSelected()){
00890 btnBBdisp_.doClick();
00891 }
00892 modelItem.addObserver(this);
00893 }
00894 break;
00895 case GrxPluginManager.REMOVE_ITEM:
00896 case GrxPluginManager.NOTSELECTED_ITEM:
00897 if(modelItem.bgRoot_.isLive()){
00898 modelItem.bgRoot_.detach();
00899 currentModels_.remove(modelItem);
00900 behaviorManager_.setItem(currentModels_, currentCollisionPairs_);
00901 if(modelItem.isModified())
00902 optionButtonEnable(true);
00903 showOption();
00904 modelItem.deleteObserver(this);
00905 }
00906
00907
00908 break;
00909 default:
00910 break;
00911 }
00912 }else if(item instanceof GrxWorldStateItem){
00913 GrxWorldStateItem worldStateItem = (GrxWorldStateItem) item;
00914 switch(event){
00915 case GrxPluginManager.SELECTED_ITEM:
00916 if(currentWorld_!=worldStateItem){
00917 currentWorld_ = worldStateItem;
00918 currentWorld_.addObserver(this);
00919 currentWorld_.addPosObserver(this);
00920 currentState_ = currentWorld_.getValue();
00921 updatePosition(currentWorld_, currentWorld_.getPosition());
00922 }
00923 break;
00924 case GrxPluginManager.REMOVE_ITEM:
00925 case GrxPluginManager.NOTSELECTED_ITEM:
00926 if(currentWorld_==worldStateItem){
00927 currentWorld_.deleteObserver(this);
00928 currentWorld_.deletePosObserver(this);
00929 currentWorld_ = null;
00930 currentState_ = null;
00931 }
00932 break;
00933 default:
00934 break;
00935 }
00936 }else if(item instanceof GrxCollisionPairItem){
00937 GrxCollisionPairItem collisionPairItem = (GrxCollisionPairItem) item;
00938 switch(event){
00939 case GrxPluginManager.SELECTED_ITEM:
00940 if(!currentCollisionPairs_.contains(collisionPairItem)){
00941 currentCollisionPairs_.add(collisionPairItem);
00942 behaviorManager_.setItem(currentModels_, currentCollisionPairs_);
00943 showOption();
00944 }
00945 break;
00946 case GrxPluginManager.REMOVE_ITEM:
00947 case GrxPluginManager.NOTSELECTED_ITEM:
00948 if(currentCollisionPairs_.contains(collisionPairItem)){
00949 currentCollisionPairs_.remove(collisionPairItem);
00950 behaviorManager_.setItem(currentModels_, currentCollisionPairs_);
00951 showOption();
00952 }
00953 break;
00954 }
00955 }else if(item instanceof GrxSimulationItem){
00956 GrxSimulationItem simItem = (GrxSimulationItem) item;
00957 switch(event){
00958 case GrxPluginManager.SELECTED_ITEM:
00959 if(simItem_!=simItem){
00960 simItem_ = simItem;
00961 simItem_.addObserver(this);
00962 }
00963 break;
00964 case GrxPluginManager.REMOVE_ITEM:
00965 case GrxPluginManager.NOTSELECTED_ITEM:
00966 if(simItem_==simItem){
00967 simItem_.deleteObserver(this);
00968 simItem_ = null;
00969 }
00970 break;
00971 default:
00972 break;
00973 }
00974 }
00975 }
00976
00977 public void update(GrxBasePlugin plugin, Object... arg) {
00978 if(simItem_==plugin){
00979 if((String)arg[0]=="StartSimulation"){
00980 disableButton();
00981 objectToolBar_.setMode(ObjectToolBar.DISABLE_MODE);
00982 if((Boolean)arg[1])
00983 showViewSimulator(true);
00984 viewMode_ = SIMULATION;
00985 }else if((String)arg[0]=="StopSimulation"){
00986 objectToolBar_.setMode(ObjectToolBar.OBJECT_MODE);
00987 enableButton();
00988 viewMode_ = VIEW;
00989 }
00990 }else if(currentModels_.contains(plugin)){
00991 if((String)arg[0]=="PropertyChange"){
00992 if((String)arg[1]=="name" ){
00993 behaviorManager_.setItemChange();
00994 showOption();
00995 }
00996 if(((String)arg[1]).contains("translation") || ((String)arg[1]).contains("rotation") ||
00997 ((String)arg[1]).contains("angle"))
00998 showOption();
00999 }
01000 else if((String)arg[0]=="BodyInfoChange"){
01001 behaviorManager_.setItemChange();
01002 showOption();
01003 }else if((String)arg[0]=="Modified"){
01004 optionButtonEnable(false);
01005 }else if((String)arg[0]=="ClearModified"){
01006 optionButtonEnable(true);
01007 }
01008 }else if(currentWorld_==plugin){
01009 if((String)arg[0]=="ClearLog"){
01010 currentState_ = null;
01011 }
01012 }
01013 }
01014
01015 public void updatePosition(GrxBasePlugin plugin, Integer arg_pos){
01016 if(currentWorld_ != plugin)
01017 return;
01018
01019 if(viewMode_ == VIEW || viewMode_ == SIMULATION){
01020 int pos = arg_pos.intValue();
01021 currentState_ = currentWorld_.getValue(pos);
01022 if(currentState_!=null){
01023 _showCollision(currentState_.collisions);
01024 updateModels(currentState_);
01025 updateViewSimulator(currentState_.time);
01026 }
01027 if(viewMode_ == VIEW)
01028 showOptionWithoutCollision();
01029 }
01030 }
01031
01032 private void disableButton(){
01033 disableOperation();
01034 if (btnDistance_.isSelected())
01035 btnDistance_.doClick();
01036 if (btnIntersection_.isSelected())
01037 btnIntersection_.doClick();
01038 btnDistance_.setEnabled(false);
01039 btnIntersection_.setEnabled(false);
01040 btnRestore_.setEnabled(false);
01041 btnRec_.setEnabled(false);
01042 btnPlayer_.setEnabled(false);
01043 }
01044
01045 private void enableButton(){
01046 btnDistance_.setEnabled(true);
01047 btnIntersection_.setEnabled(true);
01048 btnRestore_.setEnabled(true);
01049 btnRec_.setEnabled(true);
01050 btnPlayer_.setEnabled(true);
01051 }
01052
01053 public void showOption(){
01054 if(viewMode_==SIMULATION) return;
01055 if (btnCollision_.isSelected()) {
01056 _showCollision(behaviorManager_.getCollision());
01057 behaviorManager_.setMessageSkip(true);
01058 }
01059 if (btnDistance_.isSelected()){
01060 _showDistance(behaviorManager_.getDistance());
01061 behaviorManager_.setMessageSkip(true);
01062 }
01063 if (btnIntersection_.isSelected()){
01064 _showIntersection(behaviorManager_.getIntersection());
01065 }
01066 behaviorManager_.setMessageSkip(false);
01067 }
01068
01069 private void showOptionWithoutCollision(){
01070 if(viewMode_==SIMULATION) return;
01071 if (btnDistance_.isSelected()){
01072 _showDistance(behaviorManager_.getDistance());
01073 behaviorManager_.setMessageSkip(true);
01074 }
01075 if (btnIntersection_.isSelected()){
01076 _showIntersection(behaviorManager_.getIntersection());
01077 }
01078 behaviorManager_.setMessageSkip(false);
01079 }
01080
01081 public void showViewSimulator(boolean b) {
01082 for (int i=0; i<currentModels_.size(); i++) {
01083 List<Camera_impl> l = currentModels_.get(i).getCameraSequence();
01084 for (int j=0; j<l.size(); j++) {
01085 Camera_impl c = l.get(j);
01086 c.setVisible(b);
01087 }
01088 }
01089 }
01090
01091 public void updateModels(WorldStateEx state){
01092
01093 for (int i=0; i<currentModels_.size(); i++) {
01094 GrxModelItem model = currentModels_.get(i);
01095 CharacterStateEx charStat = state.get(model.getName());
01096 if (charStat != null) {
01097 if (charStat.sensorState != null){
01098 double[] angles;
01099 if (showActualState_) {
01100 angles = charStat.sensorState.q;
01101 } else {
01102 angles = charStat.targetState;
01103 }
01104 model.setCharacterPos(charStat.position, angles);
01105 if (charStat.sensorState.range != null && charStat.sensorState.range.length > 0){
01106 List<GrxSensorItem> sensors = model.getSensors("Range");
01107 for (int j=0; j<sensors.size(); j++){
01108 GrxSensorItem sensor = sensors.get(j);
01109 if (sensor.isVisible() && sensor.id_ >= 0 && sensor.id_ < charStat.sensorState.range.length){
01110 sensor.updateShapeOfVisibleArea(charStat.sensorState.range[sensor.id_]);
01111 }
01112 }
01113 }
01114 }
01115 else
01116 model.setCharacterPos(charStat.position, null);
01117 }
01118 }
01119 }
01120
01121 private void rec(){
01122 RecordingDialog dialog = new RecordingDialog(frame_, currentWorld_.getTime(currentWorld_.getLogSize()-1));
01123 if (dialog.showModalDialog() != ModalDialog.OK_BUTTON){
01124 btnRec_.setSelected(false);
01125 return;
01126 }
01127
01128 Dimension canvasSize = dialog.getImageSize();
01129 int framerate=10;
01130 try{
01131 framerate = dialog.getFrameRate();
01132 }catch(Exception NumberFormatException ){
01133 new ErrorDialog(frame_, MessageBundle.get("Grx3DView.dialog.title.error"), MessageBundle.get("Grx3DView.dialog.message.error") ).showModalDialog();
01134 btnRec_.setSelected(false);
01135 return;
01136 }
01137 double playbackRate = dialog.getPlaybackRate();
01138
01139 GrxDebugUtil.println("ScreenSize: " + canvasSize.width + "x" + canvasSize.height + " (may be)");
01140
01141 BufferedImage image=new BufferedImage(canvasSize.width,canvasSize.height,BufferedImage.TYPE_INT_ARGB);
01142
01143 ImageComponent2D buffer=new ImageComponent2D(ImageComponent.FORMAT_RGBA,image,true,false);
01144 buffer.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
01145
01146
01147 offscreen_=new Canvas3D(graphicsConfiguration,true);
01148 offscreen_.setOffScreenBuffer(buffer);
01149 view_.addCanvas3D(offscreen_);
01150
01151 Screen3D screen = canvas_.getScreen3D();
01152 offscreen_.getScreen3D().setSize(screen.getSize());
01153 offscreen_.getScreen3D().setPhysicalScreenWidth(screen.getPhysicalScreenWidth());
01154 offscreen_.getScreen3D().setPhysicalScreenHeight(screen.getPhysicalScreenHeight());
01155
01156 recordingMgr_ = RecordingManager.getInstance();
01157 recordingMgr_.setImageSize(canvasSize.width , canvasSize.height);
01158 recordingMgr_.setFrameRate((float)framerate);
01159
01160 String fileName = dialog.getFileName();
01161 if (new File(fileName).exists()) {
01162 if (!fileOverwriteDialog(fileName)){
01163 btnRec_.setSelected(false);
01164 return;
01165 }
01166 }
01167
01168 lastMovieFileName = pathToURL(fileName);
01169 ComboBoxDialog cmb = new ComboBoxDialog(
01170 frame_,
01171 MessageBundle.get("Grx3DView.dialog.title.videoFormat"),
01172 MessageBundle.get("Grx3DView.dialog.message.videoFormat"),
01173 recordingMgr_.preRecord(lastMovieFileName, ImageToMovie.QUICKTIME));
01174 String format__ = (String)cmb.showComboBoxDialog();
01175 if (format__ == null) {
01176 btnRec_.setSelected(false);
01177 return;
01178 }
01179
01180 try {
01181 if(!recordingMgr_.startRecord(format__)){
01182 btnRec_.setSelected(false);
01183 return;
01184 }
01185 } catch (Exception e) {
01186 GrxDebugUtil.printErr("Grx3DView.rec():",e);
01187 syncExec(new Runnable(){
01188 public void run(){
01189 MessageDialog.openError( comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.error"), MessageBundle.get("Grx3DView.dialog.message.recError"));
01190 }
01191 });
01192 btnRec_.setSelected(false);
01193 return;
01194 }
01195
01196 disableButton();
01197 viewMode_ = VIEW;
01198 objectToolBar_.setMode(ObjectToolBar.DISABLE_MODE);
01199
01200 final double stepTime = 1.0/framerate*playbackRate;
01201 double startTime = dialog.getStartTime();
01202 double endTime = dialog.getEndTime();
01203 final int startPosition = currentWorld_.getPositionAt(startTime);
01204 final int endPosition = currentWorld_.getPositionAt(endTime);
01205 Thread recThread_ = new Thread() {
01206 public void run() {
01207 try {
01208 double playRateLogTime_ = currentWorld_.getTime(startPosition);
01209 for (int position=startPosition; position <= endPosition; position++) {
01210 if(!btnRec_.isSelected())break;
01211 double time = currentWorld_.getTime(position);
01212 if (time >= playRateLogTime_) {
01213 playRateLogTime_ += stepTime;
01214 final int _position = position;
01215 syncExec(new Runnable(){
01216 public void run() {
01217 currentWorld_.setPosition(_position);
01218 }
01219 });
01220 _doRecording();
01221 }
01222 }
01223 stopRecording();
01224 } catch (Exception e) {
01225 syncExec(new Runnable(){
01226 public void run(){
01227 MessageDialog.openError( comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.error"), MessageBundle.get("Grx3DView.dialog.message.recException"));
01228 }
01229 });
01230 stopRecording();
01231 GrxDebugUtil.printErr("Recording Interrupted by Exception:",e);
01232 }
01233 }
01234 };
01235
01236 recThread_.start();
01237 }
01238
01239 private void stopRecording(){
01240 recordingMgr_.endRecord();
01241 btnRec_.setSelected(false);
01242 view_.removeCanvas3D(offscreen_);
01243 syncExec(new Runnable(){
01244 public void run(){
01245 MessageDialog.openInformation( comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.Infomation"), MessageBundle.get("Grx3DView.dialog.message.recFinish"));
01246 }
01247 });
01248 objectToolBar_.setMode(ObjectToolBar.OBJECT_MODE);
01249 enableButton();
01250 }
01251
01252 private boolean ret_;
01253 private boolean fileOverwriteDialog(final String fileName){
01254 if (new File(fileName).isDirectory())
01255 return false;
01256
01257 syncExec(new Runnable(){
01258 public void run(){
01259 ret_ = MessageDialog.openConfirm( comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.fileExist"),
01260 fileName + " " + MessageBundle.get("Grx3DView.dialog.message.fileExist"));
01261 }
01262 });
01263 if(ret_)
01264 return true;
01265 else
01266 return false;
01267 }
01268
01269 private String pathToURL(String path) {
01270 if (path.startsWith("file:///")) {
01271
01272 path = path.replace(java.io.File.separatorChar, '/');
01273 return path;
01274 }
01275 if (path.startsWith("http://")) {
01276 return path;
01277 }
01278 if (!path.startsWith(java.io.File.separator) && (path.indexOf(':') != 1)) {
01279 path = System.getProperty("user.dir") + java.io.File.separator + path;
01280 }
01281 if (path.indexOf(':') == 1) {
01282 path = path.replace(java.io.File.separatorChar, '/');
01283 return "file:///" + path;
01284 }
01285 return "file://" + path;
01286 }
01287
01288 private void _doRecording() {
01289 offscreen_.renderOffScreenBuffer();
01290 offscreen_.waitForOffScreenRendering();
01291 recordingMgr_.pushImage( offscreen_.getOffScreenBuffer().getImage() );
01292 }
01293
01294 public void _showCollision(Collision[] collisions) {
01295 collision_.removeAllGeometries();
01296 if (collisions == null || collisions.length <= 0 || !btnCollision_.isSelected())
01297 return;
01298
01299 int length = 0;
01300 for (int i = 0; i < collisions.length; i++) {
01301 if (collisions[i].points != null)
01302 length += collisions[i].points.length;
01303 }
01304 if (length > 0) {
01305 CollisionPoint[] cd = new CollisionPoint[length];
01306 for (int i=0, n=0; i<collisions.length; i++) {
01307 for (int j=0; j<collisions[i].points.length; j++)
01308 cd[n++] = collisions[i].points[j];
01309 }
01310
01311 Point3d[] p3d = new Point3d[cd.length * 2];
01312 for (int j=0; j<cd.length; j++) {
01313 p3d[j*2] = new Point3d(cd[j].position);
01314
01315 Vector3d pole = new Vector3d(cd[j].normal);
01316 pole.normalize();
01317 float depth = (float) cd[j].idepth*colprop+coldiff;
01318 p3d[j*2+1] = new Point3d(
01319 cd[j].position[0] + pole.x*depth,
01320 cd[j].position[1] + pole.y*depth,
01321 cd[j].position[2] + pole.z*depth
01322 );
01323 }
01324
01325 LineArray la = new LineArray(p3d.length, LineArray.COLOR_3
01326 | LineArray.COORDINATES | LineArray.NORMALS);
01327 la.setCoordinates(0, p3d);
01328
01329 Vector3f[] v3f = new Vector3f[p3d.length];
01330 Color3f[] c3f = new Color3f[p3d.length];
01331 for (int i=0; i<v3f.length; i++) {
01332 v3f[i] = new Vector3f(0.0f, 0.0f, 1.0f);
01333 if ((i % 2) == 0)
01334 c3f[i] = new Color3f(0.0f, 0.8f, 0.8f);
01335 else
01336 c3f[i] = new Color3f(0.8f, 0.0f, 0.8f);
01337 }
01338 la.setNormals(0, v3f);
01339 la.setColors(0, c3f);
01340 collision_.addGeometry(la);
01341 } else {
01342 collision_.addGeometry(null);
01343 }
01344 }
01345
01346 private void _showDistance(Distance[] distances) {
01347 distance_.removeAllGeometries();
01348 if (distances == null || distances.length <= 0 || !btnDistance_.isSelected())
01349 return;
01350
01351 int length = distances.length;
01352
01353 if (length > 0) {
01354 Point3d[] p3d = new Point3d[length * 2];
01355 for (int j=0; j<length; j++) {
01356 p3d[j*2] = new Point3d(distances[j].point0);
01357 p3d[j*2+1] = new Point3d(distances[j].point1);
01358 }
01359
01360 LineArray la = new LineArray(p3d.length, LineArray.COLOR_3
01361 | LineArray.COORDINATES | LineArray.NORMALS);
01362 la.setCoordinates(0, p3d);
01363
01364 Vector3f[] v3f = new Vector3f[p3d.length];
01365 Color3f[] c3f = new Color3f[p3d.length];
01366 for (int i=0; i<v3f.length; i++) {
01367 v3f[i] = new Vector3f(0.0f, 0.0f, 1.0f);
01368 c3f[i] = new Color3f(1.0f, 0.0f, 0.0f);
01369 }
01370 la.setNormals(0, v3f);
01371 la.setColors(0, c3f);
01372 distance_.addGeometry(la);
01373 } else {
01374 distance_.addGeometry(null);
01375 }
01376 }
01377
01378 @SuppressWarnings("unchecked")
01379 private void _showIntersection(LinkPair[] pairs){
01380 if (pairs == null){
01381 for (int i=0; i<intersectingLinks_.size(); i++){
01382 intersectingLinks_.get(i).restoreColor();
01383 }
01384 intersectingLinks_.clear();
01385 return;
01386 }else{
01387 Map<String, GrxModelItem> modelMap = (Map<String, GrxModelItem>)manager_.getItemMap(GrxModelItem.class);
01388 Vector<GrxLinkItem> links = new Vector<GrxLinkItem>();
01389 for (int i=0; i<pairs.length; i++){
01390 GrxModelItem m1 = modelMap.get(pairs[i].charName1);
01391 if (m1 != null){
01392 GrxLinkItem l = m1.getLink(pairs[i].linkName1);
01393 if (l != null){
01394 links.add(l);
01395 if (!intersectingLinks_.contains(l)){
01396 l.setColor(java.awt.Color.RED);
01397 }
01398 }
01399 }
01400 GrxModelItem m2 = modelMap.get(pairs[i].charName2);
01401 if (m2 != null){
01402 GrxLinkItem l = m2.getLink(pairs[i].linkName2);
01403 if (l != null) links.add(l);
01404 if (!intersectingLinks_.contains(l)){
01405 l.setColor(java.awt.Color.RED);
01406 }
01407 }
01408 }
01409 for (int i=0; i<intersectingLinks_.size(); i++){
01410 GrxLinkItem l = intersectingLinks_.get(i);
01411 if (!links.contains(l)){
01412 l.restoreColor();
01413 }
01414 }
01415 intersectingLinks_ = links;
01416 }
01417 }
01418
01419 public void updateViewSimulator(double time) {
01420 for (int i=0; i<currentModels_.size(); i++) {
01421 List<Camera_impl> l = currentModels_.get(i).getCameraSequence();
01422 for (int j=0; j<l.size(); j++) {
01423 Camera_impl c = l.get(j);
01424 if (c.isVisible()) c.updateView(time);
01425 }
01426 }
01427 }
01428
01429 public BranchGroup getRuler() {
01430 if (rulerBg_ == null) {
01431 rulerBg_ = new BranchGroup();
01432 rulerBg_.setCapability(BranchGroup.ALLOW_DETACH);
01433 int n = 40;
01434 Point3d[] p = new Point3d[n * 4];
01435 double width = n/2.0;
01436 for (int i=0; i<n; i++) {
01437 p[2*i] = new Point3d(-width+i, -width, 0.0);
01438 p[2*i+1] = new Point3d(-width+i, width, 0.0);
01439 p[2*i+n*2] = new Point3d(-width, -width+i, 0.0);
01440 p[2*i+n*2+1] = new Point3d( width, -width+i, 0.0);
01441 }
01442 LineArray geometry = new LineArray(p.length,
01443 GeometryArray.COORDINATES | GeometryArray.COLOR_3);
01444 geometry.setCoordinates(0, p);
01445 for (int i = 0; i < p.length; i++)
01446 geometry.setColor(i, new Color3f(Color.white));
01447
01448 Shape3D shape = new Shape3D(geometry);
01449 shape.setPickable(false);
01450 rulerBg_.addChild(shape);
01451 rulerBg_.compile();
01452 }
01453 return rulerBg_;
01454 }
01455
01456 public boolean registerCORBA() {
01457 NamingContext rootnc = GrxCorbaUtil.getNamingContext();
01458
01459 OnlineViewer_impl olvImpl = new OnlineViewer_impl();
01460 OnlineViewer olv = olvImpl._this(manager_.orb_);
01461 NameComponent[] path1 = {new NameComponent("OnlineViewer", "")};
01462 ViewSimulator_impl viewImpl = new ViewSimulator_impl();
01463 ViewSimulator view = viewImpl._this(manager_.orb_);
01464 NameComponent[] path2 = {new NameComponent("ViewSimulator", "")};
01465
01466
01467
01468 try {
01469 rootnc.rebind(path1, olv);
01470 rootnc.rebind(path2, view);
01471
01472 } catch (Exception ex) {
01473 GrxDebugUtil.println("3DVIEW : failed to bind to localhost NameService");
01474 return false;
01475 }
01476
01477 GrxDebugUtil.println("3DVIEW : successfully bound to localhost NameService");
01478 return true;
01479 }
01480
01481
01482 public void unregisterCORBA() {
01483 NamingContext rootnc = GrxCorbaUtil.getNamingContext();
01484 NameComponent[] path1 = {new NameComponent("OnlineViewer", "")};
01485 NameComponent[] path2 = {new NameComponent("ViewSimulator", "")};
01486
01487 try{
01488 rootnc.unbind(path1);
01489 rootnc.unbind(path2);
01490
01491 GrxDebugUtil.println("3DVIEW : successfully unbound to localhost NameService");
01492 }catch(Exception ex){
01493 GrxDebugUtil.println("3DVIEW : failed to unbind to localhost NameService");
01494 }
01495 }
01496
01497 private class ModelEditKeyAdapter extends KeyAdapter {
01498 public void keyPressed(KeyEvent arg0) {
01499 GrxLinkItem li = null;
01500 GrxBaseItem bitem = manager_.focusedItem();
01501 if (bitem instanceof GrxLinkItem){
01502 li = (GrxLinkItem)bitem;
01503 }else{
01504 arg0.consume();
01505 return;
01506 }
01507 GrxModelItem item = li.model();
01508
01509 KeyStroke ks = KeyStroke.getKeyStrokeForEvent(arg0);
01510 if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_UP,0) ||
01511 ks == KeyStroke.getKeyStroke(KeyEvent.VK_K,0)) {
01512 int next = li.jointId_-1;
01513 if (next >= 0) {
01514 for (int j=0; j<item.links_.size(); j++) {
01515 if (next == item.links_.get(j).jointId_) {
01516 behaviorManager_.setPickTarget(item.links_.get(j).tg_);
01517 break;
01518 }
01519 }
01520 }
01521 } else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,0) ||
01522 ks == KeyStroke.getKeyStroke(KeyEvent.VK_J,0)) {
01523 int next = li.jointId_+1;
01524 for (int j=0; j<item.links_.size(); j++) {
01525 if (next == item.links_.get(j).jointId_) {
01526 behaviorManager_.setPickTarget(item.links_.get(j).tg_);
01527 break;
01528 }
01529 }
01530 } else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,KeyEvent.SHIFT_MASK) ||
01531 ks == KeyStroke.getKeyStroke(KeyEvent.VK_H,KeyEvent.SHIFT_MASK)) {
01532 li.jointValue(li.jointValue_-dAngle_);
01533
01534 if (li.llimit_[0] < li.ulimit_[0])
01535 li.jointValue(Math.max(li.jointValue_, li.llimit_[0]));
01536 item.calcForwardKinematics();
01537 item.setProperty(li.getName()+".angle",String.valueOf(li.jointValue_));
01538
01539 } else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,KeyEvent.SHIFT_MASK) ||
01540 ks == KeyStroke.getKeyStroke(KeyEvent.VK_L,KeyEvent.SHIFT_MASK)) {
01541 li.jointValue(li.jointValue_+dAngle_);
01542 if (li.llimit_[0] < li.ulimit_[0])
01543 li.jointValue(Math.min(li.jointValue_, li.ulimit_[0]));
01544 item.calcForwardKinematics();
01545 item.setProperty(li.getName()+".angle",String.valueOf(li.jointValue_));
01546
01547 } else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_H,0) ||
01548 ks == KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,0)) {
01549 li.jointValue(li.jointValue_-dAngle_*20);
01550 if (li.llimit_[0] < li.ulimit_[0])
01551 li.jointValue(Math.max(li.jointValue_, li.llimit_[0]));
01552 item.calcForwardKinematics();
01553 item.setProperty(li.getName()+".angle",String.valueOf(li.jointValue_));
01554
01555 } else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_L,0) ||
01556 ks == KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0)) {
01557 li.jointValue(li.jointValue_+dAngle_*20);
01558 if (li.llimit_[0] < li.ulimit_[0])
01559 li.jointValue(Math.min(li.jointValue_, li.ulimit_[0]));
01560 item.calcForwardKinematics();
01561 item.setProperty(li.getName()+".angle",String.valueOf(li.jointValue_));
01562 }
01563 arg0.consume();
01564 }
01565 }
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586 private class ViewSimulator_impl extends ViewSimulatorPOA {
01587 public void destroy() {
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604 }
01605
01606 public void getCameraSequence(CameraSequenceHolder arg0) {
01607 List<Camera_impl> allList = new ArrayList<Camera_impl>();
01608 for (int i=0; i<currentModels_.size(); i++) {
01609 List<Camera_impl> l = currentModels_.get(i).getCameraSequence();
01610 allList.addAll(l);
01611 }
01612
01613 arg0.value = new Camera[allList.size()];
01614 for (int i=0; i<allList.size(); i++) {
01615 try {
01616 arg0.value[i] = CameraHelper.narrow(manager_.poa_.servant_to_reference(allList.get(i)));
01617 } catch (ServantNotActive e) {
01618 e.printStackTrace();
01619 } catch (WrongPolicy e) {
01620 e.printStackTrace();
01621 }
01622 }
01623 }
01624
01625 public void getCameraSequenceOf(String objectName, CameraSequenceHolder arg1) {
01626 for (int i=0; i<currentModels_.size(); i++) {
01627 GrxModelItem item = currentModels_.get(i);
01628 if (item.getName().equals(objectName)) {
01629 List<Camera_impl> l = item.getCameraSequence();
01630 arg1.value = new Camera[l.size()];
01631 for (int j=0; j<l.size(); j++) {
01632 try {
01633 arg1.value[j] = CameraHelper.narrow(manager_.poa_.servant_to_reference(l.get(j)));
01634 } catch (ServantNotActive e) {
01635 e.printStackTrace();
01636 } catch (WrongPolicy e) {
01637 e.printStackTrace();
01638 }
01639 }
01640 return;
01641 }
01642 }
01643 arg1.value = new Camera[0];
01644 }
01645
01646 public void registerCharacter(final String name, final BodyInfo bInfo) {
01647 syncExec(new Runnable(){
01648 public void run(){
01649 GrxBaseItem newItem = manager_.createItem(GrxModelItem.class, name);
01650 if(newItem!=null){
01651 manager_.itemChange(newItem, GrxPluginManager.ADD_ITEM);
01652 manager_.setSelectedItem(newItem, true);
01653 ((GrxModelItem)newItem).registerCharacter(bInfo);
01654 ((GrxModelItem)newItem).setURL(bInfo.url());
01655 }
01656 }
01657 });
01658 }
01659
01660 public void updateScene(WorldState worldState) {
01661 final WorldStateEx statex = new WorldStateEx(worldState);
01662 syncExec(new Runnable(){
01663 public void run(){
01664 updateModels(statex);
01665 updateViewSimulator(0);
01666 }
01667 });
01668 }
01669 }
01670
01671 private class OnlineViewer_impl extends OnlineViewerPOA {
01672 private double prevTime = 0.0;
01673 private boolean firstTime_ = true;
01674 private double logTimeStep_ = 0.0;
01675 private boolean updateTimer_ = false;
01676 private GrxBaseItem newItem = null;
01677
01678 public void clearLog() {
01679 if (currentWorld_ != null){
01680 syncExec(new Runnable(){
01681 public void run(){
01682 currentWorld_.clearLog();
01683 }
01684 });
01685 currentState_=null;
01686 }
01687 firstTime_ = true;
01688 }
01689
01690 public void load(final String name, String url) throws OnlineViewerException{
01691 System.out.println(name+":"+url);
01692 final String url0 = url;
01693 try {
01694 URL u = new URL(url);
01695 final String url_ = u.getFile();
01696 syncExec(new Runnable(){
01697 public void run(){
01698 newItem = manager_.loadItem(GrxModelItem.class, name, url_);
01699 if(newItem!=null){
01700 manager_.itemChange(newItem, GrxPluginManager.ADD_ITEM);
01701 manager_.setSelectedItem(newItem, true);
01702 }
01703 }
01704 });
01705 } catch (MalformedURLException e) {
01706 e.printStackTrace();
01707 syncExec(new Runnable(){
01708 public void run(){
01709 MessageDialog.openError( comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.error"), MessageBundle.get("OnlineViewer.dialog.message.MalformedURLException"));
01710 }
01711 });
01712 throw new OnlineViewerException("Malformed URL Exception");
01713 }
01714 if(newItem==null){
01715 syncExec(new Runnable(){
01716 public void run(){
01717 MessageDialog.openError( comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.error"), url0+MessageBundle.get("OnlineViewer.dialog.message.loadError"));
01718 }
01719 });
01720 throw new OnlineViewerException(url+"cannot be loaded.");
01721 }
01722 }
01723
01724 public boolean getPosture(String name , DblSequenceHolder posture) {
01725 Object obj = manager_.getItem(GrxModelItem.class, name);
01726 if (obj != null) {
01727 GrxModelItem model = (GrxModelItem)obj;
01728 posture.value = model.getJointValues();
01729 return true;
01730 }
01731 posture.value = new double[0];
01732 return false;
01733 }
01734
01735 public void update(WorldState arg0) {
01736 final GrxWorldStateItem.WorldStateEx statex = new GrxWorldStateItem.WorldStateEx(arg0);
01737 if (currentWorld_ == null) {
01738 syncExec(new Runnable(){
01739 public void run(){
01740 GrxWorldStateItem item = (GrxWorldStateItem)manager_.createItem(GrxWorldStateItem.class, null);
01741 manager_.itemChange(item, GrxPluginManager.ADD_ITEM);
01742 manager_.setSelectedItem(item, true);
01743 }
01744 });
01745 }
01746 if (firstTime_) {
01747 firstTime_ = false;
01748 prevTime = 0.0;
01749 logTimeStep_ = 0.0;
01750 String[] chars = statex.characters();
01751 for (int i=0; i<chars.length; i++) {
01752 GrxModelItem model = (GrxModelItem)manager_.getItem(GrxModelItem.class, chars[i]);
01753 BodyInfo bodyInfo = model.getBodyInfo();
01754 if(bodyInfo==null) return;
01755 currentWorld_.registerCharacter(chars[i], bodyInfo);
01756 }
01757 syncExec(new Runnable(){
01758 public void run(){
01759 if(statex.time > 0){
01760 logTimeStep_ = statex.time;
01761 currentWorld_.setDbl("logTimeStep", logTimeStep_);
01762 }
01763 }
01764 });
01765 }
01766
01767 final double stepTime = statex.time - prevTime;
01768 if(stepTime > 0 && Math.abs(stepTime-logTimeStep_)>10e-9){
01769 logTimeStep_ = stepTime;
01770 syncExec(new Runnable(){
01771 public void run(){
01772 currentWorld_.setDbl("logTimeStep", logTimeStep_);
01773 }
01774 });
01775 }
01776
01777 currentWorld_.addValue(statex.time, statex);
01778 Thread.yield();
01779 if(!updateTimer_){
01780 java.util.Timer timer = new java.util.Timer();
01781 timer.schedule(new updateView(),20);
01782 updateTimer_ = true;
01783 }
01784 prevTime = statex.time;
01785 }
01786
01787 public void clearData() {}
01788
01789 public void drawScene(WorldState arg0) {
01790 GrxWorldStateItem.WorldStateEx statex = new GrxWorldStateItem.WorldStateEx(arg0);
01791 _showCollision(statex.collisions);
01792 updateModels(statex);
01793 updateViewSimulator(statex.time);
01794 }
01795
01796 public void setLineScale(float arg0) {}
01797 public void setLineWidth(float arg0) {}
01798
01799 private class updateView extends java.util.TimerTask {
01800 public void run() {
01801 updateTimer_ = false;
01802 final int pos = currentWorld_.getLogSize()-1;
01803 syncExec(new Runnable(){
01804 public void run(){
01805 currentWorld_.setPosition(pos);
01806 }
01807 });
01808 }
01809 }
01810
01811 public void setLogName(final String name){
01812 syncExec(new Runnable(){
01813 public void run(){
01814 GrxWorldStateItem item = (GrxWorldStateItem)manager_.getItem(GrxWorldStateItem.class, name);
01815 if(item==null){
01816 item = (GrxWorldStateItem)manager_.createItem(GrxWorldStateItem.class, name);
01817 manager_.itemChange(item, GrxPluginManager.ADD_ITEM);
01818 firstTime_ = true;
01819 }
01820 manager_.setSelectedItem(item, true);
01821 }
01822 });
01823 }
01824 }
01825
01826 public void attach(BranchGroup bg) {
01827 bgRoot_.addChild(bg);
01828 }
01829
01830 public void attachUnclickable( BranchGroup bg) {
01831 unclickableBgRoot_.addChild(bg);
01832 }
01833
01834 public String getFullName() {
01835 return getName();
01836 }
01837
01838 public TransformGroup getTransformGroupRoot() {
01839 return tgView_;
01840 }
01841
01842 public ViewInfo getViewInfo() {
01843 return info_;
01844 }
01845
01846 public void setDirection(int dir) {
01847 }
01848
01849 public void setTransform(Transform3D transform) {
01850 tgView_.setTransform(transform);
01851 }
01852
01853 public void setViewMode(int mode) {
01854 }
01855
01856 private void _registerAction() {
01857 GUIAction.ROOM_VIEW.addActionListener(new ActionListener() {
01858 public void actionPerformed(ActionEvent e) {
01859 info_.setViewMode(ViewInfo.VIEW_MODE_ROOM);
01860 view_.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
01861 behaviorManager_.setViewMode(BehaviorManager.ROOM_VIEW_MODE);
01862 viewToolBar_.setMode(ViewToolBar.ROOM_MODE);
01863 syncExec(new Runnable(){
01864 public void run(){
01865 setProperty("view.mode", ViewToolBar.COMBO_SELECT_ROOM);
01866 }
01867 });
01868 }
01869 });
01870
01871 GUIAction.WALK_VIEW.addActionListener(new ActionListener() {
01872 public void actionPerformed(ActionEvent e) {
01873 info_.setViewMode(ViewInfo.VIEW_MODE_WALK);
01874 view_.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
01875 behaviorManager_.setViewMode(BehaviorManager.WALK_VIEW_MODE);
01876 viewToolBar_.setMode(ViewToolBar.WALK_MODE);
01877 syncExec(new Runnable(){
01878 public void run(){
01879 setProperty("view.mode", ViewToolBar.COMBO_SELECT_WALK);
01880 }
01881 });
01882 }
01883 });
01884
01885 GUIAction.FRONT_VIEW.addActionListener(new ActionListener() {
01886 public void actionPerformed(ActionEvent e) {
01887 if (info_.getDirection() != ViewInfo.FRONT_VIEW)
01888 info_.setDirection(ViewInfo.FRONT_VIEW);
01889 info_.setViewMode(ViewInfo.VIEW_MODE_PARALLEL);
01890 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
01891 setTransform(info_.getTransform());
01892 behaviorManager_.setViewMode(BehaviorManager.PARALLEL_VIEW_MODE);
01893 viewToolBar_.setMode(ViewToolBar.PARALLEL_MODE);
01894 syncExec(new Runnable(){
01895 public void run(){
01896 setProperty("view.mode", ViewToolBar.COMBO_SELECT_FRONT);
01897 }
01898 });
01899 }
01900 });
01901
01902 GUIAction.BACK_VIEW.addActionListener(new ActionListener() {
01903 public void actionPerformed(ActionEvent e) {
01904 if (info_.getDirection() != ViewInfo.BACK_VIEW)
01905 info_.setDirection(ViewInfo.BACK_VIEW);
01906 info_.setViewMode(ViewInfo.VIEW_MODE_PARALLEL);
01907 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
01908 setTransform(info_.getTransform());
01909 behaviorManager_.setViewMode(BehaviorManager.PARALLEL_VIEW_MODE);
01910 viewToolBar_.setMode(ViewToolBar.PARALLEL_MODE);
01911 syncExec(new Runnable(){
01912 public void run(){
01913 setProperty("view.mode", ViewToolBar.COMBO_SELECT_BACK);
01914 }
01915 });
01916 }
01917 });
01918
01919 GUIAction.LEFT_VIEW.addActionListener(new ActionListener() {
01920 public void actionPerformed(ActionEvent e) {
01921 if (info_.getDirection() != ViewInfo.LEFT_VIEW)
01922 info_.setDirection(ViewInfo.LEFT_VIEW);
01923 info_.setViewMode(ViewInfo.VIEW_MODE_PARALLEL);
01924 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
01925 setTransform(info_.getTransform());
01926 behaviorManager_.setViewMode(BehaviorManager.PARALLEL_VIEW_MODE);
01927 viewToolBar_.setMode(ViewToolBar.PARALLEL_MODE);
01928 syncExec(new Runnable(){
01929 public void run(){
01930 setProperty("view.mode", ViewToolBar.COMBO_SELECT_LEFT);
01931 }
01932 });
01933 }
01934 });
01935
01936 GUIAction.RIGHT_VIEW.addActionListener(new ActionListener() {
01937 public void actionPerformed(ActionEvent e) {
01938 if (info_.getDirection() != ViewInfo.RIGHT_VIEW)
01939 info_.setDirection(ViewInfo.RIGHT_VIEW);
01940 info_.setViewMode(ViewInfo.VIEW_MODE_PARALLEL);
01941 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
01942 setTransform(info_.getTransform());
01943 behaviorManager_.setViewMode(BehaviorManager.PARALLEL_VIEW_MODE);
01944 viewToolBar_.setMode(ViewToolBar.PARALLEL_MODE);
01945 syncExec(new Runnable(){
01946 public void run(){
01947 setProperty("view.mode", ViewToolBar.COMBO_SELECT_RIGHT);
01948 }
01949 });
01950 }
01951 });
01952
01953 GUIAction.TOP_VIEW.addActionListener(new ActionListener() {
01954 public void actionPerformed(ActionEvent e) {
01955 if (info_.getDirection() != ViewInfo.TOP_VIEW)
01956 info_.setDirection(ViewInfo.TOP_VIEW);
01957 info_.setViewMode(ViewInfo.VIEW_MODE_PARALLEL);
01958 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
01959 setTransform(info_.getTransform());
01960 behaviorManager_.setViewMode(BehaviorManager.PARALLEL_VIEW_MODE);
01961 viewToolBar_.setMode(ViewToolBar.PARALLEL_MODE);
01962 syncExec(new Runnable(){
01963 public void run(){
01964 setProperty("view.mode", ViewToolBar.COMBO_SELECT_TOP);
01965 }
01966 });
01967 }
01968 });
01969
01970 GUIAction.BOTTOM_VIEW.addActionListener(new ActionListener() {
01971 public void actionPerformed(ActionEvent e) {
01972 if (info_.getDirection() != ViewInfo.BOTTOM_VIEW)
01973 info_.setDirection(ViewInfo.BOTTOM_VIEW);
01974 info_.setViewMode(ViewInfo.VIEW_MODE_PARALLEL);
01975 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
01976 setTransform(info_.getTransform());
01977 behaviorManager_.setViewMode(BehaviorManager.PARALLEL_VIEW_MODE);
01978 viewToolBar_.setMode(ViewToolBar.PARALLEL_MODE);
01979 syncExec(new Runnable(){
01980 public void run(){
01981 setProperty("view.mode", ViewToolBar.COMBO_SELECT_BOTTOM);
01982 }
01983 });
01984 }
01985 });
01986 GUIAction.VIEW_ZOOM_MODE.addActionListener(new ActionListener() {
01987 public void actionPerformed(ActionEvent e) {
01988 behaviorManager_.setViewHandlerMode("button_mode_zoom");
01989
01990 viewToolBar_.setOperation(ViewToolBar.ZOOM);
01991
01992
01993 }
01994 });
01995
01996 GUIAction.VIEW_ROTATION_MODE.addActionListener(new ActionListener() {
01997 public void actionPerformed(ActionEvent e) {
01998 behaviorManager_.setViewHandlerMode("button_mode_rotation");
01999
02000 viewToolBar_.setOperation(ViewToolBar.ROTATE);
02001
02002
02003 }
02004 });
02005
02006 GUIAction.VIEW_PAN_MODE.addActionListener(new ActionListener() {
02007 public void actionPerformed(ActionEvent e) {
02008 behaviorManager_.setViewHandlerMode("button_mode_translation");
02009
02010 viewToolBar_.setOperation(ViewToolBar.PAN);
02011
02012
02013 }
02014 });
02015
02016 GUIAction.WIRE_FRAME.addActionListener(new ActionListener() {
02017 public void actionPerformed(ActionEvent e) {
02018 Iterator<?> it = manager_.getItemMap(GrxModelItem.class).values().iterator();
02019 while (it.hasNext()) {
02020 ((GrxModelItem)it.next()).setWireFrame(viewToolBar_.isWireFrameSelected());
02021 }
02022 }
02023 });
02024
02025 GUIAction.BG_COLOR.addActionListener(new ActionListener() {
02026 public void actionPerformed(ActionEvent e) {
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039 Display display = Display.getDefault();
02040 if ( display!=null && !display.isDisposed())
02041 display.asyncExec(
02042 new Runnable(){
02043 public void run() {
02044 ColorDialog dialog = new ColorDialog( getParent().getShell() );
02045 RGB color = dialog.open();
02046 Color3f c = new Color3f( color.red/255f, color.green/255f, color.blue/255f );
02047 backGround_.setColor(new Color3f(c));
02048 }
02049 }
02050 );
02051 }
02052 });
02053
02054
02055 GUIAction.CAPTURE.addActionListener(new ActionListener() {
02056 public void actionPerformed(ActionEvent e) {
02057 Display display = Display.getDefault();
02058 if ( display!=null && !display.isDisposed())
02059 display.asyncExec(
02060 new Runnable(){
02061 public void run() {
02062 FileDialog fdlg = new FileDialog( getParent().getShell(), SWT.SAVE);
02063 String[] fe = { "*.png" };
02064 fdlg.setFilterExtensions( fe );
02065 String fPath = fdlg.open();
02066 if( fPath != null ){
02067 saveScreenShot( new File( fPath ) );
02068 }
02069 }
02070 }
02071 );
02072 }
02073 });
02074
02075 GUIAction.OBJECT_TRANSLATION.addActionListener(new ActionListener() {
02076 public void actionPerformed(ActionEvent e) {
02077 if (behaviorManager_.getOperationMode() != BehaviorManager.OBJECT_TRANSLATION_MODE){
02078 behaviorManager_.setOperationMode(BehaviorManager.OBJECT_TRANSLATION_MODE);
02079 viewMode_ = EDIT;
02080 objectToolBar_.setMode(ObjectToolBar.OBJECT_MODE);
02081 lblMode_.setText(MessageBundle.get("Grx3DView.text.editTranslate"));
02082 showOption();
02083 }
02084 }
02085 });
02086
02087 GUIAction.OBJECT_ROTATION.addActionListener(new ActionListener() {
02088 public void actionPerformed(ActionEvent e) {
02089 if (behaviorManager_.getOperationMode() != BehaviorManager.OBJECT_ROTATION_MODE){
02090 behaviorManager_.setOperationMode(BehaviorManager.OBJECT_ROTATION_MODE);
02091 viewMode_ = EDIT;
02092 objectToolBar_.setMode(ObjectToolBar.OBJECT_MODE);
02093 lblMode_.setText(MessageBundle.get("Grx3DView.text,editRotate"));
02094 showOption();
02095 }
02096 }
02097 });
02098 GUIAction.JOINT_ROTATION.addActionListener(new ActionListener() {
02099 public void actionPerformed(ActionEvent e) {
02100 if (behaviorManager_.getOperationMode() != BehaviorManager.JOINT_ROTATION_MODE){
02101 behaviorManager_.setOperationMode(BehaviorManager.JOINT_ROTATION_MODE);
02102 viewMode_ = EDIT;
02103 objectToolBar_.setMode(ObjectToolBar.OBJECT_MODE);
02104 lblMode_.setText(MessageBundle.get("Grx3DView.text.editMove"));
02105 showOption();
02106 }
02107 }
02108 });
02109
02110 GUIAction.FITTING_SRC.addActionListener(new ActionListener() {
02111 public void actionPerformed(ActionEvent e) {
02112 if (behaviorManager_.getOperationMode() != BehaviorManager.FITTING_FROM_MODE){
02113 objectToolBar_.setMode(ObjectToolBar.FITTING_MODE);
02114 viewToolBar_.setEnabled(true);
02115 behaviorManager_.setOperationMode(BehaviorManager.FITTING_FROM_MODE);
02116 viewMode_ = EDIT;
02117 lblMode_.setText(MessageBundle.get("Grx3DView.text.editObjectSelect"));
02118 showOption();
02119 }
02120 }
02121 });
02122
02123 GUIAction.FITTING_DEST.addActionListener(new ActionListener() {
02124 public void actionPerformed(ActionEvent e) {
02125 if (behaviorManager_.getOperationMode() != BehaviorManager.FITTING_TO_MODE){
02126 objectToolBar_.setMode(ObjectToolBar.FITTING_MODE);
02127 viewToolBar_.setEnabled(true);
02128 behaviorManager_.setOperationMode(BehaviorManager.FITTING_TO_MODE);
02129 viewMode_ = EDIT;
02130 lblMode_.setText(MessageBundle.get("Grx3DView.text,editObjectDestination"));
02131 showOption();
02132 }
02133 }
02134 });
02135
02136 GUIAction.DO_FIT.addActionListener(new ActionListener() {
02137 public void actionPerformed(ActionEvent e) {
02138
02139 behaviorManager_.fit();
02140 objectToolBar_.setMode(ObjectToolBar.FITTING_START_MODE);
02141 viewToolBar_.setEnabled(true);
02142 behaviorManager_.setOperationMode(BehaviorManager.FITTING_FROM_MODE);
02143 viewMode_ = EDIT;
02144 lblMode_.setText(MessageBundle.get("Grx3DView.text.editObjectSelect"));
02145 showOption();
02146 }
02147 });
02148
02149 GUIAction.INV_KINEMA_FROM.addActionListener(new ActionListener() {
02150 public void actionPerformed(ActionEvent e) {
02151 if (behaviorManager_.getOperationMode() != BehaviorManager.INV_KINEMA_FROM_MODE){
02152 objectToolBar_.setMode(ObjectToolBar.INV_KINEMA_MODE);
02153 behaviorManager_.setOperationMode(BehaviorManager.INV_KINEMA_FROM_MODE);
02154 viewMode_ = EDIT;
02155 lblMode_.setText(MessageBundle.get("Grx3DView.text.IKbaseLink"));
02156 showOption();
02157 }
02158 }
02159 });
02160
02161 GUIAction.INV_KINEMA_TRANS.addActionListener(new ActionListener() {
02162 public void actionPerformed(ActionEvent e) {
02163 if (behaviorManager_.getOperationMode() != BehaviorManager.INV_KINEMA_TRANSLATION_MODE){
02164 objectToolBar_.setMode(ObjectToolBar.INV_KINEMA_MODE);
02165 behaviorManager_.setOperationMode(BehaviorManager.INV_KINEMA_TRANSLATION_MODE);
02166 viewMode_ = EDIT;
02167 lblMode_.setText(MessageBundle.get("Grx3DView.text.IKtranslate"));
02168 showOption();
02169 }
02170 }
02171 });
02172
02173 GUIAction.INV_KINEMA_ROT.addActionListener(new ActionListener() {
02174 public void actionPerformed(ActionEvent e) {
02175 if (behaviorManager_.getOperationMode() != BehaviorManager.INV_KINEMA_ROTATION_MODE){
02176 objectToolBar_.setMode(ObjectToolBar.INV_KINEMA_MODE);
02177 behaviorManager_.setOperationMode(BehaviorManager.INV_KINEMA_ROTATION_MODE);
02178 viewMode_ = EDIT;
02179 lblMode_.setText(MessageBundle.get("Grx3DView.text.IKRotate"));
02180 showOption();
02181 }
02182 }
02183 });
02184
02185 GUIAction.OPERATION_DISABLE.addActionListener(new ActionListener() {
02186 public void actionPerformed(ActionEvent e) {
02187 disableOperation();
02188 viewMode_ = VIEW;
02189 }
02190 });
02191 }
02192
02193 public void disableOperation(){
02194
02195
02196 behaviorManager_.setOperationMode(BehaviorManager.OPERATION_MODE_NONE);
02197 objectToolBar_.setMode(ObjectToolBar.OBJECT_MODE);
02198 objectToolBar_.selectNone();
02199 viewToolBar_.setEnabled(true);
02200 lblMode_.setText(MessageBundle.get("Grx3DView.text.view"));
02201
02202 if(currentState_!=null){
02203 syncExec(new Runnable(){
02204 public void run(){
02205 updateModels(currentState_);
02206 _showCollision(currentState_.collisions);
02207 }
02208 });
02209 updateViewSimulator(currentState_.time);
02210 showOptionWithoutCollision();
02211 }
02212 }
02213
02214 public void addClickListener( Grx3DViewClickListener listener ){
02215 behaviorManager_.addClickListener( listener );
02216 }
02217
02218 public void removeClickListener( Grx3DViewClickListener listener ){
02219 behaviorManager_.removeClickListener( listener );
02220 }
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297 public void saveScreenShot( File file ){
02298 if ( file == null )
02299 return;
02300
02301
02302 Raster raster = null;
02303
02304 BufferedImage bimageRead = new BufferedImage(canvas_.getWidth(),
02305 canvas_.getHeight(), BufferedImage.TYPE_INT_RGB);
02306 ImageComponent2D readImage = new ImageComponent2D(
02307 ImageComponent.FORMAT_RGB, bimageRead);
02308
02309 raster = new Raster(new Point3f(0.0f, 0.0f, 0.0f),
02310 Raster.RASTER_COLOR, 0, 0, bimageRead.getWidth(),
02311 bimageRead.getHeight(), readImage, null
02312
02313
02314 );
02315
02316 raster.setCapability(Raster.ALLOW_IMAGE_READ);
02317 canvas_.getGraphicsContext3D().readRaster(raster);
02318
02319 BufferedImage image = raster.getImage().getImage();
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337 try {
02338 javax.imageio.ImageIO.write(image, "PNG", file);
02339 } catch (IOException ex) {
02340
02341 MessageDialog.openWarning( getParent().getShell(), "", MessageBundle.get("message.ioexception") );
02342 }
02343 }
02344
02345 public View getView(){
02346 return view_;
02347 }
02348
02349 private boolean xor(boolean a, boolean b){
02350 return (a || b) && (!a || !b);
02351 }
02352
02353 public boolean propertyChanged(String key, String value){
02354 if (super.propertyChanged(key, value)){
02355 return true;
02356 }else {
02357 if (key.equals("showScale")){
02358 if(xor(btnFloor_.isSelected(), value.equals("true")))
02359 btnFloor_.doClick();
02360 }else if (key.equals("showCollision")){
02361 if(xor(btnCollision_.isSelected(), value.equals("true")))
02362 btnCollision_.doClick();
02363 }else if (key.equals("showDistance")){
02364 if(xor(btnDistance_.isSelected(), value.equals("true")))
02365 btnDistance_.doClick();
02366 }else if (key.equals("showIntersection")){
02367 if(xor(btnIntersection_.isSelected(), value.equals("true")))
02368 btnIntersection_.doClick();
02369 }else if (key.equals("showCoM")){
02370 if(xor(btnCoM_.isSelected(), value.equals("true")))
02371 btnCoM_.doClick();
02372 }else if (key.equals("showCoMonFloor")){
02373 if(xor(btnCoMonFloor_.isSelected(), value.equals("true")))
02374 btnCoMonFloor_.doClick();
02375 }else if (key.equals("view.mode")){
02376 value = viewToolBar_.selectViewMode(value);
02377 }else if (key.equals("showActualState")){
02378 showActualState_ = value.equals("true");
02379 }else if (key.equals("eyeHomePosition")){
02380 double[] eyeHomePosition = getDblAry(value);
02381 t3dViewHome_.set(eyeHomePosition);
02382 setTransform(t3dViewHome_);
02383 }else{
02384 return false;
02385 }
02386 final String key_ = key;
02387 final String value_ = value;
02388 syncExec(new Runnable(){
02389 public void run(){
02390 setProperty(key_, value_);
02391 }
02392 });
02393 return true;
02394 }
02395 }
02396
02397
02398 public void shutdown() {
02399 showViewSimulator(false);
02400 behaviorManager_.destroyDynamicsSimulator();
02401 Iterator<GrxModelItem> it = currentModels_.iterator();
02402 while(it.hasNext()) {
02403 GrxModelItem model = it.next();
02404 model.bgRoot_.detach();
02405 model.deleteObserver(this);
02406 }
02407 manager_.removeItemChangeListener(this, GrxModelItem.class);
02408 manager_.removeItemChangeListener(this, GrxWorldStateItem.class);
02409 if(currentWorld_!=null)
02410 {
02411 currentWorld_.deleteObserver(this);
02412 currentWorld_.deletePosObserver(this);
02413 }
02414 manager_.removeItemChangeListener(this, GrxCollisionPairItem.class);
02415 if(simItem_!=null)
02416 simItem_.deleteObserver(this);
02417 manager_.removeItemChangeListener(this, GrxSimulationItem.class);
02418 }
02419
02420 public void repaint(){
02421 view_.repaint();
02422 objectToolBar_.repaint();
02423 viewToolBar_.repaint();
02424 }
02425
02426 private boolean ans_;
02427 private List<GrxModelItem> setNumOfAABB(){
02428 List<GrxModelItem> ret = new ArrayList<GrxModelItem>();
02429 List<GrxModelItem> models = new ArrayList<GrxModelItem>();
02430 models.addAll(currentModels_);
02431 while(!models.isEmpty()){
02432 final GrxModelItem model = models.get(0);
02433 final List<GrxModelItem> sameModels = model.getSameUrlModels();
02434 boolean flg=false;
02435 for(int i=0; i<model.links_.size(); i++){
02436 if(model.links_.get(i).getStr("NumOfAABB").equals("original data")){
02437 flg = true;
02438 break;
02439 }
02440 }
02441 if(flg){
02442 syncExec(new Runnable(){
02443 public void run(){
02444 ans_ = MessageDialog.openConfirm(comp.getShell(), MessageBundle.get("Grx3DView.dialog.title.confirmation"), model.getName()+" "+MessageBundle.get("Grx3DView.dialog.message.setAABBdepth"));
02445 if(ans_){
02446 for(int i=0; i<model.links_.size(); i++){
02447 if(model.links_.get(i).getStr("NumOfAABB").equals("original data")){
02448 model.links_.get(i).setInt("NumOfAABB",1);
02449 model.setProperty(model.links_.get(i).getName()+".NumOfAABB", "1");
02450 }
02451 }
02452 model.makeAABBforSameUrlModels();
02453 }
02454 }
02455 });
02456 if(ans_){
02457 ret.addAll(sameModels);
02458 ret.add(model);
02459 }
02460 }else{
02461 ret.add(model);
02462 ret.addAll(sameModels);
02463 }
02464 models.removeAll(sameModels);
02465 models.remove(model);
02466 }
02467 return ret;
02468 }
02469
02470 private boolean btnStateCollision_=true;
02471 private boolean btnStateDistance_=false;
02472 private boolean btnStateIntersection_=false;
02473 private boolean modelModified_ = false;
02474 private void optionButtonEnable(boolean enable){
02475 if(!modelModified_ && enable )
02476 return;
02477 if(modelModified_ && !enable)
02478 return;
02479 if(enable){
02480 for(GrxModelItem model : currentModels_ ){
02481 if(model.isModified())
02482 return;
02483 }
02484 }
02485 if(!enable){
02486 btnStateCollision_ = btnCollision_.isSelected();
02487 btnStateDistance_ = btnDistance_.isSelected();
02488 btnStateIntersection_ = btnIntersection_.isSelected();
02489 if(btnCollision_.isSelected())
02490 btnCollision_.doClick();
02491 if(btnDistance_.isSelected())
02492 btnDistance_.doClick();
02493 if(btnIntersection_.isSelected())
02494 btnIntersection_.doClick();
02495 modelModified_ = true;
02496 }
02497 btnCollision_.setEnabled(enable);
02498 btnDistance_.setEnabled(enable);
02499 btnIntersection_.setEnabled(enable);
02500 if(enable){
02501 if(btnStateCollision_)
02502 btnCollision_.doClick();
02503 if(btnStateDistance_)
02504 btnDistance_.doClick();
02505 if(btnStateIntersection_)
02506 btnIntersection_.doClick();
02507 modelModified_ = false;
02508 }
02509 }
02510
02511 public ValueEditType GetValueEditType(String key) {
02512 if(key.equals("showCoM") || key.equals("showCoMonFloor") || key.equals("showDistance") ||
02513 key.equals("showIntersection") || key.equals("showCollision") || key.equals("showActualState") ||
02514 key.equals("showScale"))
02515 {
02516 return new ValueEditCombo(booleanComboItem_);
02517 }else if(key.equals("view.mode")){
02518 return new ValueEditCombo(ViewToolBar.VIEW_MODE);
02519 }
02520 return super.GetValueEditType(key);
02521 }
02522 }