Search in sources :

Example 6 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class MuscleBundleEditor method addElementsNearFibres.

private void addElementsNearFibres(MuscleBundle bundle) {
    WidgetDialog dialog = WidgetDialog.createDialog(myMain.getFrame(), "Specify fibre distance", "Set");
    DoubleField widget = new DoubleField("distance:", myLastElementFibreDist);
    widget.setRange(0, Double.POSITIVE_INFINITY);
    dialog.addWidget(widget);
    GuiUtils.locateCenter(dialog, myMain.getFrame());
    dialog.setVisible(true);
    if (dialog.getReturnValue() == OptionPanel.OK_OPTION) {
        double dist = widget.getDoubleValue();
        LinkedList<MuscleElementDesc> list = bundle.getNewElementsNearFibres(dist);
        AddComponentsCommand cmd = new AddComponentsCommand("Add near elements", list, bundle.getElements());
        myMain.getUndoManager().saveStateAndExecute(cmd);
        myLastElementFibreDist = dist;
    }
}
Also used : WidgetDialog(maspack.widgets.WidgetDialog) DoubleField(maspack.widgets.DoubleField) MuscleElementDesc(artisynth.core.femmodels.MuscleElementDesc)

Example 7 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class GeometryInertiaPanel method createInertiaWidgets.

// Called once at panel creation time to create and add the widgets needed
// for controlling the inertia.
protected void createInertiaWidgets() {
    myInertiaMethodSelector = new EnumSelector("set inertia by", InertiaMethod.values());
    myInertiaMethodSelector.addValueChangeListener(this);
    addWidget(myInertiaMethodSelector);
    myDensityField = new DoubleField("density", 1, "%.6g");
    myDensityField.addValueChangeListener(this);
    myDensityField.setGUIVoidEnabled(true);
    myDensityField.setStretchable(true);
    myDensityField.addValueCheckListener(new PositiveValueCheck());
    addWidget(myDensityField);
    myMassField = new DoubleField("mass");
    myMassField.addValueChangeListener(this);
    myMassField.setStretchable(true);
    myMassField.addValueCheckListener(new PositiveValueCheck());
    addWidget(myMassField);
    myInertiaField = new SymmetricMatrix3dField("rotational inertia");
    myInertiaField.setFormat("%.5g");
    myInertiaField.addValueChangeListener(this);
    myInertiaField.setStretchable(true);
    addWidget(myInertiaField);
    myCOMField = new VectorField("center of mass", new Point3d(), "%.5g");
    myCOMField.setResultHolder(new Point3d());
    myCOMField.addValueChangeListener(this);
    myCOMField.setStretchable(true);
    addWidget(myCOMField);
// if myOriginalInertia was not set from widgets, then this will
// default to the identity inertia
// setInertiaWidgets (myOriginalInertia);
}
Also used : VectorField(maspack.widgets.VectorField) SymmetricMatrix3dField(maspack.widgets.SymmetricMatrix3dField) EnumSelector(maspack.widgets.EnumSelector) DoubleField(maspack.widgets.DoubleField)

Example 8 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class GeometryInertiaPanel method createGeometryWidgets.

// Called once at panel creation time to create all the widgets
// that may be needed for the Geometry.
protected void createGeometryWidgets() {
    myBoxWidthsField = new VectorField("widths", new Vector3d(), "%.4g");
    myBoxWidthsField.setResultHolder(new Vector3d());
    initWidget(myBoxWidthsField);
    myPointRadiusField = new DoubleField("radius", 0, "%.4g");
    initWidget(myPointRadiusField);
    myPointSlicesField = new IntegerField("slices", 12);
    initWidget(myPointSlicesField);
    myMeshFileField = new FileNameField("file name", "", 20);
    initWidget(myMeshFileField);
    myMeshXformWidget = new AffineTransformWidget("", "TRS", new RigidTransform3d());
    initWidget(myMeshXformWidget);
    myMeshXformWidget.unpackFields();
    myMeshXformWidget.getTranslationField().setLabelText("offset");
    myMeshXformWidget.getScaleField().setLabelText("scale");
    myMeshXformWidget.getRotationField().setLabelText("rotation");
    myCOMButton = new JButton("COM");
    myCOMButton.addActionListener(this);
    myCOMButton.setToolTipText("puts mesh origin at its center of mass");
    GuiUtils.setFixedSize(myCOMButton, myMeshFileField.getBrowseButton().getPreferredSize());
    myMeshXformWidget.getTranslationField().addMajorComponent(myCOMButton);
}
Also used : VectorField(maspack.widgets.VectorField) AffineTransformWidget(maspack.widgets.AffineTransformWidget) IntegerField(maspack.widgets.IntegerField) DoubleField(maspack.widgets.DoubleField) FileNameField(maspack.widgets.FileNameField)

Example 9 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class DefaultCollisionsDialog method updateWidget.

private void updateWidget(BooleanSelector enabledField, Collidable.Group col0, Collidable.Group col1) {
    DoubleField frictionField = (DoubleField) enabledField.getMajorComponent(2);
    CollisionBehavior behavior = myMechModel.getDefaultCollisionBehavior(col0, col1);
    enabledField.setValue(behavior.isEnabled());
    frictionField.setValue(behavior.getFriction());
}
Also used : DoubleField(maspack.widgets.DoubleField)

Example 10 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class TimelineController method getWayPointFromUser.

/**
 * Gets waypoint information from the user and adds the waypoint to
 * the waypoint probe.
 */
public void getWayPointFromUser() {
    DoubleField myTimeField = new DoubleField("Time");
    myTimeField.addValueCheckListener(new ValueCheckListener() {

        public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
            Object val = e.getValue();
            if (val instanceof Double && ((Double) val).doubleValue() <= 0) {
                if (errMsg != null) {
                    errMsg.value = "Time value must be positive";
                }
                return Property.IllegalValue;
            } else {
                if (errMsg != null) {
                    errMsg.value = null;
                }
                return val;
            }
        }
    });
    myTimeField.setVoidValueEnabled(true);
    myTimeField.setValue(Property.VoidValue);
    IntegerField myRepeatField = new IntegerField("Repeat", 1);
    myRepeatField.setRange(1, Integer.MAX_VALUE);
    BooleanSelector myBreakpointSelector = new BooleanSelector("Breakpoint", false);
    PropertyPanel addPanel = new PropertyPanel();
    addPanel.addWidget(myTimeField);
    addPanel.addWidget(myRepeatField);
    addPanel.addWidget(myBreakpointSelector);
    PropertyDialog addDialog = new PropertyDialog(this, "Add Waypoints", addPanel, "OK Cancel");
    addDialog.setModal(true);
    GuiUtils.locateCenter(addDialog, this);
    addDialog.setVisible(true);
    if (addDialog.getReturnValue() == OptionPanel.OK_OPTION && !myTimeField.valueIsVoid()) {
        double t = myTimeField.getDoubleValue();
        for (int i = 1; i <= myRepeatField.getIntValue(); i++) {
            addWayPoint(t * i, myBreakpointSelector.getBooleanValue());
        }
        myToolBar.validateFastForward(myMain.getRootModel());
    }
}
Also used : ValueCheckListener(maspack.widgets.ValueCheckListener) ValueChangeEvent(maspack.widgets.ValueChangeEvent) StringHolder(maspack.util.StringHolder) BooleanSelector(maspack.widgets.BooleanSelector) PropertyDialog(maspack.widgets.PropertyDialog) IntegerField(maspack.widgets.IntegerField) DoubleField(maspack.widgets.DoubleField) WayPoint(artisynth.core.probes.WayPoint) PropertyPanel(maspack.widgets.PropertyPanel)

Aggregations

DoubleField (maspack.widgets.DoubleField)19 BooleanSelector (maspack.widgets.BooleanSelector)4 Dimension (java.awt.Dimension)3 JLabel (javax.swing.JLabel)3 IntegerField (maspack.widgets.IntegerField)3 VectorField (maspack.widgets.VectorField)3 SelectableComponentPanel (artisynth.core.gui.SelectableComponentPanel)2 ModelComponent (artisynth.core.modelbase.ModelComponent)2 JButton (javax.swing.JButton)2 JScrollPane (javax.swing.JScrollPane)2 StringHolder (maspack.util.StringHolder)2 OptionPanel (maspack.widgets.OptionPanel)2 ValueChangeEvent (maspack.widgets.ValueChangeEvent)2 ValueCheckListener (maspack.widgets.ValueCheckListener)2 MuscleElementDesc (artisynth.core.femmodels.MuscleElementDesc)1 ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)1 MotionTargetComponent (artisynth.core.mechmodels.MotionTargetComponent)1 WayPoint (artisynth.core.probes.WayPoint)1 File (java.io.File)1 BoxLayout (javax.swing.BoxLayout)1