Image Component Library (ICL)
ManipulatablePaper.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2014 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLPhysics/src/ICLPhysics/ManipulatablePaper.h **
10 ** Module : ICLPhysics **
11 ** Author : Christof Elbrechter, Matthias Esau **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 #pragma once
31 #include <ICLGeom/Scene.h>
34 #include <ICLCore/Img.h>
35 #include <ICLUtils/Mutex.h>
36 #include <ICLQt/MouseHandler.h>
37 
38 #include <map>
39 
40 namespace icl{
41 namespace physics{
42 
45  struct VertexAttractor : public SceneObject{
52 
54  bool oscillating, ManipulatablePaper *parent);
55  ~VertexAttractor();
56  void apply(float streangth);
57  };
58 
59 
61 
62  struct LineAnnotation : public SceneObject{
66 
68  const utils::Point32f &b, const geom::GeomColor &color);
69  virtual void prepareForRendering();
70  };
71 
72 
73  struct DraggedPositionIndicator : public SceneObject{
77  virtual void prepareForRendering();
78  };
79 
80 
81  std::vector<SceneObject *> nodes;
82  typedef std::map<std::string,VertexAttractor*> AttractorMap;
88  std::vector<LineAnnotation*> lines;
90  friend class ManipulatablePaperMouseHandler;
92 
93  public:
96  int W, int H, const geom::Vec *init,
97  bool initByCorners,
98  const core::Img8u *frontTexture=0,
99  const core::Img8u *backTexture=0 );
100 
102  geom::Vec getPos(const utils::Point &idx);
103 
105  void prepareForRendering();
106 
108  void addAttractor(utils::Point coords, bool oscillating=false);
109 
111  void removeAttractor(utils::Point coords);
112 
114  void removeAllAttractors();
115 
117  void applyAllForces(float attractorForce, float mouseForce);
118 
120  qt::MouseHandler *createMouseHandler(int cameraIndex = 0);
121 
123  void setCubesVisible(bool on);
124 
126  void setTextureVisible(bool on);
127 
129  virtual void adaptRowStiffness(float val, int row);
130 
132  virtual void adaptColStiffness(float val, int col);
133 
135  virtual void adaptGlobalStiffness(float val);
136 
138  void removeAllLineAnnoations();
139 
140 
142 
145  void adaptStiffnessAlongLine(const utils::Point32f &a, const utils::Point32f &b, float val);
146 
148  void addLineAnnotation(const utils::Point32f &a, const utils::Point32f &b,
149  const geom::GeomColor &color=geom::GeomColor(255,100,0,255));
150 
151  void removeAllAnnoations();
152 
154  utils::Point32f getPaperCoordinates(const utils::Point32f &screenPosition2D);
155 
157  void setDraggedPosition(const utils::Point32f &paperPos);
158 
161 
164  showAllConstraints = show;
165  }
166 
168  bool getShowAllConstraints() const{
169  return showAllConstraints;
170  }
171 
173  virtual void complexCustomRender(icl::geom::ShaderUtil *u);
174 
176  virtual void saveCFG(const std::string &filename);
177 
179  virtual void loadCFG(const std::string &filename);
180 
181  struct Shadow : public geom::SceneObject{
182  Shadow(float zLevel, ManipulatablePaper *parent);
183  virtual void customRender();
184  float zLevel;
186  };
187 
189 
190  void addShadow(float zLevel){
191  if(m_shadow){
192  throw utils::ICLException("shadow cannot be added twice!");
193  }
194  m_shadow = new Shadow(zLevel,this);
195  addChild(m_shadow.get());
196  }
197  };
198 
199 }
200 }
std::vector< LineAnnotation * > lines
Definition: ManipulatablePaper.h:88
undocument this line if you encounter any issues!
Definition: Any.h:37
Definition: ManipulatablePaper.h:181
utils::Mutex attractorMutex
Definition: ManipulatablePaper.h:86
A physical world that handles physical objects.
Definition: PhysicsWorld.h:56
utils::Point idx
Definition: ManipulatablePaper.h:46
ICL Time class (taken from the Ice lib)
Definition: Time.h:52
DraggedPositionIndicator * draggedPositionIndicator
Definition: ManipulatablePaper.h:89
ManipulatablePaper * parent
Definition: ManipulatablePaper.h:51
utils::Point32f a
Definition: ManipulatablePaper.h:63
float zLevel
Definition: ManipulatablePaper.h:184
ManipulatablePaper * parent
Definition: ManipulatablePaper.h:185
utils::Point32f b
Definition: ManipulatablePaper.h:64
utils::Point32f p
Definition: ManipulatablePaper.h:75
PhysicsWorld * world
Definition: ManipulatablePaper.h:84
utils::Point32f getPaperCoordinates(const geom::ViewRay &ray)
finds the optimal paper coordinates for a given point in the world
Definition: ShaderUtil.h:47
This class represents cloth or paper like soft-body objects.
Definition: PhysicsPaper.h:51
Scene Implementation that is used to handle a list of objects and cameras.
Definition: Scene.h:138
Utility class for extra annotations, rendered in paper coordinates.
Definition: ManipulatablePaper.h:62
bool oscillating
Definition: ManipulatablePaper.h:49
T * get()
returns the pointer to the data
Definition: SmartPtrBase.h:345
void addShadow(float zLevel)
Definition: ManipulatablePaper.h:190
#define ICLPhysics_API
Definition: CompatMacros.h:181
bool getShowAllConstraints() const
returns whether constraints are shown
Definition: ManipulatablePaper.h:168
extension of the standard physical paper class
Definition: ManipulatablePaper.h:44
utils::Time time
Definition: ManipulatablePaper.h:47
MouseEvent Handler.
Definition: MouseHandler.h:92
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
ICLQt_API void color(float r, float g=-1, float b=-1, float alpha=255)
sets the current color to given r,g,b,alpha value
Base class for Exception handling in the ICL.
Definition: Exception.h:42
geom::Scene * scene
Definition: ManipulatablePaper.h:85
std::vector< SceneObject * > nodes
Definition: ManipulatablePaper.h:81
geom::Scene * scene
Definition: ManipulatablePaper.h:50
ManipulatablePaper * parent
Definition: ManipulatablePaper.h:76
void setShowAllConstraints(bool show)
sets whether contraints are visualized
Definition: ManipulatablePaper.h:163
PhysicsPaper * parent
Definition: ManipulatablePaper.h:65
Mutex class of the ICL.
Definition: Mutex.h:54
utils::SmartPtr< qt::MouseHandler > mouse
Definition: ManipulatablePaper.h:87
Definition: ManipulatablePaper.h:45
ICLQt_API void show(const icl::core::ImgBase &image)
shows an image using TestImages::show
bool showAllConstraints
Definition: ManipulatablePaper.h:91
utils::SmartPtr< Shadow > m_shadow
Definition: ManipulatablePaper.h:188
Specialization of the SmartPtrBase class for Pointers.
Definition: SmartPtr.h:75
The SceneObject class defines visible objects in scenes or scene graph nodes.
Definition: SceneObject.h:140
AttractorMap attractors
Definition: ManipulatablePaper.h:83
std::map< std::string, VertexAttractor * > AttractorMap
Definition: ManipulatablePaper.h:82
geom::Vec startPos
Definition: ManipulatablePaper.h:48