Search in sources :

Example 31 with ModelComponent

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

Example 32 with ModelComponent

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());
}
Also used : RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent) ActionEvent(java.awt.event.ActionEvent) Property(maspack.properties.Property)

Example 33 with ModelComponent

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

Example 34 with ModelComponent

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

Example 35 with ModelComponent

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);
    // }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) MotionTargetComponent(artisynth.core.mechmodels.MotionTargetComponent) DoubleField(maspack.widgets.DoubleField)

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