2011-02-23 10:52:22 +00:00
/*
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
* * * * * * 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 ,
2010-02-12 13:34:04 +00:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
*
* The Original Code is Copyright ( C ) 2001 - 2002 by NaN Holding BV .
* All rights reserved .
*
2010-03-23 01:22:33 +00:00
* Contributor ( s ) : Blender Foundation , 2002 - 2009 , Xavier Thomas
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
2011-02-27 20:29:51 +00:00
/** \file blender/editors/space_image/image_ops.c
* \ ingroup spimage
*/
2010-06-17 07:20:12 +00:00
# include <stddef.h>
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include <string.h>
# include <stdlib.h>
2010-07-03 17:47:06 +00:00
# include <errno.h>
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "MEM_guardedalloc.h"
2011-01-07 18:36:47 +00:00
# include "BLI_math.h"
# include "BLI_blenlib.h"
# include "BLI_utildefines.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "DNA_object_types.h"
2010-07-23 14:34:43 +00:00
# include "DNA_node_types.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "DNA_packedFile_types.h"
# include "DNA_scene_types.h"
# include "BKE_colortools.h"
# include "BKE_context.h"
# include "BKE_image.h"
# include "BKE_global.h"
# include "BKE_library.h"
2010-02-13 13:09:30 +00:00
# include "BKE_main.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "BKE_node.h"
# include "BKE_packedFile.h"
2009-02-10 23:17:58 +00:00
# include "BKE_report.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "BKE_screen.h"
# include "IMB_imbuf.h"
# include "IMB_imbuf_types.h"
# include "RE_pipeline.h"
# include "RNA_access.h"
# include "RNA_define.h"
2009-08-28 20:41:12 +00:00
# include "RNA_enum_types.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-09 20:58:31 +00:00
# include "ED_image.h"
2011-03-03 15:18:35 +00:00
# include "ED_render.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "ED_screen.h"
2009-02-10 23:17:58 +00:00
# include "ED_space_api.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "ED_uvedit.h"
2011-01-26 14:18:16 +00:00
# include "ED_util.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-11 19:16:14 +00:00
# include "UI_interface.h"
# include "UI_resources.h"
2009-02-10 23:17:58 +00:00
# include "UI_view2d.h"
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
# include "WM_api.h"
# include "WM_types.h"
# include "image_intern.h"
/******************** view navigation utilities *********************/
static void sima_zoom_set ( SpaceImage * sima , ARegion * ar , float zoom )
{
float oldzoom = sima - > zoom ;
int width , height ;
sima - > zoom = zoom ;
if ( sima - > zoom > 0.1f & & sima - > zoom < 4.0f )
return ;
/* check zoom limits */
2009-02-09 20:58:31 +00:00
ED_space_image_size ( sima , & width , & height ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
width * = sima - > zoom ;
height * = sima - > zoom ;
if ( ( width < 4 ) & & ( height < 4 ) )
sima - > zoom = oldzoom ;
else if ( ( ar - > winrct . xmax - ar - > winrct . xmin ) < = sima - > zoom )
sima - > zoom = oldzoom ;
else if ( ( ar - > winrct . ymax - ar - > winrct . ymin ) < = sima - > zoom )
sima - > zoom = oldzoom ;
}
static void sima_zoom_set_factor ( SpaceImage * sima , ARegion * ar , float zoomfac )
{
sima_zoom_set ( sima , ar , sima - > zoom * zoomfac ) ;
}
2010-04-19 07:28:23 +00:00
#if 0 // currently unused
2009-10-09 22:00:33 +00:00
static int image_poll ( bContext * C )
{
return ( CTX_data_edit_image ( C ) ! = NULL ) ;
}
2010-04-19 07:28:23 +00:00
# endif
2009-10-09 22:00:33 +00:00
2010-04-19 07:28:23 +00:00
static int space_image_buffer_exists_poll ( bContext * C )
2009-02-10 23:17:58 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-18 18:08:33 +00:00
if ( sima & & sima - > spacetype = = SPACE_IMAGE )
2009-09-30 18:18:32 +00:00
if ( ED_space_image_has_buffer ( sima ) )
2009-02-18 18:08:33 +00:00
return 1 ;
return 0 ;
}
2009-02-10 23:17:58 +00:00
2009-02-18 18:08:33 +00:00
static int space_image_file_exists_poll ( bContext * C )
{
2010-04-19 07:28:23 +00:00
if ( space_image_buffer_exists_poll ( C ) ) {
2010-11-16 13:08:24 +00:00
Main * bmain = CTX_data_main ( C ) ;
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-09-30 18:18:32 +00:00
ImBuf * ibuf ;
void * lock ;
2010-07-21 14:09:45 +00:00
int poll = 0 ;
char name [ FILE_MAX ] ;
2009-09-30 18:18:32 +00:00
ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
2010-07-21 14:09:45 +00:00
if ( ibuf ) {
BLI_strncpy ( name , ibuf - > name , FILE_MAX ) ;
2010-11-16 13:08:24 +00:00
BLI_path_abs ( name , bmain - > name ) ;
2011-10-22 15:35:49 +00:00
poll = ( BLI_exists ( name ) & & BLI_file_is_writable ( name ) ) ;
2010-07-21 14:09:45 +00:00
}
2009-09-30 18:18:32 +00:00
ED_space_image_release_buffer ( sima , lock ) ;
return poll ;
2009-02-18 18:08:33 +00:00
}
return 0 ;
2009-02-10 23:17:58 +00:00
}
2010-04-19 07:28:23 +00:00
static int space_image_poll ( bContext * C )
{
SpaceImage * sima = CTX_wm_space_image ( C ) ;
if ( sima & & sima - > spacetype = = SPACE_IMAGE & & sima - > image )
return 1 ;
return 0 ;
}
2009-01-30 12:58:00 +00:00
int space_image_main_area_poll ( bContext * C )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-06-16 01:22:56 +00:00
// XXX ARegion *ar= CTX_wm_region(C);
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-07-28 16:33:02 +00:00
if ( sima )
2009-06-16 01:22:56 +00:00
return 1 ; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW);
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
return 0 ;
}
/********************** view pan operator *********************/
typedef struct ViewPanData {
float x , y ;
float xof , yof ;
2011-03-22 15:20:25 +00:00
int event_type ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
} ViewPanData ;
static void view_pan_init ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ViewPanData * vpd ;
op - > customdata = vpd = MEM_callocN ( sizeof ( ViewPanData ) , " ImageViewPanData " ) ;
WM_cursor_modal ( CTX_wm_window ( C ) , BC_NSEW_SCROLLCURSOR ) ;
vpd - > x = event - > x ;
vpd - > y = event - > y ;
vpd - > xof = sima - > xof ;
vpd - > yof = sima - > yof ;
2011-03-22 15:20:25 +00:00
vpd - > event_type = event - > type ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
static void view_pan_exit ( bContext * C , wmOperator * op , int cancel )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ViewPanData * vpd = op - > customdata ;
if ( cancel ) {
sima - > xof = vpd - > xof ;
sima - > yof = vpd - > yof ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
WM_cursor_restore ( CTX_wm_window ( C ) ) ;
MEM_freeN ( op - > customdata ) ;
}
static int view_pan_exec ( bContext * C , wmOperator * op )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
float offset [ 2 ] ;
RNA_float_get_array ( op - > ptr , " offset " , offset ) ;
sima - > xof + = offset [ 0 ] ;
sima - > yof + = offset [ 1 ] ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* XXX notifier? */
#if 0
if ( image_preview_active ( curarea , NULL , NULL ) ) {
/* recalculates new preview rect */
scrarea_do_windraw ( curarea ) ;
image_preview_event ( 2 ) ;
}
# endif
return OPERATOR_FINISHED ;
}
static int view_pan_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2010-01-11 11:14:36 +00:00
if ( event - > type = = MOUSEPAN ) {
SpaceImage * sima = CTX_wm_space_image ( C ) ;
float offset [ 2 ] ;
offset [ 0 ] = ( event - > x - event - > prevx ) / sima - > zoom ;
offset [ 1 ] = ( event - > y - event - > prevy ) / sima - > zoom ;
RNA_float_set_array ( op - > ptr , " offset " , offset ) ;
view_pan_exec ( C , op ) ;
return OPERATOR_FINISHED ;
}
else {
view_pan_init ( C , op , event ) ;
return OPERATOR_RUNNING_MODAL ;
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
static int view_pan_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ViewPanData * vpd = op - > customdata ;
float offset [ 2 ] ;
switch ( event - > type ) {
case MOUSEMOVE :
sima - > xof = vpd - > xof ;
sima - > yof = vpd - > yof ;
offset [ 0 ] = ( vpd - > x - event - > x ) / sima - > zoom ;
offset [ 1 ] = ( vpd - > y - event - > y ) / sima - > zoom ;
RNA_float_set_array ( op - > ptr , " offset " , offset ) ;
view_pan_exec ( C , op ) ;
break ;
2011-03-22 15:20:25 +00:00
default :
if ( event - > type = = vpd - > event_type & & event - > val = = KM_RELEASE ) {
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
view_pan_exit ( C , op , 0 ) ;
return OPERATOR_FINISHED ;
}
break ;
}
return OPERATOR_RUNNING_MODAL ;
}
static int view_pan_cancel ( bContext * C , wmOperator * op )
{
view_pan_exit ( C , op , 1 ) ;
return OPERATOR_CANCELLED ;
}
void IMAGE_OT_view_pan ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View Pan " ;
ot - > idname = " IMAGE_OT_view_pan " ;
/* api callbacks */
ot - > exec = view_pan_exec ;
ot - > invoke = view_pan_invoke ;
ot - > modal = view_pan_modal ;
ot - > cancel = view_pan_cancel ;
ot - > poll = space_image_main_area_poll ;
2009-07-11 14:51:13 +00:00
/* flags */
ot - > flag = OPTYPE_BLOCKING ;
2009-01-31 19:40:40 +00:00
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* properties */
2009-01-16 23:53:11 +00:00
RNA_def_float_vector ( ot - > srna , " offset " , 2 , NULL , - FLT_MAX , FLT_MAX ,
2011-09-19 12:26:20 +00:00
" Offset " , " Offset in floating point units, 1.0 is the width and height of the image " , - FLT_MAX , FLT_MAX ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
/********************** view zoom operator *********************/
typedef struct ViewZoomData {
float x , y ;
float zoom ;
2011-03-22 15:20:25 +00:00
int event_type ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
} ViewZoomData ;
static void view_zoom_init ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ViewZoomData * vpd ;
op - > customdata = vpd = MEM_callocN ( sizeof ( ViewZoomData ) , " ImageViewZoomData " ) ;
WM_cursor_modal ( CTX_wm_window ( C ) , BC_NSEW_SCROLLCURSOR ) ;
vpd - > x = event - > x ;
vpd - > y = event - > y ;
vpd - > zoom = sima - > zoom ;
2011-03-22 15:20:25 +00:00
vpd - > event_type = event - > type ;
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
static void view_zoom_exit ( bContext * C , wmOperator * op , int cancel )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ViewZoomData * vpd = op - > customdata ;
if ( cancel ) {
sima - > zoom = vpd - > zoom ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
WM_cursor_restore ( CTX_wm_window ( C ) ) ;
MEM_freeN ( op - > customdata ) ;
}
static int view_zoom_exec ( bContext * C , wmOperator * op )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
sima_zoom_set_factor ( sima , ar , RNA_float_get ( op - > ptr , " factor " ) ) ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* XXX notifier? */
#if 0
if ( image_preview_active ( curarea , NULL , NULL ) ) {
/* recalculates new preview rect */
scrarea_do_windraw ( curarea ) ;
image_preview_event ( 2 ) ;
}
# endif
return OPERATOR_FINISHED ;
}
static int view_zoom_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2010-01-11 11:14:36 +00:00
if ( event - > type = = MOUSEZOOM ) {
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
float factor ;
2011-03-27 17:22:04 +00:00
factor = 1.0f + ( event - > x - event - > prevx + event - > y - event - > prevy ) / 300.0f ;
2010-01-11 11:14:36 +00:00
RNA_float_set ( op - > ptr , " factor " , factor ) ;
sima_zoom_set ( sima , ar , sima - > zoom * factor ) ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2010-01-11 11:14:36 +00:00
return OPERATOR_FINISHED ;
}
else {
view_zoom_init ( C , op , event ) ;
return OPERATOR_RUNNING_MODAL ;
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
static int view_zoom_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
ViewZoomData * vpd = op - > customdata ;
float factor ;
switch ( event - > type ) {
case MOUSEMOVE :
2011-03-27 14:59:55 +00:00
factor = 1.0f + ( vpd - > x - event - > x + vpd - > y - event - > y ) / 300.0f ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
RNA_float_set ( op - > ptr , " factor " , factor ) ;
sima_zoom_set ( sima , ar , vpd - > zoom * factor ) ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
break ;
2011-03-22 15:20:25 +00:00
default :
if ( event - > type = = vpd - > event_type & & event - > val = = KM_RELEASE ) {
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
view_zoom_exit ( C , op , 0 ) ;
return OPERATOR_FINISHED ;
}
break ;
}
return OPERATOR_RUNNING_MODAL ;
}
static int view_zoom_cancel ( bContext * C , wmOperator * op )
{
view_zoom_exit ( C , op , 1 ) ;
return OPERATOR_CANCELLED ;
}
void IMAGE_OT_view_zoom ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View Zoom " ;
ot - > idname = " IMAGE_OT_view_zoom " ;
/* api callbacks */
ot - > exec = view_zoom_exec ;
ot - > invoke = view_zoom_invoke ;
ot - > modal = view_zoom_modal ;
ot - > cancel = view_zoom_cancel ;
ot - > poll = space_image_main_area_poll ;
2009-07-11 14:51:13 +00:00
/* flags */
ot - > flag = OPTYPE_BLOCKING ;
2009-01-31 19:40:40 +00:00
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* properties */
2009-01-16 23:53:11 +00:00
RNA_def_float ( ot - > srna , " factor " , 0.0f , 0.0f , FLT_MAX ,
2011-09-19 12:26:20 +00:00
" Factor " , " Zoom factor, values higher than 1.0 zoom in, lower values zoom out " , - FLT_MAX , FLT_MAX ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2011-06-25 18:51:29 +00:00
/********************** NDOF operator *********************/
/* Combined pan/zoom from a 3D mouse device.
2011-06-27 20:12:10 +00:00
* Z zooms , XY pans
2011-06-25 18:51:29 +00:00
* " view " ( not " paper " ) control - - user moves the viewpoint , not the image being viewed
* that explains the negative signs in the code below
*/
2011-08-02 05:52:27 +00:00
static int view_ndof_invoke ( bContext * C , wmOperator * UNUSED ( op ) , wmEvent * event )
2011-06-25 18:51:29 +00:00
{
2011-08-06 22:31:16 +00:00
if ( event - > type ! = NDOF_MOTION )
return OPERATOR_CANCELLED ;
else {
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
wmNDOFMotionData * ndof = ( wmNDOFMotionData * ) event - > customdata ;
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
float dt = ndof - > dt ;
/* tune these until it feels right */
const float zoom_sensitivity = 0.5f ; // 50% per second (I think)
const float pan_sensitivity = 300.f ; // screen pixels per second
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
float pan_x = pan_sensitivity * dt * ndof - > tvec [ 0 ] / sima - > zoom ;
float pan_y = pan_sensitivity * dt * ndof - > tvec [ 1 ] / sima - > zoom ;
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
/* "mouse zoom" factor = 1 + (dx + dy) / 300
* what about " ndof zoom " factor ? should behave like this :
* at rest - > factor = 1
* move forward - > factor > 1
* move backward - > factor < 1
*/
float zoom_factor = 1.f + zoom_sensitivity * dt * - ndof - > tvec [ 2 ] ;
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
if ( U . ndof_flag & NDOF_ZOOM_INVERT )
zoom_factor = - zoom_factor ;
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
sima_zoom_set_factor ( sima , ar , zoom_factor ) ;
sima - > xof + = pan_x ;
sima - > yof + = pan_y ;
2011-06-25 18:51:29 +00:00
2011-08-06 22:31:16 +00:00
ED_region_tag_redraw ( ar ) ;
return OPERATOR_FINISHED ;
}
2011-06-25 18:51:29 +00:00
}
void IMAGE_OT_view_ndof ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " NDOF Pan/Zoom " ;
ot - > idname = " IMAGE_OT_view_ndof " ;
/* api callbacks */
ot - > invoke = view_ndof_invoke ;
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/********************** view all operator *********************/
/* Updates the fields of the View2D member of the SpaceImage struct.
* Default behavior is to reset the position of the image and set the zoom to 1
* If the image will not fit within the window rectangle , the zoom is adjusted */
2010-10-14 12:24:08 +00:00
static int view_all_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
SpaceImage * sima ;
ARegion * ar ;
float aspx , aspy , zoomx , zoomy , w , h ;
int width , height ;
/* retrieve state */
2009-07-28 16:33:02 +00:00
sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ar = CTX_wm_region ( C ) ;
2009-02-09 20:58:31 +00:00
ED_space_image_size ( sima , & width , & height ) ;
ED_space_image_aspect ( sima , & aspx , & aspy ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
w = width * aspx ;
h = height * aspy ;
/* check if the image will fit in the image with zoom==1 */
width = ar - > winrct . xmax - ar - > winrct . xmin + 1 ;
height = ar - > winrct . ymax - ar - > winrct . ymin + 1 ;
if ( ( w > = width | | h > = height ) & & ( width > 0 & & height > 0 ) ) {
/* find the zoom value that will fit the image in the image space */
zoomx = width / w ;
zoomy = height / h ;
sima_zoom_set ( sima , ar , 1.0f / power_of_2 ( 1 / MIN2 ( zoomx , zoomy ) ) ) ;
}
else
sima_zoom_set ( sima , ar , 1.0f ) ;
sima - > xof = sima - > yof = 0.0f ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
return OPERATOR_FINISHED ;
}
void IMAGE_OT_view_all ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View All " ;
ot - > idname = " IMAGE_OT_view_all " ;
/* api callbacks */
ot - > exec = view_all_exec ;
ot - > poll = space_image_main_area_poll ;
}
/********************** view selected operator *********************/
2010-10-14 12:24:08 +00:00
static int view_selected_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
SpaceImage * sima ;
ARegion * ar ;
Scene * scene ;
Object * obedit ;
Image * ima ;
2011-07-27 07:42:53 +00:00
float size , min [ 2 ] , max [ 2 ] , d [ 2 ] , aspx , aspy ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
int width , height ;
/* retrieve state */
2009-07-28 16:33:02 +00:00
sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ar = CTX_wm_region ( C ) ;
scene = ( Scene * ) CTX_data_scene ( C ) ;
obedit = CTX_data_edit_object ( C ) ;
2009-02-09 20:58:31 +00:00
ima = ED_space_image ( sima ) ;
ED_space_image_size ( sima , & width , & height ) ;
2011-07-27 07:42:53 +00:00
ED_image_aspect ( ima , & aspx , & aspy ) ;
width = width * aspx ;
height = height * aspy ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* get bounds */
if ( ! ED_uvedit_minmax ( scene , ima , obedit , min , max ) )
return OPERATOR_CANCELLED ;
/* adjust offset and zoom */
sima - > xof = ( int ) ( ( ( min [ 0 ] + max [ 0 ] ) * 0.5f - 0.5f ) * width ) ;
sima - > yof = ( int ) ( ( ( min [ 1 ] + max [ 1 ] ) * 0.5f - 0.5f ) * height ) ;
d [ 0 ] = max [ 0 ] - min [ 0 ] ;
d [ 1 ] = max [ 1 ] - min [ 1 ] ;
2011-03-27 14:59:55 +00:00
size = 0.5f * MAX2 ( d [ 0 ] , d [ 1 ] ) * MAX2 ( width , height ) / 256.0f ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2011-03-27 14:59:55 +00:00
if ( size < = 0.01f ) size = 0.01f ;
sima_zoom_set ( sima , ar , 0.7f / size ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
return OPERATOR_FINISHED ;
}
2010-04-09 01:44:24 +00:00
static int view_selected_poll ( bContext * C )
{
return ( space_image_main_area_poll ( C ) & & ED_operator_uvedit ( C ) ) ;
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
void IMAGE_OT_view_selected ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View Center " ;
ot - > idname = " IMAGE_OT_view_selected " ;
/* api callbacks */
ot - > exec = view_selected_exec ;
2010-04-09 01:44:24 +00:00
ot - > poll = view_selected_poll ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
/********************** view zoom in/out operator *********************/
2010-10-14 12:24:08 +00:00
static int view_zoom_in_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
sima_zoom_set_factor ( sima , ar , 1.25f ) ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
return OPERATOR_FINISHED ;
}
void IMAGE_OT_view_zoom_in ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View Zoom In " ;
ot - > idname = " IMAGE_OT_view_zoom_in " ;
/* api callbacks */
ot - > exec = view_zoom_in_exec ;
ot - > poll = space_image_main_area_poll ;
}
2010-10-14 12:24:08 +00:00
static int view_zoom_out_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
sima_zoom_set_factor ( sima , ar , 0.8f ) ;
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
return OPERATOR_FINISHED ;
}
void IMAGE_OT_view_zoom_out ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View Zoom Out " ;
ot - > idname = " IMAGE_OT_view_zoom_out " ;
/* api callbacks */
ot - > exec = view_zoom_out_exec ;
ot - > poll = space_image_main_area_poll ;
}
/********************** view zoom ratio operator *********************/
static int view_zoom_ratio_exec ( bContext * C , wmOperator * op )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
sima_zoom_set ( sima , ar , RNA_float_get ( op - > ptr , " ratio " ) ) ;
/* ensure pixel exact locations for draw */
sima - > xof = ( int ) sima - > xof ;
sima - > yof = ( int ) sima - > yof ;
/* XXX notifier? */
#if 0
if ( image_preview_active ( curarea , NULL , NULL ) ) {
/* recalculates new preview rect */
scrarea_do_windraw ( curarea ) ;
image_preview_event ( 2 ) ;
}
# endif
2010-04-06 02:05:54 +00:00
ED_region_tag_redraw ( CTX_wm_region ( C ) ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
return OPERATOR_FINISHED ;
}
void IMAGE_OT_view_zoom_ratio ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " View Zoom Ratio " ;
ot - > idname = " IMAGE_OT_view_zoom_ratio " ;
/* api callbacks */
ot - > exec = view_zoom_ratio_exec ;
ot - > poll = space_image_main_area_poll ;
/* properties */
2009-01-16 23:53:11 +00:00
RNA_def_float ( ot - > srna , " ratio " , 0.0f , 0.0f , FLT_MAX ,
2011-09-19 12:26:20 +00:00
" Ratio " , " Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out " , - FLT_MAX , FLT_MAX ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
/**************** load/replace/save callbacks ******************/
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-06-24 21:27:10 +00:00
/* XXX make dynamic */
static const EnumPropertyItem image_file_type_items [ ] = {
{ R_TARGA , " TARGA " , 0 , " Targa " , " " } ,
{ R_RAWTGA , " TARGA RAW " , 0 , " Targa Raw " , " " } ,
{ R_PNG , " PNG " , 0 , " PNG " , " " } ,
2011-05-07 20:53:49 +00:00
# ifdef WITH_DDS
{ R_DDS , " DDS " , 0 , " DirectDraw Surface " , " " } ,
# endif
2009-06-24 21:27:10 +00:00
{ R_BMP , " BMP " , 0 , " BMP " , " " } ,
{ R_JPEG90 , " JPEG " , 0 , " Jpeg " , " " } ,
2009-06-08 20:08:19 +00:00
# ifdef WITH_OPENJPEG
2009-06-24 21:27:10 +00:00
{ R_JP2 , " JPEG_2000 " , 0 , " Jpeg 2000 " , " " } ,
2009-06-08 20:08:19 +00:00
# endif
2009-06-24 21:27:10 +00:00
{ R_IRIS , " IRIS " , 0 , " Iris " , " " } ,
2010-05-21 03:25:38 +00:00
# ifdef WITH_TIFF
2009-06-24 21:27:10 +00:00
{ R_TIFF , " TIFF " , 0 , " Tiff " , " " } ,
2010-05-21 03:25:38 +00:00
# endif
2010-08-03 11:25:34 +00:00
# ifdef WITH_DDS
2009-06-24 21:27:10 +00:00
{ R_RADHDR , " RADIANCE_HDR " , 0 , " Radiance HDR " , " " } ,
2010-08-03 11:25:34 +00:00
# endif
# ifdef WITH_CINEON
2009-06-24 21:27:10 +00:00
{ R_CINEON , " CINEON " , 0 , " Cineon " , " " } ,
{ R_DPX , " DPX " , 0 , " DPX " , " " } ,
2010-08-03 11:25:34 +00:00
# endif
2009-02-10 23:17:58 +00:00
# ifdef WITH_OPENEXR
2009-06-24 21:27:10 +00:00
{ R_OPENEXR , " OPENEXR " , 0 , " OpenEXR " , " " } ,
2009-02-10 23:17:58 +00:00
/* saving sequences of multilayer won't work, they copy buffers */
2009-06-24 21:27:10 +00:00
/*if(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER);
else */
{ R_MULTILAYER , " MULTILAYER " , 0 , " MultiLayer " , " " } ,
2009-02-10 23:17:58 +00:00
# endif
2009-06-24 21:27:10 +00:00
{ 0 , NULL , 0 , NULL , NULL } } ;
2009-02-10 23:17:58 +00:00
static void image_filesel ( bContext * C , wmOperator * op , const char * path )
{
2010-06-14 03:52:10 +00:00
RNA_string_set ( op - > ptr , " filepath " , path ) ;
2009-02-16 12:14:04 +00:00
WM_event_add_fileselect ( C , op ) ;
2009-02-10 23:17:58 +00:00
}
/******************** open image operator ********************/
2009-10-01 23:32:57 +00:00
static void open_init ( bContext * C , wmOperator * op )
{
PropertyPointerRNA * pprop ;
op - > customdata = pprop = MEM_callocN ( sizeof ( PropertyPointerRNA ) , " OpenPropertyPointerRNA " ) ;
uiIDContextProperty ( C , & pprop - > ptr , & pprop - > prop ) ;
}
2010-10-14 12:24:08 +00:00
static int open_cancel ( bContext * UNUSED ( C ) , wmOperator * op )
2009-10-01 23:32:57 +00:00
{
MEM_freeN ( op - > customdata ) ;
op - > customdata = NULL ;
return OPERATOR_CANCELLED ;
}
2009-02-10 23:17:58 +00:00
static int open_exec ( bContext * C , wmOperator * op )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2010-11-08 19:03:42 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ; /* XXX other space types can call */
2009-02-10 23:17:58 +00:00
Scene * scene = CTX_data_scene ( C ) ;
Object * obedit = CTX_data_edit_object ( C ) ;
2010-11-08 19:03:42 +00:00
ImageUser * iuser = NULL ;
2009-10-01 23:32:57 +00:00
PropertyPointerRNA * pprop ;
PointerRNA idptr ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
Image * ima = NULL ;
2009-02-18 18:08:33 +00:00
char str [ FILE_MAX ] ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , str ) ;
2010-01-08 03:55:06 +00:00
/* default to frame 1 if there's no scene in context */
2010-07-03 17:47:06 +00:00
errno = 0 ;
2010-10-15 12:29:02 +00:00
ima = BKE_add_image_file ( str ) ;
2009-02-10 23:17:58 +00:00
2009-10-01 23:32:57 +00:00
if ( ! ima ) {
if ( op - > customdata ) MEM_freeN ( op - > customdata ) ;
2011-09-19 12:26:20 +00:00
BKE_reportf ( op - > reports , RPT_ERROR , " Can't read: \" %s \" , %s " , str , errno ? strerror ( errno ) : " Unsupported image format " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2009-10-01 23:32:57 +00:00
}
2009-09-16 19:27:08 +00:00
2009-10-01 23:32:57 +00:00
if ( ! op - > customdata )
open_init ( C , op ) ;
/* hook into UI */
pprop = op - > customdata ;
if ( pprop - > prop ) {
/* when creating new ID blocks, use is already 1, but RNA
* pointer se also increases user , so this compensates it */
ima - > id . us - - ;
RNA_id_pointer_create ( & ima - > id , & idptr ) ;
RNA_property_pointer_set ( & pprop - > ptr , pprop - > prop , idptr ) ;
RNA_property_update ( C , & pprop - > ptr , pprop - > prop ) ;
}
2010-11-08 19:03:42 +00:00
else if ( sima ) {
2009-10-01 23:32:57 +00:00
ED_space_image_set ( C , sima , scene , obedit , ima ) ;
2010-11-08 19:03:42 +00:00
iuser = & sima - > iuser ;
}
else {
Tex * tex = CTX_data_pointer_get_type ( C , " texture " , & RNA_Texture ) . data ;
if ( tex & & tex - > type = = TEX_IMAGE )
iuser = & tex - > iuser ;
}
/* initialize because of new image */
if ( iuser ) {
iuser - > sfra = 1 ;
iuser - > offset = 0 ;
iuser - > fie_ima = 2 ;
}
2009-02-10 23:17:58 +00:00
2011-03-03 15:18:35 +00:00
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs ( C ) ;
2010-11-08 19:03:42 +00:00
BKE_image_signal ( ima , iuser , IMA_SIGNAL_RELOAD ) ;
2010-01-19 01:32:06 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2009-10-01 23:32:57 +00:00
MEM_freeN ( op - > customdata ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2010-10-14 12:24:08 +00:00
static int open_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2010-11-08 19:03:42 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ; /* XXX other space types can call */
2010-08-11 03:31:56 +00:00
char * path = U . textudir ;
Image * ima = NULL ;
if ( sima ) {
2011-04-21 15:53:30 +00:00
ima = sima - > image ;
2010-08-11 03:31:56 +00:00
}
if ( ima = = NULL ) {
2011-04-21 15:53:30 +00:00
Tex * tex = CTX_data_pointer_get_type ( C , " texture " , & RNA_Texture ) . data ;
if ( tex & & tex - > type = = TEX_IMAGE )
ima = tex - > ima ;
2010-08-11 03:31:56 +00:00
}
if ( ima )
path = ima - > name ;
2010-03-09 16:57:24 +00:00
2010-06-14 03:52:10 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) )
2009-02-10 23:17:58 +00:00
return open_exec ( C , op ) ;
2009-10-01 23:32:57 +00:00
open_init ( C , op ) ;
2009-02-10 23:17:58 +00:00
image_filesel ( C , op , path ) ;
return OPERATOR_RUNNING_MODAL ;
}
2010-11-08 19:03:42 +00:00
/* called by other space types too */
2009-02-10 23:17:58 +00:00
void IMAGE_OT_open ( wmOperatorType * ot )
{
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Open Image " ;
2011-05-15 17:59:48 +00:00
ot - > description = " Open image " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_open " ;
/* api callbacks */
ot - > exec = open_exec ;
ot - > invoke = open_invoke ;
2009-10-01 23:32:57 +00:00
ot - > cancel = open_cancel ;
2009-02-10 23:17:58 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE | MOVIEFILE , FILE_SPECIAL , FILE_OPENFILE , WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH ) ;
2009-02-10 23:17:58 +00:00
}
/******************** replace image operator ********************/
static int replace_exec ( bContext * C , wmOperator * op )
{
2009-07-28 16:46:14 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-18 18:08:33 +00:00
char str [ FILE_MAX ] ;
2009-02-10 23:17:58 +00:00
if ( ! sima - > image )
return OPERATOR_CANCELLED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , str ) ;
2010-11-05 07:35:21 +00:00
BLI_strncpy ( sima - > image - > name , str , sizeof ( sima - > image - > name ) ) ; /* we cant do much if the str is longer then 240 :/ */
2009-02-10 23:17:58 +00:00
2011-03-03 15:18:35 +00:00
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
BKE_image_signal ( sima - > image , & sima - > iuser , IMA_SIGNAL_RELOAD ) ;
2009-02-11 19:16:14 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , sima - > image ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
}
2010-10-14 12:24:08 +00:00
static int replace_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-02-10 23:17:58 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
if ( ! sima - > image )
return OPERATOR_CANCELLED ;
2010-06-14 03:52:10 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) )
2009-02-10 23:17:58 +00:00
return replace_exec ( C , op ) ;
2010-06-25 12:04:04 +00:00
if ( ! RNA_property_is_set ( op - > ptr , " relative_path " ) )
RNA_boolean_set ( op - > ptr , " relative_path " , ( strncmp ( sima - > image - > name , " // " , 2 ) ) = = 0 ) ;
image_filesel ( C , op , sima - > image - > name ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_RUNNING_MODAL ;
}
void IMAGE_OT_replace ( wmOperatorType * ot )
{
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Replace Image " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_replace " ;
/* api callbacks */
ot - > exec = replace_exec ;
ot - > invoke = replace_invoke ;
ot - > poll = space_image_poll ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE | MOVIEFILE , FILE_SPECIAL , FILE_OPENFILE , WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
/******************** save image as operator ********************/
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2011-08-24 00:44:58 +00:00
typedef struct {
/* matching scene->r settings */
short planes , imtype , subimtype , quality ;
char filepath [ FILE_MAX ] ; /* keep absolute */
} SaveImageOptions ;
static void save_image_options_defaults ( SaveImageOptions * simopts )
{
simopts - > planes = R_PLANES24 ;
simopts - > imtype = R_PNG ;
simopts - > subimtype = 0 ;
simopts - > quality = 90 ;
simopts - > filepath [ 0 ] = ' \0 ' ;
}
static int save_image_options_init ( SaveImageOptions * simopts , SpaceImage * sima , Scene * scene , const short guess_path )
{
void * lock ;
ImBuf * ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
if ( ibuf ) {
Image * ima = sima - > image ;
simopts - > planes = ibuf - > depth ;
2011-08-30 23:37:46 +00:00
if ( ELEM ( ima - > type , IMA_TYPE_R_RESULT , IMA_TYPE_COMPOSITE ) ) {
2011-08-24 00:44:58 +00:00
simopts - > imtype = scene - > r . imtype ;
2011-08-30 23:37:46 +00:00
simopts - > planes = scene - > r . planes ;
}
else if ( ima - > source = = IMA_SRC_GENERATED ) {
2011-08-24 00:44:58 +00:00
simopts - > imtype = R_PNG ;
2011-08-30 23:37:46 +00:00
}
else {
2011-08-24 00:44:58 +00:00
simopts - > imtype = BKE_ftype_to_imtype ( ibuf - > ftype ) ;
2011-08-30 23:37:46 +00:00
}
2011-08-24 00:44:58 +00:00
simopts - > subimtype = scene - > r . subimtype ; /* XXX - this is lame, we need to make these available too! */
simopts - > quality = ibuf - > ftype & 0xff ;
BLI_strncpy ( simopts - > filepath , ibuf - > name , sizeof ( simopts - > filepath ) ) ;
/* sanitize all settings */
/* unlikely but just incase */
if ( ELEM3 ( simopts - > planes , R_PLANESBW , R_PLANES24 , R_PLANES32 ) = = 0 ) {
2011-08-26 01:32:07 +00:00
simopts - > planes = R_PLANES32 ;
2011-08-24 00:44:58 +00:00
}
/* some formats dont use quality so fallback to scenes quality */
if ( simopts - > quality = = 0 ) {
simopts - > quality = scene - > r . quality ;
}
/* check for empty path */
if ( guess_path & & simopts - > filepath [ 0 ] = = 0 ) {
if ( ( G . ima [ 0 ] = = ' / ' ) & & ( G . ima [ 1 ] = = ' / ' ) & & ( G . ima [ 2 ] = = ' \0 ' ) ) {
BLI_strncpy ( simopts - > filepath , " //untitled " , FILE_MAX ) ;
} else {
BLI_strncpy ( simopts - > filepath , G . ima , FILE_MAX ) ;
}
BLI_path_abs ( simopts - > filepath , G . main - > name ) ;
}
}
ED_space_image_release_buffer ( sima , lock ) ;
return ( ibuf ! = NULL ) ;
}
static void save_image_options_from_op ( SaveImageOptions * simopts , wmOperator * op )
{
if ( RNA_property_is_set ( op - > ptr , " color_mode " ) ) simopts - > planes = RNA_enum_get ( op - > ptr , " color_mode " ) ;
if ( RNA_property_is_set ( op - > ptr , " file_format " ) ) simopts - > imtype = RNA_enum_get ( op - > ptr , " file_format " ) ;
// if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX
if ( RNA_property_is_set ( op - > ptr , " file_quality " ) ) simopts - > quality = RNA_int_get ( op - > ptr , " file_quality " ) ;
2011-08-30 23:37:46 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) ) {
RNA_string_get ( op - > ptr , " filepath " , simopts - > filepath ) ;
BLI_path_abs ( simopts - > filepath , G . main - > name ) ;
}
2011-08-24 00:44:58 +00:00
}
static void save_image_options_to_op ( SaveImageOptions * simopts , wmOperator * op )
{
RNA_enum_set ( op - > ptr , " color_mode " , simopts - > planes ) ;
RNA_enum_set ( op - > ptr , " file_format " , simopts - > imtype ) ;
// RNA_enum_set(op->ptr, "subimtype", simopts->subimtype);
RNA_int_set ( op - > ptr , " file_quality " , simopts - > quality ) ;
2011-08-26 01:32:07 +00:00
2011-08-24 00:44:58 +00:00
RNA_string_set ( op - > ptr , " filepath " , simopts - > filepath ) ;
}
2009-02-18 18:08:33 +00:00
/* assumes name is FILE_MAX */
/* ima->name and ibuf->name should end up the same */
2011-08-24 00:44:58 +00:00
static void save_image_doit ( bContext * C , SpaceImage * sima , wmOperator * op , SaveImageOptions * simopts , int do_newpath )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-02-09 20:58:31 +00:00
Image * ima = ED_space_image ( sima ) ;
2009-09-30 18:18:32 +00:00
void * lock ;
ImBuf * ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2010-03-09 16:57:24 +00:00
if ( ibuf ) {
2010-11-16 13:08:24 +00:00
Main * bmain = CTX_data_main ( C ) ;
const short relative = ( RNA_struct_find_property ( op - > ptr , " relative_path " ) & & RNA_boolean_get ( op - > ptr , " relative_path " ) ) ;
const short save_copy = ( RNA_struct_find_property ( op - > ptr , " copy " ) & & RNA_boolean_get ( op - > ptr , " copy " ) ) ;
short ok = FALSE ;
2010-04-21 19:14:20 +00:00
2011-02-05 16:32:56 +00:00
/* old global to ensure a 2nd save goes to same dir */
2011-08-24 00:44:58 +00:00
BLI_strncpy ( G . ima , simopts - > filepath , sizeof ( G . ima ) ) ;
2010-11-30 18:07:44 +00:00
2010-11-16 13:08:24 +00:00
WM_cursor_wait ( 1 ) ;
2010-11-30 18:07:44 +00:00
if ( ima - > type = = IMA_TYPE_R_RESULT ) {
/* enforce user setting for RGB or RGBA, but skip BW */
2011-08-26 01:32:07 +00:00
if ( simopts - > planes = = R_PLANES32 ) {
2010-11-30 18:07:44 +00:00
ibuf - > depth = 32 ;
}
2011-08-26 01:32:07 +00:00
else if ( simopts - > planes = = R_PLANES24 ) {
2010-11-30 18:07:44 +00:00
ibuf - > depth = 24 ;
}
}
2010-11-30 23:38:31 +00:00
else {
/* TODO, better solution, if a 24bit image is painted onto it may contain alpha */
if ( ibuf - > userflags & IB_BITMAPDIRTY ) { /* it has been painted onto */
/* checks each pixel, not ideal */
ibuf - > depth = BKE_alphatest_ibuf ( ibuf ) ? 32 : 24 ;
}
}
2010-11-16 13:08:24 +00:00
2011-08-24 00:44:58 +00:00
if ( simopts - > imtype = = R_MULTILAYER ) {
Scene * scene = CTX_data_scene ( C ) ;
2009-09-30 18:18:32 +00:00
RenderResult * rr = BKE_image_acquire_renderresult ( scene , ima ) ;
2009-02-18 18:08:33 +00:00
if ( rr ) {
2011-08-30 23:08:38 +00:00
RE_WriteRenderResult ( op - > reports , rr , simopts - > filepath , simopts - > quality ) ;
2010-11-16 13:08:24 +00:00
ok = TRUE ;
2009-02-18 18:08:33 +00:00
}
2010-11-16 13:08:24 +00:00
else {
2009-02-18 18:08:33 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Did not write, no Multilayer Image " ) ;
2010-11-16 13:08:24 +00:00
}
2009-09-30 18:18:32 +00:00
BKE_image_release_renderresult ( scene , ima ) ;
2009-02-18 18:08:33 +00:00
}
2011-08-24 00:44:58 +00:00
else if ( BKE_write_ibuf ( ibuf , simopts - > filepath , simopts - > imtype , simopts - > subimtype , simopts - > quality ) ) {
2010-11-16 13:08:24 +00:00
ok = TRUE ;
}
2010-03-09 16:57:24 +00:00
2010-11-16 13:08:24 +00:00
if ( ok ) {
2010-03-09 16:57:24 +00:00
if ( relative )
2011-08-24 00:44:58 +00:00
BLI_path_rel ( simopts - > filepath , bmain - > name ) ; /* only after saving */
2010-03-09 16:57:24 +00:00
2010-11-07 15:07:14 +00:00
if ( ibuf - > name [ 0 ] = = 0 ) {
2011-08-24 00:44:58 +00:00
BLI_strncpy ( ibuf - > name , simopts - > filepath , sizeof ( ibuf - > name ) ) ;
BLI_strncpy ( ima - > name , simopts - > filepath , sizeof ( ima - > name ) ) ;
2010-11-07 15:07:14 +00:00
}
2010-11-16 13:08:24 +00:00
2010-04-21 19:14:20 +00:00
if ( ! save_copy ) {
2010-09-06 13:28:57 +00:00
if ( do_newpath ) {
2011-08-24 00:44:58 +00:00
BLI_strncpy ( ima - > name , simopts - > filepath , sizeof ( ima - > name ) ) ;
BLI_strncpy ( ibuf - > name , simopts - > filepath , sizeof ( ibuf - > name ) ) ;
2010-09-06 13:28:57 +00:00
}
2010-04-21 19:14:20 +00:00
ibuf - > userflags & = ~ IB_BITMAPDIRTY ;
/* change type? */
if ( ima - > type = = IMA_TYPE_R_RESULT ) {
ima - > type = IMA_TYPE_IMAGE ;
/* workaround to ensure the render result buffer is no longer used
* by this image , otherwise can crash when a new render result is
* created . */
if ( ibuf - > rect & & ! ( ibuf - > mall & IB_rect ) )
imb_freerectImBuf ( ibuf ) ;
if ( ibuf - > rect_float & & ! ( ibuf - > mall & IB_rectfloat ) )
imb_freerectfloatImBuf ( ibuf ) ;
if ( ibuf - > zbuf & & ! ( ibuf - > mall & IB_zbuf ) )
IMB_freezbufImBuf ( ibuf ) ;
if ( ibuf - > zbuf_float & & ! ( ibuf - > mall & IB_zbuffloat ) )
IMB_freezbuffloatImBuf ( ibuf ) ;
}
if ( ELEM ( ima - > source , IMA_SRC_GENERATED , IMA_SRC_VIEWER ) ) {
ima - > source = IMA_SRC_FILE ;
ima - > type = IMA_TYPE_IMAGE ;
}
}
2010-11-16 13:08:24 +00:00
}
else {
2011-08-24 00:44:58 +00:00
BKE_reportf ( op - > reports , RPT_ERROR , " Couldn't write image: %s " , simopts - > filepath ) ;
2010-11-16 13:08:24 +00:00
}
2010-11-30 18:07:44 +00:00
2009-02-18 18:08:33 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , sima - > image ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-18 18:08:33 +00:00
WM_cursor_wait ( 0 ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-09-30 18:18:32 +00:00
ED_space_image_release_buffer ( sima , lock ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
static int save_as_exec ( bContext * C , wmOperator * op )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2011-08-24 00:44:58 +00:00
SaveImageOptions simopts ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2011-08-24 00:44:58 +00:00
/* just incase to initialize values,
* these should be set on invoke or by the caller . */
save_image_options_defaults ( & simopts ) ;
save_image_options_from_op ( & simopts , op ) ;
2009-06-24 21:27:10 +00:00
2011-08-24 00:44:58 +00:00
save_image_doit ( C , sima , op , & simopts , TRUE ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2010-09-17 09:27:31 +00:00
2010-10-14 12:24:08 +00:00
static int save_as_check ( bContext * UNUSED ( C ) , wmOperator * op )
2010-09-17 09:27:31 +00:00
{
char filepath [ FILE_MAX ] ;
RNA_string_get ( op - > ptr , " filepath " , filepath ) ;
2011-08-24 00:44:58 +00:00
if ( BKE_add_image_extension ( filepath , RNA_enum_get ( op - > ptr , " file_format " ) ) ) {
2010-09-17 09:27:31 +00:00
RNA_string_set ( op - > ptr , " filepath " , filepath ) ;
return TRUE ;
}
return FALSE ;
}
2010-10-14 12:24:08 +00:00
static int save_as_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
Image * ima = ED_space_image ( sima ) ;
Scene * scene = CTX_data_scene ( C ) ;
2011-08-24 00:44:58 +00:00
SaveImageOptions simopts ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2010-06-14 03:52:10 +00:00
if ( RNA_property_is_set ( op - > ptr , " filepath " ) )
2009-02-10 23:17:58 +00:00
return save_as_exec ( C , op ) ;
2010-05-06 16:37:39 +00:00
2011-08-24 00:44:58 +00:00
if ( save_image_options_init ( & simopts , sima , scene , TRUE ) = = 0 )
return OPERATOR_CANCELLED ;
save_image_options_to_op ( & simopts , op ) ;
2009-09-30 18:18:32 +00:00
2011-08-24 00:44:58 +00:00
/* enable save_copy by default for render results */
if ( ELEM ( ima - > type , IMA_TYPE_R_RESULT , IMA_TYPE_COMPOSITE ) & & ! RNA_property_is_set ( op - > ptr , " copy " ) ) {
RNA_boolean_set ( op - > ptr , " copy " , TRUE ) ;
2009-02-10 23:17:58 +00:00
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2011-08-24 00:44:58 +00:00
// XXX note: we can give default menu enums to operator for this
image_filesel ( C , op , simopts . filepath ) ;
2009-09-30 18:18:32 +00:00
2011-08-24 00:44:58 +00:00
return OPERATOR_RUNNING_MODAL ;
2009-02-10 23:17:58 +00:00
}
void IMAGE_OT_save_as ( wmOperatorType * ot )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2011-08-24 00:44:58 +00:00
PropertyRNA * prop ;
2009-02-10 23:17:58 +00:00
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Save As Image " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_save_as " ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-10 23:17:58 +00:00
/* api callbacks */
ot - > exec = save_as_exec ;
2010-09-17 09:27:31 +00:00
ot - > check = save_as_check ;
2009-02-10 23:17:58 +00:00
ot - > invoke = save_as_invoke ;
2010-04-19 07:28:23 +00:00
ot - > poll = space_image_buffer_exists_poll ;
2009-02-10 23:17:58 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
2011-08-24 00:44:58 +00:00
/* format options */
2011-09-19 12:26:20 +00:00
RNA_def_enum ( ot - > srna , " file_format " , image_file_type_items , R_PNG , " File Type " , " File type to save image as " ) ;
2011-08-24 00:44:58 +00:00
RNA_def_enum ( ot - > srna , " color_mode " , image_color_mode_items , R_PLANES24 , " Channels " , " Image channels to save " ) ;
prop = RNA_def_int ( ot - > srna , " file_quality " , 90 , 0 , 100 , " Quality " , " " , 0 , 100 ) ;
RNA_def_property_subtype ( prop , PROP_PERCENTAGE ) ;
2010-07-01 19:28:45 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE | MOVIEFILE , FILE_SPECIAL , FILE_SAVE , WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH ) ;
2010-03-09 16:57:24 +00:00
2010-04-21 19:14:20 +00:00
RNA_def_boolean ( ot - > srna , " copy " , 0 , " Copy " , " Create a new image file without modifying the current image in blender " ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
/******************** save image operator ********************/
static int save_exec ( bContext * C , wmOperator * op )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-07-28 16:46:14 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
Scene * scene = CTX_data_scene ( C ) ;
2011-08-24 00:44:58 +00:00
SaveImageOptions simopts ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2011-08-24 00:44:58 +00:00
if ( save_image_options_init ( & simopts , sima , scene , FALSE ) = = 0 )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2011-08-24 00:44:58 +00:00
save_image_options_from_op ( & simopts , op ) ;
2009-09-30 18:18:32 +00:00
2011-10-22 15:35:49 +00:00
if ( BLI_exists ( simopts . filepath ) & & BLI_file_is_writable ( simopts . filepath ) ) {
2011-08-24 00:44:58 +00:00
save_image_doit ( C , sima , op , & simopts , FALSE ) ;
2009-02-18 18:08:33 +00:00
}
else {
2011-09-19 12:26:20 +00:00
BKE_reportf ( op - > reports , RPT_ERROR , " Can not save image, path '%s' is not writable " , simopts . filepath ) ;
2009-02-18 18:08:33 +00:00
return OPERATOR_CANCELLED ;
}
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
void IMAGE_OT_save ( wmOperatorType * ot )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-02-10 23:17:58 +00:00
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Save Image " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_save " ;
/* api callbacks */
ot - > exec = save_exec ;
2009-02-18 18:08:33 +00:00
ot - > poll = space_image_file_exists_poll ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-10 23:17:58 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
/******************* save sequence operator ********************/
static int save_sequence_exec ( bContext * C , wmOperator * op )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2010-11-16 13:08:24 +00:00
Main * bmain = CTX_data_main ( C ) ;
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
ImBuf * ibuf ;
int tot = 0 ;
char di [ FILE_MAX ] , fi [ FILE_MAX ] ;
if ( sima - > image = = NULL )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
if ( sima - > image - > source ! = IMA_SRC_SEQUENCE ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Can only save sequence on image sequences " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
if ( sima - > image - > type = = IMA_TYPE_MULTILAYER ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Can't save multilayer sequences " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
/* get total */
for ( ibuf = sima - > image - > ibufs . first ; ibuf ; ibuf = ibuf - > next )
if ( ibuf - > userflags & IB_BITMAPDIRTY )
tot + + ;
if ( tot = = 0 ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_WARNING , " No images have been changed " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* get a filename for menu */
for ( ibuf = sima - > image - > ibufs . first ; ibuf ; ibuf = ibuf - > next )
if ( ibuf - > userflags & IB_BITMAPDIRTY )
break ;
BLI_strncpy ( di , ibuf - > name , FILE_MAX ) ;
BLI_splitdirstring ( di , fi ) ;
2009-02-11 19:16:14 +00:00
BKE_reportf ( op - > reports , RPT_INFO , " %d Image(s) will be saved in %s " , tot , di ) ;
2009-02-10 23:17:58 +00:00
2009-02-11 19:16:14 +00:00
for ( ibuf = sima - > image - > ibufs . first ; ibuf ; ibuf = ibuf - > next ) {
if ( ibuf - > userflags & IB_BITMAPDIRTY ) {
char name [ FILE_MAX ] ;
BLI_strncpy ( name , ibuf - > name , sizeof ( name ) ) ;
2010-11-16 13:08:24 +00:00
BLI_path_abs ( name , bmain - > name ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-11 19:16:14 +00:00
if ( 0 = = IMB_saveiff ( ibuf , name , IB_rect | IB_zbuf | IB_zbuffloat ) ) {
2011-09-19 12:26:20 +00:00
BKE_reportf ( op - > reports , RPT_ERROR , " Could not write image %s " , name ) ;
2009-02-11 19:16:14 +00:00
break ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-11 19:16:14 +00:00
2010-01-22 06:48:29 +00:00
BKE_reportf ( op - > reports , RPT_INFO , " Saved: %s \n " , ibuf - > name ) ;
2009-02-11 19:16:14 +00:00
ibuf - > userflags & = ~ IB_BITMAPDIRTY ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
}
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
void IMAGE_OT_save_sequence ( wmOperatorType * ot )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-02-10 23:17:58 +00:00
/* identifiers */
ot - > name = " Save Sequence " ;
ot - > idname = " IMAGE_OT_save_sequence " ;
/* api callbacks */
ot - > exec = save_sequence_exec ;
2010-04-19 07:28:23 +00:00
ot - > poll = space_image_buffer_exists_poll ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-10 23:17:58 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
/******************** reload image operator ********************/
2010-10-14 12:24:08 +00:00
static int reload_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-10-09 22:00:33 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-10-09 22:00:33 +00:00
if ( ! ima )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2011-03-03 15:18:35 +00:00
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs ( C ) ;
2009-10-09 22:00:33 +00:00
// XXX other users?
BKE_image_signal ( ima , ( sima ) ? & sima - > iuser : NULL , IMA_SIGNAL_RELOAD ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-10-09 22:00:33 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
void IMAGE_OT_reload ( wmOperatorType * ot )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2009-02-10 23:17:58 +00:00
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Reload Image " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_reload " ;
/* api callbacks */
ot - > exec = reload_exec ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
2009-02-10 23:17:58 +00:00
/* flags */
2011-08-19 20:25:25 +00:00
ot - > flag = OPTYPE_REGISTER ; /* no undo, image buffer is not handled by undo */
2009-02-10 23:17:58 +00:00
}
/********************** new image operator *********************/
2010-11-28 12:38:29 +00:00
static int image_new_exec ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
SpaceImage * sima ;
Scene * scene ;
Object * obedit ;
Image * ima ;
2009-10-01 23:32:57 +00:00
PointerRNA ptr , idptr ;
PropertyRNA * prop ;
2011-04-19 06:59:49 +00:00
char name [ MAX_ID_NAME - 2 ] ;
2009-02-10 23:17:58 +00:00
float color [ 4 ] ;
2010-06-29 22:07:27 +00:00
int width , height , floatbuf , uvtestgrid , alpha ;
2009-02-10 23:17:58 +00:00
/* retrieve state */
2009-07-28 16:33:02 +00:00
sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
scene = ( Scene * ) CTX_data_scene ( C ) ;
obedit = CTX_data_edit_object ( C ) ;
RNA_string_get ( op - > ptr , " name " , name ) ;
width = RNA_int_get ( op - > ptr , " width " ) ;
height = RNA_int_get ( op - > ptr , " height " ) ;
floatbuf = RNA_boolean_get ( op - > ptr , " float " ) ;
uvtestgrid = RNA_boolean_get ( op - > ptr , " uv_test_grid " ) ;
RNA_float_get_array ( op - > ptr , " color " , color ) ;
2010-06-29 22:07:27 +00:00
alpha = RNA_boolean_get ( op - > ptr , " alpha " ) ;
2010-03-12 02:43:36 +00:00
if ( ! floatbuf & & scene - > r . color_mgt_flag & R_COLOR_MANAGEMENT )
linearrgb_to_srgb_v3_v3 ( color , color ) ;
2009-02-10 23:17:58 +00:00
2010-06-29 22:07:27 +00:00
if ( ! alpha )
color [ 3 ] = 1.0f ;
ima = BKE_add_image_size ( width , height , name , alpha ? 32 : 24 , floatbuf , uvtestgrid , color ) ;
2009-09-16 19:27:08 +00:00
2009-10-01 23:32:57 +00:00
if ( ! ima )
return OPERATOR_CANCELLED ;
/* hook into UI */
uiIDContextProperty ( C , & ptr , & prop ) ;
if ( prop ) {
/* when creating new ID blocks, use is already 1, but RNA
* pointer se also increases user , so this compensates it */
ima - > id . us - - ;
RNA_id_pointer_create ( & ima - > id , & idptr ) ;
RNA_property_pointer_set ( & ptr , prop , idptr ) ;
RNA_property_update ( C , & ptr , prop ) ;
2009-09-16 19:27:08 +00:00
}
2009-10-01 23:32:57 +00:00
else if ( sima )
ED_space_image_set ( C , sima , scene , obedit , ima ) ;
// XXX other users?
BKE_image_signal ( ima , ( sima ) ? & sima - > iuser : NULL , IMA_SIGNAL_USER_NEW_IMAGE ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
}
2010-11-28 12:38:29 +00:00
/* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */
static int image_new_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2010-11-20 17:31:59 +00:00
{
2010-11-28 12:38:29 +00:00
return WM_operator_props_dialog_popup ( C , op , 300 , 100 ) ;
2010-11-20 17:31:59 +00:00
}
2009-02-10 23:17:58 +00:00
void IMAGE_OT_new ( wmOperatorType * ot )
{
2010-06-29 22:07:27 +00:00
PropertyRNA * prop ;
2010-07-23 14:35:23 +00:00
static float default_color [ 4 ] = { 0.0f , 0.0f , 0.0f , 1.0f } ;
2010-06-29 22:07:27 +00:00
2009-02-10 23:17:58 +00:00
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " New Image " ;
2011-05-15 17:59:48 +00:00
ot - > description = " Create a new image " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_new " ;
/* api callbacks */
2010-11-28 12:38:29 +00:00
ot - > exec = image_new_exec ;
ot - > invoke = image_new_invoke ;
2010-11-20 17:31:59 +00:00
2009-02-10 23:17:58 +00:00
/* flags */
2011-04-02 15:30:58 +00:00
ot - > flag = OPTYPE_UNDO ;
2009-02-10 23:17:58 +00:00
/* properties */
2011-09-19 12:26:20 +00:00
RNA_def_string ( ot - > srna , " name " , " untitled " , MAX_ID_NAME - 2 , " Name " , " Image datablock name " ) ;
RNA_def_int ( ot - > srna , " width " , 1024 , 1 , INT_MAX , " Width " , " Image width " , 1 , 16384 ) ;
RNA_def_int ( ot - > srna , " height " , 1024 , 1 , INT_MAX , " Height " , " Image height " , 1 , 16384 ) ;
prop = RNA_def_float_color ( ot - > srna , " color " , 4 , NULL , 0.0f , FLT_MAX , " Color " , " Default fill color " , 0.0f , 1.0f ) ;
2010-06-29 22:07:27 +00:00
RNA_def_property_float_array_default ( prop , default_color ) ;
2011-09-19 12:26:20 +00:00
RNA_def_boolean ( ot - > srna , " alpha " , 1 , " Alpha " , " Create an image with an alpha channel " ) ;
RNA_def_boolean ( ot - > srna , " uv_test_grid " , 0 , " UV Test Grid " , " Fill the image with a grid for UV map testing " ) ;
RNA_def_boolean ( ot - > srna , " float " , 0 , " 32 bit Float " , " Create image with 32 bit floating point bit depth " ) ;
2009-02-10 23:17:58 +00:00
}
2011-02-23 12:02:43 +00:00
/********************* invert operators *********************/
2011-02-25 11:00:38 +00:00
static int image_invert_poll ( bContext * C )
{
Image * ima = CTX_data_edit_image ( C ) ;
ImBuf * ibuf = BKE_image_get_ibuf ( ima , NULL ) ;
if ( ibuf ! = NULL )
return 1 ;
return 0 ;
}
static int image_invert_exec ( bContext * C , wmOperator * op )
{
2011-02-23 12:02:43 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
ImBuf * ibuf = BKE_image_get_ibuf ( ima , NULL ) ;
2011-02-28 03:17:20 +00:00
2011-02-23 12:02:43 +00:00
// flags indicate if this channel should be inverted
2011-02-28 03:17:20 +00:00
const short r = RNA_boolean_get ( op - > ptr , " invert_r " ) ;
const short g = RNA_boolean_get ( op - > ptr , " invert_g " ) ;
const short b = RNA_boolean_get ( op - > ptr , " invert_b " ) ;
const short a = RNA_boolean_get ( op - > ptr , " invert_a " ) ;
int i ;
2011-02-25 11:00:38 +00:00
if ( ibuf = = NULL ) // TODO: this should actually never happen, but does for render-results -> cleanup
return OPERATOR_CANCELLED ;
2011-02-28 03:17:20 +00:00
2011-02-23 12:02:43 +00:00
/* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */
if ( ibuf - > rect_float ) {
float * fp = ( float * ) ibuf - > rect_float ;
for ( i = ibuf - > x * ibuf - > y ; i > 0 ; i - - , fp + = 4 ) {
if ( r ) fp [ 0 ] = 1.0f - fp [ 0 ] ;
if ( g ) fp [ 1 ] = 1.0f - fp [ 1 ] ;
if ( b ) fp [ 2 ] = 1.0f - fp [ 2 ] ;
if ( a ) fp [ 3 ] = 1.0f - fp [ 3 ] ;
}
2011-02-28 03:17:20 +00:00
if ( ibuf - > rect ) {
IMB_rect_from_float ( ibuf ) ;
}
2011-02-23 12:02:43 +00:00
}
else if ( ibuf - > rect ) {
char * cp = ( char * ) ibuf - > rect ;
for ( i = ibuf - > x * ibuf - > y ; i > 0 ; i - - , cp + = 4 ) {
if ( r ) cp [ 0 ] = 255 - cp [ 0 ] ;
if ( g ) cp [ 1 ] = 255 - cp [ 1 ] ;
if ( b ) cp [ 2 ] = 255 - cp [ 2 ] ;
if ( a ) cp [ 3 ] = 255 - cp [ 3 ] ;
}
}
2011-02-28 03:17:20 +00:00
else {
2011-02-23 12:02:43 +00:00
return OPERATOR_CANCELLED ;
2011-02-28 03:17:20 +00:00
}
2011-02-23 12:02:43 +00:00
2011-02-28 03:17:20 +00:00
ibuf - > userflags | = IB_BITMAPDIRTY ;
2011-05-08 20:21:31 +00:00
if ( ibuf - > mipmap [ 0 ] )
ibuf - > userflags | = IB_MIPMAP_INVALID ;
2011-02-23 12:02:43 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
return OPERATOR_FINISHED ;
}
2011-02-25 11:00:38 +00:00
void IMAGE_OT_invert ( wmOperatorType * ot )
{
2011-02-23 12:02:43 +00:00
/* identifiers */
ot - > name = " Invert Channels " ;
ot - > idname = " IMAGE_OT_invert " ;
/* api callbacks */
ot - > exec = image_invert_exec ;
2011-02-25 11:00:38 +00:00
ot - > poll = image_invert_poll ;
2011-02-23 12:02:43 +00:00
/* properties */
2011-02-23 19:40:24 +00:00
RNA_def_boolean ( ot - > srna , " invert_r " , 0 , " Red " , " Invert Red Channel " ) ;
RNA_def_boolean ( ot - > srna , " invert_g " , 0 , " Green " , " Invert Green Channel " ) ;
RNA_def_boolean ( ot - > srna , " invert_b " , 0 , " Blue " , " Invert Blue Channel " ) ;
RNA_def_boolean ( ot - > srna , " invert_a " , 0 , " Alpha " , " Invert Alpha Channel " ) ;
2011-02-23 12:02:43 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
}
2009-02-10 23:17:58 +00:00
/********************* pack operator *********************/
2009-02-11 19:16:14 +00:00
static int pack_test ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
Image * ima = CTX_data_edit_image ( C ) ;
int as_png = RNA_boolean_get ( op - > ptr , " as_png " ) ;
if ( ! ima )
2009-02-11 19:16:14 +00:00
return 0 ;
2009-02-10 23:17:58 +00:00
if ( ! as_png & & ima - > packedfile )
2009-02-11 19:16:14 +00:00
return 0 ;
2009-02-10 23:17:58 +00:00
if ( ima - > source = = IMA_SRC_SEQUENCE | | ima - > source = = IMA_SRC_MOVIE ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Packing movies or image sequences not supported " ) ;
2009-02-11 19:16:14 +00:00
return 0 ;
2009-02-10 23:17:58 +00:00
}
2009-02-11 19:16:14 +00:00
return 1 ;
}
static int pack_exec ( bContext * C , wmOperator * op )
{
2011-10-08 11:02:58 +00:00
struct Main * bmain = CTX_data_main ( C ) ;
2009-09-30 18:18:32 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
ImBuf * ibuf = BKE_image_get_ibuf ( ima , NULL ) ;
2009-02-11 19:16:14 +00:00
int as_png = RNA_boolean_get ( op - > ptr , " as_png " ) ;
if ( ! pack_test ( C , op ) )
return OPERATOR_CANCELLED ;
if ( ! as_png & & ( ibuf & & ( ibuf - > userflags & IB_BITMAPDIRTY ) ) ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Can't pack edited image from disk, only as internal PNG " ) ;
2009-02-11 19:16:14 +00:00
return OPERATOR_CANCELLED ;
2009-02-10 23:17:58 +00:00
}
2009-02-11 19:16:14 +00:00
if ( as_png )
BKE_image_memorypack ( ima ) ;
else
2011-10-08 11:02:58 +00:00
ima - > packedfile = newPackedFile ( op - > reports , ima - > name , ID_BLEND_PATH ( bmain , & ima - > id ) ) ;
2009-02-11 19:16:14 +00:00
2010-06-17 07:20:12 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2009-02-11 19:16:14 +00:00
return OPERATOR_FINISHED ;
}
2010-10-14 12:24:08 +00:00
static int pack_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-02-11 19:16:14 +00:00
{
2009-09-30 18:18:32 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
ImBuf * ibuf = BKE_image_get_ibuf ( ima , NULL ) ;
2009-04-22 18:39:44 +00:00
uiPopupMenu * pup ;
uiLayout * layout ;
2009-02-11 19:16:14 +00:00
int as_png = RNA_boolean_get ( op - > ptr , " as_png " ) ;
if ( ! pack_test ( C , op ) )
return OPERATOR_CANCELLED ;
if ( ! as_png & & ( ibuf & & ( ibuf - > userflags & IB_BITMAPDIRTY ) ) ) {
2009-05-23 07:19:31 +00:00
pup = uiPupMenuBegin ( C , " OK " , ICON_QUESTION ) ;
2009-04-22 18:39:44 +00:00
layout = uiPupMenuLayout ( pup ) ;
2011-02-27 18:03:19 +00:00
uiItemBooleanO ( layout , " Can't pack edited image from disk. Pack as internal PNG? " , ICON_NONE , op - > idname , " as_png " , 1 ) ;
2009-04-22 18:39:44 +00:00
uiPupMenuEnd ( C , pup ) ;
2009-02-11 19:16:14 +00:00
return OPERATOR_CANCELLED ;
2009-02-10 23:17:58 +00:00
}
2009-02-11 19:16:14 +00:00
return pack_exec ( C , op ) ;
2009-02-10 23:17:58 +00:00
}
void IMAGE_OT_pack ( wmOperatorType * ot )
{
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Pack Image " ;
2010-06-17 07:20:12 +00:00
ot - > description = " Pack an image as embedded data into the .blend file " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_pack " ;
/* api callbacks */
ot - > exec = pack_exec ;
2009-02-11 19:16:14 +00:00
ot - > invoke = pack_invoke ;
2009-02-10 23:17:58 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
2011-09-19 12:26:20 +00:00
RNA_def_boolean ( ot - > srna , " as_png " , 0 , " Pack As PNG " , " Pack image as lossless PNG " ) ;
2009-02-10 23:17:58 +00:00
}
/********************* unpack operator *********************/
2011-01-26 14:18:16 +00:00
static int image_unpack_exec ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
Image * ima = CTX_data_edit_image ( C ) ;
2009-06-30 19:20:45 +00:00
int method = RNA_enum_get ( op - > ptr , " method " ) ;
2009-02-10 23:17:58 +00:00
2010-06-17 07:20:12 +00:00
/* find the suppplied image by name */
2011-01-26 14:18:16 +00:00
if ( RNA_property_is_set ( op - > ptr , " id " ) ) {
2011-04-19 06:59:49 +00:00
char imaname [ MAX_ID_NAME - 2 ] ;
2011-01-26 14:18:16 +00:00
RNA_string_get ( op - > ptr , " id " , imaname ) ;
2010-06-17 07:20:12 +00:00
ima = BLI_findstring ( & CTX_data_main ( C ) - > image , imaname , offsetof ( ID , name ) + 2 ) ;
if ( ! ima ) ima = CTX_data_edit_image ( C ) ;
}
2009-06-30 19:20:45 +00:00
if ( ! ima | | ! ima - > packedfile )
return OPERATOR_CANCELLED ;
if ( ima - > source = = IMA_SRC_SEQUENCE | | ima - > source = = IMA_SRC_MOVIE ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Unpacking movies or image sequences not supported " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2009-06-30 19:20:45 +00:00
}
if ( G . fileflags & G_AUTOPACK )
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_WARNING , " AutoPack is enabled, so image will be packed again on file save " ) ;
2011-03-03 15:18:35 +00:00
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs ( C ) ;
2009-06-30 19:20:45 +00:00
unpackImage ( op - > reports , ima , method ) ;
2010-06-17 07:20:12 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2009-06-30 19:20:45 +00:00
return OPERATOR_FINISHED ;
}
2011-01-26 14:18:16 +00:00
static int image_unpack_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-06-30 19:20:45 +00:00
{
Image * ima = CTX_data_edit_image ( C ) ;
2011-01-26 14:18:16 +00:00
if ( RNA_property_is_set ( op - > ptr , " id " ) )
return image_unpack_exec ( C , op ) ;
2010-06-17 07:20:12 +00:00
2009-06-30 19:20:45 +00:00
if ( ! ima | | ! ima - > packedfile )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
if ( ima - > source = = IMA_SRC_SEQUENCE | | ima - > source = = IMA_SRC_MOVIE ) {
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Unpacking movies or image sequences not supported " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
}
if ( G . fileflags & G_AUTOPACK )
2011-09-19 12:26:20 +00:00
BKE_report ( op - > reports , RPT_WARNING , " AutoPack is enabled, so image will be packed again on file save " ) ;
2011-01-26 14:18:16 +00:00
unpack_menu ( C , " IMAGE_OT_unpack " , ima - > id . name + 2 , ima - > name , " textures " , ima - > packedfile ) ;
2009-02-10 23:17:58 +00:00
2009-02-11 19:16:14 +00:00
return OPERATOR_FINISHED ;
2009-02-10 23:17:58 +00:00
}
void IMAGE_OT_unpack ( wmOperatorType * ot )
{
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Unpack Image " ;
2010-06-17 07:20:12 +00:00
ot - > description = " Save an image packed in the .blend file to disk " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_unpack " ;
/* api callbacks */
2011-01-26 14:18:16 +00:00
ot - > exec = image_unpack_exec ;
ot - > invoke = image_unpack_invoke ;
2009-02-10 23:17:58 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-02-23 19:40:24 +00:00
/* properties */
2011-09-19 12:26:20 +00:00
RNA_def_enum ( ot - > srna , " method " , unpack_method_items , PF_USE_LOCAL , " Method " , " How to unpack " ) ;
RNA_def_string ( ot - > srna , " id " , " " , MAX_ID_NAME - 2 , " Image Name " , " Image datablock name to unpack " ) ; /* XXX, weark!, will fail with library, name collisions */
2009-02-10 23:17:58 +00:00
}
/******************** sample image operator ********************/
typedef struct ImageSampleInfo {
ARegionType * art ;
void * draw_handle ;
int x , y ;
2009-09-30 18:18:32 +00:00
int channels ;
2009-02-10 23:17:58 +00:00
char col [ 4 ] ;
float colf [ 4 ] ;
int z ;
float zf ;
char * colp ;
float * colfp ;
int * zp ;
float * zfp ;
int draw ;
} ImageSampleInfo ;
2010-10-14 12:24:08 +00:00
static void sample_draw ( const bContext * UNUSED ( C ) , ARegion * ar , void * arg_info )
2009-02-10 23:17:58 +00:00
{
ImageSampleInfo * info = arg_info ;
2011-02-15 04:06:13 +00:00
if ( info - > draw ) {
2011-04-23 08:30:28 +00:00
/* no color management needed for images (color_manage=0) */
draw_image_info ( ar , 0 , info - > channels , info - > x , info - > y , info - > colp , info - > colfp , info - > zp , info - > zfp ) ;
2011-02-15 04:06:13 +00:00
}
2009-02-10 23:17:58 +00:00
}
static void sample_apply ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2009-09-30 18:18:32 +00:00
void * lock ;
ImBuf * ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
2009-02-10 23:17:58 +00:00
ImageSampleInfo * info = op - > customdata ;
float fx , fy ;
2009-09-30 18:18:32 +00:00
if ( ibuf = = NULL ) {
ED_space_image_release_buffer ( sima , lock ) ;
2009-02-10 23:17:58 +00:00
return ;
2009-09-30 18:18:32 +00:00
}
2009-02-10 23:17:58 +00:00
2011-05-20 07:40:05 +00:00
UI_view2d_region_to_view ( & ar - > v2d , event - > mval [ 0 ] , event - > mval [ 1 ] , & fx , & fy ) ;
2009-02-10 23:17:58 +00:00
2011-03-27 14:59:55 +00:00
if ( fx > = 0.0f & & fy > = 0.0f & & fx < 1.0f & & fy < 1.0f ) {
2009-02-10 23:17:58 +00:00
float * fp ;
char * cp ;
int x = ( int ) ( fx * ibuf - > x ) , y = ( int ) ( fy * ibuf - > y ) ;
CLAMP ( x , 0 , ibuf - > x - 1 ) ;
CLAMP ( y , 0 , ibuf - > y - 1 ) ;
info - > x = x ;
info - > y = y ;
info - > draw = 1 ;
2009-09-30 18:18:32 +00:00
info - > channels = ibuf - > channels ;
2009-02-10 23:17:58 +00:00
info - > colp = NULL ;
info - > colfp = NULL ;
info - > zp = NULL ;
info - > zfp = NULL ;
if ( ibuf - > rect ) {
cp = ( char * ) ( ibuf - > rect + y * ibuf - > x + x ) ;
info - > col [ 0 ] = cp [ 0 ] ;
info - > col [ 1 ] = cp [ 1 ] ;
info - > col [ 2 ] = cp [ 2 ] ;
info - > col [ 3 ] = cp [ 3 ] ;
info - > colp = info - > col ;
info - > colf [ 0 ] = ( float ) cp [ 0 ] / 255.0f ;
info - > colf [ 1 ] = ( float ) cp [ 1 ] / 255.0f ;
info - > colf [ 2 ] = ( float ) cp [ 2 ] / 255.0f ;
info - > colf [ 3 ] = ( float ) cp [ 3 ] / 255.0f ;
info - > colfp = info - > colf ;
}
if ( ibuf - > rect_float ) {
fp = ( ibuf - > rect_float + ( ibuf - > channels ) * ( y * ibuf - > x + x ) ) ;
info - > colf [ 0 ] = fp [ 0 ] ;
info - > colf [ 1 ] = fp [ 1 ] ;
info - > colf [ 2 ] = fp [ 2 ] ;
2010-03-16 22:19:43 +00:00
info - > colf [ 3 ] = fp [ 3 ] ;
2009-02-10 23:17:58 +00:00
info - > colfp = info - > colf ;
}
if ( ibuf - > zbuf ) {
info - > z = ibuf - > zbuf [ y * ibuf - > x + x ] ;
info - > zp = & info - > z ;
}
if ( ibuf - > zbuf_float ) {
info - > zf = ibuf - > zbuf_float [ y * ibuf - > x + x ] ;
info - > zfp = & info - > zf ;
}
2009-02-11 19:16:14 +00:00
if ( sima - > cumap & & ibuf - > channels = = 4 ) {
/* we reuse this callback for set curves point operators */
if ( RNA_struct_find_property ( op - > ptr , " point " ) ) {
int point = RNA_enum_get ( op - > ptr , " point " ) ;
if ( point = = 1 ) {
curvemapping_set_black_white ( sima - > cumap , NULL , info - > colfp ) ;
2010-10-02 19:31:58 +00:00
if ( ibuf - > rect_float )
curvemapping_do_ibuf ( sima - > cumap , ibuf ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-11 19:16:14 +00:00
else if ( point = = 0 ) {
curvemapping_set_black_white ( sima - > cumap , info - > colfp , NULL ) ;
2010-10-02 19:31:58 +00:00
if ( ibuf - > rect_float )
curvemapping_do_ibuf ( sima - > cumap , ibuf ) ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
}
}
2009-02-10 23:17:58 +00:00
// XXX node curve integration ..
#if 0
{
ScrArea * sa , * cur = curarea ;
node_curvemap_sample ( fp ) ; /* sends global to node editor */
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
if ( sa - > spacetype = = SPACE_NODE ) {
areawinset ( sa - > win ) ;
scrarea_do_windraw ( sa ) ;
}
}
node_curvemap_sample ( NULL ) ; /* clears global in node editor */
curarea = cur ;
}
# endif
}
else
info - > draw = 0 ;
2009-09-30 18:18:32 +00:00
ED_space_image_release_buffer ( sima , lock ) ;
2009-02-10 23:17:58 +00:00
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
}
static void sample_exit ( bContext * C , wmOperator * op )
{
ImageSampleInfo * info = op - > customdata ;
ED_region_draw_cb_exit ( info - > art , info - > draw_handle ) ;
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
MEM_freeN ( info ) ;
}
static int sample_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
ImageSampleInfo * info ;
2009-09-30 18:18:32 +00:00
if ( ! ED_space_image_has_buffer ( sima ) )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
info = MEM_callocN ( sizeof ( ImageSampleInfo ) , " ImageSampleInfo " ) ;
info - > art = ar - > type ;
2009-10-20 21:05:22 +00:00
info - > draw_handle = ED_region_draw_cb_activate ( ar - > type , sample_draw , info , REGION_DRAW_POST_PIXEL ) ;
2009-02-10 23:17:58 +00:00
op - > customdata = info ;
sample_apply ( C , op , event ) ;
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_RUNNING_MODAL ;
}
static int sample_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
switch ( event - > type ) {
case LEFTMOUSE :
case RIGHTMOUSE : // XXX hardcoded
sample_exit ( C , op ) ;
return OPERATOR_CANCELLED ;
case MOUSEMOVE :
sample_apply ( C , op , event ) ;
break ;
}
return OPERATOR_RUNNING_MODAL ;
}
static int sample_cancel ( bContext * C , wmOperator * op )
{
sample_exit ( C , op ) ;
return OPERATOR_CANCELLED ;
}
void IMAGE_OT_sample ( wmOperatorType * ot )
{
/* identifiers */
2011-04-02 15:30:58 +00:00
ot - > name = " Sample Color " ;
2009-02-10 23:17:58 +00:00
ot - > idname = " IMAGE_OT_sample " ;
/* api callbacks */
ot - > invoke = sample_invoke ;
ot - > modal = sample_modal ;
ot - > cancel = sample_cancel ;
ot - > poll = space_image_main_area_poll ;
2009-07-11 14:51:13 +00:00
/* flags */
ot - > flag = OPTYPE_BLOCKING ;
2009-02-10 23:17:58 +00:00
}
2010-03-23 01:22:33 +00:00
/******************** sample line operator ********************/
2010-04-04 00:21:37 +00:00
static int sample_line_exec ( bContext * C , wmOperator * op )
2010-03-23 01:22:33 +00:00
{
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2010-06-03 20:25:00 +00:00
Scene * scene = CTX_data_scene ( C ) ;
2010-04-04 00:21:37 +00:00
int x_start = RNA_int_get ( op - > ptr , " xstart " ) ;
int y_start = RNA_int_get ( op - > ptr , " ystart " ) ;
int x_end = RNA_int_get ( op - > ptr , " xend " ) ;
int y_end = RNA_int_get ( op - > ptr , " yend " ) ;
2010-03-23 01:22:33 +00:00
void * lock ;
ImBuf * ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
Histogram * hist = & sima - > sample_line_hist ;
2010-04-04 00:21:37 +00:00
2010-03-23 01:22:33 +00:00
float x1f , y1f , x2f , y2f ;
int x1 , y1 , x2 , y2 ;
int i , x , y ;
float * fp ;
2010-06-03 20:25:00 +00:00
float rgb [ 3 ] ;
2010-03-23 01:22:33 +00:00
unsigned char * cp ;
if ( ibuf = = NULL ) {
ED_space_image_release_buffer ( sima , lock ) ;
2010-04-04 00:21:37 +00:00
return OPERATOR_CANCELLED ;
2010-03-23 01:22:33 +00:00
}
/* hmmmm */
if ( ibuf - > channels < 3 ) {
ED_space_image_release_buffer ( sima , lock ) ;
2010-04-04 00:21:37 +00:00
return OPERATOR_CANCELLED ;
2010-03-23 01:22:33 +00:00
}
2010-04-04 00:21:37 +00:00
UI_view2d_region_to_view ( & ar - > v2d , x_start , y_start , & x1f , & y1f ) ;
UI_view2d_region_to_view ( & ar - > v2d , x_end , y_end , & x2f , & y2f ) ;
2010-03-23 01:22:33 +00:00
x1 = 0.5f + x1f * ibuf - > x ;
x2 = 0.5f + x2f * ibuf - > x ;
y1 = 0.5f + y1f * ibuf - > y ;
y2 = 0.5f + y2f * ibuf - > y ;
hist - > channels = 3 ;
hist - > x_resolution = 256 ;
hist - > xmax = 1.0f ;
hist - > ymax = 1.0f ;
for ( i = 0 ; i < 256 ; i + + ) {
x = ( int ) ( 0.5f + x1 + ( float ) i * ( x2 - x1 ) / 255.0f ) ;
y = ( int ) ( 0.5f + y1 + ( float ) i * ( y2 - y1 ) / 255.0f ) ;
if ( x < 0 | | y < 0 | | x > = ibuf - > x | | y > = ibuf - > y ) {
2010-06-06 16:26:49 +00:00
hist - > data_luma [ i ] = hist - > data_r [ i ] = hist - > data_g [ i ] = hist - > data_b [ i ] = 0.0f ;
2010-03-23 01:22:33 +00:00
} else {
if ( ibuf - > rect_float ) {
fp = ( ibuf - > rect_float + ( ibuf - > channels ) * ( y * ibuf - > x + x ) ) ;
2010-06-03 20:25:00 +00:00
if ( scene - > r . color_mgt_flag & R_COLOR_MANAGEMENT )
linearrgb_to_srgb_v3_v3 ( rgb , fp ) ;
else
copy_v3_v3 ( rgb , fp ) ;
hist - > data_r [ i ] = rgb [ 0 ] ;
hist - > data_g [ i ] = rgb [ 1 ] ;
hist - > data_b [ i ] = rgb [ 2 ] ;
hist - > data_luma [ i ] = ( 0.299f * rgb [ 0 ] + 0.587f * rgb [ 1 ] + 0.114f * rgb [ 2 ] ) ;
2010-03-23 01:22:33 +00:00
}
else if ( ibuf - > rect ) {
cp = ( unsigned char * ) ( ibuf - > rect + y * ibuf - > x + x ) ;
hist - > data_r [ i ] = ( float ) cp [ 0 ] / 255.0f ;
hist - > data_g [ i ] = ( float ) cp [ 1 ] / 255.0f ;
hist - > data_b [ i ] = ( float ) cp [ 2 ] / 255.0f ;
2010-04-06 02:05:54 +00:00
hist - > data_luma [ i ] = ( 0.299f * cp [ 0 ] + 0.587f * cp [ 1 ] + 0.114f * cp [ 2 ] ) / 255 ;
2010-03-23 01:22:33 +00:00
}
}
}
ED_space_image_release_buffer ( sima , lock ) ;
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
2010-04-04 00:21:37 +00:00
return OPERATOR_FINISHED ;
2010-03-23 01:22:33 +00:00
}
static int sample_line_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2010-04-04 00:21:37 +00:00
2010-03-23 01:22:33 +00:00
if ( ! ED_space_image_has_buffer ( sima ) )
return OPERATOR_CANCELLED ;
2010-04-04 00:21:37 +00:00
return WM_gesture_straightline_invoke ( C , op , event ) ;
2010-03-23 01:22:33 +00:00
}
void IMAGE_OT_sample_line ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Sample Line " ;
ot - > idname = " IMAGE_OT_sample_line " ;
/* api callbacks */
ot - > invoke = sample_line_invoke ;
2010-04-04 00:21:37 +00:00
ot - > modal = WM_gesture_straightline_modal ;
ot - > exec = sample_line_exec ;
2010-03-23 01:22:33 +00:00
ot - > poll = space_image_main_area_poll ;
2011-06-06 11:04:54 +00:00
ot - > cancel = WM_gesture_straightline_cancel ;
2010-04-04 00:21:37 +00:00
2010-03-23 01:22:33 +00:00
/* flags */
2011-08-19 20:25:25 +00:00
ot - > flag = 0 ; /* no undo/register since this operates on the space */
2010-04-04 00:21:37 +00:00
WM_operator_properties_gesture_straightline ( ot , CURSOR_EDIT ) ;
2010-03-23 01:22:33 +00:00
}
2009-02-11 19:16:14 +00:00
/******************** set curve point operator ********************/
2009-03-29 02:15:13 +00:00
void IMAGE_OT_curves_point_set ( wmOperatorType * ot )
2009-02-11 19:16:14 +00:00
{
static EnumPropertyItem point_items [ ] = {
2009-06-16 00:52:21 +00:00
{ 0 , " BLACK_POINT " , 0 , " Black Point " , " " } ,
{ 1 , " WHITE_POINT " , 0 , " White Point " , " " } ,
{ 0 , NULL , 0 , NULL , NULL } } ;
2009-02-11 19:16:14 +00:00
/* identifiers */
ot - > name = " Set Curves Point " ;
2009-03-29 02:15:13 +00:00
ot - > idname = " IMAGE_OT_curves_point_set " ;
2009-02-11 19:16:14 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* api callbacks */
ot - > invoke = sample_invoke ;
ot - > modal = sample_modal ;
ot - > cancel = sample_cancel ;
ot - > poll = space_image_main_area_poll ;
/* properties */
2011-09-19 12:26:20 +00:00
RNA_def_enum ( ot - > srna , " point " , point_items , 0 , " Point " , " Set black point or white point for curves " ) ;
2009-02-11 19:16:14 +00:00
}
2009-02-10 23:17:58 +00:00
/******************** record composite operator *********************/
typedef struct RecordCompositeData {
wmTimer * timer ;
int old_cfra ;
int sfra , efra ;
} RecordCompositeData ;
2011-02-14 17:55:27 +00:00
static int record_composite_apply ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
RecordCompositeData * rcd = op - > customdata ;
Scene * scene = CTX_data_scene ( C ) ;
ImBuf * ibuf ;
2009-02-11 19:16:14 +00:00
WM_timecursor ( CTX_wm_window ( C ) , scene - > r . cfra ) ;
2009-02-10 23:17:58 +00:00
// XXX scene->nodetree->test_break= blender_test_break;
// XXX scene->nodetree->test_break= NULL;
2009-02-11 19:16:14 +00:00
BKE_image_all_free_anim_ibufs ( scene - > r . cfra ) ;
2009-02-10 23:17:58 +00:00
ntreeCompositTagAnimated ( scene - > nodetree ) ;
ntreeCompositExecTree ( scene - > nodetree , & scene - > r , scene - > r . cfra ! = rcd - > old_cfra ) ; /* 1 is no previews */
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
ibuf = BKE_image_get_ibuf ( sima - > image , & sima - > iuser ) ;
/* save memory in flipbooks */
if ( ibuf )
imb_freerectfloatImBuf ( ibuf ) ;
scene - > r . cfra + + ;
return ( scene - > r . cfra < = rcd - > efra ) ;
}
static int record_composite_init ( bContext * C , wmOperator * op )
{
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
Scene * scene = CTX_data_scene ( C ) ;
RecordCompositeData * rcd ;
if ( sima - > iuser . frames < 2 )
return 0 ;
if ( scene - > nodetree = = NULL )
return 0 ;
op - > customdata = rcd = MEM_callocN ( sizeof ( RecordCompositeData ) , " ImageRecordCompositeData " ) ;
rcd - > old_cfra = scene - > r . cfra ;
rcd - > sfra = sima - > iuser . sfra ;
rcd - > efra = sima - > iuser . sfra + sima - > iuser . frames - 1 ;
scene - > r . cfra = rcd - > sfra ;
return 1 ;
}
static void record_composite_exit ( bContext * C , wmOperator * op )
{
Scene * scene = CTX_data_scene ( C ) ;
2009-07-28 16:33:02 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
RecordCompositeData * rcd = op - > customdata ;
scene - > r . cfra = rcd - > old_cfra ;
2009-02-11 19:16:14 +00:00
WM_cursor_restore ( CTX_wm_window ( C ) ) ;
2009-02-10 23:17:58 +00:00
if ( rcd - > timer )
2009-10-20 13:58:53 +00:00
WM_event_remove_timer ( CTX_wm_manager ( C ) , CTX_wm_window ( C ) , rcd - > timer ) ;
2009-02-10 23:17:58 +00:00
2009-02-11 19:16:14 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , sima - > image ) ;
2009-02-10 23:17:58 +00:00
// XXX play_anim(0);
// XXX allqueue(REDRAWNODE, 1);
MEM_freeN ( rcd ) ;
}
static int record_composite_exec ( bContext * C , wmOperator * op )
{
if ( ! record_composite_init ( C , op ) )
return OPERATOR_CANCELLED ;
while ( record_composite_apply ( C , op ) )
;
record_composite_exit ( C , op ) ;
return OPERATOR_FINISHED ;
}
2010-10-14 12:24:08 +00:00
static int record_composite_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-02-10 23:17:58 +00:00
{
2011-01-12 03:41:12 +00:00
RecordCompositeData * rcd ;
2009-02-10 23:17:58 +00:00
if ( ! record_composite_init ( C , op ) )
return OPERATOR_CANCELLED ;
rcd = op - > customdata ;
2009-10-20 13:58:53 +00:00
rcd - > timer = WM_event_add_timer ( CTX_wm_manager ( C ) , CTX_wm_window ( C ) , TIMER , 0.0f ) ;
2009-09-18 12:43:36 +00:00
WM_event_add_modal_handler ( C , op ) ;
2009-02-10 23:17:58 +00:00
if ( ! record_composite_apply ( C , op ) )
return OPERATOR_FINISHED ;
return OPERATOR_RUNNING_MODAL ;
}
static int record_composite_modal ( bContext * C , wmOperator * op , wmEvent * event )
{
RecordCompositeData * rcd = op - > customdata ;
switch ( event - > type ) {
case TIMER :
if ( rcd - > timer = = event - > customdata ) {
if ( ! record_composite_apply ( C , op ) ) {
record_composite_exit ( C , op ) ;
return OPERATOR_FINISHED ;
}
}
break ;
case ESCKEY :
record_composite_exit ( C , op ) ;
return OPERATOR_FINISHED ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2009-02-10 23:17:58 +00:00
return OPERATOR_RUNNING_MODAL ;
}
static int record_composite_cancel ( bContext * C , wmOperator * op )
{
record_composite_exit ( C , op ) ;
return OPERATOR_CANCELLED ;
}
void IMAGE_OT_record_composite ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Record Composite " ;
ot - > idname = " IMAGE_OT_record_composite " ;
/* api callbacks */
ot - > exec = record_composite_exec ;
ot - > invoke = record_composite_invoke ;
ot - > modal = record_composite_modal ;
ot - > cancel = record_composite_cancel ;
2010-04-19 07:28:23 +00:00
ot - > poll = space_image_buffer_exists_poll ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2010-02-09 19:37:37 +00:00
/********************* cycle render slot operator *********************/
static int cycle_render_slot_poll ( bContext * C )
{
Image * ima = CTX_data_edit_image ( C ) ;
return ( ima & & ima - > type = = IMA_TYPE_R_RESULT ) ;
}
2010-12-13 05:02:23 +00:00
static int cycle_render_slot_exec ( bContext * C , wmOperator * op )
2010-02-09 19:37:37 +00:00
{
2010-03-27 15:35:34 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
int a , slot , cur = ima - > render_slot ;
2010-12-13 05:02:23 +00:00
const short use_reverse = RNA_boolean_get ( op - > ptr , " reverse " ) ;
2010-02-09 19:37:37 +00:00
2010-03-27 15:35:34 +00:00
for ( a = 1 ; a < IMA_MAX_RENDER_SLOT ; a + + ) {
2010-12-13 05:02:23 +00:00
slot = ( cur + ( use_reverse ? - a : a ) ) % IMA_MAX_RENDER_SLOT ;
if ( slot < 0 ) slot + = IMA_MAX_RENDER_SLOT ;
2010-02-09 19:37:37 +00:00
2010-03-27 15:35:34 +00:00
if ( ima - > renders [ slot ] | | slot = = ima - > last_render_slot ) {
ima - > render_slot = slot ;
2010-02-09 19:37:37 +00:00
break ;
}
2010-09-28 03:26:17 +00:00
else if ( ( slot - 1 ) = = ima - > last_render_slot & & slot < IMA_MAX_RENDER_SLOT ) {
ima - > render_slot = slot ;
break ;
}
2010-02-09 19:37:37 +00:00
}
2010-03-27 15:35:34 +00:00
if ( a = = IMA_MAX_RENDER_SLOT )
ima - > render_slot = ( ( cur = = 1 ) ? 0 : 1 ) ;
2010-02-09 19:37:37 +00:00
WM_event_add_notifier ( C , NC_IMAGE | ND_DRAW , NULL ) ;
2011-03-10 17:34:27 +00:00
/* no undo push for browsing existing */
2011-03-12 15:09:29 +00:00
if ( ima - > renders [ ima - > render_slot ] | | ima - > render_slot = = ima - > last_render_slot )
2011-03-10 17:34:27 +00:00
return OPERATOR_CANCELLED ;
2010-02-09 19:37:37 +00:00
return OPERATOR_FINISHED ;
}
void IMAGE_OT_cycle_render_slot ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Cycle Render Slot " ;
ot - > idname = " IMAGE_OT_cycle_render_slot " ;
/* api callbacks */
ot - > exec = cycle_render_slot_exec ;
ot - > poll = cycle_render_slot_poll ;
2011-03-10 17:34:27 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2010-12-13 05:02:23 +00:00
RNA_def_boolean ( ot - > srna , " reverse " , 0 , " Cycle in Reverse " , " " ) ;
2010-02-09 19:37:37 +00:00
}
2009-02-10 23:17:58 +00:00
/******************** TODO ********************/
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* XXX notifier? */
2010-02-13 13:09:30 +00:00
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
2010-02-13 13:09:30 +00:00
2010-11-02 09:34:32 +00:00
void ED_image_update_frame ( const Main * mainp , int cfra )
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
{
2010-11-02 09:34:32 +00:00
wmWindowManager * wm ;
2010-07-23 14:34:43 +00:00
wmWindow * win ;
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
Tex * tex ;
/* texture users */
2010-02-13 13:09:30 +00:00
for ( tex = mainp - > tex . first ; tex ; tex = tex - > id . next ) {
if ( tex - > type = = TEX_IMAGE & & tex - > ima ) {
if ( ELEM ( tex - > ima - > source , IMA_SRC_MOVIE , IMA_SRC_SEQUENCE ) ) {
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
if ( tex - > iuser . flag & IMA_ANIM_ALWAYS )
2010-11-02 09:34:32 +00:00
BKE_image_user_calc_frame ( & tex - > iuser , cfra , 0 ) ;
2010-02-13 13:09:30 +00:00
}
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
2010-02-13 13:09:30 +00:00
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
/* image window, compo node users */
2010-11-02 09:34:32 +00:00
for ( wm = mainp - > wm . first ; wm ; wm = wm - > id . next ) { /* only 1 wm */
2010-07-23 14:34:43 +00:00
for ( win = wm - > windows . first ; win ; win = win - > next ) {
ScrArea * sa ;
for ( sa = win - > screen - > areabase . first ; sa ; sa = sa - > next ) {
if ( sa - > spacetype = = SPACE_VIEW3D ) {
View3D * v3d = sa - > spacedata . first ;
BGpic * bgpic ;
for ( bgpic = v3d - > bgpicbase . first ; bgpic ; bgpic = bgpic - > next )
2010-07-26 02:08:47 +00:00
if ( bgpic - > iuser . flag & IMA_ANIM_ALWAYS )
2010-11-02 09:34:32 +00:00
BKE_image_user_calc_frame ( & bgpic - > iuser , cfra , 0 ) ;
2010-07-23 14:34:43 +00:00
}
else if ( sa - > spacetype = = SPACE_IMAGE ) {
SpaceImage * sima = sa - > spacedata . first ;
if ( sima - > iuser . flag & IMA_ANIM_ALWAYS )
2010-11-02 09:34:32 +00:00
BKE_image_user_calc_frame ( & sima - > iuser , cfra , 0 ) ;
2010-07-23 14:34:43 +00:00
}
else if ( sa - > spacetype = = SPACE_NODE ) {
SpaceNode * snode = sa - > spacedata . first ;
if ( ( snode - > treetype = = NTREE_COMPOSIT ) & & ( snode - > nodetree ) ) {
bNode * node ;
for ( node = snode - > nodetree - > nodes . first ; node ; node = node - > next ) {
if ( node - > id & & node - > type = = CMP_NODE_IMAGE ) {
Image * ima = ( Image * ) node - > id ;
ImageUser * iuser = node - > storage ;
if ( ELEM ( ima - > source , IMA_SRC_MOVIE , IMA_SRC_SEQUENCE ) )
if ( iuser - > flag & IMA_ANIM_ALWAYS )
2010-11-02 09:34:32 +00:00
BKE_image_user_calc_frame ( iuser , cfra , 0 ) ;
2010-07-23 14:34:43 +00:00
}
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
}
}
}
}
}
}
2010-02-13 13:09:30 +00:00
}