Search in sources :

Example 1 with MutableCompositeComponent

use of artisynth.core.modelbase.MutableCompositeComponent in project artisynth_core by artisynth.

the class ControlPanel method removeFromParent.

private void removeFromParent() {
    if (myParent instanceof MutableCompositeComponent) {
        RemoveComponentsCommand rmCmd = new RemoveComponentsCommand("delete controlPanel", this);
        Main.getMain().getUndoManager().saveStateAndExecute(rmCmd);
    }
}
Also used : MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand)

Example 2 with MutableCompositeComponent

use of artisynth.core.modelbase.MutableCompositeComponent in project artisynth_core by artisynth.

the class SelectionPopup method duplicateSelection.

private void duplicateSelection() {
    LinkedList<ModelComponent> selection = mySelectionManager.getCurrentSelection();
    LinkedList<ModelComponent> copySelection = mySelectionManager.getCopyExpandedSelection();
    LinkedList<ModelComponent> copyList = new LinkedList<ModelComponent>();
    HashMap<ModelComponent, ModelComponent> copyMap = new HashMap<ModelComponent, ModelComponent>(copySelection.size());
    if (copySelection.size() > selection.size()) {
        for (ModelComponent c : copySelection) {
            if (!c.isSelected()) {
                mySelectionManager.addSelected(c);
            }
        }
    }
    // component are ordered with referenced components first, so we want to
    // reverse this ordering when building the add list
    LinkedList<MutableCompositeComponent<?>> parentList = new LinkedList<MutableCompositeComponent<?>>();
    for (ModelComponent c : copySelection) {
        ModelComponent copy;
        if ((copy = copyMap.get(c)) == null) {
            copy = ((CopyableComponent) c).copy(CopyableComponent.COPY_REFERENCES, copyMap);
            copyMap.put(c, copy);
            System.out.println("copying " + c);
        }
        parentList.addFirst((MutableCompositeComponent<?>) c.getParent());
        copyList.addFirst(copy);
    }
    DuplicateAgent widget = new DuplicateAgent(myMain, copyList, parentList);
    widget.show();
}
Also used : MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) DuplicateAgent(artisynth.core.gui.editorManager.DuplicateAgent) ModelComponent(artisynth.core.modelbase.ModelComponent) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList)

Example 3 with MutableCompositeComponent

use of artisynth.core.modelbase.MutableCompositeComponent in project artisynth_core by artisynth.

the class ProbeInfo method duplicateProbe.

/**
 * duplicate the probe
 */
private void duplicateProbe() {
    // don't need to supply a copyMap to copy because it won't be used
    Probe oldProbe = getProbe();
    if (!(oldProbe.getParent() instanceof MutableCompositeComponent)) {
        throw new InternalErrorException("Probe's parent is not editable");
    }
    Probe newProbe = null;
    try {
        newProbe = (Probe) getProbe().clone();
    } catch (Exception e) {
        e.printStackTrace();
        throw new InternalErrorException("Cannot clone probe of type " + getProbe().getClass());
    }
    // set start time so that probe follows right after this one ...
    double startTime = getProbe().getStartTime();
    double stopTime = getProbe().getStopTime();
    newProbe.setStartTime(stopTime);
    newProbe.setStopTime(stopTime + (stopTime - startTime));
    AddComponentsCommand cmd = new AddComponentsCommand("duplicate probe", newProbe, (MutableCompositeComponent) oldProbe.getParent());
    getMain().getUndoManager().saveStateAndExecute(cmd);
    SelectionManager selman = getMain().getSelectionManager();
    selman.removeSelected(oldProbe);
    selman.addSelected(newProbe);
// myController.deselectAllProbes(); XXX need to fix?
}
Also used : SelectionManager(artisynth.core.gui.selectionManager.SelectionManager) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) AddComponentsCommand(artisynth.core.gui.editorManager.AddComponentsCommand) InternalErrorException(maspack.util.InternalErrorException) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) WayPointProbe(artisynth.core.probes.WayPointProbe) Probe(artisynth.core.probes.Probe) NumericInputProbe(artisynth.core.probes.NumericInputProbe) InternalErrorException(maspack.util.InternalErrorException) IOException(java.io.IOException)

Example 4 with MutableCompositeComponent

use of artisynth.core.modelbase.MutableCompositeComponent in project artisynth_core by artisynth.

the class MechModelAgent method createAndAddMechModel.

private void createAndAddMechModel() {
    MechModel model = new MechModel();
    setProperties(model, getPrototypeComponent(myComponentType));
    // update properties in the prototype as well ...
    setProperties(myPrototype, myPrototype);
    addComponent(new AddComponentsCommand("add MechModel", model, (MutableCompositeComponent<?>) myRootModel.models()));
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent)

Example 5 with MutableCompositeComponent

use of artisynth.core.modelbase.MutableCompositeComponent in project artisynth_core by artisynth.

the class RigidBodyAgent method actionPerformed.

public void actionPerformed(ActionEvent evt) {
    String cmd = evt.getActionCommand();
    if (cmd.equals("Add")) {
        ViewerManager viewerMan = myMain.getWorkspace().getViewerManager();
        viewerMan.removeRenderable(body);
        viewerMan.removeDragger(rotator);
        rotator = null;
        setProperties(body, getPrototypeComponent(myComponentType));
        // basicPropTree.setTreeValuesInHost (
        // body, getPrototypeComponent (myComponentType));
        // myPropTree.setTreeValuesInHost (
        // body, getPrototypeComponent (myComponentType));
        setProperties(myPrototype, myPrototype);
        myGeometryPanel.setBodyInertia(body);
        body.setRenderProps(body.createRenderProps());
        addComponent(new AddComponentsCommand("add RigidBody", body, (MutableCompositeComponent<?>) myModel.rigidBodies()));
        myDisplay.setVisible(false);
        dispose();
    } else if (cmd.equals("Clear")) {
        maskAllValueChangeListeners(true);
        positionField.setVoidValueEnabled(true);
        positionField.setValue(Property.VoidValue);
        positionField.setVoidValueEnabled(false);
        resetScaling();
        myGeometryPanel.restoreDefaultValues();
        myHostList.restoreBackupValues();
        myPropertyPanel.updateWidgetValues();
        // boolean setDefaults = myPropTree.setSingleEditDefaultValues();
        // resetDefaultProperties();
        // if (setDefaults && myPropertyPanel != null) {
        // myPropertyPanel.updateWidgetValues(/* updateFromSource= */false);
        // }
        // moreHostList.restoreBackupValues();
        // basicHostList.restoreBackupValues ();
        // basicPropsPanel.updateWidgetValues();
        // morePropsPanel.updateWidgetValues();
        disposePreviewBody();
        if (geometrySelector.getValue() == GeometryType.Mesh) {
            fileCheck = false;
        }
        setState(State.SelectingLocation);
        maskAllValueChangeListeners(false);
    } else if (cmd.equals("Cancel")) {
        disposePreviewBody();
        myDisplay.setVisible(false);
        dispose();
    } else if (evt.getSource() == autoScaleBtn) {
        if (body != null) {
            updateScale();
        }
    } else {
        super.actionPerformed(evt);
    }
}
Also used : MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) ViewerManager(artisynth.core.driver.ViewerManager)

Aggregations

MutableCompositeComponent (artisynth.core.modelbase.MutableCompositeComponent)6 InternalErrorException (maspack.util.InternalErrorException)2 ViewerManager (artisynth.core.driver.ViewerManager)1 AddComponentsCommand (artisynth.core.gui.editorManager.AddComponentsCommand)1 DuplicateAgent (artisynth.core.gui.editorManager.DuplicateAgent)1 RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)1 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)1 BodyConnector (artisynth.core.mechmodels.BodyConnector)1 MechModel (artisynth.core.mechmodels.MechModel)1 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)1 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 NumericInputProbe (artisynth.core.probes.NumericInputProbe)1 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)1 Probe (artisynth.core.probes.Probe)1 WayPointProbe (artisynth.core.probes.WayPointProbe)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 RigidTransform3d (maspack.matrix.RigidTransform3d)1