Search in sources :

Example 1 with CompositeComponent

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();
        }
    }
}
Also used : PropertyChangeEvent(artisynth.core.modelbase.PropertyChangeEvent) RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent) CompositeComponent(artisynth.core.modelbase.CompositeComponent)

Example 2 with CompositeComponent

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;
}
Also used : HasMenuItems(artisynth.core.modelbase.HasMenuItems) ModelComponent(artisynth.core.modelbase.ModelComponent) ArrayList(java.util.ArrayList) CompositeComponent(artisynth.core.modelbase.CompositeComponent)

Example 3 with CompositeComponent

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("]");
    }
}
Also used : CompositeComponent(artisynth.core.modelbase.CompositeComponent) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Example 4 with CompositeComponent

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("]");
}
Also used : CompositeComponent(artisynth.core.modelbase.CompositeComponent) Point(artisynth.core.mechmodels.Point)

Example 5 with CompositeComponent

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("]");
}
Also used : MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) CompositeComponent(artisynth.core.modelbase.CompositeComponent) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) Component(java.awt.Component) ModelComponent(artisynth.core.modelbase.ModelComponent) CompositeComponent(artisynth.core.modelbase.CompositeComponent) JComponent(javax.swing.JComponent) OptionPanel(maspack.widgets.OptionPanel)

Aggregations

CompositeComponent (artisynth.core.modelbase.CompositeComponent)12 ModelComponent (artisynth.core.modelbase.ModelComponent)7 Point (artisynth.core.mechmodels.Point)3 MutableCompositeComponent (artisynth.core.modelbase.MutableCompositeComponent)3 ContactPoint (artisynth.core.mechmodels.ContactPoint)2 Component (java.awt.Component)2 JComponent (javax.swing.JComponent)2 HasMenuItems (artisynth.core.modelbase.HasMenuItems)1 PropertyChangeEvent (artisynth.core.modelbase.PropertyChangeEvent)1 RenderableComponentList (artisynth.core.modelbase.RenderableComponentList)1 RootModel (artisynth.core.workspace.RootModel)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CompositeProperty (maspack.properties.CompositeProperty)1 EditingProperty (maspack.properties.EditingProperty)1 Property (maspack.properties.Property)1 RenderProps (maspack.render.RenderProps)1 LabeledComponentBase (maspack.widgets.LabeledComponentBase)1 LabeledControl (maspack.widgets.LabeledControl)1 OptionPanel (maspack.widgets.OptionPanel)1