Search in sources :

Example 36 with ModelComponent

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

Example 37 with ModelComponent

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

Example 38 with ModelComponent

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);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) RenderableComponent(artisynth.core.modelbase.RenderableComponent) HasProperties(maspack.properties.HasProperties) PropertyInfo(maspack.properties.PropertyInfo) Traceable(artisynth.core.modelbase.Traceable) JMenuItem(javax.swing.JMenuItem) Point(java.awt.Point)

Example 39 with ModelComponent

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);
            }
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) TracingProbePanel(artisynth.core.gui.editorManager.TracingProbePanel) InternalErrorException(maspack.util.InternalErrorException) TracingProbe(artisynth.core.probes.TracingProbe) Traceable(artisynth.core.modelbase.Traceable)

Example 40 with ModelComponent

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

Aggregations

ModelComponent (artisynth.core.modelbase.ModelComponent)53 RootModel (artisynth.core.workspace.RootModel)9 Property (maspack.properties.Property)8 CompositeComponent (artisynth.core.modelbase.CompositeComponent)5 ArrayList (java.util.ArrayList)5 Point (artisynth.core.mechmodels.Point)4 Renderable (maspack.render.Renderable)4 InternalErrorException (maspack.util.InternalErrorException)4 HasCoordinateFrame (artisynth.core.modelbase.HasCoordinateFrame)3 Traceable (artisynth.core.modelbase.Traceable)3 WayPoint (artisynth.core.probes.WayPoint)3 Point (java.awt.Point)3 LinkedList (java.util.LinkedList)3 CompositeProperty (maspack.properties.CompositeProperty)3 FractionRenderType (artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)2 FemModel3d (artisynth.core.femmodels.FemModel3d)2 HexElement (artisynth.core.femmodels.HexElement)2 DirectionRenderType (artisynth.core.femmodels.MuscleBundle.DirectionRenderType)2 RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)2 ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)2