--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007- VTT Technical Research Centre of Finland.\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.actions;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.action.IToolBarManager;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.proconf.g3d.Activator;\r
+import org.simantics.proconf.g3d.base.ConstraintDetector;\r
+import org.simantics.proconf.g3d.base.JmeRenderingComponent;\r
+import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
+import org.simantics.proconf.g3d.common.OrbitalCamera;\r
+\r
+\r
+public abstract class ConstrainedTransformAction extends WriteInteractiveAction {\r
+ private static final ImageDescriptor LOCK_ICON = Activator.imageDescriptorFromPlugin("org.simantic.proconf.g3d", "icons/silk/lock.png");\r
+ private static final ImageDescriptor LOCK_OPEN_ICON = Activator.imageDescriptorFromPlugin("org.simantic.proconf.g3d", "icons/silk/lock_open.png");\r
+ \r
+ protected JmeRenderingComponent component;\r
+ protected OrbitalCamera camera;\r
+ \r
+ protected boolean useConstraints = false;\r
+ protected ConstraintDetector detector;\r
+ \r
+ protected Action useConstraintsAction;\r
+ \r
+ //protected IToolBarManager manager;\r
+ \r
+ public ConstrainedTransformAction(ThreeDimensionalEditorBase editor) {\r
+ super(editor, true);\r
+ component = parent.getRenderingComponent();\r
+ camera = parent.getCamera();\r
+ detector = new ConstraintDetector(parent);\r
+ useConstraintsAction = new Action("Constraints", Action.AS_CHECK_BOX) {\r
+ public void run() {\r
+ useConstraints = this.isChecked();\r
+ }\r
+\r
+ public void setChecked(boolean b) {\r
+ super.setChecked(b);\r
+ if (b) {\r
+ setImageDescriptor(LOCK_ICON);\r
+ } else {\r
+ setImageDescriptor(LOCK_OPEN_ICON);\r
+ }\r
+ }\r
+ };\r
+ useConstraintsAction.setImageDescriptor(LOCK_OPEN_ICON);\r
+\r
+ }\r
+ \r
+ @Override\r
+ public void deactivate() {\r
+ detector.clearConstraintHighlights();\r
+ }\r
+ \r
+ @Override\r
+ public void fillToolBar(IToolBarManager manager) {\r
+ //this.manager = manager;\r
+ useConstraintsAction.setChecked(useConstraints);\r
+ manager.add(useConstraintsAction);\r
+ }\r
+\r
+}\r