Search in sources :

Example 66 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class FemModel3dAgent method initializePrototype.

protected void initializePrototype(ModelComponent comp, Class type) {
    if (type == FemModel3d.class) {
        FemModel3d mkr = (FemModel3d) comp;
        RenderProps.setPointRadius(mkr, getDefaultPointRadius());
    } else {
        throw new InternalErrorException("Unimplemented type " + type);
    }
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) InternalErrorException(maspack.util.InternalErrorException)

Example 67 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class RigidBodyConnectorList method createAndAddConnector.

private void createAndAddConnector(Point3d origin) {
    BodyConnector connector;
    RigidTransform3d TCW = new RigidTransform3d();
    TCW.R.set(myBodyA.getPose().R);
    TCW.p.set(origin);
    RigidTransform3d TCA = new RigidTransform3d();
    TCA.mulInverseLeft(myBodyA.getPose(), TCW);
    if (myComponentType == RevoluteJoint.class) {
        RevoluteJoint joint;
        if (myBodyB == null) {
            joint = new RevoluteJoint(myBodyA, TCA, TCW);
        } else {
            RigidTransform3d TCB = new RigidTransform3d();
            TCB.mulInverseLeft(myBodyB.getPose(), TCW);
            joint = new RevoluteJoint(myBodyA, TCA, myBodyB, TCB);
        }
        connector = joint;
    } else if (myComponentType == SphericalJoint.class) {
        SphericalJoint joint;
        if (myBodyB == null) {
            joint = new SphericalJoint(myBodyA, TCA, TCW);
        } else {
            RigidTransform3d TCB = new RigidTransform3d();
            TCB.mulInverseLeft(myBodyB.getPose(), TCW);
            joint = new SphericalJoint(myBodyA, TCA, myBodyB, TCB);
        }
        connector = joint;
    } else {
        throw new InternalErrorException("Unimplemented connector type " + myComponentType);
    }
    connector.setName(getNameFieldValue());
    setProperties(connector, getPrototypeComponent(myComponentType));
    // update properties in the prototype as well ...
    setProperties(myPrototype, myPrototype);
    addComponent(new AddComponentsCommand("add BodyConnector", connector, (MutableCompositeComponent<?>) myModel.bodyConnectors()));
    setState(State.Complete);
    myMain.setSelectionMode(Main.SelectionMode.Translate);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) SphericalJoint(artisynth.core.mechmodels.SphericalJoint) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) InternalErrorException(maspack.util.InternalErrorException) BodyConnector(artisynth.core.mechmodels.BodyConnector)

Example 68 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class SelectionPopup method addTracing.

private void addTracing(LinkedList<ModelComponent> selectedItems) {
    // RootModel root = myMain.getRootModel();
    // String name = null;
    // double startTime = myMain.getTimeSec();
    // double updateInterval = root.getMaxStepSizeSec();
    Traceable firstTraceable = null;
    for (ModelComponent comp : selectedItems) {
        if (comp instanceof Traceable) {
            firstTraceable = (Traceable) comp;
        }
    }
    if (firstTraceable == null) {
        throw new InternalErrorException("'Add tracing' called with no traceabled in selection");
    }
    TracingProbePanel panel = new TracingProbePanel(firstTraceable, getCommonTraceables(selectedItems));
    panel.pack();
    GuiUtils.locateRelative(panel, myLastBounds, 0.5, 0.5, 0, 0.5);
    // if (myTraceItemLoc != null)
    // { panel.setLocation (
    // myTraceItemLoc.x, myTraceItemLoc.y);
    // }
    panel.setVisible(true);
    if (panel.getReturnValue() == OptionPanel.OK_OPTION) {
        for (ModelComponent comp : selectedItems) {
            if (comp instanceof Traceable) {
                TracingProbe probe = panel.createProbe((Traceable) comp);
                myMain.getRootModel().addOutputProbe(probe);
            }
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) TracingProbePanel(artisynth.core.gui.editorManager.TracingProbePanel) InternalErrorException(maspack.util.InternalErrorException) TracingProbe(artisynth.core.probes.TracingProbe) Traceable(artisynth.core.modelbase.Traceable)

Example 69 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class ReadlinePanel method killLine.

protected void killLine() {
    int offs = getCaretPosition();
    int endOffs = getLineEnd();
    if (offs < endOffs) {
        try {
            myKillBuffer = getText(offs, endOffs - offs);
            doDelete(offs, endOffs);
        } catch (BadLocationException ble) {
            throw new InternalErrorException("bad location");
        }
    }
}
Also used : InternalErrorException(maspack.util.InternalErrorException) BadLocationException(javax.swing.text.BadLocationException)

Example 70 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class ReadlinePanel method acceptLine.

// we synchronize acceptLine so that we can ensure that scripts
// don't start running while we are still in this method
protected synchronized void acceptLine() {
    String line = getLineText();
    appendText("\n");
    setHistory(0, line);
    addHistory("");
    myHistoryIdx = 0;
    myInputRequested = false;
    if (myInputWriter == null) {
        String result = processInput(line);
        if (result != null && !result.endsWith("\n")) {
            result = result + "\n";
        }
        appendText(result);
        requestInput(myPrompt);
    } else {
        try {
            myInputWriter.write(line + "\n");
            myInputWriter.flush();
        } catch (Exception e) {
            throw new InternalErrorException("Error writing to commandWriter: " + e);
        }
    }
}
Also used : InternalErrorException(maspack.util.InternalErrorException) HeadlessException(java.awt.HeadlessException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) InternalErrorException(maspack.util.InternalErrorException) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

InternalErrorException (maspack.util.InternalErrorException)92 Vector3d (maspack.matrix.Vector3d)9 CompositeProperty (maspack.properties.CompositeProperty)8 Point3d (maspack.matrix.Point3d)7 Property (maspack.properties.Property)7 FemModel3d (artisynth.core.femmodels.FemModel3d)6 Point (artisynth.core.mechmodels.Point)6 ModelComponent (artisynth.core.modelbase.ModelComponent)5 PolygonalMesh (maspack.geometry.PolygonalMesh)5 Line (maspack.matrix.Line)5 RigidTransform3d (maspack.matrix.RigidTransform3d)5 EditingProperty (maspack.properties.EditingProperty)5 BadLocationException (javax.swing.text.BadLocationException)4 RotationMatrix3d (maspack.matrix.RotationMatrix3d)4 RigidBody (artisynth.core.mechmodels.RigidBody)3 RootModel (artisynth.core.workspace.RootModel)3 File (java.io.File)3 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)2