Search in sources :

Example 6 with PropertyDialog

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

the class MenuBarHandler method showPullControllerPropertyDialog.

private void showPullControllerPropertyDialog() {
    if (myPullControllerPropertyDialog == null) {
        PullController pc = myMain.getPullController();
        PropertyPanel panel = new PropertyPanel();
        PropertyDialog dialog = new PropertyDialog("PullController properties", panel, "OK");
        dialog.addWidget(pc, "stiffness");
        dialog.locateRight(myMain.getFrame());
        // dialog.setSynchronizeObject(myMain.getRootModel());
        dialog.addWindowListener(new WindowAdapter() {

            public void windowClosed(WindowEvent e) {
                myPullControllerPropertyDialog = null;
            }
        });
        myMain.registerWindow(dialog);
        myPullControllerPropertyDialog = dialog;
        dialog.pack();
        dialog.setVisible(true);
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) PullController(artisynth.core.workspace.PullController) PropertyPanel(maspack.widgets.PropertyPanel)

Example 7 with PropertyDialog

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

the class SelectionPopup method createPropertyDialog.

public void createPropertyDialog(Collection<? extends ModelComponent> selectedItems) {
    HostList hostList = new HostList(selectedItems);
    PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
    true);
    tree.removeDescendant("renderProps");
    if (tree.numChildren() == 0) {
        JOptionPane.showMessageDialog(myParentGUIComponent, "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 (myLocatePropEditClose) {
            GuiUtils.locateRelative(propDialog, myLastBounds, 0.5, 0.5, 0, 0.5);
        } else {
            propDialog.locateRight(myMain.getFrame());
        }
        // propDialog.setSynchronizeObject (myMain.getRootModel());
        myMain.registerWindow(propDialog);
        propDialog.setTitle("Properties for " + getNameForSelection(selectedItems));
        propDialog.setVisible(true);
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList)

Example 8 with PropertyDialog

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

the class MeshThicken method actionPerformed.

public void actionPerformed(ActionEvent evt) {
    String cmd = evt.getActionCommand();
    if (cmd.equals("Load mesh ...")) {
        if (myMeshFile != null) {
            myMeshChooser.setSelectedFile(myMeshFile);
        }
        int retVal = myMeshChooser.showOpenDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myMeshChooser.getSelectedFile();
            try {
                loadMesh(file, /*vertexSkip=*/
                1);
            } catch (Exception e) {
                showError("Can't load mesh", e);
            }
        }
    } else if (cmd.equals("Save mesh")) {
        saveMesh(myMeshFile);
    } else if (cmd.equals("Save mesh as ...")) {
        if (myMeshFile != null) {
            myMeshChooser.setSelectedFile(myMeshFile);
        }
        int retVal = myMeshChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myMeshChooser.getSelectedFile();
            if (!file.exists() || confirmOverwrite(file)) {
                try {
                    saveMesh(file);
                } catch (Exception e) {
                    showError("Can't save mesh", e);
                }
            }
        }
    } else if (cmd.equals("Clear regions")) {
        clearRegions();
    } else if (cmd.equals("Load regions ...")) {
        if (myRegionFile != null) {
            myRegionChooser.setSelectedFile(myRegionFile);
        }
        int retVal = myRegionChooser.showOpenDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myRegionChooser.getSelectedFile();
            try {
                loadRegions(file);
            } catch (Exception e) {
                showError("Can't load regions", e);
            }
        }
    } else if (cmd.equals("Save regions")) {
        saveRegions(myRegionFile);
    } else if (cmd.equals("Save regions as ...")) {
        if (myRegionFile != null) {
            myRegionChooser.setSelectedFile(myRegionFile);
        }
        int retVal = myRegionChooser.showSaveDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myRegionChooser.getSelectedFile();
            if (!file.exists() || confirmOverwrite(file)) {
                try {
                    saveRegions(file);
                } catch (Exception e) {
                    showError("Can't save regions", e);
                }
            }
        }
    } else if (cmd.equals("Grow")) {
        PolygonalMesh pmesh = (PolygonalMesh) myMesh;
        applyGrowth(pmesh, myGrowLength);
    } else if (cmd.equals("Remesh")) {
        PolygonalMesh pmesh = (PolygonalMesh) myMesh;
        applyRemesh(pmesh, myRemeshRes);
    } else if (cmd.equals("Thicken")) {
        for (Region region : myRegions) {
            applyThickening(region, myMesh, region.getThickening());
        }
    } else if (cmd.equals("Unthicken")) {
        for (Region region : myRegions) {
            applyThickening(region, myMesh, -region.getUnthickening());
        }
    } else if (cmd.equals("Reverse thicken")) {
        for (Region region : myRegions) {
            applyThickening(region, myMesh, -region.getThickening());
        }
    } else if (cmd.equals("Reverse unthicken")) {
        for (Region region : myRegions) {
            applyThickening(region, myMesh, region.getUnthickening());
        }
    } else if (cmd.equals("Smooth")) {
        PolygonalMesh pmesh = (PolygonalMesh) myMesh;
        LaplacianSmoother.smooth(pmesh, mySmoothingCount, mySmoothingLambda, mySmoothingMu);
        pmesh.notifyVertexPositionsModified();
        viewer.rerender();
    } else if (cmd.equals("Hide all regions")) {
        for (Region region : myRegions) {
            region.setVisible(false);
        }
        viewer.rerender();
    } else if (cmd.equals("Hide regions")) {
        for (Region region : getSelectedRegions()) {
            region.setVisible(false);
        }
        viewer.rerender();
    } else if (cmd.equals("Show all regions")) {
        for (Region region : myRegions) {
            region.setVisible(true);
        }
        viewer.rerender();
    } else if (cmd.equals("Edit MeshThicken properties ...")) {
        ArrayList<HasProperties> list = new ArrayList<HasProperties>();
        list.add(this);
        PropertyDialog dialog = PropertyDialog.createDialog("MeshThicken properties", list, "OK Cancel", viewer.getCanvas().getComponent(), myRerenderListener);
        if (dialog != null) {
            dialog.setVisible(true);
        }
    } else if (cmd.equals("Edit region properties ...")) {
        PropertyDialog dialog = PropertyDialog.createDialog("Region properties", getSelectedRegions(), "OK Cancel", viewer.getCanvas().getComponent(), myRerenderListener);
        if (dialog != null) {
            dialog.setVisible(true);
        }
    } else if (cmd.equals("Edit mesh render properties ...")) {
        PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(myMesh.getRenderProps())), "Done");
        dialog.locateRight(this);
        dialog.addGlobalValueChangeListener(myRerenderListener);
        dialog.setVisible(true);
    } else if (cmd.equals("Quit")) {
        System.exit(0);
    } else {
        super.actionPerformed(evt);
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) RenderPropsPanel(maspack.widgets.RenderPropsPanel) ArrayList(java.util.ArrayList) HasProperties(maspack.properties.HasProperties) File(java.io.File) PolygonalMesh(maspack.geometry.PolygonalMesh) IOException(java.io.IOException)

Example 9 with PropertyDialog

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

the class MeshViewer method setPropertyDialogVisible.

private void setPropertyDialogVisible(boolean visible) {
    if (isPropertyDialogVisible() != visible) {
        if (visible) {
            if (myPropertyDialog == null) {
                myPropertyDialog = new PropertyDialog("Edit properties", this, "Done");
            }
            myPropertyDialog.locateRight(this);
            myPropertyDialog.setVisible(true);
        } else {
            myPropertyDialog.setVisible(false);
        }
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog)

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