19 package com.generalrobotix.ui.view;
21 import java.awt.BorderLayout;
22 import java.awt.Color;
23 import java.awt.Component;
24 import java.awt.Dimension;
26 import java.awt.Frame;
27 import java.awt.GraphicsConfiguration;
28 import java.awt.GridLayout;
29 import java.awt.MenuItem;
30 import java.awt.Panel;
31 import java.awt.PopupMenu;
32 import java.awt.TextField;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35 import java.awt.event.KeyAdapter;
36 import java.awt.event.KeyEvent;
37 import java.awt.event.MouseEvent;
38 import java.awt.event.MouseListener;
39 import java.awt.image.BufferedImage;
41 import java.io.IOException;
42 import java.net.MalformedURLException;
44 import java.util.ArrayList;
45 import java.util.Iterator;
46 import java.util.List;
48 import java.util.Vector;
51 import javax.media.j3d.*;
52 import javax.vecmath.*;
54 import org.eclipse.swt.SWT;
55 import org.eclipse.swt.awt.SWT_AWT;
56 import org.eclipse.swt.events.ControlEvent;
57 import org.eclipse.swt.events.ControlListener;
58 import org.eclipse.swt.graphics.RGB;
59 import org.eclipse.swt.widgets.ColorDialog;
60 import org.eclipse.swt.widgets.Composite;
61 import org.eclipse.swt.widgets.Display;
62 import org.eclipse.swt.widgets.FileDialog;
63 import org.omg.CosNaming.NameComponent;
64 import org.omg.CosNaming.NamingContext;
67 import org.omg.PortableServer.POAPackage.ServantNotActive;
68 import org.omg.PortableServer.POAPackage.WrongPolicy;
69 import org.eclipse.jface.dialogs.MessageDialog;
72 import com.sun.j3d.utils.universe.SimpleUniverse;
91 @SuppressWarnings(
"serial")
96 public static final String TITLE =
"3DView";
98 public static final GraphicsConfiguration graphicsConfiguration = SimpleUniverse.getPreferredConfiguration();
101 private List<GrxModelItem> currentModels_ =
new ArrayList<GrxModelItem>();
102 private List<GrxCollisionPairItem> currentCollisionPairs_ =
new ArrayList<GrxCollisionPairItem>();
105 private final static int VIEW=0;
106 private final static int EDIT=1;
107 private final static int SIMULATION = 2;
108 private int viewMode_ = VIEW;
109 private double dAngle_ = Math.toRadians(0.1);
118 private float LineWidth_ = 1.0f;
119 private float colprop = 10.0f;
120 private float coldiff = 0.1f;
127 private Transform3D t3dViewHome_ =
new Transform3D();
130 private Background backGround_ =
new Background(0.0
f, 0.0
f, 0.0
f);
131 private double[] default_eye =
new double[]{2.0, 2.0, 0.8};
132 private double[] default_lookat =
new double[]{0.0, 0.0, 0.8};
133 private double[] default_upward =
new double[]{0.0, 0.0, 1.0};
142 private JButton btnHomePos_ =
new JButton(
new ImageIcon(getClass().getResource(
"/resources/images/home.png")));
143 private JToggleButton btnFloor_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/floor.png")));
144 private JToggleButton btnCollision_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/collision.png")));
145 private JToggleButton btnDistance_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/distance.png")));
146 private JToggleButton btnIntersection_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/proximity.png")));
147 private JToggleButton btnCoM_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/com.png")));
148 private JToggleButton btnCoMonFloor_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/com_z0.png")));
149 private JToggleButton btnRec_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/record.png")));
150 private JButton btnPlayer_ =
new JButton(
new ImageIcon(getClass().getResource(
"/resources/images/movie_player.png")));
151 private JButton btnRestore_ =
new JButton(
new ImageIcon(getClass().getResource(
"/resources/images/undo.png")));
152 private JToggleButton btnBBdisp_ =
new JToggleButton(
new ImageIcon(getClass().getResource(
"/resources/images/AABB.png")));
155 private JLabel lblTarget_ =
new JLabel(
"");
156 private JLabel lblValue_ =
new JLabel(
"");
162 private boolean showActualState_ =
true;
170 super(name, manager, vp, parent);
171 isScrollable_ =
false;
177 comp =
new Composite( getComposite(), SWT.EMBEDDED);
178 frame_ = SWT_AWT.new_Frame( comp );
180 comp.addControlListener(
new ControlListener() {
181 public void controlMoved(ControlEvent e) {}
182 public void controlResized(ControlEvent e) {
183 frame_.setBounds(0, 0, comp.getSize().x, comp.getSize().y );
193 Panel contentPane =
new Panel();
197 frame_.add(contentPane);
199 contentPane.setLayout(
new BorderLayout());
200 contentPane.setBackground(Color.lightGray);
203 lblMode_.setForeground(Color.black);
204 lblMode_.setFont(
new Font(
"Monospaced", Font.BOLD, 12));
205 lblMode_.setPreferredSize(
new Dimension(300, 20));
207 lblTarget_.setForeground(Color.white);
208 lblTarget_.setFont(
new Font(
"Monospaced", Font.BOLD, 12));
209 lblTarget_.setPreferredSize(
new Dimension(500, 20));
211 lblValue_.setForeground(Color.white);
212 lblValue_.setFont(
new Font(
"Monospaced", Font.BOLD, 12));
213 lblValue_.setPreferredSize(
new Dimension(300, 20));
215 JPanel southPanel =
new JPanel();
216 southPanel.setLayout(
new GridLayout(1,0));
217 southPanel.add( lblMode_ );
218 Box clipPanel = Box.createHorizontalBox();
219 JLabel clipDistLabel0 =
new JLabel(
MessageBundle.
get(
"Grx3DView.label.clipDistance0"));
220 JLabel clipDistLabel1 =
new JLabel(
MessageBundle.
get(
"Grx3DView.label.clipDistance1"));
221 final TextField frontText =
new TextField(6);
222 final TextField backText =
new TextField(6);
223 frontText.addActionListener(
new ActionListener(){
224 public void actionPerformed(ActionEvent arg0) {
225 String str = frontText.getText();
229 }
catch(NumberFormatException e){
234 backText.addActionListener(
new ActionListener(){
235 public void actionPerformed(ActionEvent arg0) {
236 String str = backText.getText();
240 }
catch(NumberFormatException e){
246 clipPanel.add(clipDistLabel0);
247 clipPanel.add(frontText);
248 clipPanel.add(clipDistLabel1);
249 clipPanel.add(backText);
250 southPanel.add(clipPanel);
252 canvas_ =
new Canvas3D(graphicsConfiguration);
253 canvas_.setDoubleBufferEnable(
true);
259 JPanel mainPane =
new JPanel(
new BorderLayout());
260 mainPane.setBackground(Color.black);
261 contentPane.add(southPanel, BorderLayout.SOUTH);
262 mainPane.add(canvas_, BorderLayout.CENTER);
263 contentPane.add(mainPane, BorderLayout.CENTER);
266 contentPane.add(objectToolBar_, BorderLayout.WEST);
267 contentPane.add(viewToolBar_, BorderLayout.NORTH);
269 collision_ =
new Shape3D();
270 collision_.setPickable(
false);
271 collision_.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
273 Appearance
app =
new Appearance();
274 LineAttributes latt =
new LineAttributes();
275 latt.setLineWidth(LineWidth_);
276 app.setLineAttributes(latt);
277 collision_.setAppearance(app);
278 }
catch (Exception ex) {
279 ex.printStackTrace();
281 BranchGroup bg =
new BranchGroup();
282 bg.addChild(collision_);
283 bgRoot_.addChild(bg);
285 distance_ =
new Shape3D();
286 distance_.setPickable(
false);
287 distance_.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
289 Appearance
app =
new Appearance();
290 LineAttributes latt =
new LineAttributes();
291 latt.setLineWidth(LineWidth_);
292 app.setLineAttributes(latt);
293 distance_.setAppearance(app);
294 }
catch (Exception ex) {
295 ex.printStackTrace();
297 BranchGroup bgDistance =
new BranchGroup();
298 bgDistance.addChild(distance_);
299 bgRoot_.addChild(bgDistance);
301 intersectingLinks_ =
new Vector<GrxLinkItem>();
303 setScrollMinSize(SWT.DEFAULT,SWT.DEFAULT);
308 behaviorManager_.
setItem(currentModels_, currentCollisionPairs_);
320 manager_.registerItemChangeListener(
this,
GrxModelItem.class);
328 Iterator<GrxModelItem> it = currentModels_.iterator();
329 while(it.hasNext()) {
337 behaviorManager_.
setItem(currentModels_, currentCollisionPairs_);
338 it = currentModels_.iterator();
339 boolean modelModified =
false;
340 while(it.hasNext()) {
342 bgRoot_.addChild(model.
bgRoot_);
348 optionButtonEnable(
false);
350 optionButtonEnable(
true);
351 if(btnBBdisp_.isSelected()){
352 btnBBdisp_.doClick();
355 if(currentWorld_ !=
null){
360 if(currentWorld_!=
null){
365 currentState_ =
null;
366 if(currentState_ ==
null)
367 updateViewSimulator(0);
369 updatePosition(currentWorld_, currentWorld_.
getPosition());
378 viewMode_ = SIMULATION;
380 if(viewMode_==SIMULATION){
387 universe_ =
new VirtualUniverse();
388 locale_ =
new javax.media.j3d.Locale(universe_);
389 bgRoot_ =
new BranchGroup();
391 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
392 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
393 bgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
396 bgRoot_.addChild(_createLights());
397 bgRoot_.addChild(_createView());
399 locale_.addBranchGraph(bgRoot_);
401 unclickableBgRoot_ =
new BranchGroup();
402 unclickableBgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
403 unclickableBgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
404 unclickableBgRoot_.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
406 locale_.addBranchGraph( unclickableBgRoot_ );
410 BranchGroup bg =
new BranchGroup();
411 ViewPlatform platform =
new ViewPlatform();
414 view_.setScreenScalePolicy(View.SCALE_EXPLICIT);
415 view_.setScreenScale(0.1);
416 tgView_ =
new TransformGroup();
418 view_.setPhysicalBody(
new PhysicalBody());
419 view_.setPhysicalEnvironment(
new PhysicalEnvironment());
420 view_.setFrontClipPolicy(View.VIRTUAL_EYE);
421 view_.setBackClipPolicy(View.VIRTUAL_EYE);
424 view_.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
425 view_.setFieldOfView(Math.PI/4);
426 view_.addCanvas3D(canvas_);
428 tgView_.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
429 tgView_.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
430 tgView_.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
431 tgView_.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
432 tgView_.setCapability(TransformGroup.ALLOW_LOCAL_TO_VWORLD_READ);
434 view_.attachViewPlatform(platform);
435 tgView_.addChild(platform);
436 bg.addChild(tgView_);
438 _setViewHomePosition();
444 BranchGroup bg =
new BranchGroup();
445 DirectionalLight[] light =
new DirectionalLight[4];
446 TransformGroup[] tg =
new TransformGroup[4];
447 BoundingSphere bounds =
448 new BoundingSphere(
new Point3d(0.0,0.0,0.0), 100.0);
454 light[0] =
new DirectionalLight(
true,
455 new Color3f(0.7
f, 0.7
f, 0.7
f),
456 new Vector3f(0.0
f, 0.0
f, -1.0
f)
459 light[1] =
new DirectionalLight(
true,
460 new Color3f(0.4
f, 0.4
f, 0.4
f),
461 new Vector3f(0.0
f, 0.0
f, -1.0
f)
464 light[2] =
new DirectionalLight(
true,
465 new Color3f(0.7
f, 0.7
f, 0.7
f),
466 new Vector3f(0.0
f, 0.0
f, -1.0
f)
469 light[3] =
new DirectionalLight(
true,
470 new Color3f(0.4
f, 0.4
f, 0.4
f),
471 new Vector3f(0.0
f, 0.0
f, -1.0
f)
474 for (
int i = 0;
i < 4;
i ++) {
475 light[
i].setInfluencingBounds(bounds);
476 tg[
i] =
new TransformGroup();
478 tg[
i].addChild(light[i]);
481 Transform3D transform =
new Transform3D();
482 Vector3d pos =
new Vector3d();
485 pos.set(10.0, 10.0, 5.0);
487 rot.set(-0.5, 0.5, 0.0, 1.2);
489 tg[0].setTransform(transform);
491 pos.set(10.0, -10.0, -5.0);
493 rot.set(0.5, 0.5, 0.0, 3.14 - 1.2);
495 tg[1].setTransform(transform);
497 pos.set(-10.0, -10.0, 5.0);
499 rot.set(0.5, -0.5, 0.0, 1.2);
501 tg[2].setTransform(transform);
503 pos.set(-10.0, 10.0, -5.0);
505 rot.set(-0.5, -0.5, 0.0, 3.14 - 1.2);
507 tg[3].setTransform(transform);
510 AmbientLight alight =
new AmbientLight(
new Color3f(1.0
f, 1.0
f, 1.0
f));
511 alight.setInfluencingBounds(bounds);
512 tg[0].addChild(alight);
515 backGround_.setCapability(Background.ALLOW_COLOR_READ);
516 backGround_.setCapability(Background.ALLOW_COLOR_WRITE);
517 backGround_.setApplicationBounds(bounds);
518 bg.addChild(backGround_);
524 btnHomePos_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.goHomeEyePos"));
525 btnHomePos_.addActionListener(
new ActionListener() {
526 public void actionPerformed(ActionEvent arg0) {
527 tgView_.setTransform(t3dViewHome_);
530 btnHomePos_.addMouseListener(
new MouseListener(){
531 public void mouseClicked(MouseEvent arg0) {
533 public void mouseEntered(MouseEvent arg0) {
535 public void mouseExited(MouseEvent arg0) {
537 public void mousePressed(MouseEvent arg0) {
538 if(arg0.getButton()==MouseEvent.BUTTON2 || arg0.getButton()==MouseEvent.BUTTON3){
539 PopupMenu popupMenu =
new PopupMenu();
540 final MenuItem menu0 =
new MenuItem(
MessageBundle.
get(
"Grx3DView.popupmenu.setHomeEyePos"));
541 menu0.addActionListener(
new ActionListener(){
542 public void actionPerformed(ActionEvent arg0) {
543 if(arg0.getSource()==menu0){
544 tgView_.getTransform(t3dViewHome_);
545 final double[] eyeHomePosition =
new double[16];
546 t3dViewHome_.get(eyeHomePosition);
549 setDblAry(
"eyeHomePosition", eyeHomePosition, 5);
555 final MenuItem menu1 =
new MenuItem(
MessageBundle.
get(
"Grx3DView.popupmenu.restoreDefault"));
556 menu1.addActionListener(
new ActionListener(){
557 public void actionPerformed(ActionEvent arg0) {
558 if(arg0.getSource()==menu1){
559 _setViewHomePosition();
560 final double[] eyeHomePosition =
new double[16];
561 t3dViewHome_.get(eyeHomePosition);
564 setDblAry(
"eyeHomePosition", eyeHomePosition, 5);
570 popupMenu.add(menu0);
571 popupMenu.add(menu1);
572 btnHomePos_.add(popupMenu);
573 popupMenu.show(btnHomePos_, arg0.getX(), arg0.getY());
576 public void mouseReleased(MouseEvent arg0) {
581 btnFloor_.setSelected(
false);
582 btnFloor_.addActionListener(
new ActionListener() {
583 public void actionPerformed(ActionEvent arg0) {
584 if (btnFloor_.isSelected()) {
588 setProperty(
"showScale",
"true");
591 if (bgRoot_.indexOfChild(getRuler()) == -1)
592 bgRoot_.addChild(getRuler());
597 setProperty(
"showScale",
"false");
600 if (bgRoot_.indexOfChild(getRuler()) != -1)
606 btnCollision_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.showCollision"));
607 btnCollision_.setSelected(
false);
608 btnCollision_.addActionListener(
new ActionListener() {
609 public void actionPerformed(ActionEvent arg0) {
610 if (btnCollision_.isSelected()){
611 btnCollision_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.hideCollision"));
614 setProperty(
"showCollision",
"true");
617 if (viewMode_ == SIMULATION || ( viewMode_ == VIEW && currentState_ !=
null))
622 btnCollision_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.showCollision"));
625 setProperty(
"showCollision",
"false");
628 _showCollision(
null);
633 btnDistance_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.showDistance"));
634 btnDistance_.setSelected(
false);
635 btnDistance_.addActionListener(
new ActionListener() {
636 public void actionPerformed(ActionEvent arg0) {
637 if (btnDistance_.isSelected()){
638 btnDistance_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.hideDistance"));
641 setProperty(
"showDistance",
"true");
644 if (viewMode_ != SIMULATION)
647 btnDistance_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.showDistance"));
650 setProperty(
"showDistance",
"false");
658 btnIntersection_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.checkIntersection"));
659 btnIntersection_.setSelected(
false);
660 btnIntersection_.addActionListener(
new ActionListener() {
661 public void actionPerformed(ActionEvent arg0) {
662 if (btnIntersection_.isSelected()){
663 btnIntersection_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.nocheckIntersection"));
666 setProperty(
"showIntersection",
"true");
669 if (viewMode_ != SIMULATION)
672 btnIntersection_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.checkIntersection"));
675 setProperty(
"showIntersection",
"false");
678 _showIntersection(
null);
684 btnCoM_.setSelected(
false);
685 btnCoM_.addActionListener(
new ActionListener() {
686 public void actionPerformed(ActionEvent arg0) {
687 boolean b = btnCoM_.isSelected();
688 for (
int i=0;
i<currentModels_.size();
i++)
689 currentModels_.get(
i).setVisibleCoM(b);
693 setProperty(
"showCoM",
"true");
699 setProperty(
"showCoM",
"false");
705 btnCoMonFloor_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.showcomFloor"));
706 btnCoMonFloor_.setSelected(
false);
707 btnCoMonFloor_.addActionListener(
new ActionListener() {
708 public void actionPerformed(ActionEvent arg0) {
709 boolean b = btnCoMonFloor_.isSelected();
710 for (
int i=0;
i<currentModels_.size();
i++)
711 currentModels_.get(
i).setVisibleCoMonFloor(b);
715 setProperty(
"showCoMonFloor",
"true");
721 setProperty(
"showCoMonFloor",
"false");
728 btnRec_.addActionListener(
new ActionListener() {
729 public void actionPerformed(ActionEvent e) {
730 if (btnRec_.isSelected()) {
734 btnRec_.setSelected(
false);
736 btnRec_.setSelected(
false);
742 btnPlayer_.addActionListener(
new ActionListener() {
743 public void actionPerformed(ActionEvent e) {
744 Display.getDefault().syncExec(
new Runnable(){
754 final JButton btnCamera =
new JButton(
"C");
755 btnCamera.addActionListener(
new ActionListener(){
756 public void actionPerformed(ActionEvent e) {
757 for (
int i=0;
i<currentModels_.size();
i++) {
758 List<Camera_impl> l = currentModels_.get(
i).getCameraSequence();
759 for (
int j=0;
j<l.size();
j++) {
767 btnBBdisp_.addActionListener(
new ActionListener() {
768 public void actionPerformed(ActionEvent e) {
769 boolean b = btnBBdisp_.isSelected();
771 List<GrxModelItem> visibleModels = setNumOfAABB();
772 Iterator<GrxModelItem> it = visibleModels.iterator();
774 it.next().setVisibleAABB(b);
775 if(visibleModels.isEmpty())
776 btnBBdisp_.setSelected(
false);
778 for (
int i=0;
i<currentModels_.size();
i++)
779 currentModels_.get(
i).setVisibleAABB(b);
783 viewToolBar_.add(btnHomePos_,0);
784 viewToolBar_.add(btnFloor_, 8);
785 viewToolBar_.add(btnCollision_, 9);
786 viewToolBar_.add(btnDistance_, 10);
787 viewToolBar_.add(btnIntersection_, 11);
788 viewToolBar_.add(btnCoM_, 12);
789 viewToolBar_.add(btnCoMonFloor_, 13);
790 viewToolBar_.add(btnRec_);
791 viewToolBar_.add(btnPlayer_);
792 viewToolBar_.add(btnCamera);
793 viewToolBar_.add(btnBBdisp_);
795 btnRestore_.setToolTipText(
MessageBundle.
get(
"Grx3DView.text.restoreModel"));
796 btnRestore_.addActionListener(
new ActionListener() {
797 public void actionPerformed(ActionEvent e) {
798 for (
int i=0;
i<currentModels_.size();
i++) {
811 objectToolBar_.add(btnRestore_, 0);
812 objectToolBar_.setOrientation(JToolBar.VERTICAL);
814 JToolBar bars[] =
new JToolBar[]{viewToolBar_, objectToolBar_};
815 for (
int i=0;
i<bars.length;
i++) {
816 JToolBar bar = bars[
i];
817 bar.setFloatable(
false);
818 for (
int j=0;
j<bar.getComponentCount();
j++) {
819 Component
c = bar.getComponent(
j);
820 if (c instanceof AbstractButton) {
821 AbstractButton
b = (AbstractButton)c;
841 new Point3d(default_eye),
842 new Point3d(default_lookat),
843 new Vector3d(default_upward));
844 t3dViewHome_.invert();
845 tgView_.setTransform(t3dViewHome_);
849 super.restoreProperties();
850 if(getStr(
"showScale")==
null) propertyChanged(
"showScale",
"true");
851 if(getStr(
"showCollision")==
null) propertyChanged(
"showCollision",
"true");
852 if(getStr(
"showDistance")==
null) propertyChanged(
"showDistance",
"false");
853 if(getStr(
"showIntersection")==
null) propertyChanged(
"showIntersection",
"false");
854 if(getStr(
"showCoM")==
null) propertyChanged(
"showCoM",
"false");
855 if(getStr(
"showCoMonFloor")==
null) propertyChanged(
"showCoMonFloor",
"false");
857 if(getStr(
"showActualState")==
null) propertyChanged(
"showActualState",
"true");
858 if(getStr(
"eyeHomePosition")==
null){
859 final double[] eyeHomePosition =
new double[16];
860 _setViewHomePosition();
861 t3dViewHome_.get(eyeHomePosition);
864 setDblAry(
"eyeHomePosition", eyeHomePosition, 5);
867 propertyChanged(
"eyeHomePosiotion", getProperty(
"eyeHomePosition"));
873 GrxModelItem modelItem = (GrxModelItem) item;
876 if(!modelItem.
bgRoot_.isLive()){
878 bgRoot_.addChild(modelItem.
bgRoot_);
879 currentModels_.add(modelItem);
880 behaviorManager_.
setItem(currentModels_, currentCollisionPairs_);
881 if(viewMode_ == VIEW && currentState_!=
null){
882 updateModels(currentState_);
883 updateViewSimulator(currentState_.
time);
885 updateViewSimulator(0);
887 optionButtonEnable(
false);
889 if(btnBBdisp_.isSelected()){
890 btnBBdisp_.doClick();
897 if(modelItem.
bgRoot_.isLive()){
899 currentModels_.remove(modelItem);
900 behaviorManager_.
setItem(currentModels_, currentCollisionPairs_);
902 optionButtonEnable(
true);
913 GrxWorldStateItem worldStateItem = (GrxWorldStateItem) item;
916 if(currentWorld_!=worldStateItem){
917 currentWorld_ = worldStateItem;
920 currentState_ = currentWorld_.
getValue();
921 updatePosition(currentWorld_, currentWorld_.
getPosition());
926 if(currentWorld_==worldStateItem){
929 currentWorld_ =
null;
930 currentState_ =
null;
937 GrxCollisionPairItem collisionPairItem = (GrxCollisionPairItem) item;
940 if(!currentCollisionPairs_.contains(collisionPairItem)){
941 currentCollisionPairs_.add(collisionPairItem);
942 behaviorManager_.
setItem(currentModels_, currentCollisionPairs_);
948 if(currentCollisionPairs_.contains(collisionPairItem)){
949 currentCollisionPairs_.remove(collisionPairItem);
950 behaviorManager_.
setItem(currentModels_, currentCollisionPairs_);
956 GrxSimulationItem simItem = (GrxSimulationItem) item;
959 if(simItem_!=simItem){
966 if(simItem_==simItem){
978 if(simItem_==plugin){
979 if((String)
arg[0]==
"StartSimulation"){
983 showViewSimulator(
true);
984 viewMode_ = SIMULATION;
985 }
else if((String)
arg[0]==
"StopSimulation"){
990 }
else if(currentModels_.contains(plugin)){
991 if((String)
arg[0]==
"PropertyChange"){
992 if((String)
arg[1]==
"name" ){
996 if(((String)
arg[1]).contains(
"translation") || ((String)arg[1]).contains(
"rotation") ||
997 ((String)arg[1]).contains(
"angle"))
1000 else if((String)
arg[0]==
"BodyInfoChange"){
1003 }
else if((String)
arg[0]==
"Modified"){
1004 optionButtonEnable(
false);
1005 }
else if((String)
arg[0]==
"ClearModified"){
1006 optionButtonEnable(
true);
1008 }
else if(currentWorld_==plugin){
1009 if((String)
arg[0]==
"ClearLog"){
1010 currentState_ =
null;
1016 if(currentWorld_ != plugin)
1019 if(viewMode_ == VIEW || viewMode_ == SIMULATION){
1020 int pos = arg_pos.intValue();
1021 currentState_ = currentWorld_.
getValue(pos);
1022 if(currentState_!=
null){
1024 updateModels(currentState_);
1025 updateViewSimulator(currentState_.
time);
1027 if(viewMode_ == VIEW)
1028 showOptionWithoutCollision();
1034 if (btnDistance_.isSelected())
1035 btnDistance_.doClick();
1036 if (btnIntersection_.isSelected())
1037 btnIntersection_.doClick();
1038 btnDistance_.setEnabled(
false);
1039 btnIntersection_.setEnabled(
false);
1040 btnRestore_.setEnabled(
false);
1041 btnRec_.setEnabled(
false);
1042 btnPlayer_.setEnabled(
false);
1046 btnDistance_.setEnabled(
true);
1047 btnIntersection_.setEnabled(
true);
1048 btnRestore_.setEnabled(
true);
1049 btnRec_.setEnabled(
true);
1050 btnPlayer_.setEnabled(
true);
1054 if(viewMode_==SIMULATION)
return;
1055 if (btnCollision_.isSelected()) {
1059 if (btnDistance_.isSelected()){
1063 if (btnIntersection_.isSelected()){
1070 if(viewMode_==SIMULATION)
return;
1071 if (btnDistance_.isSelected()){
1075 if (btnIntersection_.isSelected()){
1082 for (
int i=0;
i<currentModels_.size();
i++) {
1083 List<Camera_impl> l = currentModels_.get(
i).getCameraSequence();
1084 for (
int j=0;
j<l.size();
j++) {
1093 for (
int i=0;
i<currentModels_.size();
i++) {
1096 if (charStat !=
null) {
1099 if (showActualState_) {
1106 List<GrxSensorItem> sensors = model.
getSensors(
"Range");
1107 for (
int j=0;
j<sensors.size();
j++){
1124 btnRec_.setSelected(
false);
1132 }
catch(Exception NumberFormatException ){
1134 btnRec_.setSelected(
false);
1139 GrxDebugUtil.
println(
"ScreenSize: " + canvasSize.width +
"x" + canvasSize.height +
" (may be)");
1141 BufferedImage
image=
new BufferedImage(canvasSize.width,canvasSize.height,BufferedImage.TYPE_INT_ARGB);
1143 ImageComponent2D
buffer=
new ImageComponent2D(ImageComponent.FORMAT_RGBA,image,
true,
false);
1144 buffer.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
1147 offscreen_=
new Canvas3D(graphicsConfiguration,
true);
1148 offscreen_.setOffScreenBuffer(buffer);
1149 view_.addCanvas3D(offscreen_);
1151 Screen3D screen = canvas_.getScreen3D();
1152 offscreen_.getScreen3D().setSize(screen.getSize());
1153 offscreen_.getScreen3D().setPhysicalScreenWidth(screen.getPhysicalScreenWidth());
1154 offscreen_.getScreen3D().setPhysicalScreenHeight(screen.getPhysicalScreenHeight());
1157 recordingMgr_.
setImageSize(canvasSize.width , canvasSize.height);
1161 if (
new File(fileName).exists()) {
1162 if (!fileOverwriteDialog(fileName)){
1163 btnRec_.setSelected(
false);
1168 lastMovieFileName = pathToURL(fileName);
1175 if (format__ ==
null) {
1176 btnRec_.setSelected(
false);
1182 btnRec_.setSelected(
false);
1185 }
catch (Exception e) {
1192 btnRec_.setSelected(
false);
1200 final double stepTime = 1.0/framerate*playbackRate;
1203 final int startPosition = currentWorld_.
getPositionAt(startTime);
1204 final int endPosition = currentWorld_.
getPositionAt(endTime);
1205 Thread recThread_ =
new Thread() {
1208 double playRateLogTime_ = currentWorld_.
getTime(startPosition);
1210 if(!btnRec_.isSelected())
break;
1212 if (time >= playRateLogTime_) {
1213 playRateLogTime_ += stepTime;
1224 }
catch (Exception e) {
1241 btnRec_.setSelected(
false);
1242 view_.removeCanvas3D(offscreen_);
1245 MessageDialog.openInformation( comp.getShell(),
MessageBundle.
get(
"Grx3DView.dialog.title.Infomation"),
MessageBundle.
get(
"Grx3DView.dialog.message.recFinish"));
1254 if (
new File(fileName).isDirectory())
1259 ret_ = MessageDialog.openConfirm( comp.getShell(),
MessageBundle.
get(
"Grx3DView.dialog.title.fileExist"),
1270 if (path.startsWith(
"file:///")) {
1272 path = path.replace(java.io.File.separatorChar,
'/');
1275 if (path.startsWith(
"http://")) {
1278 if (!path.startsWith(java.io.File.separator) && (path.indexOf(
':') != 1)) {
1279 path = System.getProperty(
"user.dir") + java.io.File.separator + path;
1281 if (path.indexOf(
':') == 1) {
1282 path = path.replace(java.io.File.separatorChar,
'/');
1283 return "file:///" + path;
1285 return "file://" + path;
1289 offscreen_.renderOffScreenBuffer();
1290 offscreen_.waitForOffScreenRendering();
1291 recordingMgr_.
pushImage( offscreen_.getOffScreenBuffer().getImage() );
1295 collision_.removeAllGeometries();
1296 if (collisions ==
null || collisions.length <= 0 || !btnCollision_.isSelected())
1300 for (
int i = 0;
i < collisions.length;
i++) {
1301 if (collisions[
i].points !=
null)
1302 length += collisions[
i].points.length;
1305 CollisionPoint[] cd =
new CollisionPoint[
length];
1306 for (
int i=0,
n=0;
i<collisions.length;
i++) {
1307 for (
int j=0;
j<collisions[
i].points.length;
j++)
1308 cd[
n++] = collisions[
i].points[
j];
1311 Point3d[] p3d =
new Point3d[cd.length * 2];
1312 for (
int j=0;
j<cd.length;
j++) {
1315 Vector3d pole =
new Vector3d(cd[
j].normal);
1317 float depth = (float) cd[
j].idepth*colprop+coldiff;
1318 p3d[
j*2+1] =
new Point3d(
1319 cd[
j].position[0] + pole.x*depth,
1320 cd[
j].position[1] + pole.y*depth,
1321 cd[
j].position[2] + pole.z*depth
1325 LineArray la =
new LineArray(p3d.length, LineArray.COLOR_3
1326 | LineArray.COORDINATES | LineArray.NORMALS);
1327 la.setCoordinates(0, p3d);
1329 Vector3f[] v3f =
new Vector3f[p3d.length];
1330 Color3f[] c3f =
new Color3f[p3d.length];
1331 for (
int i=0;
i<v3f.length;
i++) {
1332 v3f[
i] =
new Vector3f(0.0
f, 0.0
f, 1.0
f);
1334 c3f[
i] =
new Color3f(0.0
f, 0.8
f, 0.8
f);
1336 c3f[
i] =
new Color3f(0.8
f, 0.0
f, 0.8
f);
1338 la.setNormals(0, v3f);
1339 la.setColors(0, c3f);
1340 collision_.addGeometry(la);
1342 collision_.addGeometry(
null);
1347 distance_.removeAllGeometries();
1348 if (distances ==
null || distances.length <= 0 || !btnDistance_.isSelected())
1351 int length = distances.length;
1354 Point3d[] p3d =
new Point3d[length * 2];
1356 p3d[
j*2] =
new Point3d(distances[
j].point0);
1357 p3d[
j*2+1] =
new Point3d(distances[
j].point1);
1360 LineArray la =
new LineArray(p3d.length, LineArray.COLOR_3
1361 | LineArray.COORDINATES | LineArray.NORMALS);
1362 la.setCoordinates(0, p3d);
1364 Vector3f[] v3f =
new Vector3f[p3d.length];
1365 Color3f[] c3f =
new Color3f[p3d.length];
1366 for (
int i=0;
i<v3f.length;
i++) {
1367 v3f[
i] =
new Vector3f(0.0
f, 0.0
f, 1.0
f);
1368 c3f[
i] =
new Color3f(1.0
f, 0.0
f, 0.0
f);
1370 la.setNormals(0, v3f);
1371 la.setColors(0, c3f);
1372 distance_.addGeometry(la);
1374 distance_.addGeometry(
null);
1378 @SuppressWarnings(
"unchecked")
1379 private
void _showIntersection(LinkPair[] pairs){
1381 for (
int i=0;
i<intersectingLinks_.size();
i++){
1382 intersectingLinks_.get(
i).restoreColor();
1384 intersectingLinks_.clear();
1387 Map<String, GrxModelItem> modelMap = (Map<String, GrxModelItem>)manager_.getItemMap(
GrxModelItem.class);
1388 Vector<GrxLinkItem> links =
new Vector<GrxLinkItem>();
1389 for (
int i=0;
i<pairs.length;
i++){
1395 if (!intersectingLinks_.contains(l)){
1403 if (l !=
null) links.add(l);
1404 if (!intersectingLinks_.contains(l)){
1409 for (
int i=0;
i<intersectingLinks_.size();
i++){
1411 if (!links.contains(l)){
1415 intersectingLinks_ = links;
1420 for (
int i=0;
i<currentModels_.size();
i++) {
1421 List<Camera_impl> l = currentModels_.get(
i).getCameraSequence();
1422 for (
int j=0;
j<l.size();
j++) {
1430 if (rulerBg_ ==
null) {
1431 rulerBg_ =
new BranchGroup();
1432 rulerBg_.setCapability(BranchGroup.ALLOW_DETACH);
1434 Point3d[] p =
new Point3d[n * 4];
1435 double width = n/2.0;
1436 for (
int i=0;
i<
n;
i++) {
1437 p[2*
i] =
new Point3d(-width+
i, -width, 0.0);
1438 p[2*
i+1] =
new Point3d(-width+
i, width, 0.0);
1439 p[2*
i+n*2] =
new Point3d(-width, -width+
i, 0.0);
1440 p[2*
i+n*2+1] =
new Point3d( width, -width+
i, 0.0);
1442 LineArray geometry =
new LineArray(p.length,
1443 GeometryArray.COORDINATES | GeometryArray.COLOR_3);
1444 geometry.setCoordinates(0, p);
1445 for (
int i = 0;
i < p.length;
i++)
1446 geometry.setColor(
i,
new Color3f(Color.white));
1448 Shape3D shape =
new Shape3D(geometry);
1449 shape.setPickable(
false);
1450 rulerBg_.addChild(shape);
1460 OnlineViewer olv = olvImpl._this(manager_.orb_);
1463 ViewSimulator
view = viewImpl._this(manager_.orb_);
1469 rootnc.rebind(path1, olv);
1470 rootnc.rebind(path2, view);
1472 }
catch (Exception ex) {
1488 rootnc.unbind(path1);
1489 rootnc.unbind(path2);
1492 }
catch(Exception ex){
1502 li = (GrxLinkItem)bitem;
1509 KeyStroke ks = KeyStroke.getKeyStrokeForEvent(arg0);
1510 if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_UP,0) ||
1511 ks == KeyStroke.getKeyStroke(KeyEvent.VK_K,0)) {
1514 for (
int j=0;
j<item.
links_.size();
j++) {
1515 if (next == item.
links_.get(
j).jointId_) {
1521 }
else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,0) ||
1522 ks == KeyStroke.getKeyStroke(KeyEvent.VK_J,0)) {
1524 for (
int j=0;
j<item.
links_.size();
j++) {
1525 if (next == item.
links_.get(
j).jointId_) {
1530 }
else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,KeyEvent.SHIFT_MASK) ||
1531 ks == KeyStroke.getKeyStroke(KeyEvent.VK_H,KeyEvent.SHIFT_MASK)) {
1539 }
else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,KeyEvent.SHIFT_MASK) ||
1540 ks == KeyStroke.getKeyStroke(KeyEvent.VK_L,KeyEvent.SHIFT_MASK)) {
1547 }
else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_H,0) ||
1548 ks == KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,0)) {
1555 }
else if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_L,0) ||
1556 ks == KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0)) {
1607 List<Camera_impl> allList =
new ArrayList<Camera_impl>();
1608 for (
int i=0;
i<currentModels_.size();
i++) {
1609 List<Camera_impl> l = currentModels_.get(
i).getCameraSequence();
1613 arg0.value =
new Camera[allList.size()];
1614 for (
int i=0;
i<allList.size();
i++) {
1616 arg0.value[
i] = CameraHelper.narrow(manager_.poa_.servant_to_reference(allList.get(
i)));
1617 }
catch (ServantNotActive e) {
1618 e.printStackTrace();
1619 }
catch (WrongPolicy e) {
1620 e.printStackTrace();
1626 for (
int i=0;
i<currentModels_.size();
i++) {
1628 if (item.
getName().equals(objectName)) {
1630 arg1.value =
new Camera[l.size()];
1631 for (
int j=0;
j<l.size();
j++) {
1633 arg1.value[
j] = CameraHelper.narrow(manager_.poa_.servant_to_reference(l.get(
j)));
1634 }
catch (ServantNotActive e) {
1635 e.printStackTrace();
1636 }
catch (WrongPolicy e) {
1637 e.printStackTrace();
1643 arg1.value =
new Camera[0];
1652 manager_.setSelectedItem(newItem,
true);
1664 updateModels(statex);
1665 updateViewSimulator(0);
1672 private double prevTime = 0.0;
1673 private boolean firstTime_ =
true;
1674 private double logTimeStep_ = 0.0;
1675 private boolean updateTimer_ =
false;
1679 if (currentWorld_ !=
null){
1690 public void load(
final String
name, String url)
throws OnlineViewerException{
1691 System.out.println(
name+
":"+url);
1692 final String url0 = url;
1694 URL u =
new URL(url);
1695 final String url_ = u.getFile();
1701 manager_.setSelectedItem(newItem,
true);
1705 }
catch (MalformedURLException e) {
1706 e.printStackTrace();
1709 MessageDialog.openError( comp.getShell(),
MessageBundle.
get(
"Grx3DView.dialog.title.error"),
MessageBundle.
get(
"OnlineViewer.dialog.message.MalformedURLException"));
1712 throw new OnlineViewerException(
"Malformed URL Exception");
1717 MessageDialog.openError( comp.getShell(),
MessageBundle.
get(
"Grx3DView.dialog.title.error"), url0+
MessageBundle.
get(
"OnlineViewer.dialog.message.loadError"));
1720 throw new OnlineViewerException(url+
"cannot be loaded.");
1731 posture.value =
new double[0];
1737 if (currentWorld_ ==
null) {
1742 manager_.setSelectedItem(item,
true);
1750 String[] chars = statex.characters();
1751 for (
int i=0;
i<chars.length;
i++) {
1754 if(bodyInfo==
null)
return;
1759 if(statex.time > 0){
1760 logTimeStep_ = statex.time;
1761 currentWorld_.
setDbl(
"logTimeStep", logTimeStep_);
1767 final double stepTime = statex.time - prevTime;
1768 if(stepTime > 0 && Math.abs(stepTime-logTimeStep_)>10e-9){
1769 logTimeStep_ = stepTime;
1772 currentWorld_.
setDbl(
"logTimeStep", logTimeStep_);
1777 currentWorld_.
addValue(statex.time, statex);
1780 java.util.Timer timer =
new java.util.Timer();
1782 updateTimer_ =
true;
1784 prevTime = statex.time;
1791 _showCollision(statex.collisions);
1792 updateModels(statex);
1793 updateViewSimulator(statex.time);
1801 updateTimer_ =
false;
1802 final int pos = currentWorld_.
getLogSize()-1;
1820 manager_.setSelectedItem(item,
true);
1827 bgRoot_.addChild(bg);
1831 unclickableBgRoot_.addChild(bg);
1850 tgView_.setTransform(transform);
1858 public void actionPerformed(ActionEvent e) {
1860 view_.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
1872 public void actionPerformed(ActionEvent e) {
1874 view_.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
1886 public void actionPerformed(ActionEvent e) {
1890 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
1903 public void actionPerformed(ActionEvent e) {
1907 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
1920 public void actionPerformed(ActionEvent e) {
1924 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
1937 public void actionPerformed(ActionEvent e) {
1941 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
1954 public void actionPerformed(ActionEvent e) {
1958 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
1971 public void actionPerformed(ActionEvent e) {
1975 view_.setProjectionPolicy(View.PARALLEL_PROJECTION);
1987 public void actionPerformed(ActionEvent e) {
1997 public void actionPerformed(ActionEvent e) {
2007 public void actionPerformed(ActionEvent e) {
2017 public void actionPerformed(ActionEvent e) {
2018 Iterator<?> it = manager_.getItemMap(
GrxModelItem.class).values().iterator();
2019 while (it.hasNext()) {
2026 public void actionPerformed(ActionEvent e) {
2039 Display display = Display.getDefault();
2040 if ( display!=
null && !display.isDisposed())
2044 ColorDialog dialog =
new ColorDialog( getParent().getShell() );
2045 RGB color = dialog.open();
2046 Color3f
c =
new Color3f( color.red/255
f, color.green/255
f, color.blue/255
f );
2047 backGround_.setColor(
new Color3f(c));
2056 public void actionPerformed(ActionEvent e) {
2057 Display display = Display.getDefault();
2058 if ( display!=
null && !display.isDisposed())
2062 FileDialog fdlg =
new FileDialog( getParent().getShell(), SWT.SAVE);
2063 String[] fe = {
"*.png" };
2064 fdlg.setFilterExtensions( fe );
2065 String fPath = fdlg.open();
2066 if( fPath !=
null ){
2067 saveScreenShot(
new File( fPath ) );
2076 public void actionPerformed(ActionEvent e) {
2088 public void actionPerformed(ActionEvent e) {
2099 public void actionPerformed(ActionEvent e) {
2111 public void actionPerformed(ActionEvent e) {
2124 public void actionPerformed(ActionEvent e) {
2130 lblMode_.setText(
MessageBundle.
get(
"Grx3DView.text,editObjectDestination"));
2137 public void actionPerformed(ActionEvent e) {
2139 behaviorManager_.
fit();
2150 public void actionPerformed(ActionEvent e) {
2162 public void actionPerformed(ActionEvent e) {
2174 public void actionPerformed(ActionEvent e) {
2186 public void actionPerformed(ActionEvent e) {
2202 if(currentState_!=
null){
2205 updateModels(currentState_);
2209 updateViewSimulator(currentState_.
time);
2210 showOptionWithoutCollision();
2302 Raster raster =
null;
2304 BufferedImage bimageRead =
new BufferedImage(canvas_.getWidth(),
2305 canvas_.getHeight(), BufferedImage.TYPE_INT_RGB);
2306 ImageComponent2D readImage =
new ImageComponent2D(
2307 ImageComponent.FORMAT_RGB, bimageRead);
2309 raster =
new Raster(
new Point3f(0.0
f, 0.0
f, 0.0
f),
2310 Raster.RASTER_COLOR, 0, 0, bimageRead.getWidth(),
2311 bimageRead.getHeight(), readImage,
null 2316 raster.setCapability(Raster.ALLOW_IMAGE_READ);
2317 canvas_.getGraphicsContext3D().readRaster(raster);
2319 BufferedImage
image = raster.getImage().getImage();
2338 javax.imageio.ImageIO.write(image,
"PNG", file);
2339 }
catch (IOException ex) {
2341 MessageDialog.openWarning( getParent().getShell(),
"",
MessageBundle.
get(
"message.ioexception") );
2349 private boolean xor(
boolean a,
boolean b){
2350 return (a || b) && (!a || !
b);
2354 if (super.propertyChanged(key, value)){
2357 if (key.equals(
"showScale")){
2358 if(xor(btnFloor_.isSelected(), value.equals(
"true")))
2359 btnFloor_.doClick();
2360 }
else if (key.equals(
"showCollision")){
2361 if(xor(btnCollision_.isSelected(), value.equals(
"true")))
2362 btnCollision_.doClick();
2363 }
else if (key.equals(
"showDistance")){
2364 if(xor(btnDistance_.isSelected(), value.equals(
"true")))
2365 btnDistance_.doClick();
2366 }
else if (key.equals(
"showIntersection")){
2367 if(xor(btnIntersection_.isSelected(), value.equals(
"true")))
2368 btnIntersection_.doClick();
2369 }
else if (key.equals(
"showCoM")){
2370 if(xor(btnCoM_.isSelected(), value.equals(
"true")))
2372 }
else if (key.equals(
"showCoMonFloor")){
2373 if(xor(btnCoMonFloor_.isSelected(), value.equals(
"true")))
2374 btnCoMonFloor_.doClick();
2375 }
else if (key.equals(
"view.mode")){
2377 }
else if (key.equals(
"showActualState")){
2378 showActualState_ = value.equals(
"true");
2379 }
else if (key.equals(
"eyeHomePosition")){
2380 double[] eyeHomePosition = getDblAry(value);
2381 t3dViewHome_.set(eyeHomePosition);
2382 setTransform(t3dViewHome_);
2386 final String key_ = key;
2387 final String value_ =
value;
2390 setProperty(key_, value_);
2399 showViewSimulator(
false);
2401 Iterator<GrxModelItem> it = currentModels_.iterator();
2402 while(it.hasNext()) {
2407 manager_.removeItemChangeListener(
this,
GrxModelItem.class);
2409 if(currentWorld_!=
null)
2422 objectToolBar_.repaint();
2423 viewToolBar_.repaint();
2428 List<GrxModelItem>
ret =
new ArrayList<GrxModelItem>();
2429 List<GrxModelItem> models =
new ArrayList<GrxModelItem>();
2430 models.addAll(currentModels_);
2431 while(!models.isEmpty()){
2435 for(
int i=0;
i<model.
links_.size();
i++){
2436 if(model.
links_.get(
i).getStr(
"NumOfAABB").equals(
"original data")){
2446 for(
int i=0;
i<model.
links_.size();
i++){
2447 if(model.
links_.get(
i).getStr(
"NumOfAABB").equals(
"original data")){
2448 model.
links_.get(
i).setInt(
"NumOfAABB",1);
2457 ret.addAll(sameModels);
2462 ret.addAll(sameModels);
2464 models.removeAll(sameModels);
2465 models.remove(model);
2470 private boolean btnStateCollision_=
true;
2471 private boolean btnStateDistance_=
false;
2472 private boolean btnStateIntersection_=
false;
2473 private boolean modelModified_ =
false;
2475 if(!modelModified_ && enable )
2477 if(modelModified_ && !enable)
2481 if(model.isModified())
2486 btnStateCollision_ = btnCollision_.isSelected();
2487 btnStateDistance_ = btnDistance_.isSelected();
2488 btnStateIntersection_ = btnIntersection_.isSelected();
2489 if(btnCollision_.isSelected())
2490 btnCollision_.doClick();
2491 if(btnDistance_.isSelected())
2492 btnDistance_.doClick();
2493 if(btnIntersection_.isSelected())
2494 btnIntersection_.doClick();
2495 modelModified_ =
true;
2497 btnCollision_.setEnabled(enable);
2498 btnDistance_.setEnabled(enable);
2499 btnIntersection_.setEnabled(enable);
2501 if(btnStateCollision_)
2502 btnCollision_.doClick();
2503 if(btnStateDistance_)
2504 btnDistance_.doClick();
2505 if(btnStateIntersection_)
2506 btnIntersection_.doClick();
2507 modelModified_ =
false;
2512 if(key.equals(
"showCoM") || key.equals(
"showCoMonFloor") || key.equals(
"showDistance") ||
2513 key.equals(
"showIntersection") || key.equals(
"showCollision") || key.equals(
"showActualState") ||
2514 key.equals(
"showScale"))
2517 }
else if(key.equals(
"view.mode")){
2520 return super.GetValueEditType(key);
void replaceWorld(List< GrxBaseItem > list)
static GUIAction FITTING_SRC
void setColor(java.awt.Color color)
void registerCharacter(String cname, BodyInfo binfo)
static final String get(String key)
boolean xor(boolean a, boolean b)
void getCameraSequence(CameraSequenceHolder arg0)
void setOperationMode(int mode)
static final int VIEW_MODE_PARALLEL
static final int VIEW_MODE_WALK
javax.media.j3d.Locale locale_
void updateScene(WorldState worldState)
Distance[] getDistance()
get distance information
void makeAABBforSameUrlModels()
static GUIAction BACK_VIEW
void setDirection(int dir)
static final int VIEW_MODE_ROOM
void registerItemChange(GrxBaseItem item, int event)
static GUIAction VIEW_PAN_MODE
static final int INV_KINEMA_FROM_MODE
boolean fileOverwriteDialog(final String fileName)
void addActionListener(ActionListener listener)
boolean getPosture(String name, DblSequenceHolder posture)
void updateModels(WorldStateEx state)
void addValue(Double t, Object obj)
static GUIAction INV_KINEMA_FROM
void addObserver(GrxObserver v)
void showOptionWithoutCollision()
static final int TOP_VIEW
#define null
our own NULL pointer
void setMessageSkip(boolean flg)
static GUIAction JOINT_ROTATION
static GUIAction VIEW_ZOOM_MODE
BodyInfo getBodyInfo()
get BodyInfo
void setWireFrame(boolean b)
switch display mode between fill and line
GrxLinkItem getLink(String name)
get link from name
png_infop png_charpp name
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
CharacterStateEx get(int idx)
item corresponds to a robot model
static final int OPERATION_MODE_NONE
static final int FITTING_TO_MODE
void deleteObserver(GrxObserver v)
static VirtualUniverse universe_
static final int ADD_ITEM
void setPickTarget(TransformGroup tg)
static final int LEFT_VIEW
RecordingManager recordingMgr_
void keyPressed(KeyEvent arg0)
TransformGroup getTransformGroupRoot()
static final int OBJECT_ROTATION_MODE
void restoreProperties()
restore properties
void setURL(String url)
set URL property
static GUIAction INV_KINEMA_TRANS
BranchGroup unclickableBgRoot_
png_bytep png_bytep png_size_t length
static GUIAction WALK_VIEW
void setTransform(Transform3D transform)
void setViewMode(int mode)
void _showCollision(Collision[] collisions)
void setViewMode(int mode)
final void setDbl(String key, double value)
associate double value to key
void setPosition(Integer pos)
void setLineWidth(float arg0)
png_infop png_uint_32 * width
BranchGroup _createView()
static void printErr(String s)
static final int SELECTED_ITEM
void updateView(double time)
static final int FRONT_VIEW
void deletePosObserver(GrxPositionObserver v)
Object showComboBoxDialog()
void setDirection(int dir)
static final int ROOM_VIEW_MODE
void setThreeDViewer(Grx3DView viewer)
LinkPair[] getIntersection()
get intersection information
void setFrameRate(float rate)
static final int BOTTOM_VIEW
void pushImage(BufferedImage image)
BranchGroup getBranchGroupRoot()
static final int OK_BUTTON
void updateShapeOfVisibleArea(double[] distances)
update shape of visible area(only used for RangeSensor)
static GUIAction RIGHT_VIEW
void registerCharacter(final String name, final BodyInfo bInfo)
boolean propertyChanged(String key, String value)
void showViewSimulator(boolean b)
static final int RIGHT_VIEW
static final int INV_KINEMA_ROTATION_MODE
List< GrxSensorItem > getSensors(String type)
void setImageSize(int w, int h)
void optionButtonEnable(boolean enable)
static final int JOINT_ROTATION_MODE
Vector< GrxLinkItem > links_
boolean initDynamicsSimulator()
initialize dynamics server
def j(str, encoding="cp932")
void getCameraSequenceOf(String objectName, CameraSequenceHolder arg1)
void setLineScale(float arg0)
static GUIAction TOP_VIEW
static final int REMOVE_ITEM
int getPositionAt(Double t)
void setVisible(boolean b)
void setViewHandlerMode(String str)
static GUIAction FITTING_DEST
static GUIAction ROOM_VIEW
static GUIAction BOTTOM_VIEW
static final int WALK_VIEW_MODE
static GUIAction OBJECT_TRANSLATION
static void println(String s)
Vector< GrxLinkItem > intersectingLinks_
void removeClickListener(Grx3DViewClickListener listener)
void calcForwardKinematics()
compute forward kinematics
Object setProperty(String key, String value)
set property value associated with a keyword
void _showDistance(Distance[] distances)
void setLogName(final String name)
static final int BACK_VIEW
void load(final String name, String url)
static GUIAction VIEW_ROTATION_MODE
void attach(BranchGroup bg)
void addPosObserver(GrxPositionObserver v)
static final int INV_KINEMA_TRANSLATION_MODE
static GUIAction FRONT_VIEW
String pathToURL(String path)
void setViewIndicator(BehaviorHandler handler)
void addClickListener(Grx3DViewClickListener listener)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
Transform3D getTransform()
void jointValue(double jv)
set new joint value
void _setViewHomePosition()
void attachUnclickable(BranchGroup bg)
static GUIAction WIRE_FRAME
double[] getJointValues()
png_infop png_bytep buffer
ValueEditType GetValueEditType(String key)
void update(GrxBasePlugin plugin, Object...arg)
Object[] preRecord(String fileName, String fileType)
void update(WorldState arg0)
final String getName()
get name
void setCharacterPos(LinkPosition[] lpos, double[] q)
set transformation of the root joint and all joint values
static GUIAction BG_COLOR
void setItem(List< GrxModelItem > models, List< GrxCollisionPairItem > cols)
static GUIAction OPERATION_DISABLE
void destroyDynamicsSimulator()
static final int NOTSELECTED_ITEM
void removeClickListener(Grx3DViewClickListener listener)
List< GrxModelItem > getSameUrlModels()
static final int OBJECT_TRANSLATION_MODE
Grx3DView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent)
void updatePosition(GrxBasePlugin plugin, Integer arg_pos)
static Dimension getDefaultButtonSize()
get default button size
static GUIAction INV_KINEMA_ROT
void updateViewSimulator(double time)
static NamingContext getNamingContext()
get naming context
static GUIAction OBJECT_ROTATION
List< GrxModelItem > setNumOfAABB()
void drawScene(WorldState arg0)
static final int PARALLEL_VIEW_MODE
static RecordingManager getInstance()
Collision[] getCollision()
get collision information
BranchGroup _createLights()
List< Camera_impl > getCameraSequence()
get sequence of cameras
void setViewMode(int mode)
static final int FITTING_FROM_MODE
boolean startRecord(String formatStr)
static GUIAction LEFT_VIEW
void addClickListener(Grx3DViewClickListener listener)
void saveScreenShot(File file)