use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class Main method componentChanged.
public void componentChanged(ComponentChangeEvent e) {
if (e.getCode() == ComponentChangeEvent.Code.STRUCTURE_CHANGED || e.getCode() == ComponentChangeEvent.Code.DYNAMIC_ACTIVITY_CHANGED) {
boolean invalidateWaypoints = false;
RootModel root = getRootModel();
ModelComponent c = e.getComponent();
if (myFrame != null && c != null && (c == root || c.getParent() == root)) {
updateApplicationMenuPresent(root);
}
if (root != null) {
invalidateWaypoints = changeAffectsWaypoints(root, e);
if (invalidateWaypoints) {
root.getWayPoints().invalidateAfterTime(0);
}
}
if (myTimeline != null) {
if (root != null && c == root.getWayPoints()) {
myTimeline.requestUpdateWidgets();
} else {
// update timeline display regardless
myTimeline.requestUpdateDisplay();
}
}
if (e.getCode() == ComponentChangeEvent.Code.STRUCTURE_CHANGED) {
if (c != null && c instanceof CompositeComponent && myFrame != null) {
myFrame.getNavPanel().updateStructure(c);
if (root != null && (c == root.getInputProbes() || c == root.getOutputProbes())) {
myTimeline.updateProbes(root);
}
}
if (!getScheduler().isPlaying()) {
rerender();
}
}
// if (invalidateWaypoints) && !myScheduler.isPlaying()) {
if (invalidateWaypoints) {
myScheduler.invalidateInitialState();
}
} else if (e.getCode() == ComponentChangeEvent.Code.NAME_CHANGED) {
ModelComponent c = e.getComponent();
if (myFrame != null) {
if (c.getParent() != null) {
myFrame.getNavPanel().updateStructure(c.getParent());
} else {
myFrame.getNavPanel().updateStructure(c);
}
}
} else if (e.getCode() == ComponentChangeEvent.Code.PROPERTY_CHANGED) {
PropertyChangeEvent pe = (PropertyChangeEvent) e;
ModelComponent c = e.getComponent();
if (c == getRootModel()) {
if (pe.getPropertyName().equals("maxStepSize")) {
doSetMaxStep(getRootModel().getMaxStepSize());
} else if (pe.getPropertyName().equals("defaultViewOrientation")) {
if (myViewerManager != null) {
myViewerManager.resetViewers(getDefaultViewOrientation(getRootModel()));
}
}
} else if (pe.getPropertyName().startsWith("navpanel")) {
if (myFrame != null) {
myFrame.getNavPanel().updateStructure(e.getComponent());
}
}
} else if (e.getCode() == ComponentChangeEvent.Code.GEOMETRY_CHANGED) {
// myTimeline.requestUpdateDisplay();
if (!getScheduler().isPlaying()) {
rerender();
}
}
}
use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class MenuBarHandler method getApplicationMenuItems.
ArrayList<Object> getApplicationMenuItems(RootModel root) {
ArrayList<Object> items = new ArrayList<Object>();
boolean hasItems = false;
hasItems |= addMenuItems(items, root);
for (int i = 0; i < root.numComponents(); i++) {
ModelComponent comp0 = root.get(i);
if (comp0 instanceof HasMenuItems) {
hasItems |= addMenuItems(items, (HasMenuItems) comp0);
}
if (comp0 instanceof CompositeComponent) {
CompositeComponent ccomp = (CompositeComponent) comp0;
for (int j = 0; j < ccomp.numComponents(); j++) {
ModelComponent comp1 = ccomp.get(j);
if (comp1 instanceof HasMenuItems) {
hasItems |= addMenuItems(items, (HasMenuItems) comp1);
}
}
}
}
return hasItems ? items : null;
}
use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class SkinMeshBody method writeFemModelInfo.
protected void writeFemModelInfo(PrintWriter pw, NumberFormat fmt, Object ref) throws IOException {
if (myFemModelInfo.size() == 0) {
pw.println("[ ]");
} else {
CompositeComponent ancestor = ComponentUtils.castRefToAncestor(ref);
pw.println("[");
IndentingPrintWriter.addIndentation(pw, 2);
for (int i = 0; i < myFemModelInfo.size(); i++) {
FemModelInfo finfo = myFemModelInfo.get(i);
pw.println(ComponentUtils.getWritePathName(ancestor, finfo.myFemModel));
}
IndentingPrintWriter.addIndentation(pw, -2);
pw.println("]");
}
}
use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class PointFem3dAttachment method writeNodes.
protected static void writeNodes(PrintWriter pw, NumberFormat fmt, FemNode[] nodes, double[] weights, Object ref) throws IOException {
CompositeComponent ancestor = ComponentUtils.castRefToAncestor(ref);
pw.println("[");
IndentingPrintWriter.addIndentation(pw, 2);
for (int i = 0; i < nodes.length; i++) {
pw.println(ComponentUtils.getWritePathName(ancestor, nodes[i]) + " " + weights[i]);
}
IndentingPrintWriter.addIndentation(pw, -2);
pw.println("]");
}
use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class ControlPanel method write.
public void write(PrintWriter pw, NumberFormat fmt, Object ref) throws IOException {
CompositeComponent ancestor = ComponentUtils.castRefToAncestor(ref);
pw.print("[ ");
IndentingPrintWriter.addIndentation(pw, 2);
getAllPropertyInfo().writeNonDefaultProps(this, pw, fmt);
String optionsStr = null;
if (myFrame != null) {
OptionPanel optpanel = myFrame.getOptionPanel();
if (optpanel != null) {
optionsStr = optpanel.getButtonString();
}
} else {
optionsStr = myOptionsString;
}
if (optionsStr != null) {
pw.println("options=\"" + optionsStr + "\"");
} else {
pw.println("options=null");
}
for (Component comp : myPanel.getWidgets()) {
writeWidget(pw, comp, fmt, ancestor);
}
IndentingPrintWriter.addIndentation(pw, -2);
pw.println("]");
}
Aggregations