Search in sources :

Example 11 with PropertyInfo

use of maspack.properties.PropertyInfo 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 12 with PropertyInfo

use of maspack.properties.PropertyInfo in project artisynth_core by artisynth.

the class PropertyWidgetDialog method valueChange.

public void valueChange(ValueChangeEvent e) {
    if (e.getSource() == myPropField) {
        PropertyInfo info = myPropField.getPropertyInfo();
        ModelComponent comp = myPropField.getModelComponent();
        if (info != null && PropertyWidget.canCreateWithSlider(info)) {
            mySliderSelector.setEnabledAll(true);
            mySliderSelector.setValue(true);
            updateRange(comp, info);
        } else {
            mySliderSelector.setValue(false);
            mySliderSelector.setEnabledAll(false);
        }
        if (info != null && comp != null) {
            myOKButton.setEnabled(true);
            myLabelTextField.setEnabledAll(true);
            myLabelTextField.setValue(info.getName());
        } else {
            myOKButton.setEnabled(false);
            myLabelTextField.setEnabledAll(false);
            myLabelTextField.setValue(null);
        }
    } else if (e.getSource() == mySliderSelector) {
        boolean sliderChoosen = (Boolean) mySliderSelector.getValue();
        myRangeField.setEnabledAll(sliderChoosen);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) PropertyInfo(maspack.properties.PropertyInfo)

Aggregations

PropertyInfo (maspack.properties.PropertyInfo)12 HasProperties (maspack.properties.HasProperties)4 EnumRange (maspack.util.EnumRange)4 Range (maspack.util.Range)4 StringRange (maspack.util.StringRange)4 IntegerInterval (maspack.util.IntegerInterval)3 NumericInterval (maspack.util.NumericInterval)3 ModelComponent (artisynth.core.modelbase.ModelComponent)2 VectorNd (maspack.matrix.VectorNd)2 CompositeProperty (maspack.properties.CompositeProperty)2 HostList (maspack.properties.HostList)2 PropTreeCell (maspack.properties.PropTreeCell)2 InternalErrorException (maspack.util.InternalErrorException)2 RenderableComponent (artisynth.core.modelbase.RenderableComponent)1 Traceable (artisynth.core.modelbase.Traceable)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Font (java.awt.Font)1 Point (java.awt.Point)1 LinkedList (java.util.LinkedList)1