atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
m_proj.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'm_proj.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'View -> Projection' submenu
29
30*
31* List of functions:
32
33 G_MODULE_EXPORT void set_camera_pos (GtkWidget * widg, gpointer data);
34 G_MODULE_EXPORT void to_set_camera_pos (GSimpleAction * action, GVariant * parameter, gpointer data);
35
36 GtkWidget * menu_proj (glwin * view);
37
38 GMenu * menu_proj (glwin * view, int popm);
39
40*/
41
42#include "global.h"
43#include "glview.h"
44#include "glwindow.h"
45
48 RIGHT = 0,
49 LEFT = 1,
50 TOP = 2,
51 BOTTOM = 3,
52 FRONT = 4,
53 BACK = 5
54};
55
64G_MODULE_EXPORT void set_camera_pos (GtkWidget * widg, gpointer data)
65{
66 tint * id = (tint *)data;
67 double angle_x, angle_y;
68 switch (id -> b)
69 {
70 case RIGHT:
71 angle_x = 0.0;
72 angle_y = -90.0;
73 break;
74 case LEFT:
75 angle_x = 0.0;
76 angle_y = 90.0;
77 break;
78 case TOP:
79 angle_x = 90.0;
80 angle_y = 0.0;
81 break;
82 case BOTTOM:
83 angle_x = -90.0;
84 angle_y = 0.0;
85 break;
86 case FRONT:
87 angle_x = 0.0;
88 angle_y = 0.0;
89 break;
90 case BACK:
91 angle_x = 0.0;
92 angle_y = 180.0;
93 break;
94 }
95 vec4_t q_a, q_b;
97 axis.x = 0.0;
98 axis.y = 1.0;
99 axis.z = 0.0;
100 q_a = axis_to_quat (axis, -pi*angle_y/180.0);
101 axis.x = 1.0;
102 axis.y = 0.0;
103 axis.z = 0.0;
104 q_b = axis_to_quat (axis, -pi*angle_x/180.0);
105 get_project_by_id(id -> a) -> modelgl -> anim -> last -> img -> rotation_quaternion = q4_mul (q_a, q_b);
106 update (get_project_by_id(id -> a) -> modelgl);
107}
108
109#ifdef GTK3
117GtkWidget * menu_proj (glwin * view)
118{
119 GtkWidget * menup = gtk_menu_new ();
120 GtkWidget * r = create_menu_item (FALSE, "Right [1, 0, 0]");
121 g_signal_connect (G_OBJECT (r), "activate", G_CALLBACK(set_camera_pos), & view -> colorp[RIGHT][0]);
122 gtk_menu_shell_append ((GtkMenuShell *)menup, r);
123 GtkWidget * l = create_menu_item (FALSE, "Left [-1, 0, 0]");
124 g_signal_connect (G_OBJECT (l), "activate", G_CALLBACK(set_camera_pos), & view -> colorp[LEFT][0]);
125 gtk_menu_shell_append ((GtkMenuShell *)menup, l);
126 GtkWidget * t = create_menu_item (FALSE, "Top [0, 1, 0]");
127 g_signal_connect (G_OBJECT (t), "activate", G_CALLBACK(set_camera_pos), & view -> colorp[TOP][0]);
128 gtk_menu_shell_append ((GtkMenuShell *)menup, t);
129 GtkWidget * b = create_menu_item (FALSE, "Bottom [0, -1, 0]");
130 g_signal_connect (G_OBJECT (b), "activate", G_CALLBACK(set_camera_pos), & view -> colorp[BOTTOM][0]);
131 gtk_menu_shell_append ((GtkMenuShell *)menup, b);
132 GtkWidget * f = create_menu_item (FALSE, "Front [0, 0, 1]");
133 g_signal_connect (G_OBJECT (f), "activate", G_CALLBACK(set_camera_pos), & view -> colorp[FRONT][0]);
134 gtk_menu_shell_append ((GtkMenuShell *)menup, f);
135 GtkWidget * a = create_menu_item (FALSE, "Back [0, 0, -1]");
136 g_signal_connect (G_OBJECT (a), "activate", G_CALLBACK(set_camera_pos), & view -> colorp[BACK][0]);
137 gtk_menu_shell_append ((GtkMenuShell *)menup, a);
138
139 return menup;
140}
141#else
151G_MODULE_EXPORT void to_set_camera_pos (GSimpleAction * action, GVariant * parameter, gpointer data)
152{
153 set_camera_pos (NULL, data);
154}
155
164GMenu * menu_proj (glwin * view, int popm)
165{
166 GMenu * menu = g_menu_new ();
167 gchar * projection[6]={"Right [1, 0, 0]", "Left [-1, 0, 0]", "Top [0, 1, 0]", "Bottom [0, -1, 0]", "Front [0, 0, 1]", "Back [0, 0, -1]"};
168 int i;
169 for (i=0; i<6; i++)
170 {
171 append_opengl_item (view, menu, projection[i], "proj", popm, i, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(to_set_camera_pos), & view -> colorp[i][0], FALSE, FALSE, FALSE, TRUE);
172 }
173 return menu;
174}
175#endif
gchar * axis[3]
Definition w_axis.c:65
color colorp[64]
double pi
Definition global.c:195
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
action
Definition glview.h:189
Function declarations for the creation of the OpenGL window.
void append_opengl_item(glwin *view, GMenu *menu, const gchar *name, gchar *key, int mpop, int item_id, gchar *accel, int image_format, gpointer icon, gboolean custom, GCallback handler, gpointer data, gboolean check, gboolean status, gboolean radio, gboolean sensitive)
position
Definition m_proj.c:47
@ TOP
Definition m_proj.c:50
@ FRONT
Definition m_proj.c:52
@ BOTTOM
Definition m_proj.c:51
@ BACK
Definition m_proj.c:53
@ LEFT
Definition m_proj.c:49
@ RIGHT
Definition m_proj.c:48
GMenu * menu_proj(glwin *view, int popm)
create the 'View -> Projection' submenu - GTK4
Definition m_proj.c:164
G_MODULE_EXPORT void set_camera_pos(GtkWidget *widg, gpointer data)
set camera position callback
Definition m_proj.c:64
G_MODULE_EXPORT void to_set_camera_pos(GSimpleAction *action, GVariant *parameter, gpointer data)
set camera position callback GTK4
Definition m_proj.c:151
Definition glwin.h:875
Definition global.h:104
float x
Definition math_3d.h:130
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
GtkWidget * img
Definition workspace.c:70