use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class SelectableComponentPanel method selectWidget.
public void selectWidget(JComponent widget) {
super.selectWidget(widget);
ModelComponent comp = myWidgetComponentMap.get(widget);
if (mySelectionManager != null && comp != null && !comp.isSelected()) {
mySelectionManager.addSelected(comp);
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class SelectableComponentPanel method deselectWidget.
public void deselectWidget(JComponent widget) {
super.deselectWidget(widget);
ModelComponent comp = myWidgetComponentMap.get(widget);
if (mySelectionManager != null && comp != null && comp.isSelected()) {
mySelectionManager.removeSelected(comp);
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class ControlPanel method getSoftReferences.
@Override
public void getSoftReferences(List<ModelComponent> refs) {
HashSet<ModelComponent> myrefs = new HashSet<ModelComponent>();
for (int i = 0; i < myPanel.numWidgets(); i++) {
if (myPanel.getWidget(i) instanceof LabeledComponentBase) {
LabeledComponentBase widget = (LabeledComponentBase) myPanel.getWidget(i);
Property prop = myPanel.getWidgetProperty(widget);
if (prop instanceof GenericPropertyHandle) {
ModelComponent comp = ComponentUtils.getPropertyComponent(prop);
if (comp != null && !ComponentUtils.isAncestorOf(comp, this)) {
myrefs.add(comp);
}
} else {
// TODO - handle other cases
}
}
}
refs.addAll(myrefs);
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class ControlPanel method isStale.
private boolean isStale(Property prop) {
ModelComponent comp = ComponentUtils.getPropertyComponent(prop);
if (comp == null) {
System.out.println("no comp");
return true;
}
if (!PropertyUtils.isConnectedToHierarchy(prop)) {
System.out.println("not connected");
return true;
}
RootModel myroot = RootModel.getRoot(this);
// we don't bother with the stale check
if (myroot != null && RootModel.getRoot(comp) != myroot) {
System.out.println("not in root");
return true;
}
return false;
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class PointSkinAttachment method updateReferences.
/**
* {@inheritDoc}
*/
@Override
public void updateReferences(boolean undo, Deque<Object> undoInfo) {
if (undo) {
Object obj = undoInfo.removeFirst();
if (obj != NULL_OBJ) {
myConnections = (Connection[]) obj;
myNumConnections = myConnections.length;
myMasters = null;
}
} else {
ArrayList<Connection> updated = new ArrayList<Connection>();
// total original weight of all base connections
double wbaseOld = 0;
// total weight of all removed displacement connections
double wdispDel = 0;
for (int i = 0; i < myNumConnections; i++) {
Connection c = myConnections[i];
ModelComponent m = c.getMaster();
if (m == null || ComponentUtils.isConnected(this, m)) {
updated.add(c);
if (c instanceof BaseConnection) {
wbaseOld += c.myWeight;
}
} else {
if (c instanceof FemDisplacementConnection) {
wdispDel += c.getWeight();
}
}
}
if (updated.size() < myNumConnections) {
Connection[] old = new Connection[myNumConnections];
for (int i = 0; i < myNumConnections; i++) {
old[i] = myConnections[i].copy();
}
// updated.clear();
// updated.add (new BaseConnection (1));
myConnections = updated.toArray(new Connection[0]);
myNumConnections = myConnections.length;
// 1.
if (wbaseOld != 0) {
scaleBaseWeights((wbaseOld - wdispDel) / wbaseOld, myConnections);
}
double wtotal = 0;
for (int i = 0; i < myNumConnections; i++) {
Connection c = myConnections[i];
if (!(c instanceof FemDisplacementConnection)) {
wtotal += c.myWeight;
}
}
for (int i = 0; i < myNumConnections; i++) {
Connection c = myConnections[i];
c.myWeight /= wtotal;
}
myMasters = null;
undoInfo.addLast(old);
} else {
undoInfo.addLast(NULL_OBJ);
}
}
}
Aggregations