38#include "RNA_prototypes.hh"
93 Eyedropper *eye = MEM_new<Eyedropper>(__func__);
101 if (!prop_data_path || prop_data_path[0] ==
'\0') {
115 if (but !=
nullptr) {
123 if ((eye->
ptr.
data ==
nullptr) || (eye->
prop ==
nullptr) ||
136 if (eye->
ptr.
type == &RNA_CompositorNodeCryptomatteV2) {
145 const char *display_device;
147 display_device = scene->display_settings.display_device;
188 const char *type_name,
192 int material_slot = 0;
198 const ID *
id =
nullptr;
214 const char *name = &
id->name[2];
230 const int render_layer_name_len =
BLI_strnlen(render_layer->
name,
sizeof(render_layer->
name));
231 if (strncmp(prefix, render_layer->
name, render_layer_name_len) != 0) {
235 const int prefix_len = strlen(prefix);
236 if (prefix_len <= render_layer_name_len + 1) {
241 const char *render_pass_name_prefix = render_layer_name_len ?
242 prefix + 1 + render_layer_name_len :
246 if (
STRPREFIX(render_pass->name, render_pass_name_prefix) &&
247 !
STREQLEN(render_pass->name, render_pass_name_prefix,
sizeof(render_pass->name)))
252 if (!render_pass->ibuf) {
256 const int x =
int(fpos[0] * render_pass->rectx);
257 const int y =
int(fpos[1] * render_pass->recty);
258 const int offset = 4 * (y * render_pass->rectx +
x);
260 r_col[0] = render_pass->ibuf->float_buffer.data[offset];
273 bool success =
false;
300 bool success =
false;
322 const int event_xy[2],
361 const int mval[2] = {
362 event_xy_win[0] - region->winrct.xmin,
363 event_xy_win[1] - region->winrct.ymin,
365 float fpos[2] = {-1.0f, -1.0};
366 switch (area->spacetype) {
389 (fpos[0] < 0.0f || fpos[1] < 0.0f || fpos[0] >= 1.0f || fpos[1] >= 1.0f))
435 const int event_xy[2],
450 const int mval[2] = {
451 event_xy_win[0] - region->winrct.xmin,
452 event_xy_win[1] - region->winrct.ymin,
473 else if (eye !=
nullptr && area->spacetype ==
SPACE_VIEW3D) {
478 eye->
viewport_session = MEM_new<ViewportColorSampleSession>(
"viewport_session");
566 const int event_xy[2])
596 switch (event->
val) {
601 const bool is_undo = eye->
is_undo;
680 ot->
idname =
"UI_OT_eyedropper_color";
681 ot->
description =
"Sample a color from the Blender window to store in a property";
700 "Path of property to be set with the depth");
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
uint32_t BKE_cryptomatte_hash(const char *name, int name_len)
bool BKE_cryptomatte_find_name(const struct CryptomatteSession *session, float encoded_hash, char *r_name, int name_maxncpy)
void BKE_cryptomatte_free(struct CryptomatteSession *session)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
ARegion * BKE_area_find_region_xy(const ScrArea *area, int regiontype, const int xy[2]) ATTR_NONNULL(3)
ScrArea ScrArea * BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
#define LISTBASE_FOREACH(type, var, list)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
#define BLI_SCOPED_DEFER(function_to_defer)
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STREQLEN(a, b, n)
@ CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
#define RE_PASSNAME_CRYPTOMATTE_MATERIAL
#define RE_PASSNAME_CRYPTOMATTE_OBJECT
bool ED_space_clip_get_position(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_fpos[2])
bool ED_space_clip_color_sample(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_col[3])
bool ED_space_image_get_position(SpaceImage *sima, ARegion *region, const int mval[2], float r_fpos[2])
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float fpos[2])
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
void ED_region_tag_redraw(ARegion *region)
Object * ED_view3d_give_material_slot_under_cursor(bContext *C, const int mval[2], int *r_material_slot)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
uiBut * UI_context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
void UI_context_active_but_clear(bContext *C, wmWindow *win, ARegion *region)
bool UI_but_flag_is_set(uiBut *but, int flag)
@ WM_CAPABILITY_DESKTOP_SAMPLE
bool init(ARegion *region)
bool sample(const int mval[2], float r_col[3])
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int event_xy[2])
static bool eyedropper_init(bContext *C, wmOperator *op)
static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
static void eyedropper_cancel(bContext *C, wmOperator *op)
static void eyedropper_exit(bContext *C, wmOperator *op)
static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_layer, const char *prefix, const float fpos[2], float r_col[3])
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool eyedropper_cryptomatte_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void eyedropper_draw_cb(const wmWindow *, void *arg)
static bool eyedropper_cryptomatte_sample_render_fl(const bNode *node, const char *prefix, const float fpos[2], float r_col[3])
void UI_OT_eyedropper_color(wmOperatorType *ot)
static bool eyedropper_poll(bContext *C)
static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node, NodeCryptomatte *crypto, const char *prefix, const float fpos[2], float r_col[3])
static int eyedropper_exec(bContext *C, wmOperator *op)
static bool eyedropper_cryptomatte_sample_view3d_fl(bContext *C, const char *type_name, const int mval[2], float r_col[3])
void eyedropper_color_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
@ EYE_MODAL_SAMPLE_CONFIRM
void eyedropper_draw_cursor_text_region(const int xy[2], const char *name)
void MEM_freeN(void *vmemh)
void ntreeCompositCryptomatteLayerPrefix(const bNode *node, char *r_prefix, size_t prefix_maxncpy)
CryptomatteSession * ntreeCompositCryptomatteSession(bNode *node)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
RenderResult * RE_AcquireResultRead(Render *re)
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
void RE_ReleaseResult(Render *re)
Render * RE_GetSceneRender(const Scene *scene)
char sample_text[MAX_NAME]
ColorManagedDisplay * display
ViewportColorSampleSession * viewport_session
CryptomatteSession * cryptomatte_session
void * draw_handle_sample_text
ColorManagedDisplaySettings display_settings
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
struct ReportList * reports
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
void WM_draw_cb_exit(wmWindow *win, void *handle)
bool WM_desktop_cursor_sample_read(float r_col[3])
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
#define ISMOUSE_MOTION(event_type)
wmWindow * WM_window_find_under_cursor(wmWindow *win, const int event_xy[2], int r_event_xy_other[2])
eWM_CapabilitiesFlag WM_capabilities_flag()
bScreen * WM_window_get_active_screen(const wmWindow *win)