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);
}
}
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);
}
}
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);
}
}
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);
}
}
}
Aggregations