54 const float old_aspect = oldwidth / oldheight;
60 bool has_frame =
false;
63 if ((
node->flag & node_flag) == node_flag) {
84 if ((tot == 1) && (has_frame ==
false) && ((oldwidth * oldheight) > (
width *
height))) {
89 if (old_aspect < new_aspect) {
90 const float height_new =
width / old_aspect;
91 cur_new.
ymin = cur_new.
ymin - height_new / 2.0f;
92 cur_new.
ymax = cur_new.
ymax + height_new / 2.0f;
95 const float width_new =
height * old_aspect;
96 cur_new.
xmin = cur_new.
xmin - width_new / 2.0f;
97 cur_new.
xmax = cur_new.
xmax + width_new / 2.0f;
161 ot->
name =
"Frame Selected";
162 ot->
idname =
"NODE_OT_view_selected";
163 ot->
description =
"Resize view so you can see selected nodes";
192 switch (event->
type) {
195 snode->
xof -= (nvm->
mvalo[0] -
event->mval[0]);
196 snode->
yof -= (nvm->
mvalo[1] -
event->mval[1]);
197 nvm->
mvalo[0] =
event->mval[0];
198 nvm->
mvalo[1] =
event->mval[1];
243 const float pad = 32.0f;
250 if (ibuf ==
nullptr) {
255 nvm = MEM_cnew<NodeViewMove>(
"NodeViewMove struct");
257 nvm->
mvalo[0] =
event->mval[0];
258 nvm->
mvalo[1] =
event->mval[1];
285 ot->
name =
"Background Image Move";
287 ot->
idname =
"NODE_OT_backimage_move";
323 ot->
name =
"Background Image Zoom";
324 ot->
idname =
"NODE_OT_backimage_zoom";
353 const float pad = 32.0f;
362 if ((ibuf ==
nullptr) || (ibuf->
x == 0) || (ibuf->
y == 0)) {
367 facx = 1.0f * (region->
sizex -
pad) / (ibuf->
x * snode->
zoom);
368 facy = 1.0f * (region->
sizey -
pad) / (ibuf->
y * snode->
zoom);
388 ot->
name =
"Background Image Fit";
389 ot->
idname =
"NODE_OT_backimage_fit";
465 float bufx = ibuf->
x * snode->
zoom;
466 float bufy = ibuf->
y * snode->
zoom;
467 fpos[0] = (bufx > 0.0f ? ((
float)mval[0] - 0.5f * region->
winx - snode->
xof) / bufx + 0.5f :
469 fpos[1] = (bufy > 0.0f ? ((
float)mval[1] - 0.5f * region->
winy - snode->
yof) / bufy + 0.5f :
482 float fx, fy, bufx, bufy;
499 bufx = ibuf->
x * snode->
zoom;
500 bufy = ibuf->
y * snode->
zoom;
501 fx = (bufx > 0.0f ? ((
float)mval[0] - 0.5f * region->
winx - snode->
xof) / bufx + 0.5f : 0.0f);
502 fy = (bufy > 0.0f ? ((
float)mval[1] - 0.5f * region->
winy - snode->
yof) / bufy + 0.5f : 0.0f);
504 if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
507 int x = (int)(fx * ibuf->
x),
y = (int)(fy * ibuf->
y);
518 else if (ibuf->
rect) {
542 float fx, fy, bufx, bufy;
556 bufx = ibuf->x * snode->
zoom;
557 bufy = ibuf->y * snode->
zoom;
558 fx = (bufx > 0.0f ? ((
float)event->
mval[0] - 0.5f * region->
winx - snode->
xof) / bufx + 0.5f :
560 fy = (bufy > 0.0f ? ((
float)event->
mval[1] - 0.5f * region->
winy - snode->
yof) / bufy + 0.5f :
563 if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
566 int x = (int)(fx * ibuf->x),
y = (int)(fy * ibuf->y);
580 cp = (
uchar *)(ibuf->rect +
y * ibuf->x +
x);
582 info->
col[0] = cp[0];
583 info->
col[1] = cp[1];
584 info->
col[2] = cp[2];
585 info->
col[3] = cp[3];
594 info->
linearcol,
false, ibuf->rect_colorspace);
598 if (ibuf->rect_float) {
599 fp = (ibuf->rect_float + (ibuf->channels) * (
y * ibuf->x +
x));
601 info->
colf[0] = fp[0];
602 info->
colf[1] = fp[1];
603 info->
colf[2] = fp[2];
604 info->
colf[3] = fp[3];
610 info->
z = ibuf->zbuf[
y * ibuf->x +
x];
613 if (ibuf->zbuf_float) {
614 info->
zf = ibuf->zbuf_float[
y * ibuf->x +
x];
615 info->
zfp = &info->
zf;
656 info = MEM_cnew<ImageSampleInfo>(
"ImageSampleInfo");
671 switch (event->
type) {
695 ot->
name =
"Backimage Sample";
696 ot->
idname =
"NODE_OT_backimage_sample";
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct SpaceNode * CTX_wm_space_node(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float min_ff(float a, float b)
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
void BLI_rctf_scale(rctf *rect, float scale)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
void BLI_rctf_init_minmax(struct rctf *rect)
void ED_image_draw_info(struct Scene *scene, struct ARegion *region, bool color_manage, bool use_default_view, int channels, int x, int y, const unsigned char cp[4], const float fp[4], const float linearcol[4], const int *zp, const float *zpf)
bool ED_node_is_compositor(struct SpaceNode *snode)
void ED_node_sample_set(const float col[4])
void ED_area_tag_redraw(ScrArea *area)
bool ED_operator_node_active(struct bContext *C)
void ED_region_tag_redraw(struct ARegion *region)
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
#define REGION_DRAW_POST_PIXEL
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], bool predivide, struct ColorSpace *colorspace)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
void IMB_rect_from_float(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
void UI_view2d_smooth_view(const struct bContext *C, struct ARegion *region, const struct rctf *cur, int smooth_viewtx)
#define ND_SPACE_NODE_VIEW
int pad[32 - sizeof(int)]
void(* MEM_freeN)(void *vmemh)
bool node_or_socket_isect_event(bContext *C, const wmEvent *event)
static int backimage_zoom_exec(bContext *C, wmOperator *op)
static int node_view_selected_exec(bContext *C, wmOperator *op)
static void snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
bool space_node_view_flag(bContext &C, SpaceNode &snode, ARegion ®ion, int node_flag, int smooth_viewtx)
void NODE_OT_backimage_sample(wmOperatorType *ot)
static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_backimage_zoom(wmOperatorType *ot)
void NODE_OT_backimage_move(wmOperatorType *ot)
static void sample_exit(bContext *C, wmOperator *op)
static int node_view_all_exec(bContext *C, wmOperator *op)
static void sample_cancel(bContext *C, wmOperator *op)
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_view_selected(wmOperatorType *ot)
static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
void NODE_OT_view_all(wmOperatorType *ot)
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool composite_node_active(bContext *C)
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_backimage_fit(wmOperatorType *ot)
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, struct ARegion *region, const int mval[2], float fpos[2])
float RNA_float_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
struct ARegionType * type
struct ColorSpace * rect_colorspace
struct bNodeTree * edittree
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
int WM_operator_smooth_viewtx_get(const wmOperator *op)