atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
title.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: 'title.c'
24*
25* Contains:
26*
27
28 - The functions to draw the curve title
29
30*
31* List of functions:
32
33 const gchar * default_title (int ax, int c);
34
35 void show_title (cairo_t * cr, project * this_proj, int rid, int cid);
36
37*/
38
39#include <gtk/gtk.h>
40#include <cairo.h>
41#include <pango/pangocairo.h>
42
43#include "global.h"
44#include "curve.h"
45
54const gchar * default_title (int ax, int c)
55{
56 if (ax == 0)
57 {
58 if (activer == GR || activer == GK)
59 {
60 return ("r [Å]");
61 }
62 else if (activer == SQ || activer == SK)
63 {
64 return ("q [Å-1]");
65 }
66 else if (activer == BD)
67 {
68 return ("Dij [Å]");
69 }
70 else if (activer == AN)
71 {
72 return ("θ [°]");
73 }
74 else if (activer == RI)
75 {
76 return ("Size n of the ring [total number of nodes]");
77 }
78 else if (activer == CH)
79 {
80 return ("Size n of the chain [total number of nodes]");
81 }
82 else if (activer == SP)
83 {
84 return ("Ql");
85 }
86 else
87 {
88 return g_strdup_printf ("t [%s]", untime[active_project -> tunit]);
89 }
90 }
91 else
92 {
93 return active_project -> curves[activer][c] -> name;
94 }
95}
96
107void show_title (cairo_t * cr, project * this_proj, int rid, int cid)
108{
109 double x, y;
110
111 x = this_proj -> curves[rid][cid] -> title_pos[0] * resol[0];
112 y = this_proj -> curves[rid][cid] -> title_pos[1] * resol[1];
113 cairo_set_source_rgba (cr, this_proj -> curves[rid][cid] -> title_color.red,
114 this_proj -> curves[rid][cid] -> title_color.green,
115 this_proj -> curves[rid][cid] -> title_color.blue,
116 this_proj -> curves[rid][cid] -> title_color.alpha);
117 pango_layout_set_font_description (layout, pango_font_description_from_string (this_proj -> curves[rid][cid] -> title_font));
118 pango_layout_set_text (layout, this_proj -> curves[rid][cid] -> title, -1);
119 cairo_move_to (cr, x, y);
120 pango_cairo_update_layout (cr, layout);
121 pango_cairo_show_layout (cr, layout);
122 cairo_stroke (cr);
123}
int resol[2]
Definition curve.c:64
double ax
Definition curve.c:70
PangoLayout * layout
Definition curve.c:79
Variable declarations for the curve widget Functions for interactions with the curve widget.
int activer
Definition w_curve.c:74
char * untime[6]
Definition global.c:149
Global variable declarations Global convenience function declarations Global data structure defin...
#define GR
Definition global.h:294
#define SQ
Definition global.h:295
#define RI
Definition global.h:300
#define BD
Definition global.h:298
#define AN
Definition global.h:299
#define SK
Definition global.h:296
#define GK
Definition global.h:297
#define SP
Definition global.h:302
project * active_project
Definition project.c:47
#define CH
Definition global.h:301
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
int c
Definition tab-1.c:95
const gchar * default_title(int ax, int c)
default title string
Definition title.c:54
void show_title(cairo_t *cr, project *this_proj, int rid, int cid)
draw title
Definition title.c:107