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-2020 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 00366 class SoSpotLightDragger : public SoDragger 00367 { 00368 SO_KIT_HEADER(SoSpotLightDragger); 00369 00370 // This gives the dragger an overall material. It is edited by lightManips 00371 // to make its dragger match the color of the light. Any materials within 00372 // other parts will override this one. 00373 SO_KIT_CATALOG_ENTRY_HEADER(material); 00374 00375 // The translator is kept under a separator along with a 00376 // rotation that is maintained as the inverse to the rotation of the 00377 // light. This means that using the rotator does not rotate the 00378 // coordinate system that we translate the base of the dragger in. 00379 SO_KIT_CATALOG_ENTRY_HEADER(translatorSep); 00380 SO_KIT_CATALOG_ENTRY_HEADER(translatorRotInv); 00381 SO_KIT_CATALOG_ENTRY_HEADER(translator); 00382 SO_KIT_CATALOG_ENTRY_HEADER(rotator); 00383 // Beneath a separator, the beamPlacement part places the beam's local 00384 // space relative to the other parts. 00385 // The beamSwitch is flipped when the beam is dragged. 00386 SO_KIT_CATALOG_ENTRY_HEADER(beamSep); 00387 SO_KIT_CATALOG_ENTRY_HEADER(beamPlacement); 00388 SO_KIT_CATALOG_ENTRY_HEADER(beamScale); 00389 SO_KIT_CATALOG_ENTRY_HEADER(beamSwitch); 00390 SO_KIT_CATALOG_ENTRY_HEADER(beam); 00391 SO_KIT_CATALOG_ENTRY_HEADER(beamActive); 00392 00393 public: 00397 SoSpotLightDragger(); 00398 00403 SoSFRotation rotation; 00408 SoSFVec3f translation; 00413 SoSFFloat angle; 00414 00415 private: 00416 static void initClass(); // Initialize the class. 00417 static void exitClass(); 00418 00419 private: 00420 00421 SbPlaneProjector *planeProj; // used during interaciton with beam 00422 00423 static void startCB( void *, SoDragger * ); 00424 static void motionCB( void *, SoDragger * ); 00425 static void doneCB( void *, SoDragger * ); 00426 00427 void dragStart(); 00428 void drag(); 00429 void dragFinish(); 00430 00431 SoFieldSensor *rotFieldSensor; 00432 SoFieldSensor *translFieldSensor; 00433 SoFieldSensor *angleFieldSensor; 00434 static void fieldSensorCB( void *, SoSensor * ); 00435 static void valueChangedCB( void *, SoDragger * ); 00436 00437 // Returns scaleFactor for beamScale part to display beamAngle. 00438 void setBeamScaleFromAngle(float beamAngle); 00439 00440 // detach/attach any sensors, callbacks, and/or field connections. 00441 // Also set geometry of childDraggers to be our default instead of their 00442 // regular default, using our resources. 00443 // Called by: start/end of SoBaseKit::readInstance 00444 // and on new copy by: start/end of SoBaseKit::copy. 00445 // Classes that redefine must call setUpConnections(TRUE,TRUE) 00446 // at end of constructor. 00447 // Returns the state of the node when this was called. 00448 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00449 00450 virtual void setDefaultOnNonWritingFields(); 00451 00452 virtual ~SoSpotLightDragger(); 00453 00454 private: 00455 static const char geomBuffer[]; 00456 }; 00457 00458 #endif /* _SO_SPOT_LIGHT_DRAGGER_ */ 00459 00460