Search in sources :

Example 1 with PropertyDialog

use of maspack.widgets.PropertyDialog in project artisynth_core by artisynth.

the class MeshCollisionViewer method createRenderPropsPanel.

private void createRenderPropsPanel(PolygonalMesh mesh) {
    PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(mesh.getRenderProps())), "OK Cancel");
    dialog.locateRight(this);
    dialog.addGlobalValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent e) {
            viewer.rerender();
        }
    });
    dialog.setVisible(true);
}
Also used : ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) PropertyDialog(maspack.widgets.PropertyDialog) RenderPropsPanel(maspack.widgets.RenderPropsPanel)

Example 2 with PropertyDialog

use of maspack.widgets.PropertyDialog in project artisynth_core by artisynth.

the class MeshViewer method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd.equals("Edit render props")) {
        PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(myRenderProps)), "OK Cancel");
        dialog.locateRight(this);
        dialog.addGlobalValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent e) {
                for (MeshBase mesh : myMeshes) {
                    mesh.setRenderProps(myRenderProps);
                }
                viewer.rerender();
            }
        });
        myPopupManager.registerDialog(dialog);
        dialog.setVisible(true);
    } else if (cmd.equals("Edit viewer props")) {
        PropertyDialog dialog = myPopupManager.createPropertyDialog("OK Cancel");
        dialog.setVisible(true);
    } else if (cmd.equals("Quit")) {
        exit(0);
    } else if (cmd.equals("Load mesh ...")) {
        int retVal = myMeshChooser.showOpenDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myMeshChooser.getSelectedFile();
            loadMesh(file);
        }
    } else if (cmd.equals("Save mesh ...")) {
        int retVal = myMeshChooser.showOpenDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myMeshChooser.getSelectedFile();
            saveMesh(file);
        }
    } else if (cmd.equals("Show mesh selector")) {
        if (myMeshSelector == null) {
            createMeshSelector();
            myMeshSelector.setSelected(myMeshCursor);
        }
        myMeshSelector.setLocationRelativeTo(this);
        myMeshSelector.setVisible(true);
    } else if (cmd.equals("Hide mesh selector")) {
        myMeshSelector.setVisible(false);
    } else if (cmd.equals("Show property dialog ...")) {
        setPropertyDialogVisible(true);
    } else if (cmd.equals("Hide property dialog")) {
        setPropertyDialogVisible(false);
    } else if (cmd.equals("Background color")) {
        setBackgroundColor();
    } else if (cmd.equals("Perspective view")) {
        viewer.setOrthographicView(false);
    } else if (cmd.equals("Orthographic view")) {
        viewer.setOrthographicView(true);
    }
}
Also used : ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) PropertyDialog(maspack.widgets.PropertyDialog) RenderPropsPanel(maspack.widgets.RenderPropsPanel) MeshBase(maspack.geometry.MeshBase) File(java.io.File) Point(java.awt.Point)

Example 3 with PropertyDialog

use of maspack.widgets.PropertyDialog in project artisynth_core by artisynth.

the class PropertyGuiTest method main.

public static void main(String[] args) {
    TestHierarchy test = new TestHierarchy();
    LinkedList<TestNode> nodeList = new LinkedList<TestNode>();
    for (int i = 0; i < args.length; i++) {
        TestNode node = test.getNode(args[i]);
        if (node == null) {
            System.err.println("Node '" + args[i] + "' not found");
            System.exit(1);
        }
        nodeList.add(node);
    }
    // test.M1.getMaterial().setStiffness (123.0);
    System.out.println("Properties:");
    test.printAllProperties(System.out, test.recordAllProperties(test.getRoot()));
    if (nodeList.size() == 0) {
        System.err.println("Usage: java maspack.apps.PropertyGuiTest <NodeName1> <NodeName2> ... ");
        System.exit(1);
    } else if (nodeList.size() == 1) {
        HasProperties host = nodeList.get(0);
        PropertyDialog dialog = new PropertyDialog("prop panel test", host, "OK Cancel");
        dialog.setVisible(true);
        while (dialog.isVisible()) {
            try {
                Thread.sleep(100);
            } catch (Exception e) {
            // 
            }
        }
        dialog.dispose();
    } else {
        HostList hostList = new HostList((HasProperties[]) nodeList.toArray(new TestNode[0]));
        PropertyDialog dialog = new PropertyDialog("prop panel test", hostList, "OK Cancel");
        dialog.setVisible(true);
        while (dialog.isVisible()) {
            try {
                Thread.sleep(100);
            } catch (Exception e) {
            // 
            }
        }
        dialog.dispose();
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) HasProperties(maspack.properties.HasProperties) TestNode(maspack.properties.TestNode) HostList(maspack.properties.HostList) TestHierarchy(maspack.properties.TestHierarchy)

Example 4 with PropertyDialog

use of maspack.widgets.PropertyDialog in project artisynth_core by artisynth.

the class IsRenderableEditor method createPropertyDialog.

public void createPropertyDialog(Collection<? extends HasProperties> selectedItems, boolean locateClose, Rectangle popupBounds) {
    HostList hostList = new HostList(selectedItems);
    PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
    true);
    if (tree.numChildren() == 0) {
        JOptionPane.showMessageDialog(null, "No common properties for selected components", "no common properties", JOptionPane.INFORMATION_MESSAGE);
    } else {
        PropertyDialog propDialog = new PropertyDialog("Edit properties", tree, hostList, "OK Cancel LiveUpdate");
        propDialog.setScrollable(true);
        if (locateClose) {
            GuiUtils.locateRelative(propDialog, popupBounds, 0.5, 0.5, 0, 0.5);
        } else {
            propDialog.locateRight(myMain.getFrame());
        }
        // propDialog.setSynchronizeObject (myMain.getRootModel());
        myMain.registerWindow(propDialog);
        propDialog.setTitle("Properties for selected IsRenderables");
        propDialog.setVisible(true);
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList)

Example 5 with PropertyDialog

use of maspack.widgets.PropertyDialog in project artisynth_core by artisynth.

the class TimelineController method getWayPointFromUser.

/**
 * Gets waypoint information from the user and adds the waypoint to
 * the waypoint probe.
 */
public void getWayPointFromUser() {
    DoubleField myTimeField = new DoubleField("Time");
    myTimeField.addValueCheckListener(new ValueCheckListener() {

        public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
            Object val = e.getValue();
            if (val instanceof Double && ((Double) val).doubleValue() <= 0) {
                if (errMsg != null) {
                    errMsg.value = "Time value must be positive";
                }
                return Property.IllegalValue;
            } else {
                if (errMsg != null) {
                    errMsg.value = null;
                }
                return val;
            }
        }
    });
    myTimeField.setVoidValueEnabled(true);
    myTimeField.setValue(Property.VoidValue);
    IntegerField myRepeatField = new IntegerField("Repeat", 1);
    myRepeatField.setRange(1, Integer.MAX_VALUE);
    BooleanSelector myBreakpointSelector = new BooleanSelector("Breakpoint", false);
    PropertyPanel addPanel = new PropertyPanel();
    addPanel.addWidget(myTimeField);
    addPanel.addWidget(myRepeatField);
    addPanel.addWidget(myBreakpointSelector);
    PropertyDialog addDialog = new PropertyDialog(this, "Add Waypoints", addPanel, "OK Cancel");
    addDialog.setModal(true);
    GuiUtils.locateCenter(addDialog, this);
    addDialog.setVisible(true);
    if (addDialog.getReturnValue() == OptionPanel.OK_OPTION && !myTimeField.valueIsVoid()) {
        double t = myTimeField.getDoubleValue();
        for (int i = 1; i <= myRepeatField.getIntValue(); i++) {
            addWayPoint(t * i, myBreakpointSelector.getBooleanValue());
        }
        myToolBar.validateFastForward(myMain.getRootModel());
    }
}
Also used : ValueCheckListener(maspack.widgets.ValueCheckListener) ValueChangeEvent(maspack.widgets.ValueChangeEvent) StringHolder(maspack.util.StringHolder) BooleanSelector(maspack.widgets.BooleanSelector) PropertyDialog(maspack.widgets.PropertyDialog) IntegerField(maspack.widgets.IntegerField) DoubleField(maspack.widgets.DoubleField) WayPoint(artisynth.core.probes.WayPoint) PropertyPanel(maspack.widgets.PropertyPanel)

Aggregations

PropertyDialog (maspack.widgets.PropertyDialog)9 HostList (maspack.properties.HostList)3 RenderPropsPanel (maspack.widgets.RenderPropsPanel)3 ValueChangeEvent (maspack.widgets.ValueChangeEvent)3 File (java.io.File)2 HasProperties (maspack.properties.HasProperties)2 PropTreeCell (maspack.properties.PropTreeCell)2 PropertyPanel (maspack.widgets.PropertyPanel)2 ValueChangeListener (maspack.widgets.ValueChangeListener)2 WayPoint (artisynth.core.probes.WayPoint)1 PullController (artisynth.core.workspace.PullController)1 Point (java.awt.Point)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MeshBase (maspack.geometry.MeshBase)1 PolygonalMesh (maspack.geometry.PolygonalMesh)1 TestHierarchy (maspack.properties.TestHierarchy)1 TestNode (maspack.properties.TestNode)1