openrave.org

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
viewer.h
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2006-2010 Rosen Diankov (rosen.diankov@gmail.com)
3 //
4 // This file is part of OpenRAVE.
5 // OpenRAVE is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef OPENRAVE_VIEWER_H
23 #define OPENRAVE_VIEWER_H
24 
25 namespace OpenRAVE {
26 
33 {
34 public:
35  virtual ~GraphHandle() {
36  }
37 
41  virtual void SetTransform(const RaveTransform<float>& t) OPENRAVE_DUMMY_IMPLEMENTATION;
43  virtual void SetShow(bool bshow) OPENRAVE_DUMMY_IMPLEMENTATION;
44 };
45 
46 typedef boost::shared_ptr<GraphHandle> GraphHandlePtr;
47 typedef boost::shared_ptr<GraphHandle const> GraphHandleConstPtr;
48 typedef boost::weak_ptr<GraphHandle const> GraphHandleWeakPtr;
49 
54 {
55 public:
57  {
58  VE_ItemSelection = 1,
60 
61  ViewerBase(EnvironmentBasePtr penv) : InterfaceBase(PT_Viewer, penv) {
62  }
63  virtual ~ViewerBase() {
64  }
65 
67  static inline InterfaceType GetInterfaceTypeStatic() {
68  return PT_Viewer;
69  }
70 
72  virtual void RemoveKinBody(KinBodyPtr pbody) OPENRAVE_DUMMY_IMPLEMENTATION;
73 
77  virtual int main(bool bShow = true) = 0;
78 
80  virtual void quitmainloop() = 0;
81 
83 
88  virtual void SetCamera(const RaveTransform<float>& trans, float focalDistance=0) OPENRAVE_DUMMY_IMPLEMENTATION;
89 
91  virtual RaveTransform<float> GetCameraTransform() const OPENRAVE_DUMMY_IMPLEMENTATION;
92 
94  virtual geometry::RaveCameraIntrinsics<float> GetCameraIntrinsics() const OPENRAVE_DUMMY_IMPLEMENTATION;
95 
106  virtual bool GetCameraImage(std::vector<uint8_t>& memory, int width, int height, const RaveTransform<float>& t, const SensorBase::CameraIntrinsics& intrinsics) OPENRAVE_DUMMY_IMPLEMENTATION;
107 
109 
110  virtual void Reset() OPENRAVE_DUMMY_IMPLEMENTATION;
111  virtual void SetBkgndColor(const RaveVector<float>& color) OPENRAVE_DUMMY_IMPLEMENTATION;
112 
117  typedef boost::function<bool (KinBody::LinkPtr plink,RaveVector<float>,RaveVector<float>)> ItemSelectionCallbackFn;
118 
122  virtual UserDataPtr RegisterItemSelectionCallback(const ItemSelectionCallbackFn& fncallback) OPENRAVE_DUMMY_IMPLEMENTATION;
123 
128  typedef boost::function<void (const uint8_t*,int,int,int)> ViewerImageCallbackFn;
129 
133  virtual UserDataPtr RegisterViewerImageCallback(const ViewerImageCallbackFn& fncallback) OPENRAVE_DUMMY_IMPLEMENTATION;
134 
136  typedef boost::function<void ()> ViewerThreadCallbackFn;
137 
142  virtual UserDataPtr RegisterViewerThreadCallback(const ViewerThreadCallbackFn& fncallback) OPENRAVE_DUMMY_IMPLEMENTATION;
143 
144 
146  virtual void SetEnvironmentSync(bool bUpdate) OPENRAVE_DUMMY_IMPLEMENTATION;
147 
151  virtual void EnvironmentSync() OPENRAVE_DUMMY_IMPLEMENTATION;
152 
153  virtual void SetSize(int w, int h) OPENRAVE_DUMMY_IMPLEMENTATION;
154 
156  virtual void ViewerSetSize(int w, int h) RAVE_DEPRECATED {
157  SetSize(w,h);
158  }
159 
160  virtual void Move(int x, int y) OPENRAVE_DUMMY_IMPLEMENTATION;
161 
163  virtual void ViewerMove(int x, int y) RAVE_DEPRECATED {
164  Move(x,y);
165  }
166 
167  virtual void SetName(const std::string& name) OPENRAVE_DUMMY_IMPLEMENTATION;
168 
170  virtual void ViewerSetTitle(const std::string& ptitle) RAVE_DEPRECATED {
171  SetName(ptitle);
172  }
173 
174  virtual const std::string& GetName() const OPENRAVE_DUMMY_IMPLEMENTATION;
175 
177  virtual void UpdateCameraTransform() RAVE_DEPRECATED OPENRAVE_DUMMY_IMPLEMENTATION;
179  typedef ItemSelectionCallbackFn ViewerCallbackFn RAVE_DEPRECATED;
181  virtual UserDataPtr RegisterCallback(int properties, const ItemSelectionCallbackFn& fncallback) RAVE_DEPRECATED
182  {
183  return RegisterItemSelectionCallback(fncallback);
184  }
185 
186 protected:
189  body->SetUserData(GetXMLId(), data);
190  }
191 
192  virtual GraphHandlePtr plot3(const float* ppoints, int numPoints, int stride, float fPointSize, const RaveVector<float>& color, int drawstyle = 0) OPENRAVE_DUMMY_IMPLEMENTATION;
193  virtual GraphHandlePtr plot3(const float* ppoints, int numPoints, int stride, float fPointSize, const float* colors, int drawstyle = 0, bool bhasalpha=false) OPENRAVE_DUMMY_IMPLEMENTATION;
194 
195  virtual GraphHandlePtr drawlinestrip(const float* ppoints, int numPoints, int stride, float fwidth, const RaveVector<float>& color) OPENRAVE_DUMMY_IMPLEMENTATION;
196  virtual GraphHandlePtr drawlinestrip(const float* ppoints, int numPoints, int stride, float fwidth, const float* colors) OPENRAVE_DUMMY_IMPLEMENTATION;
197 
198  virtual GraphHandlePtr drawlinelist(const float* ppoints, int numPoints, int stride, float fwidth, const RaveVector<float>& color) OPENRAVE_DUMMY_IMPLEMENTATION;
199  virtual GraphHandlePtr drawlinelist(const float* ppoints, int numPoints, int stride, float fwidth, const float* colors) OPENRAVE_DUMMY_IMPLEMENTATION;
200 
201  virtual GraphHandlePtr drawarrow(const RaveVector<float>& p1, const RaveVector<float>& p2, float fwidth, const RaveVector<float>& color) OPENRAVE_DUMMY_IMPLEMENTATION;
202 
203  virtual GraphHandlePtr drawbox(const RaveVector<float>& vpos, const RaveVector<float>& vextents) OPENRAVE_DUMMY_IMPLEMENTATION;
204  virtual GraphHandlePtr drawplane(const RaveTransform<float>& tplane, const RaveVector<float>& vextents, const boost::multi_array<float,3>& vtexture) OPENRAVE_DUMMY_IMPLEMENTATION;
205 
206  virtual GraphHandlePtr drawtrimesh(const float* ppoints, int stride, const int* pIndices, int numTriangles, const RaveVector<float>& color) OPENRAVE_DUMMY_IMPLEMENTATION;
207  virtual GraphHandlePtr drawtrimesh(const float* ppoints, int stride, const int* pIndices, int numTriangles, const boost::multi_array<float,2>& colors) OPENRAVE_DUMMY_IMPLEMENTATION;
208 
209  inline ViewerBasePtr shared_viewer() {
210  return boost::static_pointer_cast<ViewerBase>(shared_from_this());
211  }
213  return boost::static_pointer_cast<ViewerBase const>(shared_from_this());
214  }
215 
216 private:
217  virtual const char* GetHash() const {
218  return OPENRAVE_VIEWER_HASH;
219  }
220 
221 #ifdef RAVE_PRIVATE
222 #ifdef _MSC_VER
223  friend class Environment;
224 #else
225  friend class ::Environment;
226 #endif
227 #endif
228 };
229 
230 } // end namespace OpenRAVE
231 
232 #endif