Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91,92 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | This file defines the two dimensional translate dragger class. 00048 | This is a simple dragger that allows an object to 00049 | be translated within a plane. (defined by the plane normal (default 00050 | normal is (0,0,1) and by the point initially hit by the user). 00051 | 00052 | If the user presses the SHIFT key while dragging, the motion will 00053 | constrain to linear motion along one of the two main axes of motion. 00054 | The axis selected will be the primary axis followed by the user's 00055 | dragging gesture. 00056 | 00057 | The amount moved in the plane determines the translation. 00058 | 00059 | NOTE TO DEVELOPERS: 00060 | For info about the structure of SoTranslate2Dragger: 00061 | [1] compile: /usr/share/src/Inventor/samples/ivNodeKitStructure 00062 | [2] type: ivNodeKitStructure SoTranslate2Dragger. 00063 | [3] The program prints a diagram of the scene graph and a table with 00064 | information about each part. 00065 | 00066 | The following parts in this dragger are created at construction time. 00067 | 'ResourceName' corresponds to the name of the default geometry for the 00068 | part. The dragger's constructor gets the scene graph for 'ResourceName' 00069 | by querying the global dictionary ( SoDB::getByName("ResourceName"); ). 00070 | 00071 | Resource Name: Part Name: 00072 | 00073 | translate2Translator - translator 00074 | translate2TranslatorActive - translatorActive 00075 | translate2Feedback - feedback 00076 | translate2FeedbackActive - feedbackActive 00077 | 00078 | NOTE: These are only shown if dragger 00079 | is moving and the axis is a 00080 | permissable direction of motion. 00081 | When pressing <shift>, motion is 00082 | constrained, and only 1 is displayed. 00083 | translate2XAxisFeedback - xAxisFeedback 00084 | translate2YAxisFeedback - yAxisFeedback 00085 | 00086 | Author(s): Paul Isaacs, Howard Look 00087 | 00088 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00089 _______________________________________________________________________ 00090 */ 00091 00092 #ifndef _SO_TRANSLATE_2_DRAGGER_ 00093 #define _SO_TRANSLATE_2_DRAGGER_ 00094 00095 #include <Inventor/SbLinear.h> 00096 #include <Inventor/draggers/SoDragger.h> 00097 #include <Inventor/fields/SoSFVec3f.h> 00098 #include <Inventor/sensors/SoSensor.h> 00099 00100 class SbDict; 00101 class SbPlaneProjector; 00102 class SoFieldSensor; 00103 00106 00169 00170 00171 class INVENTOR_API SoTranslate2Dragger : public SoDragger 00172 { 00173 SO_KIT_HEADER(SoTranslate2Dragger); 00174 00175 SO_KIT_CATALOG_ENTRY_HEADER(translatorSwitch); 00176 SO_KIT_CATALOG_ENTRY_HEADER(translator); 00177 SO_KIT_CATALOG_ENTRY_HEADER(translatorActive); 00178 SO_KIT_CATALOG_ENTRY_HEADER(feedbackSwitch); 00179 SO_KIT_CATALOG_ENTRY_HEADER(feedback); 00180 SO_KIT_CATALOG_ENTRY_HEADER(feedbackActive); 00181 SO_KIT_CATALOG_ENTRY_HEADER(axisFeedbackSwitch); 00182 SO_KIT_CATALOG_ENTRY_HEADER(xAxisFeedback); 00183 SO_KIT_CATALOG_ENTRY_HEADER(yAxisFeedback); 00184 00185 public: 00186 00188 SoTranslate2Dragger(); 00189 00190 SoSFVec3f translation; 00191 00192 SoINTERNAL public: 00193 static void initClass(); 00194 00195 protected: 00196 00197 SbVec3f worldRestartPt; 00198 00199 SbPlaneProjector *planeProj; 00200 00201 static void startCB( void *, SoDragger * ); 00202 static void motionCB( void *, SoDragger * ); 00203 static void finishCB( void *, SoDragger * ); 00204 00205 SoFieldSensor *fieldSensor; 00206 static void fieldSensorCB( void *, SoSensor * ); 00207 static void valueChangedCB( void *, SoDragger * ); 00208 00209 void dragStart(); 00210 void drag(); 00211 void dragFinish(); 00212 00214 static void metaKeyChangeCB( void *, SoDragger *); 00215 00222 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00223 00224 virtual ~SoTranslate2Dragger(); 00225 00226 private: 00227 int translateDir; 00228 SbBool shftDown; 00229 00230 static const char geomBuffer[]; 00231 }; 00232 00233 #endif /* _SO_TRANSLATE_2_DRAGGER_ */ 00234 00235 00236