00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00029 #ifndef IVMGR_HXX
00030 #include <Inventor/SbBasic.h>
00031 #include <Inventor/SbLinear.h>
00032 #include <list>
00033 #include <vector>
00034 #include <qstring.h>
00035 #include <qwidget.h>
00036 #include "material.h"
00037
00038 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
00039
00040 struct VCReportType;
00041 class SbVec3f;
00042 class transf;
00043 class position;
00044
00045 class QWidget;
00046 class SoQtExaminerViewer;
00047 class SoBlinker;
00048 class SoCenterballDragger;
00049 class SoHandleBoxDragger;
00050 class SoTranslate1Dragger;
00051 class SoRotateDiscDragger;
00052 class SoDragger;
00053 class SoMaterial;
00054 class SoPath;
00055 class SoPickedPoint;
00056 class SoScale;
00057 class SoSelection;
00058 class SoSeparator;
00059 class SoText2;
00060 class SoTransform;
00061 class SoEventCallback;
00062 class SoSensor;
00063 class SoNodeSensor;
00064 class SoQtRenderArea;
00065 class World;
00066 class WorldElement;
00067 class Robot;
00068 class HumanHand;
00069 class KinematicChain;
00070 class DOF;
00071 class GraspableBody;
00072 class Body;
00073 class Finger;
00074 class Grasp;
00075 class GWS;
00076 class GWSprojection;
00077 class QualityMeasure;
00078 struct DraggerInfo;
00079
00080 namespace db_planner {
00081 class DatabaseManager;
00082 }
00083
00084 #define HANDS_DIR "../../hands/"
00085 #define OBJECTS_DIR "../../objects/"
00086 #define MAX_POLYTOPES 15
00087 #define MAX_COLLISIONS 5
00088
00089 typedef double col_Mat4[4][4];
00090
00092
00099 class StereoViewer : public SoQtExaminerViewer {
00100 protected:
00101 bool stereoOn;
00102 void computeSeekFinalOrientation();
00103 public:
00104 void setStereo(bool s);
00105 bool isStereoOn(){return stereoOn;}
00106 StereoViewer(QWidget *parent);
00107 float mFocalPlane;
00108 };
00109
00110 enum ToolType {TRANSLATE_TOOL,ROTATE_TOOL,SELECT_TOOL};
00111
00113
00122 class IVmgr : public QWidget {
00123 Q_OBJECT
00124
00125 private:
00127 static IVmgr *ivmgr;
00128
00130 World *world;
00131
00133 FILE *camerafp;
00134
00136 const char *imgSeqStr;
00137
00139 int imgSeqCounter;
00140
00142 ToolType currTool;
00143
00145 SbBool CtrlDown;
00146
00148 SbBool ShiftDown;
00149
00151 SoSeparator *pointers;
00152
00154 std::vector<SoBlinker*> contactForceBlinkerVec;
00155
00157
00158 StereoViewer *myViewer;
00159
00161 SoSeparator *sceneRoot;
00162
00164 SoSelection *selectionRoot;
00165
00167 SoSeparator *draggerRoot;
00168
00170 SoSeparator *wireFrameRoot;
00171
00173 SoSeparator *junk;
00174
00176 SoMaterial *dynForceMat;
00177
00179 db_planner::DatabaseManager *mDBMgr;
00180
00181 void setupPointers();
00182 void transRot(DraggerInfo *dInfo);
00183 void revoluteJointChanged(DraggerInfo *dInfo);
00184 void revoluteJointFinished(DraggerInfo *dInfo);
00185 void revoluteJointClicked(DraggerInfo *dInfo);
00186 void prismaticJointChanged(DraggerInfo *dInfo);
00187 void makeCenterball(WorldElement *selectedElement,Body *surroundMe);
00188 void makeHandleBox(WorldElement *selectedElement,Body *surroundMe);
00189 void makeJointDraggers(Robot *robot,KinematicChain *chain);
00190 void drawWireFrame(SoSeparator *elementRoot);
00191 SoPath *pickFilter(const SoPickedPoint *pick);
00192 void handleSelection(SoPath* p);
00193 void handleDeselection(SoPath* p);
00194 void deleteSelections();
00195 void setCtrlDown(SbBool status) {CtrlDown = status;}
00196 void setShiftDown(SbBool status) {ShiftDown = status;}
00197 void spaceBar();
00198 void keyPressed(SoEventCallback *eventCB);
00199
00201 void drawBodyWrench(GraspableBody *body, const double *wrench);
00202
00204 static void transRotCB(void *dInfo,SoDragger *dragger);
00205
00207 static void revoluteJointChangedCB(void *dInfo,SoDragger *dragger);
00208
00210 static void revoluteJointClickedCB(void *dInfo,SoDragger *dragger);
00211
00213 static void revoluteJointFinishedCB(void *dInfo,SoDragger *dragger);
00214
00216 static void prismaticJointChangedCB(void *dInfo,SoDragger *dragger);
00217
00219 static void shiftOrCtrlDownCB(void *,SoEventCallback *eventCB);
00220
00222 static void keyPressedCB(void *,SoEventCallback *eventCB);
00223
00225 static void selectionCB(void *,SoPath *p);
00226
00228 static void deselectionCB(void *,SoPath *p);
00229
00231 static SoPath *pickFilterCB(void *,const SoPickedPoint *pick);
00232
00233 public slots:
00234 void drawDynamicForces();
00235 void drawWorstCaseWrenches();
00236 void drawUnbalancedForces();
00237 void saveNextImage();
00238 void saveCameraPos();
00239 void restoreCameraPos();
00240
00241 public:
00242 IVmgr(QWidget *parent=0,const char *name=0,Qt::WFlags f=0);
00243 ~IVmgr();
00244
00245 void deselectBody(Body *b);
00246
00251 World *getWorld() const {return world;}
00252
00256 StereoViewer *getViewer() const {return myViewer;}
00257
00262 SoSeparator *getPointers() const {return pointers;}
00263
00264 void setTool(ToolType newTool);
00265 void emptyWorld();
00266 void hilightObjContact(int contactNum);
00267 void unhilightObjContact(int contactNum);
00268
00269 void saveImageSequence(const char *fileStr);
00270 int saveCameraPositions(const char *filename);
00271 int useSavedCameraPositions(const char *filename);
00273 void setCamera(double px, double py, double pz, double q1, double q2, double q3, double q4, double fd);
00275 void getCamera(float &px, float &py, float &pz, float &q1, float &q2, float &q3, float &q4, float &fd);
00276 void setCameraTransf(transf tr);
00277 transf getCameraTransf();
00278
00279 void saveImage(QString filename);
00280 void beginMainLoop();
00281
00282 void setStereo(bool s);
00284 void flipStereo();
00285
00287 db_planner::DatabaseManager* getDBMgr(){return mDBMgr;}
00289 #ifdef CGDB_ENABLED
00290 void setDBMgr(db_planner::DatabaseManager *mgr){mDBMgr = mgr;}
00291 #else
00292 void setDBMgr(db_planner::DatabaseManager*){}
00293 #endif
00294 void setStereoWindow(QWidget *parent);
00295 };
00296 #define IVMGR_HXX
00297 #endif