use of maspack.widgets.IntegerField in project artisynth_core by artisynth.
the class FemModel3dAgent method createMeshPropPanel.
private void createMeshPropPanel() {
meshPropPanel = new LabeledComponentPanel();
gridDimField = new VectorField("widths", DEFAULT_GRID_DIM, "%8.3f");
gridDivField = new IntegerMultiField("divisions", DEFAULT_GRID_DIV, "%d");
gridDimField.setStretchable(true);
gridDivField.setStretchable(true);
tubeDimField = new VectorField("widths (L, rin, rout)", DEFAULT_TUBE_DIM, "%8.3f");
tubeDivField = new IntegerMultiField("divisions (nt, nl, nr)", DEFAULT_TUBE_DIV, "%d");
tubeDimField.setStretchable(true);
tubeDivField.setStretchable(true);
torusDimField = new VectorField("widths (R, rin, rout)", DEFAULT_TORUS_DIM, "%8.3f");
torusDivField = new IntegerMultiField("divisions (nt, nl, nr)", DEFAULT_TORUS_DIV, "%d");
torusDimField.setStretchable(true);
torusDivField.setStretchable(true);
sphereNodesField = new IntegerSelector("node count", SPHERE_NODE_OPTIONS);
extrusDepthField = new DoubleField("depth", DEFAULT_EXTRUSION_DEPTH, "%8.3f");
extrusLayersField = new IntegerField("layers", DEFAULT_EXTRUSION_LAYERS, "%d");
extrusFileField = createFileChooser("obj file", null, "obj");
extrusFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
extrusDepthField.setStretchable(true);
extrusLayersField.setStretchable(true);
ansysNodeFileField = createFileChooser("node file", null, "node");
ansysNodeFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
ansysElemFileField = createFileChooser("elem file", null, "elem");
ansysElemFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
tetgenNodeFileField = createFileChooser("node file", null, "node");
tetgenNodeFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
tetgenEleFileField = createFileChooser("ele file", null, "ele");
tetgenEleFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
ucdMeshFileField = createFileChooser("INP file", null, "inp");
ucdMeshFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
surfaceMeshFileField = createFileChooser("OBJ file", null, "obj");
surfaceMeshFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
scaleField = new ScaleField("scale", 1);
scaleField.setStretchable(true);
autoScaleBtn = new JButton("auto scale");
autoScaleBtn.addActionListener(this);
scaleField.addMajorComponent(autoScaleBtn);
restoreDefaultValues();
if (mySettings != null) {
meshSelector.maskValueChangeListeners(true);
meshSelector.setValue(mySettings.meshType);
meshSelector.maskValueChangeListeners(false);
gridDimField.setValue(mySettings.gridWidths);
gridDivField.setValue(mySettings.gridDivisions);
tubeDimField.setValue(mySettings.tubeWidths);
tubeDivField.setValue(mySettings.tubeDivisions);
torusDimField.setValue(mySettings.torusWidths);
torusDivField.setValue(mySettings.torusDivisions);
sphereNodesField.setValue(mySettings.sphereNodes);
extrusDepthField.setValue(mySettings.extrusionDepth);
extrusLayersField.setValue(mySettings.extrusionLayers);
if (new File(mySettings.extrusionFile).isFile()) {
extrusFileField.setValue(mySettings.extrusionFile);
}
if (new File(mySettings.ansysNodeFile).isFile()) {
ansysNodeFileField.setValue(mySettings.ansysNodeFile);
}
if (new File(mySettings.ansysElemFile).isFile()) {
ansysElemFileField.setValue(mySettings.ansysElemFile);
}
if (new File(mySettings.tetgenNodeFile).isFile()) {
tetgenNodeFileField.setValue(mySettings.tetgenNodeFile);
}
if (new File(mySettings.tetgenEleFile).isFile()) {
tetgenEleFileField.setValue(mySettings.tetgenEleFile);
}
if (new File(mySettings.ucdFile).isFile()) {
ucdMeshFileField.setValue(mySettings.ucdFile);
}
if (new File(mySettings.surfaceMeshFile).isFile()) {
surfaceMeshFileField.setValue(mySettings.surfaceMeshFile);
}
}
updateMeshPanel();
}
use of maspack.widgets.IntegerField 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.IntegerField 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());
}
}
use of maspack.widgets.IntegerField in project artisynth_core by artisynth.
the class EditorUtils method saveMeshAsAnsysFile.
public static void saveMeshAsAnsysFile(final FemModel3d model) {
final Main main = Main.getMain();
JFrame frame = main.getMainFrame();
final JDialog saveOptions = new JDialog(frame, "Save As Ansys File");
LabeledComponentPanel savePanel = new LabeledComponentPanel();
savePanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
final StringField dirField = new StringField("Output folder", main.getModelDirectory().getAbsolutePath(), 20);
dirField.setStretchable(true);
dirField.getTextField().setEditable(false);
final JButton browseButton = new JButton("Change");
browseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a_evt) {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(main.getModelDirectory());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showSaveDialog(browseButton) == JFileChooser.APPROVE_OPTION) {
dirField.setValue(chooser.getSelectedFile().getAbsolutePath());
}
}
});
browseButton.setMargin(new Insets(3, 3, 3, 3));
GuiUtils.setFixedSize(browseButton, new Dimension(80, 25));
dirField.add(browseButton);
savePanel.addWidget(dirField);
final StringField nodeField = new StringField("Node file name", "mesh.node", 10);
nodeField.setStretchable(true);
savePanel.addWidget(nodeField);
final StringField elemField = new StringField("Element file name", "mesh.elem", 10);
elemField.setStretchable(true);
savePanel.addWidget(elemField);
final JCheckBox elemType = new JCheckBox("Use custom type values for different elements");
savePanel.addWidget(elemType);
LabeledComponentPanel elemTypePanel = new LabeledComponentPanel();
elemTypePanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
final IntegerField tetField = new IntegerField("Tets (4 node)", 1);
tetField.getTextField().setEditable(false);
elemTypePanel.addWidget(tetField);
final IntegerField quadtetField = new IntegerField("Quadtets (10 node)", 1);
quadtetField.getTextField().setEditable(false);
elemTypePanel.addWidget(quadtetField);
final IntegerField wedgeField = new IntegerField("Wedges", 1);
wedgeField.getTextField().setEditable(false);
elemTypePanel.addWidget(wedgeField);
final IntegerField hexField = new IntegerField("Hexs (8 node)", 1);
hexField.getTextField().setEditable(false);
elemTypePanel.addWidget(hexField);
final IntegerField quadhexField = new IntegerField("Quadhexs (20 node)", 1);
quadhexField.getTextField().setEditable(false);
elemTypePanel.addWidget(quadhexField);
savePanel.addWidget(elemTypePanel);
elemType.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a_evt) {
if (elemType.isSelected()) {
tetField.getTextField().setEditable(true);
quadtetField.getTextField().setEditable(true);
wedgeField.getTextField().setEditable(true);
hexField.getTextField().setEditable(true);
quadhexField.getTextField().setEditable(true);
} else {
tetField.getTextField().setEditable(false);
quadtetField.getTextField().setEditable(false);
wedgeField.getTextField().setEditable(false);
hexField.getTextField().setEditable(false);
quadhexField.getTextField().setEditable(false);
}
}
});
OptionPanel dialogOptions = new OptionPanel("Save Cancel", new ActionListener() {
public void actionPerformed(ActionEvent a_evt) {
if (a_evt.getActionCommand().equals("Save")) {
File directory = new File(dirField.getStringValue());
File nodeFile = new File(directory, nodeField.getStringValue());
File elemFile = new File(directory, elemField.getStringValue());
AnsysWriter.writeNodeFile(model, nodeFile.getAbsolutePath());
AnsysWriter.writeElemFile(model, elemFile.getAbsolutePath());
}
saveOptions.dispose();
}
});
GuiUtils.setFixedSize(dialogOptions.getButton("Save"), new Dimension(80, 25));
GuiUtils.setFixedSize(dialogOptions.getButton("Cancel"), new Dimension(80, 25));
dialogOptions.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
savePanel.addWidget(dialogOptions);
saveOptions.getContentPane().add(savePanel);
saveOptions.pack();
saveOptions.setMinimumSize(saveOptions.getPreferredSize());
saveOptions.setVisible(true);
}
Aggregations