SoBotanicVis.h
Go to the documentation of this file.00001 /* ======================================================================== 00002 * Copyright (C) 2000 Vienna University of Technology 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * For further information please contact Dieter Schmalstieg under 00019 * <schmalstieg@ims.tuwien.ac.at> or write to Dieter Schmalstieg, 00020 * Vienna University of Technology, Favoritenstr. 9-11/188, A1040 Vienna, 00021 * Austria. 00022 * ======================================================================== 00023 * PROJECT: Studierstube 00024 * ======================================================================== */ 00025 00026 /* ======================================================================= */ 00027 /** Header file for API definitions of SoBotanicVis 00028 * 00029 * @author Valerie Maquil 00030 * 00031 * $Header: 00032 * @file */ 00033 /* ======================================================================= */ 00034 00035 #ifndef SoBotanicVis_H 00036 #define SoBotanicVis_H 00037 00038 #ifdef WIN32 00039 #include <SoWinEnterScope.h> 00040 #endif 00041 00042 00043 #include <Inventor/fields/SoSFFloat.h> 00044 #include <Inventor/fields/SoSFEnum.h> 00045 #include <Inventor/fields/SoSFInt32.h> 00046 #include <Inventor/nodekits/SoBaseKit.h> 00047 #include <Inventor/sensors/SoNodeSensor.h> 00048 #include <Inventor/sensors/SoFieldSensor.h> 00049 #include <Inventor/fields/SoSFTrigger.h> 00050 #include "SoBuildBotanicAction.h" 00051 00052 00053 #ifdef WIN32 00054 #include <SoWinLeaveScope.h> 00055 #endif 00056 00057 00058 #include <string> 00059 #include "BotanicVis.h" 00060 00061 //---------------------------------------------------------------------------- 00062 00063 /** 00064 * provides means to realise a botanical visualisation of a hierarchical structure. 00065 * Therefore the information need to be structured into SoTreeNode's and SoTreeLeaf's, 00066 * where a SoTreeNode may have multiple SoTreeNode's and SoTreeLeaf's as children as in 00067 * a conventional n-ary tree. 00068 * 00069 * This structure will then be reorganized in a botanical tree where a set of leaves corresponds 00070 * to a fruit and a node corresponds to a branch. The field "numOfBranches" indicates here 00071 * the number of branching connections leaving one branch, "lengthOfBranches" indicates the 00072 * height of the SoCylinder of each branch and "thickness" specifies a scaling value for the 00073 * radius of these cylinders. 00074 * 00075 * More information on this visualisation technique can be found in the paper "Botanical 00076 * Visualization of huge hierarchies" by Ernst Kleiberg, Huub van de Wetering and Jarke 00077 * J. van Wijk on the url http://www.win.tue.nl/~vanwijk/botatree.pdf 00078 00079 CATALOG PARTS 00080 00081 All Parts 00082 <table> 00083 <tr> <td>Part Name</td><td>Part Type</td><td>Default Type</td><td>NULL Default</td></tr> 00084 <tr> <td>geometry </td><td>SoSeparator</td><td>SoSeparator</td><td>NO</td></tr> 00085 <tr> <td>treeElements </td><td>SoSeparator</td><td>SoSeparator</td><td>YES</td></tr> 00086 </table> 00087 00088 00089 File Format / defaults: 00090 00091 @verbatim 00092 SoBotanicVis { 00093 00094 SoSFInt32 numOfBranches 3 00095 SoSFFloat lengthOfBranches 10.0f 00096 SoSFFloat thickness 0.5f 00097 SoSFFloat alpha 1.0f 00098 SoSFFloat beta 1.62f #golden ratio 00099 SoSFTrigger trigger 00100 00101 } 00102 @endverbatim 00103 00104 00105 @ingroup bot 00106 */ 00107 class BOTANIC_VIS_API SoBotanicVis : public SoBaseKit 00108 { 00109 SO_KIT_HEADER(SoBotanicVis); 00110 /** 00111 * contains the geometry of the botanic tree; is build automatically 00112 */ 00113 SO_KIT_CATALOG_ENTRY_HEADER(geometry); 00114 /** 00115 * contains the conventional tree to be visualized 00116 */ 00117 SO_KIT_CATALOG_ENTRY_HEADER(treeElements); 00118 00119 public: 00120 /** 00121 * Inventor class initialization 00122 */ 00123 static void initClass(); 00124 /** 00125 * constructor 00126 */ 00127 SoBotanicVis(); 00128 00129 /** 00130 * field that has to be connected to a SoPushButton to interactively rebuild 00131 * the botanical tree 00132 */ 00133 SoSFTrigger trigger; 00134 /** 00135 * this field specifies the height of the cylinders representing the branches 00136 */ 00137 SoSFFloat lengthOfBranches; 00138 /** 00139 * scaling value for the radius of the cylinders representing the branches. 00140 * The relative value is dependent on the number of strands of each branch. 00141 */ 00142 SoSFFloat thickness; 00143 /** 00144 * this angle constitutes a reference for the rotation of each branch around 00145 * the Z-axis. 00146 */ 00147 SoSFFloat alpha; 00148 /** 00149 * The angle beta specifies a rotation angle around the Y-axis which remains 00150 * constantly during the building process. Each branch is rotated with this 00151 * angle beta to ensure a displacing of the branches and fruits 00152 */ 00153 SoSFFloat beta; 00154 /** 00155 * This field specifies how many branching connections should at most leave one 00156 * branch. 00157 */ 00158 SoSFInt32 numOfBranches; 00159 00160 /** 00161 * sets the connections of the sensors 00162 */ 00163 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE ); 00164 00165 protected: 00166 00167 /** 00168 * starts the SoBuildBotanicAction to build the botanical tree 00169 */ 00170 void buildTree(); 00171 /** 00172 * destructor 00173 */ 00174 virtual ~SoBotanicVis(); 00175 00176 /** 00177 * is used to interactively change the parameters of the tree. If TRUE, the 00178 * structure of the botanical tree need to be reformed and the action need 00179 * to be started again 00180 */ 00181 bool numOfBranchesChanged; 00182 00183 /** 00184 * this sensor detects changes of the field numOfBranches and sets the flag 00185 * numOfBranchesChanged to TRUE 00186 */ 00187 SoFieldSensor treeSensor; 00188 /** 00189 * sets the flag numOfBranchesChanged to TRUE 00190 */ 00191 static void treeSensorCB(void *data, SoSensor *sen); 00192 00193 /** 00194 * this sensor is attached to the field "trigger" 00195 */ 00196 SoFieldSensor triggerSensor; 00197 /** 00198 * is called when the field "trigger" is triggered, i.e. when the SoPushButton 00199 * coupled to this field is pressed. 00200 */ 00201 static void triggerSensorCB(void *data, SoSensor *sen); 00202 00203 }; 00204 00205 //---------------------------------------------------------------------------- 00206 00207 #endif // SoBotanicVis_H