My Project
Loading...
Searching...
No Matches
CGenericWidget.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CGenericWidgetH
46#define CGenericWidgetH
47//------------------------------------------------------------------------------
48#include "world/CMesh.h"
49//------------------------------------------------------------------------------
50
51//------------------------------------------------------------------------------
52namespace chai3d {
53//------------------------------------------------------------------------------
54
55//==============================================================================
62//==============================================================================
63
64//==============================================================================
76//==============================================================================
77class cGenericWidget : public cMesh
78{
79 //--------------------------------------------------------------------------
80 // CONSTRUCTOR & DESTRUCTOR:
81 //--------------------------------------------------------------------------
82
83public:
84
87
89 virtual ~cGenericWidget() {};
90
91
92 //--------------------------------------------------------------------------
93 // VIRTUAL PUBLIC METHODS:
94 //--------------------------------------------------------------------------
95
96public:
97
99 virtual std::string getClassName() { return ("Widget"); }
100
102 virtual cGenericWidget* copy(const bool a_duplicateMaterialData = false,
103 const bool a_duplicateTextureData = false,
104 const bool a_duplicateMeshData = false,
105 const bool a_buildCollisionDetector = false);
106
107
108 //--------------------------------------------------------------------------
109 // VIRTUAL PUBLIC METHODS: SIZES
110 //--------------------------------------------------------------------------
111
112public:
113
115 virtual double getWidth() const { return (m_width); }
116
118 virtual double getHeight() const { return (m_height); }
119
121 virtual void updateBoundaryBox()
122 {
123 m_boundaryBoxMin.set(0.0, 0.0, 0.0);
125 }
126
127
128 //--------------------------------------------------------------------------
129 // VIRTUAL PUBLIC METHODS: ROTATING WIDGETS
130 //--------------------------------------------------------------------------
131
132public:
133
135 virtual void rotateWidgetDeg(double a_angleDeg) { rotateAboutLocalAxisDeg(cVector3d(0,0,1), a_angleDeg); }
136
138 virtual void rotateWidgetRad(double a_angleRad) { rotateAboutLocalAxisRad(cVector3d(0,0,1), a_angleRad); }
139
141 virtual void rotateWidgetAroundCenterDeg(double a_angleDeg) { rotateWidgetAroundCenterRad(cDegToRad(a_angleDeg)); }
142
144 virtual void rotateWidgetAroundCenterRad(double a_angleRad);
145
146
147 //--------------------------------------------------------------------------
148 // PROTECTED METHODS:
149 //--------------------------------------------------------------------------
150
151protected:
152
155 const bool a_duplicateMaterialData,
156 const bool a_duplicateTextureData,
157 const bool a_duplicateMeshData,
158 const bool a_buildCollisionDetector);
159
160
161 //--------------------------------------------------------------------------
162 // PROTECTED MEMBERS:
163 //--------------------------------------------------------------------------
164
165protected:
166
168 double m_width;
169
171 double m_height;
172};
173
174//------------------------------------------------------------------------------
175} // namespace chai3d
176//------------------------------------------------------------------------------
177
178//------------------------------------------------------------------------------
179#endif
180//------------------------------------------------------------------------------
Implements a class to model polygonal meshes.
cVector3d m_boundaryBoxMin
Minimum position of boundary box.
Definition CGenericObject.h:849
void rotateAboutLocalAxisDeg(const cVector3d &a_axis, const double a_angleDeg)
This method rotates this object around a local axis. Angle magnitude is defined in degrees.
Definition CGenericObject.h:244
cVector3d m_boundaryBoxMax
Maximum position of boundary box.
Definition CGenericObject.h:852
void rotateAboutLocalAxisRad(const cVector3d &a_axis, const double a_angleRad)
This method rotates this object around a local axis. Angle magnitude is defined in radians.
Definition CGenericObject.cpp:333
This class implements a base class for widgets.
Definition CGenericWidget.h:78
virtual void updateBoundaryBox()
This method updates the bounding box of the widget.
Definition CGenericWidget.h:121
virtual std::string getClassName()
This method returns the name of the object class.
Definition CGenericWidget.h:99
virtual cGenericWidget * copy(const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=false)
This method creates a copy of itself.
Definition CGenericWidget.cpp:85
double m_height
Height of this widget.
Definition CGenericWidget.h:171
virtual double getHeight() const
This method returns the height of the widget.
Definition CGenericWidget.h:118
virtual double getWidth() const
This method returns the width of the widget.
Definition CGenericWidget.h:115
virtual void rotateWidgetRad(double a_angleRad)
This method rotates the widget around the z-axis with an angle defined in radians.
Definition CGenericWidget.h:138
virtual void rotateWidgetAroundCenterRad(double a_angleRad)
This method rotates the widget around its center point with an angle defined in radians.
Definition CGenericWidget.cpp:144
cGenericWidget()
Constructor of cGenericWidget.
Definition CGenericWidget.cpp:57
double m_width
Width of this widget.
Definition CGenericWidget.h:168
virtual void rotateWidgetDeg(double a_angleDeg)
This method rotates the widget around the z-axis with an angle defined in degrees.
Definition CGenericWidget.h:135
virtual void rotateWidgetAroundCenterDeg(double a_angleDeg)
This method rotates the widget around its center point with an angle defined in degrees.
Definition CGenericWidget.h:141
void copyGenericWidgetProperties(cGenericWidget *a_obj, const bool a_duplicateMaterialData, const bool a_duplicateTextureData, const bool a_duplicateMeshData, const bool a_buildCollisionDetector)
This method copies all properties of this object to another.
Definition CGenericWidget.cpp:116
virtual ~cGenericWidget()
Destructor of cGenericWidget.
Definition CGenericWidget.h:89
This class implements a 3D polygonal mesh.
Definition CMesh.h:109
Definition CAudioBuffer.cpp:57
double cDegToRad(const double &a_angleDeg)
This function converts an angle from degrees to radians.
Definition CMaths.h:696
This class implements a 3D vector.
Definition CVector3d.h:89
void set(const double &a_x, const double &a_y, const double &a_z)
This method initializes this vector with components x, y, and z passed as arguments.
Definition CVector3d.h:278