25#include "../../common_ogl/openGL_includes.h"
30#define RADPERDEG 0.0174533f
34 wxASSERT( aSize > 0.0f );
36 SFVEC3F vec = aTargetPos - aPosition;
37 float length = glm::length( vec );
39 GLUquadricObj *quadObj;
43 glTranslatef( aPosition.x, aPosition.y, aPosition.z );
45 if( ( vec.x != 0.0f ) || ( vec.y != 0.0f ) )
47 glRotatef( atan2( vec.y, vec.x ) /
RADPERDEG, 0.0f, 0.0f, 1.0f );
48 glRotatef( atan2( sqrt( vec.x * vec.x + vec.y * vec.y ), vec.z ) /
RADPERDEG,
52 else if( vec.z < 0.0f )
54 glRotatef( 180.0f, 1.0f, 0.0f, 0.0f );
57 glTranslatef( 0.0f, 0.0f, length - 4.0f * aSize );
59 quadObj = gluNewQuadric();
60 gluQuadricDrawStyle( quadObj, GLU_FILL );
61 gluQuadricNormals( quadObj, GLU_SMOOTH );
62 gluCylinder( quadObj, 2.0 * aSize, 0.0, 4.0 * aSize, 12, 1 );
63 gluDeleteQuadric( quadObj );
65 quadObj = gluNewQuadric();
66 gluQuadricDrawStyle( quadObj, GLU_FILL );
67 gluQuadricNormals( quadObj, GLU_SMOOTH );
68 gluDisk( quadObj, 0.0, 2.0 * aSize, 12, 1 );
69 gluDeleteQuadric( quadObj );
71 quadObj = gluNewQuadric();
72 gluQuadricDrawStyle( quadObj, GLU_FILL );
73 gluQuadricNormals( quadObj, GLU_SMOOTH );
74 gluDisk( quadObj, 0.0, aSize, 12, 1 );
75 gluDeleteQuadric( quadObj );
78 quadObj = gluNewQuadric();
79 gluQuadricDrawStyle( quadObj, GLU_FILL );
80 gluQuadricNormals( quadObj, GLU_SMOOTH );
81 gluSphere( quadObj, aSize, 24, 24 );
82 gluDeleteQuadric( quadObj );
84 glTranslatef( 0.0f , 0.0f ,-length + 4.0f * aSize );
86 quadObj = gluNewQuadric();
87 gluQuadricDrawStyle( quadObj, GLU_FILL );
88 gluQuadricNormals( quadObj, GLU_SMOOTH );
89 gluCylinder( quadObj, aSize, aSize, length - 4.0 * aSize, 12, 1 );
90 gluDeleteQuadric( quadObj );
92 quadObj = gluNewQuadric();
93 gluQuadricDrawStyle( quadObj, GLU_FILL );
94 gluQuadricNormals( quadObj, GLU_SMOOTH );
95 gluDisk( quadObj, 0.0, aSize, 12, 1 );
96 gluDeleteQuadric( quadObj );
106 glBegin( GL_LINE_LOOP );
107 glVertex3f( aBBox.
Min().x, aBBox.
Min().y, aBBox.
Min().z );
108 glVertex3f( aBBox.
Max().x, aBBox.
Min().y, aBBox.
Min().z );
109 glVertex3f( aBBox.
Max().x, aBBox.
Max().y, aBBox.
Min().z );
110 glVertex3f( aBBox.
Min().x, aBBox.
Max().y, aBBox.
Min().z );
113 glBegin( GL_LINE_LOOP );
114 glVertex3f( aBBox.
Min().x, aBBox.
Min().y, aBBox.
Max().z );
115 glVertex3f( aBBox.
Max().x, aBBox.
Min().y, aBBox.
Max().z );
116 glVertex3f( aBBox.
Max().x, aBBox.
Max().y, aBBox.
Max().z );
117 glVertex3f( aBBox.
Min().x, aBBox.
Max().y, aBBox.
Max().z );
120 glBegin( GL_LINE_STRIP );
121 glVertex3f( aBBox.
Min().x, aBBox.
Min().y, aBBox.
Min().z );
122 glVertex3f( aBBox.
Min().x, aBBox.
Min().y, aBBox.
Max().z );
125 glBegin( GL_LINE_STRIP );
126 glVertex3f( aBBox.
Max().x, aBBox.
Min().y, aBBox.
Min().z );
127 glVertex3f( aBBox.
Max().x, aBBox.
Min().y, aBBox.
Max().z );
130 glBegin( GL_LINE_STRIP );
131 glVertex3f( aBBox.
Max().x, aBBox.
Max().y, aBBox.
Min().z );
132 glVertex3f( aBBox.
Max().x, aBBox.
Max().y, aBBox.
Max().z );
135 glBegin( GL_LINE_STRIP );
136 glVertex3f( aBBox.
Min().x, aBBox.
Max().y, aBBox.
Min().z );
137 glVertex3f( aBBox.
Min().x, aBBox.
Max().y, aBBox.
Max().z );
144 if( aNrSidesPerCircle > 1 )
146 const float radius = 0.5f;
150 glNormal3f( 0.0f, 0.0f,-1.0f );
151 glBegin( GL_TRIANGLE_FAN );
152 glVertex3f( 0.0, 0.0, 0.0 );
158 glVertex3f(
static_cast<GLfloat
>( corner.x ),
static_cast<GLfloat
>( corner.y ), 0.0 );
161 glVertex3d( 0.0, -radius, 0.0 );
165 glNormal3f( 0.0f, 0.0f, 1.0f );
166 glBegin( GL_TRIANGLE_FAN );
167 glVertex3f( 0.0, 0.0, 1.0 );
174 glVertex3f(
static_cast<GLfloat
>( corner.x ),
static_cast<GLfloat
>( corner.y ), 1.0 );
177 glVertex3f( 0.0, radius, 1.0 );
181 glBegin( GL_QUAD_STRIP );
188 glNormal3f(
static_cast<GLfloat
>( corner.x * 2.0f ),
189 static_cast<GLfloat
>( corner.y * 2.0f ), 0.0f );
190 glVertex3f(
static_cast<GLfloat
>( corner.x ),
static_cast<GLfloat
>( corner.y ), 1.0f );
191 glVertex3f(
static_cast<GLfloat
>( corner.x ),
static_cast<GLfloat
>( corner.y ), 0.0f );
194 glNormal3f( 0.0, 1.0f, 0.0f );
195 glVertex3d( 0.0, radius, 1.0 );
196 glVertex3d( 0.0, radius, 0.0 );
208 const float radius = aSegment.
GetRadius();
209 const float width = aSegment.
GetWidth();
210 const float length = aSegment.
GetLength();
212 glTranslatef( start.x, start.y, 0.0f );
214 if( ( end_minus_start.x != 0.0f ) || ( end_minus_start.y != 0.0f ) )
216 glRotatef( atan2( end_minus_start.y, end_minus_start.x ) /
RADPERDEG, 0.0f, 0.0f, 1.0f );
220 glTranslatef( length, 0.0, 0.0f );
221 glScalef( width, width, 1.0f );
226 glNormal3f( 0.0,-1.0, 0.0 );
227 glVertex3f( length,-radius, 1.0 );
228 glVertex3f( 0.0, -radius, 1.0 );
229 glVertex3f( 0.0, -radius, 0.0 );
230 glVertex3f( length,-radius, 0.0 );
234 glNormal3f( 0.0, 1.0, 0.0 );
235 glVertex3f( length, radius, 0.0 );
236 glVertex3f( 0.0, radius, 0.0 );
237 glVertex3f( 0.0, radius, 1.0 );
238 glVertex3f( length, radius, 1.0 );
242 glNormal3f( 0.0, 0.0, 1.0 );
243 glVertex3f( length, radius, 1.0 );
244 glVertex3f( 0.0, radius, 1.0 );
245 glVertex3f( 0.0, -radius, 1.0 );
246 glVertex3f( length,-radius, 1.0 );
250 glNormal3f( 0.0, 0.0,-1.0 );
251 glVertex3f( length,-radius, 0.0 );
252 glVertex3f( 0.0, -radius, 0.0 );
253 glVertex3f( 0.0, radius, 0.0 );
254 glVertex3f( length, radius, 0.0 );
257 glScalef( width, width, 1.0f );
258 glRotatef( 180, 0.0, 0.0, 1.0 );
const SFVEC2F & GetStart() const
const SFVEC2F & GetEnd_minus_Start() const
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
static constexpr EDA_ANGLE ANGLE_180
void DrawSegment(const ROUND_SEGMENT_2D &aSegment, unsigned int aNrSidesPerCircle)
Draw a thick line segment with rounded ends.
void DrawHalfOpenCylinder(unsigned int aNrSidesPerCircle)
Draw a half open cylinder with diameter 1.0f and height 1.0f.
void DrawRoundArrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
Draw a round arrow.
void DrawBoundingBox(const BBOX_3D &aBBox)
Draw the bounding box lines.
Manage a bounding box defined by two SFVEC3F min max points.
const SFVEC3F & Min() const
Return the minimum vertex pointer.
const SFVEC3F & Max() const
Return the maximum vertex pointer.
bool IsInitialized() const
Check if this bounding box is already initialized.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.