use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class GeometryInertiaPanel method resetMesh.
// XXX need to make sure myMeshFileTransform is not null, as it can
// be in rigid bodies
// Resets myMesh, myMeshFileName, and myMeshFileTransform based on the
// currently selected Geometry type. For all types, this will involve
// rebuilding the actual mesh (or for the Mesh type, copying/transforming it
// from myFileMesh).
//
public void resetMesh() {
GeometryType type = (GeometryType) myGeometrySelector.getValue();
switch(type) {
case Box:
{
Vector3d widths = (Vector3d) myBoxWidthsField.getValue();
myMesh = MeshFactory.createBox(widths.get(0), widths.get(1), widths.get(2), 0, 0, 0);
myMeshFileName = null;
myMeshFileTransform = null;
break;
}
case Sphere:
{
double radius = myPointRadiusField.getDoubleValue();
int slices = myPointSlicesField.getIntValue();
myMesh = MeshFactory.createSphere(radius, slices);
myMeshFileName = null;
myMeshFileTransform = null;
break;
}
case Mesh:
{
String meshFileName = myMeshFileField.getStringValue();
AffineTransform3dBase xform = myMeshXformWidget.getTransformValue();
// if (xform instanceof RigidTransform3d) {
// System.out.println ("xform.p=" + ((RigidTransform3d)xform).p);
// }
// set these to null, then override below as appropriate
myMesh = null;
myMeshFileName = null;
myMeshFileTransform = null;
if (myFileMesh != null) {
if (xform.isIdentity()) {
myMesh = myFileMesh;
} else {
myMesh = myFileMesh.copy();
myMesh.transform(xform);
}
}
if (meshFileName != null && meshFileName.length() > 0) {
myMeshFileName = meshFileName;
if (!xform.isIdentity()) {
myMeshFileTransform = xform;
}
}
break;
}
default:
{
throw new InternalErrorException("unimplemented geometry type: " + type);
}
}
updateDensityAndInertia();
if (myAttachedBody != null && myMesh != null) {
// don't update the body unless we need to ...
if (myMesh != myAttachedBody.getMesh() || !objectsEqual(myMeshFileName, myAttachedBody.getMeshFileName()) || !objectsEqual(myMeshFileTransform, myAttachedBody.getMeshFileTransform())) {
myAttachedBody.setMesh(myMesh, myMeshFileName, myMeshFileTransform);
Main.getMain().rerender();
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class GeometryInertiaPanel method rebuildGeometryWidgets.
/**
* Called once at panel creation, and then whenever the geometry type is
* changed (via the GeometrySelection widget). It rebuilds the panel to
* include the widgets appropriate to the geometry.
*/
private void rebuildGeometryWidgets(GeometryType type) {
for (LabeledControl w : myGeometryWidgets) {
removeWidget(w);
}
myGeometryWidgets.clear();
switch(type) {
case Box:
{
myGeometryWidgets.add(myBoxWidthsField);
break;
}
case Sphere:
{
myGeometryWidgets.add(myPointRadiusField);
myGeometryWidgets.add(myPointSlicesField);
break;
}
case Mesh:
{
myGeometryWidgets.add(myMeshFileField);
myGeometryWidgets.add(myMeshXformWidget.getScaleField());
myGeometryWidgets.add(myMeshXformWidget.getTranslationField());
myGeometryWidgets.add(myMeshXformWidget.getRotationField());
break;
}
default:
{
throw new InternalErrorException("unimplemented geometry type: " + type);
}
}
int idx = GuiUtils.indexOfComponent(this, myGeometrySelector) + 1;
for (LabeledControl w : myGeometryWidgets) {
addWidget(w, idx++);
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class ReadlinePanel method backwardKillLine.
protected void backwardKillLine() {
int begOffs = getLineStart();
int offs = getCaretPosition();
if (begOffs < offs) {
try {
myKillBuffer = getText(begOffs, offs - begOffs);
doDelete(begOffs, offs);
} catch (BadLocationException ble) {
throw new InternalErrorException("bad location");
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class TimelineController method deleteTrack.
void deleteTrack(int trackType, int trackIndex, boolean requireConfirm) {
if (!requireConfirm || confirmAction("Delete this track?")) {
// delete everything associated with the track to be deleted,
// also, remove it from this model's track list
Track track = null;
if (trackType == Track.TYPE_INPUT) {
track = myInTracks.remove(trackIndex);
updateTrackIndices(myInTracks);
} else if (trackType == Track.TYPE_OUTPUT) {
track = myOutTracks.remove(trackIndex);
updateTrackIndices(myOutTracks);
} else {
throw new InternalErrorException("Unimplemented track type: " + trackType);
}
track.dispose();
rebuildTimeline();
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class ComponentPropertyField method valueToTextArray.
protected String[] valueToTextArray(Object value) {
ModelComponent comp = getComponent(value);
RootModel root = myMain.getRootModel();
String compStr = "/";
String propStr = "";
if (root == null || comp == null) {
return new String[] { "", "" };
}
if (value instanceof ModelComponent) {
compStr = ComponentUtils.getPathName(root, comp);
} else if (value instanceof Property) {
Property prop = (Property) value;
boolean excludeLeaf = (myPropertySelector != null && !(prop.get() instanceof CompositeProperty));
String path = ComponentUtils.getPropertyPathName(prop, root, false);
int idx = path.indexOf(':');
// default to root
propStr = path;
if (idx >= 0) {
compStr = path.substring(0, idx);
if (idx < path.length() - 1) {
propStr = path.substring(idx + 1);
}
}
} else {
throw new InternalErrorException("Unknown value type: " + value.getClass());
}
return new String[] { compStr, propStr };
}
Aggregations