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 : SGI (MMM YYYY) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2019 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00049 // 00050 // Description: 00051 // This is the include file for the SoSpotLightDragger. 00052 // This is a composite dragger which allows independent rotation, 00053 // translation, and beam spread editting of a spot light. 00054 // 00055 // It is composed of an SoRotateSphericalDragger (for rotation), 00056 // an SoDragPointDragger (for translation), and it creates its own projector 00057 // handles mouse events for doing it's own dragging of the beam angle. 00058 // 00059 // The beam is editted by behaving like an SoRotateDiscDragger, but the 00060 // plane of the disc is re-defined every time a drag is initiated. 00061 // The plane always passes through the z axis and the selected point. 00062 // When the rotation angle is determined, however, the beam is not rotated, 00063 // but scaled so it looks like an opening or closing umbrella. This is done 00064 // by scaling evenly in x and y, and a different amount in z, so the distance 00065 // between the selected point and the origin remains constant. 00066 // 00067 // NOTE TO DEVELOPERS: 00068 // For info about the structure of SoSpotLightDragger: 00069 // [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure 00070 // [2] type: ivNodeKitStructure SoSpotLightDragger. 00071 // [3] The program prints a diagram of the scene graph and a table with 00072 // information about each part. 00073 // 00074 // 00075 // The following parts in this dragger are created at construction time. 00076 // 'ResourceName' corresponds to the name of the default geometry for the 00077 // part. The dragger's constructor gets the scene graph for 'ResourceName' 00078 // by querying the global dictionary ( SoDB::getByName("ResourceName"); ). 00079 // 00080 // Resource Name: Part Name: 00081 // 00082 // spotLightOverallMaterial - material 00083 // 00084 // spotLightTranslatorLineTranslator - 00085 // - translator.xTranslator.translator 00086 // - translator.yTranslator.translator 00087 // - translator.zTranslator.translator 00088 // spotLightTranslatorLineTranslatorActive - 00089 // - translator.xTranslator.translatorActive 00090 // - translator.yTranslator.translatorActive 00091 // - translator.zTranslator.translatorActive 00092 // 00093 // spotLightTranslatorPlaneTranslator- 00094 // - translator.yzTranslator.translator 00095 // - translator.xzTranslator.translator 00096 // - translator.xyTranslator.translator 00097 // spotLightTranslatorPlaneTranslatorActive - 00098 // - translator.yzTranslator.translatorActive 00099 // - translator.xzTranslator.translatorActive 00100 // - translator.xyTranslator.translatorActive 00101 // 00102 // spotLightRotatorRotator - rotator.rotator 00103 // spotLightRotatorRotatorActive - rotator.rotatorActive 00104 // spotLightRotatorFeedback - rotator.feedback 00105 // spotLightRotatorFeedbackActive - rotator.feedbackActive 00106 // 00107 // spotLightBeam - beam 00108 // spotLightBeamActive - beamActive 00109 // 00110 // NOTE: This is a translation node that 00111 // moves the beam origin relative 00112 // to the rest of the dragger. 00113 // spotLightBeamPlacement - beamPlacement 00114 // 00116 00117 00118 #ifndef _SO_SPOT_LIGHT_DRAGGER_ 00119 #define _SO_SPOT_LIGHT_DRAGGER_ 00120 00121 #include <Inventor/SbLinear.h> 00122 #include <Inventor/draggers/SoDragger.h> 00123 #include <Inventor/fields/SoSFVec3f.h> 00124 #include <Inventor/fields/SoSFFloat.h> 00125 #include <Inventor/fields/SoSFRotation.h> 00126 #include <Inventor/sensors/SoSensor.h> 00127 00128 class SoFieldSensor; 00129 class SbPlaneProjector; 00130 00364 class SoSpotLightDragger : public SoDragger 00365 { 00366 SO_KIT_HEADER(SoSpotLightDragger); 00367 00368 // This gives the dragger an overall material. It is edited by lightManips 00369 // to make its dragger match the color of the light. Any materials within 00370 // other parts will override this one. 00371 SO_KIT_CATALOG_ENTRY_HEADER(material); 00372 00373 // The translator is kept under a separator along with a 00374 // rotation that is maintained as the inverse to the rotation of the 00375 // light. This means that using the rotator does not rotate the 00376 // coordinate system that we translate the base of the dragger in. 00377 SO_KIT_CATALOG_ENTRY_HEADER(translatorSep); 00378 SO_KIT_CATALOG_ENTRY_HEADER(translatorRotInv); 00379 SO_KIT_CATALOG_ENTRY_HEADER(translator); 00380 SO_KIT_CATALOG_ENTRY_HEADER(rotator); 00381 // Beneath a separator, the beamPlacement part places the beam's local 00382 // space relative to the other parts. 00383 // The beamSwitch is flipped when the beam is dragged. 00384 SO_KIT_CATALOG_ENTRY_HEADER(beamSep); 00385 SO_KIT_CATALOG_ENTRY_HEADER(beamPlacement); 00386 SO_KIT_CATALOG_ENTRY_HEADER(beamScale); 00387 SO_KIT_CATALOG_ENTRY_HEADER(beamSwitch); 00388 SO_KIT_CATALOG_ENTRY_HEADER(beam); 00389 SO_KIT_CATALOG_ENTRY_HEADER(beamActive); 00390 00391 public: 00395 SoSpotLightDragger(); 00396 00401 SoSFRotation rotation; 00406 SoSFVec3f translation; 00411 SoSFFloat angle; 00412 00413 private: 00414 static void initClass(); // Initialize the class. 00415 static void exitClass(); 00416 00417 private: 00418 00419 SbPlaneProjector *planeProj; // used during interaciton with beam 00420 00421 static void startCB( void *, SoDragger * ); 00422 static void motionCB( void *, SoDragger * ); 00423 static void doneCB( void *, SoDragger * ); 00424 00425 void dragStart(); 00426 void drag(); 00427 void dragFinish(); 00428 00429 SoFieldSensor *rotFieldSensor; 00430 SoFieldSensor *translFieldSensor; 00431 SoFieldSensor *angleFieldSensor; 00432 static void fieldSensorCB( void *, SoSensor * ); 00433 static void valueChangedCB( void *, SoDragger * ); 00434 00435 // Returns scaleFactor for beamScale part to display beamAngle. 00436 void setBeamScaleFromAngle(float beamAngle); 00437 00438 // detach/attach any sensors, callbacks, and/or field connections. 00439 // Also set geometry of childDraggers to be our default instead of their 00440 // regular default, using our resources. 00441 // Called by: start/end of SoBaseKit::readInstance 00442 // and on new copy by: start/end of SoBaseKit::copy. 00443 // Classes that redefine must call setUpConnections(TRUE,TRUE) 00444 // at end of constructor. 00445 // Returns the state of the node when this was called. 00446 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00447 00448 virtual void setDefaultOnNonWritingFields(); 00449 00450 virtual ~SoSpotLightDragger(); 00451 00452 private: 00453 static const char geomBuffer[]; 00454 }; 00455 00456 #endif /* _SO_SPOT_LIGHT_DRAGGER_ */ 00457 00458