use of maspack.widgets.RenderPropsPanel 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);
}
use of maspack.widgets.RenderPropsPanel 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);
}
}
use of maspack.widgets.RenderPropsPanel 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);
}
}
Aggregations