GrxOpenHRPView.java
Go to the documentation of this file.
1 // -*- indent-tabs-mode: nil; tab-width: 4; -*-
2 /*
3  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
4  * All rights reserved. This program is made available under the terms of the
5  * Eclipse Public License v1.0 which accompanies this distribution, and is
6  * available at http://www.eclipse.org/legal/epl-v10.html
7  * Contributors:
8  * General Robotix Inc.
9  * National Institute of Advanced Industrial Science and Technology (AIST)
10  */
11 /*
12  * GrxOpenHRPView.java
13  *
14  * Copyright (C) 2007 GeneralRobotix, Inc.
15  * All Rights Reserved
16  *
17  * @author Yuichiro Kawasumi (General Robotix, Inc.)
18  */
19 
20 package com.generalrobotix.ui.view;
21 
22 import jp.go.aist.hrp.simulator.DynamicsSimulator;
23 import org.eclipse.jface.action.IAction;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.widgets.Composite;
31 
35 
36 @SuppressWarnings("serial") //$NON-NLS-1$
37 public class GrxOpenHRPView extends GrxBaseView {
38  public static final String TITLE = "OpenHRP"; //$NON-NLS-1$
40  private GrxSimulationItem simItem_=null;
42 
43  public GrxOpenHRPView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent) {
44  super(name, manager,vp,parent);
45 
46  simParamPane_ = new SimulationParameterPanel(composite_, SWT.NONE);
47  simParamPane_.setEnabled(true);//false
48 
49  setScrollMinSize(SWT.DEFAULT,SWT.DEFAULT);
50 
51  setUp();
52  manager_.registerItemChangeListener(this, GrxWorldStateItem.class);
53  manager_.registerItemChangeListener(this, GrxSimulationItem.class);
54  }
55 
56  public void setUp(){
57  if(currentWorld_ != null)
58  currentWorld_.deleteObserver(this);
59  currentWorld_ = manager_.<GrxWorldStateItem>getSelectedItem(GrxWorldStateItem.class, null);
60  simParamPane_.updateLogTime(currentWorld_);
61  if(currentWorld_!=null)
62  currentWorld_.addObserver(this);
63  if(simItem_ != null)
64  simItem_.deleteObserver(this);
65  simItem_ = manager_.<GrxSimulationItem>getSelectedItem(GrxSimulationItem.class, null);
66  simParamPane_.updateItem(simItem_);
67  if(simItem_!=null){
68  simItem_.addObserver(this);
69  }
70  }
71 
72  public void registerItemChange(GrxBaseItem item, int event){
73  if(item instanceof GrxWorldStateItem){
74  GrxWorldStateItem witem = (GrxWorldStateItem) item;
75  switch(event){
77  if(currentWorld_!=witem){
78  simParamPane_.updateLogTime(witem);
79  currentWorld_ = witem;
80  currentWorld_.addObserver(this);
81  }
82  break;
85  if(currentWorld_==witem){
86  simParamPane_.updateLogTime(null);
87  currentWorld_.deleteObserver(this);
88  currentWorld_ = null;
89  }
90  break;
91  default:
92  break;
93  }
94  }else if(item instanceof GrxSimulationItem){
95  GrxSimulationItem simItem = (GrxSimulationItem) item;
96  switch(event){
98  if(simItem_!=simItem){
99  simParamPane_.updateItem(simItem);
100  simItem_ = simItem;
101  simItem_.addObserver(this);
102  }
103  break;
106  if(simItem_==simItem){
107  simParamPane_.updateItem(null);
108  simItem_.deleteObserver(this);
109  simItem_ = null;
110  }
111  break;
112  default:
113  break;
114  }
115  }
116  }
117 
118  public void update(GrxBasePlugin plugin, Object... arg) {
119  if(simItem_==plugin){
120  if((String)arg[0]=="StartSimulation")
121  simParamPane_.setEnabled(false);
122  else if((String)arg[0]=="StopSimulation")
123  simParamPane_.setEnabled(true);
124  else if((String)arg[0]=="PropertyChange") //$NON-NLS-1$
125  simParamPane_.updateItem(simItem_);
126  }else if(currentWorld_==plugin){
127  if((String)arg[0]=="PropertyChange") //$NON-NLS-1$
128  simParamPane_.updateLogTime(currentWorld_);
129  }
130  }
131 
132  public void shutdown() {
133  if(currentWorld_!=null)
134  currentWorld_.deleteObserver(this);
135 
136  manager_.removeItemChangeListener(this, GrxWorldStateItem.class);
137 
138  if(simItem_!=null)
139  simItem_.deleteObserver(this);
140  manager_.removeItemChangeListener(this, GrxSimulationItem.class);
141  }
142 
143  // Python scriptからの呼び出しのために public宣言されていたメソッドを残す   //
148  public void startSimulation(boolean isInteractive, IAction action){
149  simParamPane_.fixParam();
150  if(simItem_==null){
151  simItem_ = (GrxSimulationItem)manager_.createItem(GrxSimulationItem.class, null);
152  simItem_.addObserver(this);
153  manager_.itemChange(simItem_, GrxPluginManager.ADD_ITEM);
154  manager_.setSelectedItem(simItem_, true);
155  }
156  simItem_.startSimulation(isInteractive);
157  }
158 
159  public void waitStopSimulation() throws InterruptedException {
160  simItem_.waitStopSimulation();
161  }
162 
166  public void stopSimulation(){
167  simItem_.stopSimulation();
168  }
169 
170  public boolean registerCORBA() {
171  if(simItem_==null){
172  simItem_ = (GrxSimulationItem)manager_.createItem(GrxSimulationItem.class, null);
173  simItem_.addObserver(this);
174  manager_.itemChange(simItem_, GrxPluginManager.ADD_ITEM);
175  manager_.setSelectedItem(simItem_, true);
176  }
177  return simItem_.registerCORBA();
178  }
179 
180  public void unregisterCORBA() {
181  simItem_.unregisterCORBA();
182  }
183 
184  public boolean initDynamicsSimulator() {
185  if(simItem_==null){
186  simItem_ = (GrxSimulationItem)manager_.createItem(GrxSimulationItem.class, null);
187  simItem_.addObserver(this);
188  manager_.itemChange(simItem_, GrxPluginManager.ADD_ITEM);
189  manager_.setSelectedItem(simItem_, true);
190  }
191  return simItem_.initDynamicsSimulator();
192  }
193 
194  public DynamicsSimulator getDynamicsSimulator(boolean update) {
195  if(simItem_==null){
196  simItem_ = (GrxSimulationItem)manager_.createItem(GrxSimulationItem.class, null);
197  simItem_.addObserver(this);
198  manager_.itemChange(simItem_, GrxPluginManager.ADD_ITEM);
199  manager_.setSelectedItem(simItem_, true);
200  }
201  return simItem_.getDynamicsSimulator(update);
202  }
203 
204  public boolean isSimulating(){
205  if(simItem_!=null)
206  return simItem_.isSimulating();
207  else
208  return false;
209  }
210 
211  public void fixParam(){
212  simParamPane_.fixParam();
213  }
214 }
void registerItemChange(GrxBaseItem item, int event)
#define null
our own NULL pointer
Definition: IceTypes.h:57
DynamicsSimulator getDynamicsSimulator(boolean update)
png_infop png_charpp name
Definition: png.h:2382
GrxOpenHRPView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent)
void update(GrxBasePlugin plugin, Object... arg)
boolean startSimulation(boolean isInteractive)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
DynamicsSimulator getDynamicsSimulator(boolean update)
org
char * arg
Definition: cdjpeg.h:136
void startSimulation(boolean isInteractive, IAction action)
start simulation


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:03