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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef _3D_SPHERES_GIZMO_H_
26#define _3D_SPHERES_GIZMO_H_
27
28#include "../render_3d_base.h"
29
35{
36public:
37 SPHERES_GIZMO( int aGizmoPosX, int aGizmoPosY );
39
40 void setViewport( int ax, int ay, int aWidth, int aHeight );
41 std::tuple<int, int, int, int> getViewport() const;
42 void setGizmoPosition( int ax, int ay );
43
44 void handleMouseInput( int aMouseX, int aMouseY );
45
51 {
52 None = -1,
53 Right = 0,
54 Left,
55 Back,
56 Front,
57 Top,
58 Bottom,
59 Count
60 };
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
99 std::array<GizmoSphere, 6> m_spheres = { { { { m_arrowSize, 0.0f, 0.0f },
101 { m_arrowSize + 0.02f, 0.0f, 0.0f },
102 { 0.9f, 0.0f, 0.0f },
103 { 0.9f, 0.0f, 0.0f } },
104 { { -m_arrowSize, 0.0f, 0.0f },
106 { -m_arrowSize - 0.02f, 0.0f, 0.0f },
107 { 0.4f, 0.0f, 0.0f },
108 { 0.4f, 0.0f, 0.0f } },
109 { { 0.0f, m_arrowSize, 0.0f },
111 { 0.0f, m_arrowSize + 0.02f, 0.0f },
112 { 0.0f, 0.9f, 0.0f },
113 { 0.0f, 0.9f, 0.0f } },
114 { { 0.0f, -m_arrowSize, 0.0f },
116 { 0.0f, -m_arrowSize - 0.02f, 0.0f },
117 { 0.0f, 0.4f, 0.0f },
118 { 0.0f, 0.4f, 0.0f } },
119 { { 0.0f, 0.0f, m_arrowSize },
121 { 0.0f, 0.0f, m_arrowSize + 0.02f },
122 { 0.0f, 0.0f, 0.9f },
123 { 0.0f, 0.0f, 0.9f } },
124 { { 0.0f, 0.0f, -m_arrowSize },
126 { 0.0f, 0.0f, -m_arrowSize - 0.02f },
127 { 0.0f, 0.0f, 0.4f },
128 { 0.0f, 0.0f, 0.4f } } } };
129
131};
132
133#endif // _3D_SPHERES_GIZMO_H_
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:66
Renders a set of colored spheres in 3D space that act as a directional orientation gizmo.
GizmoSphereSelection
Enum to indicate which sphere (direction) is selected.
@ Count
Number of selectable spheres.
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)
GizmoSphereSelection m_selectedGizmoSphere
void resetSelectedGizmoSphere()
const float m_sphereRadius
void setGizmoPosition(int ax, int ay)