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;
}
}
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);
}
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);
}
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());
}
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());
}
}
Aggregations