KiCad PCB EDA Suite
Loading...
Searching...
No Matches
3d_spheres_gizmo.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright 2025, Damjan Prerad <[email protected]>
5 * Copyright (C) The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef _3D_SPHERES_GIZMO_H_
22#define _3D_SPHERES_GIZMO_H_
23
24#include "../render_3d_base.h"
25
26class GLUquadric;
27
33{
34public:
35 SPHERES_GIZMO( int aGizmoPosX, int aGizmoPosY );
37
38 void setViewport( int ax, int ay, int aWidth, int aHeight );
39 std::tuple<int, int, int, int> getViewport() const;
40 void setGizmoPosition( int ax, int ay );
41
42 void handleMouseInput( int aMouseX, int aMouseY );
43
44 void updateSelection( glm::mat4 aCameraRotationMatrix );
45
61
64 void render3dSpheresGizmo( glm::mat4 aCameraRotationMatrix );
65
66private:
67 void setGizmoMaterial();
68
69 GLUquadric* m_quadric = nullptr;
70
71 int m_gizmoPosX = 0;
72 int m_gizmoPosY = 0;
73
74 int m_viewportX = 0;
75 int m_viewportY = 0;
76 int m_viewportW = 0;
77 int m_viewportH = 0;
78
79 float m_ndcX = -1.0f;
80 float m_ndcY = -1.0f;
81
83 {
84 glm::vec3 m_position;
85 float m_radius;
86 glm::vec3 m_labelPosition;
87 glm::vec3 m_color;
88 glm::vec3 m_originalColor;
89 };
90
91 // Define sphere positions
92 const float m_arrowSize = RANGE_SCALE_3D * 0.20f;
93 const float m_sphereRadius = 0.05f * RANGE_SCALE_3D;
94
95 glm::mat4 m_cameraRotationMatrix = glm::mat4( 1.0f );
96
101 std::array<GizmoSphere, 6> m_spheres = { { { { m_arrowSize, 0.0f, 0.0f },
103 { m_arrowSize + 0.02f, 0.0f, 0.0f },
104 { 0.9f, 0.0f, 0.0f },
105 { 0.9f, 0.0f, 0.0f } },
106 { { -m_arrowSize, 0.0f, 0.0f },
108 { -m_arrowSize - 0.02f, 0.0f, 0.0f },
109 { 0.4f, 0.0f, 0.0f },
110 { 0.4f, 0.0f, 0.0f } },
111 { { 0.0f, m_arrowSize, 0.0f },
113 { 0.0f, m_arrowSize + 0.02f, 0.0f },
114 { 0.0f, 0.9f, 0.0f },
115 { 0.0f, 0.9f, 0.0f } },
116 { { 0.0f, -m_arrowSize, 0.0f },
118 { 0.0f, -m_arrowSize - 0.02f, 0.0f },
119 { 0.0f, 0.4f, 0.0f },
120 { 0.0f, 0.4f, 0.0f } },
121 { { 0.0f, 0.0f, m_arrowSize },
123 { 0.0f, 0.0f, m_arrowSize + 0.02f },
124 { 0.0f, 0.0f, 0.9f },
125 { 0.0f, 0.0f, 0.9f } },
126 { { 0.0f, 0.0f, -m_arrowSize },
128 { 0.0f, 0.0f, -m_arrowSize - 0.02f },
129 { 0.0f, 0.0f, 0.4f },
130 { 0.0f, 0.0f, 0.4f } } } };
131
133};
134
135#endif // _3D_SPHERES_GIZMO_H_
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
GizmoSphereSelection
Enum to indicate which sphere (direction) is selected.
@ Count
Number of selectable spheres.
void updateSelection(glm::mat4 aCameraRotationMatrix)
void handleMouseInput(int aMouseX, int aMouseY)
void render3dSpheresGizmo(glm::mat4 aCameraRotationMatrix)
GLUquadric * m_quadric
const float m_arrowSize
std::array< GizmoSphere, 6 > m_spheres
List of all directional gizmo spheres.
GizmoSphereSelection getSelectedGizmoSphere() const
std::tuple< int, int, int, int > getViewport() const
void setViewport(int ax, int ay, int aWidth, int aHeight)
glm::mat4 m_cameraRotationMatrix
GizmoSphereSelection m_selectedGizmoSphere
SPHERES_GIZMO(int aGizmoPosX, int aGizmoPosY)
void resetSelectedGizmoSphere()
const float m_sphereRadius
void setGizmoPosition(int ax, int ay)