]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/HoverHighlighter.java
Perform node map updates in a procedure instead of a request
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / common / HoverHighlighter.java
1 /*******************************************************************************
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g3d.vtk.common;
13
14 import org.eclipse.jface.viewers.ISelection;
15 import org.simantics.g3d.scenegraph.NodeHighlighter;
16 import org.simantics.g3d.scenegraph.NodeHighlighter.HighlightEventType;
17 import org.simantics.g3d.scenegraph.base.INode;
18
19 public class HoverHighlighter<DBObject> extends SelectionHighlighter<DBObject> {
20
21         public HoverHighlighter(VtkView panel, VTKNodeMap<DBObject,?> nodeMap) {
22                 super(panel, nodeMap);
23         }
24         
25         @Override
26         protected void highlight(ISelection s) {
27                 highlight(s, HighlightEventType.Hover, HighlightEventType.ClearHover);
28         }
29         
30         @Override
31         protected void hilight(INode node, HighlightEventType type) {
32                 if (node instanceof NodeHighlighter) {
33                         ((NodeHighlighter)node).highlight(type);
34                         return;
35                 }
36                 if (type == HighlightEventType.Hover) {
37                         setSelectedColor(node);
38                 } else if (type == HighlightEventType.ClearHover) {
39                         setDefaultColor(node);
40                 }
41         }
42
43         @Override
44         protected void setDefaultColor(INode node) {
45                 double color[] = new double[]{0,0,0};
46                 setColor(node, true, color);
47         }
48         
49         @Override
50         protected void setSelectedColor(INode node) {
51                 double color[] = new double[]{1,0,1};
52                 setColor(node, true, color);
53         }
54         
55 }