use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class RigidBodyAgent method getPrototypeMap.
protected HashMap<Class, ModelComponent> getPrototypeMap() {
RootModel root = myMain.getRootModel();
if (root != null && root != myLastRootModel) {
myPrototypeMap = new HashMap<Class, ModelComponent>();
myLastRootModel = root;
}
return myPrototypeMap;
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class RigidBodyConnectorList method getPrototypeMap.
protected HashMap<Class, ModelComponent> getPrototypeMap() {
RootModel root = myMain.getRootModel();
if (root != null && root != myLastRootModel) {
myPrototypeMap = new HashMap<Class, ModelComponent>();
myLastRootModel = root;
}
return myPrototypeMap;
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class SelectionPopup method addPropertyEditMenuItems.
public void addPropertyEditMenuItems(LinkedList<ModelComponent> selection) {
// parse the selection list.
boolean allSelectedHaveProperties = false;
boolean allSelectedAreTraceable = false;
int tracingCnt = 0;
boolean oneSelectedIsRenderable = false;
boolean oneSelectedHasRenderProps = false;
boolean oneSelectedHasFixedRenderProps = false;
boolean oneSelectedIsVisible = false;
boolean oneSelectedIsInvisible = false;
boolean oneSelectedHasRenderPropsProperty = false;
if (selection.size() > 0) {
allSelectedHaveProperties = true;
allSelectedAreTraceable = true;
for (ModelComponent c : selection) {
if (c instanceof RenderableComponent) {
oneSelectedIsRenderable = true;
RenderableComponent rcomp = (RenderableComponent) c;
if (isVisible(rcomp)) {
oneSelectedIsVisible = true;
} else {
oneSelectedIsInvisible = true;
}
// RenderableComponent > HasProperties, but may not have
// renderProps property
PropertyInfo rinfo = rcomp.getAllPropertyInfo().get("renderProps");
if (rinfo != null) {
oneSelectedHasRenderPropsProperty = true;
}
if (rcomp.getRenderProps() != null) {
oneSelectedHasRenderProps = true;
// be set to null ...
if (!oneSelectedHasFixedRenderProps) {
if (!rinfo.getNullValueOK()) {
oneSelectedHasFixedRenderProps = true;
}
}
}
}
if (!(c instanceof HasProperties)) {
allSelectedHaveProperties = false;
}
if (!(c instanceof Traceable)) {
allSelectedAreTraceable = false;
}
}
}
Collection<Traceable> traceSet = myMain.getRootModel().getTraceSet();
for (Traceable tr : traceSet) {
if (tr instanceof ModelComponent && ((ModelComponent) tr).isSelected()) {
tracingCnt++;
}
}
if (allSelectedHaveProperties) {
addMenuItem("Edit properties ...");
}
if (oneSelectedIsRenderable && oneSelectedHasRenderPropsProperty) {
if (oneSelectedHasRenderProps) {
addMenuItem("Edit render props ...");
if (!oneSelectedHasFixedRenderProps) {
addMenuItem("Clear render props");
}
} else {
addMenuItem("Set render props ...");
}
}
if (oneSelectedIsInvisible) {
addMenuItem("Set visible");
}
if (oneSelectedIsVisible) {
addMenuItem("Set invisible");
}
if (allSelectedAreTraceable) {
if (selection.size() - tracingCnt > 0) {
addMenuItem("Enable tracing");
}
if (tracingCnt > 0) {
addMenuItem("Disable tracing");
}
JMenuItem menuItem = new JMenuItem("Clear trace");
menuItem.addActionListener(this);
String[] commonTraceables = getCommonTraceables(selection);
if (commonTraceables.length > 0) {
menuItem = new JMenuItem("Add tracing probe");
myTraceItem = menuItem;
}
menuItem.addActionListener(this);
add(menuItem);
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class SelectionPopup method addTracing.
private void addTracing(LinkedList<ModelComponent> selectedItems) {
// RootModel root = myMain.getRootModel();
// String name = null;
// double startTime = myMain.getTimeSec();
// double updateInterval = root.getMaxStepSizeSec();
Traceable firstTraceable = null;
for (ModelComponent comp : selectedItems) {
if (comp instanceof Traceable) {
firstTraceable = (Traceable) comp;
}
}
if (firstTraceable == null) {
throw new InternalErrorException("'Add tracing' called with no traceabled in selection");
}
TracingProbePanel panel = new TracingProbePanel(firstTraceable, getCommonTraceables(selectedItems));
panel.pack();
GuiUtils.locateRelative(panel, myLastBounds, 0.5, 0.5, 0, 0.5);
// if (myTraceItemLoc != null)
// { panel.setLocation (
// myTraceItemLoc.x, myTraceItemLoc.y);
// }
panel.setVisible(true);
if (panel.getReturnValue() == OptionPanel.OK_OPTION) {
for (ModelComponent comp : selectedItems) {
if (comp instanceof Traceable) {
TracingProbe probe = panel.createProbe((Traceable) comp);
myMain.getRootModel().addOutputProbe(probe);
}
}
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class SelectionPopup method getNameForSelection.
/**
* Creates a short name for the current selection by appending
* the tails of path names for the first few components. Components
* which share parents are grouped together.
*/
private String getNameForSelection(Collection<? extends ModelComponent> sel) {
StringBuilder sbuf = new StringBuilder(80);
if (sel.size() == 0) {
// paranoid
return "";
}
ModelComponent next;
boolean samePrevParent = false;
boolean sameNextParent;
Iterator<? extends ModelComponent> it = sel.iterator();
for (ModelComponent comp = it.next(); comp != null; comp = next) {
next = it.hasNext() ? it.next() : null;
sameNextParent = (next != null && next.getParent() != null && next.getParent() == comp.getParent());
if (comp.getParent() != null && !samePrevParent) {
sbuf.append(getParentPrefix(comp));
if (sameNextParent) {
sbuf.append('{');
}
}
sbuf.append(getNameOrNumber(comp));
if (samePrevParent && !sameNextParent) {
sbuf.append('}');
}
if (next != null) {
sbuf.append(',');
if (sbuf.length() > NAME_LIMIT) {
sbuf.append(" ...");
break;
}
}
samePrevParent = sameNextParent;
}
return sbuf.toString();
}
Aggregations