X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fdialogs%2FJMEDialog.java;fp=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fdialogs%2FJMEDialog.java;h=9822b816654c36ec5275ce61aaa8f4a2713f121f;hb=10f144a2bb2d7bec98b812b83acecb333fd098ea;hp=0000000000000000000000000000000000000000;hpb=3055b543aa5afc0cca4bb3b341704e7c5103fa6a;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/proconf/g3d/dialogs/JMEDialog.java b/org.simantics.g3d/src/org/simantics/proconf/g3d/dialogs/JMEDialog.java new file mode 100644 index 00000000..9822b816 --- /dev/null +++ b/org.simantics.g3d/src/org/simantics/proconf/g3d/dialogs/JMEDialog.java @@ -0,0 +1,174 @@ +/******************************************************************************* + * Copyright (c) 2007- VTT Technical Research Centre of Finland. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.proconf.g3d.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +public class JMEDialog extends Dialog { + private boolean bounds; + private boolean normals; + private boolean wireframe; + private float[] floatColor = null; + private Button boundsButton; + private Button normalsButton; + private Button wireframeButton; + private Composite colorComposite; + private Color color = null; + + public JMEDialog(Shell parentShell) { + super(parentShell); + } + + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Configure new pipeline"); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + Label label = new Label(composite, SWT.WRAP); + label.setText("JME Configuration"); + GridData data = new GridData(GridData.GRAB_HORIZONTAL + | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL + | GridData.VERTICAL_ALIGN_CENTER); + + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + boundsButton = new Button(composite,SWT.CHECK); + boundsButton.setText("Show bounds"); + boundsButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + bounds = boundsButton.getSelection(); + } + }); + boundsButton.setSelection(bounds); + normalsButton = new Button(composite,SWT.CHECK); + normalsButton.setText("Show normals"); + normalsButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + normals = normalsButton.getSelection(); + } + }); + normalsButton.setSelection(normals); + wireframeButton = new Button(composite,SWT.CHECK); + wireframeButton.setText("Show wireframe"); + wireframeButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + wireframe = wireframeButton.getSelection(); + } + }); + wireframeButton.setSelection(wireframe); + + colorComposite = new Composite(composite,SWT.BORDER); + colorComposite.addMouseListener(new MouseAdapter() { + @Override + public void mouseUp(MouseEvent e) { + ColorDialog dialog = new ColorDialog(JMEDialog.this.getShell()); + RGB rgb = dialog.open(); + if (rgb != null) { + if (color != null) + color.dispose(); + color = new Color(JMEDialog.this.getShell().getDisplay(),rgb); + colorComposite.setBackground(color); + floatColor = new float[]{rgb.red/255.f,rgb.green/255.f,rgb.blue/255.f}; + } + } + }); + updateColor(); + + return composite; + } + + @Override + public int open() { + return super.open(); + } + + + public boolean isBounds() { + return bounds; + } + + + public void setBounds(boolean bounds) { + this.bounds = bounds; + } + + + public boolean isNormals() { + return normals; + } + + + public void setNormals(boolean normals) { + this.normals = normals; + } + + + public boolean isWireframe() { + return wireframe; + } + + + public void setWireframe(boolean wireframe) { + this.wireframe = wireframe; + } + + + public float[] getFloatColor() { + return floatColor; + } + + public void setFloatColor(float[] c) { + this.floatColor = c; + if (floatColor == null) + return; + + updateColor(); + } + + private void updateColor() { + if (colorComposite == null) + return; + if (color != null) + color.dispose(); + RGB rgb = new RGB((int)(floatColor[0]*255.f),(int)(floatColor[1]*255.f),(int)(floatColor[2]*255.f)); + color = new Color(JMEDialog.this.getShell().getDisplay(),rgb); + colorComposite.setBackground(color); + } + + + + + + + +}