use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class FemModel3dEditor method applyAction.
public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
if (containsSingleSelection(selection, FemModel3d.class)) {
FemModel3d model = (FemModel3d) selection.get(0);
if (actionCommand == "Add FemMarkers ...") {
if (myEditManager.acquireEditLock()) {
Fem3dMarkerAgent agent = new Fem3dMarkerAgent(myMain, model);
agent.show(popupBounds);
}
} else if (actionCommand == "Rebuild surface mesh") {
rebuildSurfaceMesh(model);
} else if (actionCommand == "Add new surface mesh") {
addNewSurfaceMesh(model);
} else if (actionCommand == "Save surface mesh ...") {
EditorUtils.saveMesh(model.getSurfaceMesh(), /*Transform= */
null);
} else if (actionCommand == "Save mesh as Ansys file...") {
EditorUtils.saveMeshAsAnsysFile(model);
} else if (actionCommand == "Attach particles ...") {
if (myEditManager.acquireEditLock()) {
// XXX should be more general than this ... what if mechModel
// is a sub model?
MechModel mech = (MechModel) model.getGrandParent();
myMain.getSelectionManager().clearSelections();
AttachParticleFemAgent agent = new AttachParticleFemAgent(myMain, mech, model);
agent.show(popupBounds);
}
}
} else if (containsMultipleCommonParentSelection(selection, HexElement.class)) {
if (actionCommand == "Subdivide elements") {
FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
for (ModelComponent c : selection) {
mod.subdivideHex((HexElement) c);
}
}
}
if (actionCommand == "Rebuild surface mesh for selected elements") {
FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
rebuildSurfaceMeshForSelectedElements(mod);
} else if (actionCommand == "Add new surface mesh for selected elements") {
FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
addNewSurfaceMeshForSelectedElements(mod);
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class AddPropertyPane method readComponentField.
/**
* called when the component string field changes
*/
private void readComponentField() {
isComplete = false;
clearDimensionLabel();
// System.out.println("SET FALSE");
myParent.actionPerformed(new ActionEvent(this, 0, "Invalidate"));
// System.out.println("new value "+compNameField.getText());
Object compOrProp = myPropField.getValue();
RootModel root = Main.getMain().getRootModel();
if (compOrProp instanceof ModelComponent) {
propertyPath = ComponentUtils.getPathName(root, (ModelComponent) compOrProp);
myParent.actionPerformed(new ActionEvent(this, 0, "blank"));
} else if (compOrProp instanceof Property) {
Property prop = (Property) compOrProp;
propertyPath = ComponentUtils.getPropertyPathName(prop, root, /*excludeLeaf=*/
false);
if (!HasProperties.class.isAssignableFrom(prop.get().getClass())) {
isComplete = true;
int dim = NumericProbeEditor.GetPropDim(propertyPath);
setDimensionLabel(dim);
myParent.actionPerformed(new ActionEvent(this, 0, "PropSelected"));
normalColor = NumericProbeEditor.completedColor;
} else {
myParent.actionPerformed(new ActionEvent(this, 0, "blank"));
}
} else {
propertyPath = "";
myParent.actionPerformed(new ActionEvent(this, 0, "blank"));
}
updateAppearance();
// readFullPath(compNameField.getText());
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class NumericProbeEditor method getFullPropPath.
/**
* returns the full string path of a property by going up the hierachy and
* finding all its parent properties (if any) and component path.
*/
protected String getFullPropPath(Property prop) {
String compPath = prop.getName();
ModelComponent root = myMain.getRootModel();
Object host = prop.getHost();
// System.out.println("Looking for parent path...");
if (host instanceof CompositeProperty) {
while (host instanceof CompositeProperty) {
String name = ((CompositeProperty) host).getPropertyInfo().getName();
// System.out.println(name);
compPath = name + "." + compPath;
host = ((CompositeProperty) host).getPropertyHost();
}
String baseComp = ComponentUtils.getPathName((CompositeComponent) root, (ModelComponent) host);
compPath = baseComp + ComponentUtils.componentPropertySeparator + compPath;
} else {
compPath = ComponentUtils.getPathName((CompositeComponent) root, (ModelComponent) prop.getHost());
compPath += ComponentUtils.componentPropertySeparator + prop.getName();
}
// System.out.println("found component base path: "+compPath);
return compPath;
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class MechModelAgent method getPrototypeMap.
protected HashMap<Class, ModelComponent> getPrototypeMap() {
RootModel root = myMain.getRootModel();
if (root != null && root != myLastRootModel) {
myPrototypeMap = new HashMap<Class, ModelComponent>();
myLastRootModel = root;
}
return myPrototypeMap;
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class MotionTargetComponentAgent method selectionChanged.
public void selectionChanged(SelectionEvent e) {
ModelComponent c = e.getLastAddedComponent();
if (isValidTarget(c)) {
MotionTargetComponent comp = (MotionTargetComponent) c;
if (myState == State.SelectingTargets && !myController.getMotionSources().contains(comp) && !myController.getMotionTargets().contains(comp)) {
myController.addMotionTarget(comp, 1.0);
DoubleField widget = createTargetWidget(comp, 1.0);
myTargetPanel.addWidget(widget);
myTargetPanel.mapWidgetToComponent(widget, comp);
myTargetPanel.revalidate();
myTargetPanel.repaint();
}
// else if (myExciter.findTarget(ex) != -1)
// { mySelectedTargets.add (ex);
// }
}
}
Aggregations