00001 //###################################################################### 00002 // 00003 // GraspIt! 00004 // Copyright (C) 2002-2009 Columbia University in the City of New York. 00005 // All rights reserved. 00006 // 00007 // GraspIt! is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // GraspIt! is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with GraspIt!. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // Authors: Steffen Knoop 00021 // Andrew T. Miller 00022 // 00023 // $Id: grasp_visualization.cpp,v 1.2 2009/03/25 22:10:05 cmatei Exp $ 00024 // 00025 //###################################################################### 00026 00027 /***************************************************************************/ 00028 /* FILE: grasp_visualization.cc */ 00029 /* AUTHOR: Steffen Knoop */ 00030 /* DATE: 03-08-2002 */ 00031 /***************************************************************************/ 00032 00037 #include <iostream> 00038 00039 /* inventor includes */ 00040 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h> 00041 #include <Inventor/actions/SoGetBoundingBoxAction.h> 00042 #include <Inventor/actions/SoSearchAction.h> 00043 #include <Inventor/nodes/SoCylinder.h> 00044 #include <Inventor/nodes/SoCone.h> 00045 #include <Inventor/nodes/SoCube.h> 00046 #include <Inventor/nodes/SoSphere.h> 00047 #include <Inventor/SoLists.h> 00048 #include "SoArrow.h" 00049 #include "SoTorquePointer.h" 00050 #include "SoComplexShape.h" 00051 #include <Inventor/fields/SoSFFloat.h> 00052 #include <Inventor/actions/SoGetMatrixAction.h> 00053 #include <Inventor/SbLinear.h> 00054 #include <Inventor/nodes/SoRotation.h> 00055 #include <Inventor/nodes/SoCamera.h> 00056 #include <Inventor/nodes/SoTransformSeparator.h> 00057 #include <Inventor/nodes/SoDirectionalLight.h> 00058 #include <Inventor/sensors/SoIdleSensor.h> 00059 #include <Inventor/nodes/SoMaterial.h> 00060 #include <Inventor/SbColor.h> 00061 #include <Inventor/nodes/SoTransform.h> 00062 00063 #include "grasp_visualization.h" 00064 00074 grasp_representation::grasp_representation(SbMatrix mat, SbMatrix thMat, SoSeparator* glroot){ 00075 00076 parentSep = glroot; 00077 00078 top = new SoSeparator(); 00079 sep = new SoSeparator(); 00080 thSep = new SoSeparator(); 00081 00082 material = new SoMaterial(); 00083 00084 tranArrowSphere = new SoTransform(); 00085 arrow = new SoArrow(); 00086 arrow->height.setValue(50.); 00087 sphere = new SoSphere(); 00088 sphere->radius.setValue(5.0); 00089 00090 thRot = new SoTransform(); 00091 thArrow = new SoArrow(); 00092 thArrow->height.setValue(20.); 00093 00094 top->addChild(sep); 00095 top->addChild(thSep); 00096 00097 sep->addChild(tranArrowSphere); 00098 sep->addChild(material); 00099 sep->addChild(arrow); 00100 sep->addChild(sphere); 00101 00102 thSep->addChild(material); 00103 thSep->addChild(thRot); 00104 thSep->addChild(thArrow); 00105 00106 tranArrowSphere->setMatrix(mat); 00107 00108 thRot->setMatrix(thMat); 00109 00110 parentSep->addChild(top); 00111 00112 visOn = true; 00113 } 00114 00118 grasp_representation::~grasp_representation(){ 00119 00120 if (visOn) 00121 parentSep->removeChild(top); 00122 /* 00123 thSep->removeChild(thArrow); 00124 thSep->removeChild(thRot); 00125 thSep->removeChild(material); 00126 00127 sep->removeChild(sphere); 00128 sep->removeChild(arrow); 00129 sep->removeChild(material); 00130 sep->removeChild(tranArrowSphere); 00131 00132 top->removeChild(thSep); 00133 top->removeChild(sep); 00134 00135 thArrow->unref(); 00136 thRot->unref(); 00137 sphere->unref(); 00138 arrow->unref(); 00139 material->unref(); 00140 00141 thSep->unref(); 00142 sep->unref(); 00143 top->unref(); 00144 */ 00145 } 00146 00150 void 00151 grasp_representation::changeColor(double r, double g, double b){ 00152 material->diffuseColor.setValue((float)r,(float)g,(float)b); 00153 material->transparency.setValue(0.5); 00154 } 00155 00160 void 00161 grasp_representation::resetColor(){ 00162 material->setToDefaults(); 00163 } 00164 00169 void 00170 grasp_representation::changeRadius(double rad){ 00171 sphere->radius.setValue((float)(rad * GRASP_SPHERE_SIZE_FACTOR)); 00172 } 00173 00174 00175 /****************** 00176 Local Variables: 00177 mode:c++ 00178 End: 00179 ******************/ 00180 00181 00182 00183 00184 00185 00186 00187 00188