Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rna_volume.c « intern « makesrna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 551dd9915e009036b46902a9f20a4075816ad28e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Contributor(s): Jörg Müller.
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file blender/makesrna/intern/rna_volume.c
 *  \ingroup RNA
 */

#include <stdlib.h>

#include "RNA_define.h"
#include "RNA_enum_types.h"

#include "rna_internal.h"

#include "DNA_volume_types.h"

#include "BLI_math_base.h"

#ifdef RNA_RUNTIME

#include "BKE_volume.h"

static void rna_VolumeGrid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
}

static void rna_Volume_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
	Volume *volume = ptr->data;
	BKE_volume_reload(bmain, volume);
}

static void rna_VolumeGrids_active_grid_index_range(
        PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
{
	Volume *volume = (Volume *)ptr->data;

	*min = 0;
	*max = max_ii(0, BLI_listbase_count(&volume->grids) - 1);
}

static int rna_VolumeGrids_active_grid_index_get(PointerRNA *ptr)
{
	Volume *volume = (Volume *)ptr->data;
	return 0; // TODO
}

static void rna_VolumeGrids_active_grid_index_set(PointerRNA *ptr, int value)
{
	Volume *volume = (Volume *)ptr->data;
	// TODO
}

#else

static void rna_def_volume_grid(BlenderRNA *brna)
{
	StructRNA *srna;
	PropertyRNA *prop;

	srna = RNA_def_struct(brna, "VolumeGrid", NULL);
	RNA_def_struct_ui_text(srna, "Volume Grid", "3D volume grid");
	RNA_def_struct_ui_icon(srna, ICON_VOLUME);

	prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
	RNA_def_property_ui_text(prop, "Name", "Volume grid name");
	RNA_def_property_update(prop, 0, "rna_VolumeGrid_update");
}

static void rna_def_volume_grids(BlenderRNA *brna,  PropertyRNA *cprop)
{
	StructRNA *srna;
	PropertyRNA *prop;

	RNA_def_property_srna(cprop, "VolumeGrids");
	srna = RNA_def_struct(brna, "VolumeGrids", NULL);
	RNA_def_struct_sdna(srna, "Volume");
	RNA_def_struct_ui_text(srna, "Volume Grids", "3D volume grids");

	prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
	RNA_def_property_int_funcs(prop, "rna_VolumeGrids_active_grid_index_get",
	                           "rna_VolumeGrids_active_grid_index_set",
	                           "rna_VolumeGrids_active_grid_index_range");
	RNA_def_property_ui_text(prop, "Active Grid Index", "Index of active volume grid");
}

static void rna_def_volume(BlenderRNA *brna)
{
	StructRNA *srna;
	PropertyRNA *prop;

	srna = RNA_def_struct(brna, "Volume", "ID");
	RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
	RNA_def_struct_ui_icon(srna, ICON_VOLUME);

	prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
	RNA_def_property_ui_text(prop, "File Path", "Volume sample file used by this Volume data-block");
	RNA_def_property_update(prop, 0, "rna_Volume_update");

	prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
	RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
	RNA_def_property_ui_text(prop, "Packed File", "");

	prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
	RNA_def_property_struct_type(prop, "VolumeGrid");
	RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
	rna_def_volume_grids(brna, prop);


	/* common */
	rna_def_animdata_common(srna);
}


void RNA_def_volume(BlenderRNA *brna)
{
	rna_def_volume_grid(brna);
	rna_def_volume(brna);
}

#endif