00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Alain Dumesny (MMM yyyy) 00025 ** Modified by : Paul Isaacs (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_LOCATE_HIGHLIGHT_ 00052 #define _SO_LOCATE_HIGHLIGHT_ 00053 00054 #include <Inventor/helpers/SbGlContextHelper.h> 00055 #include <Inventor/fields/SoSFColor.h> 00056 #include <Inventor/fields/SoSFEnum.h> 00057 #include <Inventor/nodes/SoSeparator.h> 00058 #include <Inventor/sys/SoGLType.h> 00059 00060 class SoAction; 00061 class SoHandleEventAction; 00062 class SoGLRenderAction; 00063 class SoFullPath; 00064 class SoColorPacker; 00065 00066 00068 // 00069 // Class: SoLocateHighlight 00070 // 00072 00129 class SoLocateHighlight : public SoSeparator { 00130 00131 SO_NODE_HEADER(SoLocateHighlight); 00132 00133 public: 00134 00136 enum Styles { 00140 EMISSIVE, 00144 EMISSIVE_DIFFUSE 00145 }; 00146 00148 enum Modes { 00152 AUTO, 00156 ON, 00160 OFF 00161 }; 00162 00163 // Fields 00168 SoSFColor color; 00173 SoSFEnum style; 00178 SoSFEnum mode; 00179 00183 SoLocateHighlight(); 00184 00185 private: 00186 // Override handleEvent to look for mouse motion, to do a 00187 // pick and highlight if mouse is over us. The GLRender methods 00188 // are redefined to draw highlighted if needed. 00189 virtual void handleEvent( SoHandleEventAction *action ); 00190 virtual void GLRenderBelowPath(SoGLRenderAction *action); 00191 virtual void GLRenderInPath(SoGLRenderAction *action); 00192 00193 private: 00194 static void initClass(); // initialize the class 00195 static void exitClass(); // exit the class 00196 00197 SB_THREAD_TLS_HEADER(); 00198 00199 // This will de-highlight the currently highlighted node if any. 00200 // this should be called when the cursor leaves a window or a mode 00201 // changes happen which would prevent a highlighted node from receiving 00202 // more mouse motion events. The GL render action used to render into 00203 // that window needs to be passed to correctly un-highlight. 00204 00205 static void turnOffCurrentHighlight(SoGLRenderAction *action); 00206 00207 private: 00208 virtual ~SoLocateHighlight(); 00209 00210 // This is called when this nodes needs to highlight or de-highlight. It 00211 // can be used by subclasses to be told when the status change. 00212 virtual void redrawHighlighted(SoAction *act, SbBool flag); 00213 00214 private: 00215 00216 #if defined(_WIN32) 00217 struct MTstruct { 00218 // highlighting stuff 00219 // The following info is saved when we draw a node highlighted. 00220 // VSG added the window, context, etc so we can unhighlight the 00221 // node in the same window where it was highlighted (previously 00222 // it unhighlighted the node in the current window which could 00223 // be completely different!). -- mmh March-00 00224 SoFullPath *currentHighlightPath; 00225 }; 00226 #elif defined(__APPLE__) 00227 struct MTstruct { 00228 // highlighting stuff 00229 // The following info is saved when we draw a node highlighted. 00230 // VSG added the window, context, etc so we can unhighlight the 00231 // node in the same window where it was highlighted (previously 00232 // it unhighlighted the node in the current window which could 00233 // be completely different!). -- mmh March-00 00234 SoFullPath *currentHighlightPath; 00235 SbGlContextHelper::Drawable currentWindow; 00236 SbGlContextHelper::GLContext currentContext; 00237 SbGlContextHelper::Display currentDisplay; 00238 SoGLRenderAction *currentAction; 00239 }; 00240 #else 00241 struct MTstruct { 00242 // highlighting stuff 00243 // The following info is saved when we draw a node highlighted. 00244 // VSG added the window, context, etc so we can unhighlight the 00245 // node in the same window where it was highlighted (previously 00246 // it unhighlighted the node in the current window which could 00247 // be completely different!). -- mmh March-00 00248 SoFullPath *currentHighlightPath; 00249 }; 00250 #endif 00251 00252 SbBool highlightingPass; 00253 SbBool isHighlighted(SoAction *action); 00254 SbBool preRender(SoGLRenderAction *act, GLint &oldDepthFunc); 00255 SoColorPacker *colorPacker; 00256 SbBool m_redrawAll; 00257 }; 00258 00259 00260 #endif /* _SO_LOCATE_HIGHLIGHT_ */ 00261 00262