atomes 1.3.1
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-2026 by CNRS and University of Strasbourg */
15
21
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, gpointer data);
34
35 void show_title (cairo_t * cr, Curve * this_curve);
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, gpointer data)
55{
56 tint * pcc = (tint *)data;
57 project * this_proj = get_project_by_id (pcc -> a);
58 gchar * freq_unit[5]={" THz", " THz", " MHz", " KHz", " Hz"};
59 if (ax == 0)
60 {
61 int rid = pcc -> b;
62 int cid = pcc -> c;
63 if (rid == MSD)
64 {
65 if (this_proj -> tunit > -1)
66 {
67 return g_strdup_printf ("t [%s]", untime[this_proj -> tunit]);
68 }
69 else
70 {
71 return NULL;
72 }
73 }
74 else if (rid == SKT)
75 {
76 if (cid < this_proj -> skt_sets)
77 {
78 return g_strdup_printf ("q [&#xC5;<sup>-1</sup>]");
79 }
80 else
81 {
82 return g_strdup_printf ("ω %s", freq_unit[this_proj -> tunit]);
83 }
84 }
85 else
86 {
87 return this_proj -> analysis[rid] -> x_title;
88 }
89 }
90 else
91 {
92 return get_curve_from_pointer (data) -> name;
93 }
94}
95
104void show_title (cairo_t * cr, Curve * this_curve)
105{
106 double x, y;
107
108 x = this_curve -> title_pos[0] * resol[0];
109 y = this_curve -> title_pos[1] * resol[1];
110 cairo_set_source_rgba (cr, this_curve -> title_color.red,
111 this_curve -> title_color.green,
112 this_curve -> title_color.blue,
113 this_curve -> title_color.alpha);
114 pango_layout_set_font_description (layout, pango_font_description_from_string (this_curve -> title_font));
115 pango_layout_set_markup (layout, this_curve -> title, -1);
116 // pango_layout_set_text (layout, this_curve -> title, -1);
117 cairo_move_to (cr, x, y);
118 pango_cairo_update_layout (cr, layout);
119 pango_cairo_show_layout (cr, layout);
120 cairo_stroke (cr);
121}
int resol[2]
Definition curve.c:65
Curve * get_curve_from_pointer(gpointer data)
get Curve pointer from pointer
Definition curve.c:313
double ax
Definition curve.c:71
PangoLayout * layout
Definition curve.c:80
Variable declarations for the curve widget Functions for interactions with the curve widget.
char * untime[5]
Definition global.c:153
Global variable declarations Global convenience function declarations Global data structure defin...
#define SKT
Definition global.h:347
#define MSD
Definition global.h:346
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
double y
Definition ogl_draw.c:63
double x
Definition ogl_draw.c:63
Definition global.h:118
void show_title(cairo_t *cr, Curve *this_curve)
draw title
Definition title.c:104
const gchar * default_title(int ax, gpointer data)
default title string
Definition title.c:54