KrisLibrary  1.0.0
BoxWidget.h
1 #ifndef GLDRAW_BOX_WIDGET_H
2 #define GLDRAW_BOX_WIDGET_H
3 
4 #include "Widget.h"
5 #include "TransformWidget.h"
6 #include <KrisLibrary/math3d/AABB3D.h>
7 #include <KrisLibrary/math3d/Box3D.h>
8 #include <KrisLibrary/utils/IntTriple.h>
9 
10 namespace GLDraw {
11 
12 class BoxWidget : public Widget
13 {
14  public:
15  BoxWidget(const AABB3D& bb);
16  BoxWidget(const Box3D& bb);
17  void Get(AABB3D& bb) const;
18  void Get(Box3D& bb) const;
19  virtual ~BoxWidget() {}
20  virtual bool Hover(int x,int y,Camera::Viewport& viewport,double& distance);
21  virtual bool BeginDrag(int x,int y,Camera::Viewport& viewport,double& distance);
22  virtual void Drag(int dx,int dy,Camera::Viewport& viewport);
23  virtual void EndDrag();
24  virtual void DrawGL(Camera::Viewport& viewport);
25  virtual void SetHighlight(bool value);
26  virtual void SetFocus(bool value);
27 
28  RigidTransform T; //< the transform of the origin. bb is expressed w.r.t. this frame
29  AABB3D bb;
30  TransformWidget transformWidget; //<this widget handles the center translation and rotation changes
31 
32  //editor settings
33  GLColor cornerColor,boxColor;
34  GLColor hoverColorBlend;
35  Real cornerRadius;
36  bool scaleToScreen;
37 
38  //state
39  IntTriple hoverItem; //< 111: center, 101: lower y face, 121: upper y face, 000: -x -y -z corner, 002: -x -y +z corner, etc.
40  Vector3 hoverPos,hoverPosLocal;
41  int clickX,clickY,dragX,dragY;
42  Vector3 clickPos,clickPosLocal;
43  Real clickDistance;
44  Vector3 clickAxis;
45 };
46 
47 } //namespace GLDraw
48 
49 #endif
A lightweight integer 3-tuple class.
Definition: IntTriple.h:9
Base class for a visual widget.
Definition: Widget.h:16
A 3D vector class.
Definition: math3d/primitives.h:136
A 3D axis-aligned bounding box.
Definition: AABB3D.h:13
A rigid-body transformation.
Definition: math3d/primitives.h:820
A class containing viewport / camera information. This uses OpenGL coordinate convention in which x i...
Definition: viewport.h:11
Contains all definitions in the GLDraw package.
Definition: AnyGeometry.h:14
An rgba color.
Definition: GLColor.h:9
Definition: BoxWidget.h:12
A 3D boxThe box is the unit cube [0,1]^3 set in the scaled local coordinate system. That is, one corner is at the origin, and it has dimensions [dims.x,dims.y,dims.z] in the coordinates given by {xbasis,ybasis,zbasis}.
Definition: Box3D.h:21
Definition: TransformWidget.h:8