--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.proconf.g3d.shapeeditor.actions;\r
+\r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
+import org.simantics.proconf.g3d.occ.geometry.OccTriangulator;\r
+\r
+import com.jme.renderer.ColorRGBA;\r
+import com.jme.scene.Geometry;\r
+import com.jme.scene.state.MaterialState;\r
+\r
+\r
+public class LoadFileAction extends Action {\r
+ private ThreeDimensionalEditorBase editor;\r
+ \r
+ public LoadFileAction(ThreeDimensionalEditorBase editor) {\r
+ super("Load file");\r
+ this.editor = editor;\r
+ \r
+ }\r
+ \r
+ public void run() {\r
+ FileDialog loadDialog = new FileDialog(editor.getRenderingComposite().getShell(), SWT.OPEN);\r
+ String exts[] = { "*.stp;*.step", "*.iges", "*.brep", "*.ply" }; //$NON-NLS-1$\r
+ String names[] = { "STEP (AP214/AP203)", "IGES", "BREP", "PLY" }; //$NON-NLS-1$\r
+ loadDialog.setFilterNames(names);\r
+ loadDialog.setFilterExtensions(exts);\r
+ loadDialog.setText("Load model");\r
+\r
+ String filename = loadDialog.open();\r
+ if (filename != null) {\r
+ Geometry g = OccTriangulator.getGeometryFromFile(filename)[0];\r
+ MaterialState ms = editor.getRenderingComponent().getDisplaySystem().getRenderer().createMaterialState();\r
+ ms.setAmbient(new ColorRGBA(0.f,0.f,0.f,0.f));\r
+ ms.setEmissive(new ColorRGBA(0.f,0.f,0.f,0.f));\r
+ ms.setShininess(128.f);\r
+ ms.setDiffuse(new ColorRGBA(0.8f,0.8f,0.8f,0.f));\r
+ ms.setSpecular(new ColorRGBA(1.f,1.f,1.f,0.f));\r
+ ms.setMaterialFace(MaterialState.MF_FRONT_AND_BACK);\r
+ if (g.getColorBuffer(0) != null) {\r
+ ms.setColorMaterial(MaterialState.CM_DIFFUSE);\r
+ }\r
+ g.setRenderState(ms);\r
+ editor.getRenderingComponent().getShadowRoot().attachChild(g);\r
+ // mo.setGeometry(mesh, filename);\r
+ // xithComposite.getScene().compile();\r
+ }\r
+\r
+ }\r
+\r
+}\r