1 /*******************************************************************************
\r
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.proconf.g3d.dialogs;
\r
13 import org.eclipse.jface.dialogs.Dialog;
\r
14 import org.eclipse.jface.dialogs.IDialogConstants;
\r
15 import org.eclipse.swt.SWT;
\r
16 import org.eclipse.swt.events.MouseAdapter;
\r
17 import org.eclipse.swt.events.MouseEvent;
\r
18 import org.eclipse.swt.events.SelectionAdapter;
\r
19 import org.eclipse.swt.events.SelectionEvent;
\r
20 import org.eclipse.swt.graphics.Color;
\r
21 import org.eclipse.swt.graphics.RGB;
\r
22 import org.eclipse.swt.layout.GridData;
\r
23 import org.eclipse.swt.widgets.Button;
\r
24 import org.eclipse.swt.widgets.ColorDialog;
\r
25 import org.eclipse.swt.widgets.Composite;
\r
26 import org.eclipse.swt.widgets.Control;
\r
27 import org.eclipse.swt.widgets.Label;
\r
28 import org.eclipse.swt.widgets.Shell;
\r
30 public class JMEDialog extends Dialog {
\r
31 private boolean bounds;
\r
32 private boolean normals;
\r
33 private boolean wireframe;
\r
34 private float[] floatColor = null;
\r
35 private Button boundsButton;
\r
36 private Button normalsButton;
\r
37 private Button wireframeButton;
\r
38 private Composite colorComposite;
\r
39 private Color color = null;
\r
41 public JMEDialog(Shell parentShell) {
\r
47 protected void configureShell(Shell newShell) {
\r
48 super.configureShell(newShell);
\r
49 newShell.setText("Configure new pipeline");
\r
53 protected Control createDialogArea(Composite parent) {
\r
54 Composite composite = (Composite) super.createDialogArea(parent);
\r
55 Label label = new Label(composite, SWT.WRAP);
\r
56 label.setText("JME Configuration");
\r
57 GridData data = new GridData(GridData.GRAB_HORIZONTAL
\r
58 | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
\r
59 | GridData.VERTICAL_ALIGN_CENTER);
\r
61 data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
\r
62 boundsButton = new Button(composite,SWT.CHECK);
\r
63 boundsButton.setText("Show bounds");
\r
64 boundsButton.addSelectionListener(new SelectionAdapter() {
\r
66 public void widgetSelected(SelectionEvent e) {
\r
67 bounds = boundsButton.getSelection();
\r
70 boundsButton.setSelection(bounds);
\r
71 normalsButton = new Button(composite,SWT.CHECK);
\r
72 normalsButton.setText("Show normals");
\r
73 normalsButton.addSelectionListener(new SelectionAdapter() {
\r
75 public void widgetSelected(SelectionEvent e) {
\r
76 normals = normalsButton.getSelection();
\r
79 normalsButton.setSelection(normals);
\r
80 wireframeButton = new Button(composite,SWT.CHECK);
\r
81 wireframeButton.setText("Show wireframe");
\r
82 wireframeButton.addSelectionListener(new SelectionAdapter() {
\r
84 public void widgetSelected(SelectionEvent e) {
\r
85 wireframe = wireframeButton.getSelection();
\r
88 wireframeButton.setSelection(wireframe);
\r
90 colorComposite = new Composite(composite,SWT.BORDER);
\r
91 colorComposite.addMouseListener(new MouseAdapter() {
\r
93 public void mouseUp(MouseEvent e) {
\r
94 ColorDialog dialog = new ColorDialog(JMEDialog.this.getShell());
\r
95 RGB rgb = dialog.open();
\r
99 color = new Color(JMEDialog.this.getShell().getDisplay(),rgb);
\r
100 colorComposite.setBackground(color);
\r
101 floatColor = new float[]{rgb.red/255.f,rgb.green/255.f,rgb.blue/255.f};
\r
111 public int open() {
\r
112 return super.open();
\r
116 public boolean isBounds() {
\r
121 public void setBounds(boolean bounds) {
\r
122 this.bounds = bounds;
\r
126 public boolean isNormals() {
\r
131 public void setNormals(boolean normals) {
\r
132 this.normals = normals;
\r
136 public boolean isWireframe() {
\r
141 public void setWireframe(boolean wireframe) {
\r
142 this.wireframe = wireframe;
\r
146 public float[] getFloatColor() {
\r
150 public void setFloatColor(float[] c) {
\r
151 this.floatColor = c;
\r
152 if (floatColor == null)
\r
158 private void updateColor() {
\r
159 if (colorComposite == null)
\r
163 RGB rgb = new RGB((int)(floatColor[0]*255.f),(int)(floatColor[1]*255.f),(int)(floatColor[2]*255.f));
\r
164 color = new Color(JMEDialog.this.getShell().getDisplay(),rgb);
\r
165 colorComposite.setBackground(color);
\r