Grip-Reloaded
Grip version visualizaiton interface for DART (DynamicAnimationandRoboticsToolkits)
|
00001 /* 00002 * Copyright (c) 2014, Georgia Tech Research Corporation 00003 * All rights reserved. 00004 * 00005 * Author: Pete Vieira <pete.vieira@gatech.edu> 00006 * Date: Feb 2014 00007 * 00008 * Humanoid Robotics Lab Georgia Institute of Technology 00009 * Director: Mike Stilman http://www.golems.org 00010 * 00011 * 00012 * This file is provided under the following "BSD-style" License: 00013 * Redistribution and use in source and binary forms, with or 00014 * without modification, are permitted provided that the following 00015 * conditions are met: 00016 * 00017 * * Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * 00020 * * Redistributions in binary form must reproduce the above 00021 * copyright notice, this list of conditions and the following 00022 * disclaimer in the documentation and/or other materials provided 00023 * with the distribution. 00024 * 00025 * * Neither the name of the Humanoid Robotics Lab nor the names of 00026 * its contributors may be used to endorse or promote products 00027 * derived from this software without specific prior written 00028 * permission 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 00031 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 00032 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00033 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00034 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00035 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00036 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00037 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00038 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00039 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00040 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00041 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00042 * POSSIBILITY OF SUCH DAMAGE. 00043 */ 00044 00050 #ifndef VIEWER_WIDGET_H 00051 #define VIEWER_WIDGET_H 00052 00053 // QT includes 00054 #include <QtCore/QTimer> 00055 #include <QtGui/QGridLayout> 00056 00057 // OpenSceneGraph includes 00058 #include <osgViewer/CompositeViewer> 00059 #include <osgViewer/ViewerEventHandlers> 00060 #include <osgGA/OrbitManipulator> 00061 #include <osgDB/ReadFile> 00062 #include <osgQt/GraphicsWindowQt> 00063 #include <osg/io_utils> 00064 #include "osgUtils.h" 00065 00066 // Standard Library includes 00067 #include <iostream> 00068 00074 class ViewerWidget : public QWidget, public osgViewer::CompositeViewer 00075 { 00076 00077 public: 00081 ViewerWidget(osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::CompositeViewer::AutomaticSelection); 00082 00089 QWidget* addViewWidget(osg::Camera* camera, osg::Node* scene); 00090 00101 osg::Camera* createCamera(int x, int y, int w, int h, const std::string& name="", bool windowDecoration=false); 00102 00107 osg::Matrixd getViewMatrix(); 00108 00115 void setViewMatrix(uint i, osg::Matrixd m); 00116 00121 void setToFrontView(); 00122 00127 void setToTopView(); 00128 00133 void setToSideView(); 00134 00141 void setCameraMatrix(osg::Matrix& newMatrix, uint viewNum=0); 00142 00149 void addNodeToScene(osg::Node *node, uint viewNum=0); 00150 00159 void setBackgroundColor(const osg::Vec4& color, uint viewNum=0); 00160 00167 osgGA::CameraManipulator* getCameraManipulator(uint viewNum=0); 00168 00174 void setCameraToHomePosition(uint viewNum=0); 00175 00183 void addGrid(uint width, uint depth, uint gridSize); 00184 00190 virtual void paintEvent( QPaintEvent* event ) 00191 { frame(); } 00192 00193 protected: 00194 00195 // Timer for update the interface 00196 QTimer _timer; 00197 00206 bool viewNumIsValid(uint viewNum); 00207 }; // end class ViewerWidget 00208 00209 #endif // VIEWER_WIDGET_H