Search in sources :

Example 46 with ModelComponent

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);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 47 with ModelComponent

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);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 48 with ModelComponent

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);
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) LabeledComponentBase(maspack.widgets.LabeledComponentBase) GenericPropertyHandle(maspack.properties.GenericPropertyHandle) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty) Point(java.awt.Point)

Example 49 with ModelComponent

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;
}
Also used : RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 50 with ModelComponent

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);
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) ArrayList(java.util.ArrayList) Point(artisynth.core.mechmodels.Point)

Aggregations

ModelComponent (artisynth.core.modelbase.ModelComponent)53 RootModel (artisynth.core.workspace.RootModel)9 Property (maspack.properties.Property)8 CompositeComponent (artisynth.core.modelbase.CompositeComponent)5 ArrayList (java.util.ArrayList)5 Point (artisynth.core.mechmodels.Point)4 Renderable (maspack.render.Renderable)4 InternalErrorException (maspack.util.InternalErrorException)4 HasCoordinateFrame (artisynth.core.modelbase.HasCoordinateFrame)3 Traceable (artisynth.core.modelbase.Traceable)3 WayPoint (artisynth.core.probes.WayPoint)3 Point (java.awt.Point)3 LinkedList (java.util.LinkedList)3 CompositeProperty (maspack.properties.CompositeProperty)3 FractionRenderType (artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)2 FemModel3d (artisynth.core.femmodels.FemModel3d)2 HexElement (artisynth.core.femmodels.HexElement)2 DirectionRenderType (artisynth.core.femmodels.MuscleBundle.DirectionRenderType)2 RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)2 ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)2