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