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 *********************/
2012-02-24 14:01:42 +00:00
static void sima_zoom_set ( SpaceImage * sima , ARegion * ar , float zoom , float location [ 2 ] )
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
{
2012-03-28 11:53:18 +00:00
float oldzoom = sima - > zoom ;
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 ;
2012-03-28 11:53:18 +00:00
sima - > zoom = zoom ;
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
2012-02-24 14:01:42 +00:00
if ( sima - > zoom < 0.1f | | sima - > zoom > 4.0f ) {
/* check zoom limits */
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
2012-02-24 14:01:42 +00:00
width * = sima - > zoom ;
height * = sima - > zoom ;
2012-03-24 06:38:07 +00:00
if ( ( width < 4 ) & & ( height < 4 ) )
2012-03-28 11:53:18 +00:00
sima - > zoom = oldzoom ;
2012-03-24 06:38:07 +00:00
else if ( ( ar - > winrct . xmax - ar - > winrct . xmin ) < = sima - > zoom )
2012-03-28 11:53:18 +00:00
sima - > zoom = oldzoom ;
2012-03-24 06:38:07 +00:00
else if ( ( ar - > winrct . ymax - ar - > winrct . ymin ) < = sima - > zoom )
2012-03-28 11:53:18 +00:00
sima - > zoom = oldzoom ;
2012-02-24 14:01:42 +00:00
}
2012-03-24 06:38:07 +00:00
if ( ( U . uiflag & USER_ZOOM_TO_MOUSEPOS ) & & location ) {
2012-02-24 14:01:42 +00:00
float aspx , aspy , w , 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
2012-02-24 14:01:42 +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
2012-03-28 11:53:18 +00:00
w = width * aspx ;
h = height * aspy ;
2012-02-24 14:01:42 +00:00
2012-03-28 11:53:18 +00:00
sima - > xof + = ( ( location [ 0 ] - 0.5f ) * w - sima - > xof ) * ( sima - > zoom - oldzoom ) / sima - > zoom ;
sima - > yof + = ( ( location [ 1 ] - 0.5f ) * h - sima - > yof ) * ( sima - > zoom - oldzoom ) / sima - > zoom ;
2012-02-24 14:01:42 +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
}
2012-02-24 14:01:42 +00:00
static void sima_zoom_set_factor ( SpaceImage * sima , ARegion * ar , float zoomfac , float location [ 2 ] )
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
{
2012-03-28 11:53:18 +00:00
sima_zoom_set ( sima , ar , sima - > zoom * zoomfac , location ) ;
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-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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
if ( sima & & sima - > spacetype = = SPACE_IMAGE )
2012-03-24 06:38:07 +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 )
{
2012-03-24 06:38:07 +00:00
if ( space_image_buffer_exists_poll ( C ) ) {
2012-03-28 11:53:18 +00:00
Main * bmain = CTX_data_main ( C ) ;
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-09-30 18:18:32 +00:00
ImBuf * ibuf ;
void * lock ;
2012-03-28 11:53:18 +00:00
int ret = FALSE ;
2010-07-21 14:09:45 +00:00
char name [ FILE_MAX ] ;
2012-03-28 11:53:18 +00:00
ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
2012-03-24 06:38:07 +00:00
if ( ibuf ) {
2010-07-21 14:09:45 +00:00
BLI_strncpy ( name , ibuf - > name , FILE_MAX ) ;
2010-11-16 13:08:24 +00:00
BLI_path_abs ( name , bmain - > name ) ;
2011-10-28 04:05:52 +00:00
2012-03-24 06:38:07 +00:00
if ( BLI_exists ( name ) = = FALSE ) {
2011-10-28 04:05:52 +00:00
CTX_wm_operator_poll_msg_set ( C , " image file not found " ) ;
}
else if ( BLI_file_is_writable ( name ) = = FALSE ) {
CTX_wm_operator_poll_msg_set ( C , " image path can't be written to " ) ;
}
else {
2012-03-28 11:53:18 +00:00
ret = TRUE ;
2011-10-28 04:05:52 +00:00
}
2010-07-21 14:09:45 +00:00
}
2009-09-30 18:18:32 +00:00
ED_space_image_release_buffer ( sima , lock ) ;
2011-10-28 04:05:52 +00:00
return ret ;
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 )
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
if ( sima & & sima - > spacetype = = SPACE_IMAGE & & sima - > image )
2010-04-19 07:28:23 +00:00
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
{
2012-03-28 11:53:18 +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
2012-03-24 06:38:07 +00:00
if ( sima )
2012-03-28 11:53:18 +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 ;
}
2012-01-17 16:31:13 +00:00
/* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode */
int space_image_main_area_not_uv_brush_poll ( bContext * C )
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2012-01-17 16:31:13 +00:00
ToolSettings * toolsettings = CTX_data_scene ( C ) - > toolsettings ;
2012-03-24 06:38:07 +00:00
if ( sima & & ! toolsettings - > uvsculpt )
2012-01-17 16:31:13 +00:00
return 1 ;
return 0 ;
}
static int space_image_image_sample_poll ( bContext * C )
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
Object * obedit = CTX_data_edit_object ( C ) ;
2012-01-17 16:31:13 +00:00
ToolSettings * toolsettings = CTX_data_scene ( C ) - > toolsettings ;
2012-03-24 06:38:07 +00:00
if ( obedit ) {
if ( ED_space_image_show_uvedit ( sima , obedit ) & & ( toolsettings - > use_uv_sculpt ) )
2012-01-17 16:31:13 +00:00
return 0 ;
}
return space_image_main_area_poll ( 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
/********************** 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 ;
2011-10-28 03:02:09 +00:00
static void image_view_pan_init ( bContext * C , wmOperator * op , wmEvent * 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
{
2012-03-28 11:53:18 +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 ;
2012-03-28 11:53:18 +00:00
op - > customdata = vpd = MEM_callocN ( sizeof ( ViewPanData ) , " ImageViewPanData " ) ;
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_modal ( CTX_wm_window ( C ) , BC_NSEW_SCROLLCURSOR ) ;
2012-03-28 11:53:18 +00:00
vpd - > x = event - > x ;
vpd - > y = event - > y ;
vpd - > xof = sima - > xof ;
vpd - > yof = sima - > yof ;
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
}
2011-10-28 03:02:09 +00:00
static void image_view_pan_exit ( bContext * C , wmOperator * op , int cancel )
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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ViewPanData * vpd = op - > customdata ;
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
2012-03-24 06:38:07 +00:00
if ( cancel ) {
2012-03-28 11:53:18 +00:00
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 ) ;
}
2011-10-28 03:02:09 +00:00
static int image_view_pan_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
{
2012-03-28 11:53:18 +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
2012-03-24 06:38:07 +00:00
if ( image_preview_active ( curarea , NULL , NULL ) ) {
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
/* recalculates new preview rect */
scrarea_do_windraw ( curarea ) ;
image_preview_event ( 2 ) ;
}
# endif
return OPERATOR_FINISHED ;
}
2011-10-28 03:02:09 +00:00
static int image_view_pan_invoke ( bContext * C , wmOperator * op , wmEvent * 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-01-11 11:14:36 +00:00
if ( event - > type = = MOUSEPAN ) {
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2010-01-11 11:14:36 +00:00
float offset [ 2 ] ;
2012-03-28 11:53:18 +00:00
offset [ 0 ] = ( event - > x - event - > prevx ) / sima - > zoom ;
offset [ 1 ] = ( event - > y - event - > prevy ) / sima - > zoom ;
2010-01-11 11:14:36 +00:00
RNA_float_set_array ( op - > ptr , " offset " , offset ) ;
2011-10-28 03:02:09 +00:00
image_view_pan_exec ( C , op ) ;
2010-01-11 11:14:36 +00:00
return OPERATOR_FINISHED ;
}
else {
2011-10-28 03:02:09 +00:00
image_view_pan_init ( C , op , event ) ;
2010-01-11 11:14:36 +00:00
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
}
2011-10-28 03:02:09 +00:00
static int image_view_pan_modal ( bContext * C , wmOperator * op , wmEvent * 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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ViewPanData * vpd = op - > customdata ;
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 ] ;
2012-03-28 11:53:18 +00:00
switch ( 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
case MOUSEMOVE :
2012-03-28 11:53:18 +00:00
sima - > xof = vpd - > xof ;
sima - > yof = vpd - > yof ;
offset [ 0 ] = ( vpd - > x - event - > x ) / sima - > zoom ;
offset [ 1 ] = ( vpd - > y - event - > y ) / sima - > zoom ;
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_array ( op - > ptr , " offset " , offset ) ;
2011-10-28 03:02:09 +00:00
image_view_pan_exec ( 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
break ;
2011-03-22 15:20:25 +00:00
default :
2012-03-28 11:53:18 +00:00
if ( event - > type = = vpd - > event_type & & event - > val = = KM_RELEASE ) {
2011-10-28 03:02:09 +00:00
image_view_pan_exit ( C , op , 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
return OPERATOR_FINISHED ;
}
break ;
}
return OPERATOR_RUNNING_MODAL ;
}
2011-10-28 03:02:09 +00:00
static int image_view_pan_cancel ( 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
{
2011-10-28 03:02:09 +00:00
image_view_pan_exit ( C , op , 1 ) ;
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_CANCELLED ;
}
void IMAGE_OT_view_pan ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " View Pan " ;
ot - > idname = " IMAGE_OT_view_pan " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_view_pan_exec ;
ot - > invoke = image_view_pan_invoke ;
ot - > modal = image_view_pan_modal ;
ot - > cancel = image_view_pan_cancel ;
ot - > poll = space_image_main_area_poll ;
2009-07-11 14:51:13 +00:00
/* flags */
2012-04-02 16:29:34 +00:00
ot - > flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER ;
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 ,
2012-03-28 11:53:18 +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 ;
2012-02-24 14:01:42 +00:00
float location [ 2 ] ;
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 ;
2011-10-28 03:02:09 +00:00
static void image_view_zoom_init ( bContext * C , wmOperator * op , wmEvent * 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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
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
ViewZoomData * vpd ;
2012-03-28 11:53:18 +00:00
op - > customdata = vpd = MEM_callocN ( sizeof ( ViewZoomData ) , " ImageViewZoomData " ) ;
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_modal ( CTX_wm_window ( C ) , BC_NSEW_SCROLLCURSOR ) ;
2012-03-28 11:53:18 +00:00
vpd - > x = event - > x ;
vpd - > y = event - > y ;
vpd - > zoom = sima - > zoom ;
vpd - > event_type = event - > type ;
2012-02-24 14:01:42 +00:00
UI_view2d_region_to_view ( & ar - > v2d , event - > mval [ 0 ] , event - > mval [ 1 ] , & vpd - > location [ 0 ] , & vpd - > location [ 1 ] ) ;
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
}
2011-10-28 03:02:09 +00:00
static void image_view_zoom_exit ( bContext * C , wmOperator * op , int cancel )
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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ViewZoomData * vpd = op - > customdata ;
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
2012-03-24 06:38:07 +00:00
if ( cancel ) {
2012-03-28 11:53:18 +00:00
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 ) ;
}
2011-10-28 03:02:09 +00:00
static int image_view_zoom_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
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
2012-02-24 14:01:42 +00:00
sima_zoom_set_factor ( sima , ar , RNA_float_get ( op - > ptr , " factor " ) , NULL ) ;
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
/* XXX notifier? */
#if 0
2012-03-24 06:38:07 +00:00
if ( image_preview_active ( curarea , NULL , NULL ) ) {
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
/* recalculates new preview rect */
scrarea_do_windraw ( curarea ) ;
image_preview_event ( 2 ) ;
}
# endif
return OPERATOR_FINISHED ;
}
2011-10-28 03:02:09 +00:00
static int image_view_zoom_invoke ( bContext * C , wmOperator * op , wmEvent * 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-01-11 11:14:36 +00:00
if ( event - > type = = MOUSEZOOM ) {
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2012-02-24 14:01:42 +00:00
float factor , location [ 2 ] ;
UI_view2d_region_to_view ( & ar - > v2d , event - > mval [ 0 ] , event - > mval [ 1 ] , & location [ 0 ] , & location [ 1 ] ) ;
2012-03-28 11:53:18 +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 ) ;
2012-03-28 11:53:18 +00:00
sima_zoom_set ( sima , ar , sima - > zoom * factor , location ) ;
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 {
2011-10-28 03:02:09 +00:00
image_view_zoom_init ( C , op , event ) ;
2010-01-11 11:14:36 +00:00
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
}
2011-10-28 03:02:09 +00:00
static int image_view_zoom_modal ( bContext * C , wmOperator * op , wmEvent * 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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
ViewZoomData * vpd = op - > customdata ;
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 factor ;
2012-03-28 11:53:18 +00:00
switch ( 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
case MOUSEMOVE :
2012-03-28 11:53:18 +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 ) ;
2012-03-28 11:53:18 +00:00
sima_zoom_set ( sima , ar , vpd - > zoom * factor , vpd - > location ) ;
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 :
2012-03-28 11:53:18 +00:00
if ( event - > type = = vpd - > event_type & & event - > val = = KM_RELEASE ) {
2011-10-28 03:02:09 +00:00
image_view_zoom_exit ( C , op , 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
return OPERATOR_FINISHED ;
}
break ;
}
return OPERATOR_RUNNING_MODAL ;
}
2011-10-28 03:02:09 +00:00
static int image_view_zoom_cancel ( 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
{
2011-10-28 03:02:09 +00:00
image_view_zoom_exit ( C , op , 1 ) ;
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_CANCELLED ;
}
void IMAGE_OT_view_zoom ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " View Zoom " ;
ot - > idname = " IMAGE_OT_view_zoom " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_view_zoom_exec ;
ot - > invoke = image_view_zoom_invoke ;
ot - > modal = image_view_zoom_modal ;
ot - > cancel = image_view_zoom_cancel ;
ot - > poll = space_image_main_area_poll ;
2009-07-11 14:51:13 +00:00
/* flags */
2012-03-22 07:26:09 +00:00
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 ,
2012-03-28 11:53:18 +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-10-28 03:02:09 +00:00
static int image_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 {
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2011-06-25 18:51:29 +00:00
2012-03-28 11:53:18 +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
2012-02-24 14:01:42 +00:00
sima_zoom_set_factor ( sima , ar , zoom_factor , NULL ) ;
2011-08-06 22:31:16 +00:00
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " NDOF Pan/Zoom " ;
ot - > idname = " IMAGE_OT_view_ndof " ;
2011-06-25 18:51:29 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = image_view_ndof_invoke ;
2011-06-25 18:51:29 +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
/********************** 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 */
2011-10-28 03:02:09 +00:00
static int image_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 */
2012-03-28 11:53:18 +00:00
sima = CTX_wm_space_image ( C ) ;
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-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
2012-03-28 11:53:18 +00:00
w = width * aspx ;
h = 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
/* 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 ;
2012-03-24 06:38:07 +00:00
if ( ( w > = width | | h > = height ) & & ( width > 0 & & height > 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
/* find the zoom value that will fit the image in the image space */
2012-03-28 11:53:18 +00:00
zoomx = width / w ;
zoomy = height / h ;
sima_zoom_set ( sima , ar , 1.0f / power_of_2 ( 1 / MIN2 ( zoomx , zoomy ) ) , NULL ) ;
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
}
else
2012-02-24 14:01:42 +00:00
sima_zoom_set ( sima , ar , 1.0f , NULL ) ;
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
2012-03-28 11:53:18 +00:00
sima - > xof = sima - > yof = 0.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
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " View All " ;
ot - > idname = " IMAGE_OT_view_all " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_view_all_exec ;
ot - > poll = space_image_main_area_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 selected operator *********************/
2011-10-28 03:02:09 +00:00
static int image_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 */
2012-03-28 11:53:18 +00:00
sima = CTX_wm_space_image ( C ) ;
ar = CTX_wm_region ( C ) ;
scene = CTX_data_scene ( C ) ;
obedit = CTX_data_edit_object ( 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
2012-03-28 11:53:18 +00:00
ima = ED_space_image ( sima ) ;
2009-02-09 20:58:31 +00:00
ED_space_image_size ( sima , & width , & height ) ;
2011-07-27 07:42:53 +00:00
ED_image_aspect ( ima , & aspx , & aspy ) ;
2012-03-28 11:53:18 +00:00
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 */
2012-03-24 06:38:07 +00:00
if ( ! ED_uvedit_minmax ( scene , ima , obedit , min , 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
return OPERATOR_CANCELLED ;
/* adjust offset and zoom */
2012-03-28 11:53:18 +00:00
sima - > xof = ( int ) ( ( ( min [ 0 ] + max [ 0 ] ) * 0.5f - 0.5f ) * width ) ;
sima - > yof = ( int ) ( ( ( min [ 1 ] + max [ 1 ] ) * 0.5f - 0.5f ) * 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
2012-03-28 11:53:18 +00:00
d [ 0 ] = max [ 0 ] - min [ 0 ] ;
d [ 1 ] = max [ 1 ] - min [ 1 ] ;
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
2012-03-28 11:53:18 +00:00
if ( size < = 0.01f ) size = 0.01f ;
sima_zoom_set ( sima , ar , 0.7f / size , NULL ) ;
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 ;
}
2011-10-28 03:02:09 +00:00
static int image_view_selected_poll ( bContext * C )
2010-04-09 01:44:24 +00:00
{
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " View Center " ;
ot - > idname = " IMAGE_OT_view_selected " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_view_selected_exec ;
ot - > poll = image_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 *********************/
2012-02-24 14:01:42 +00:00
static int image_view_zoom_in_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2012-02-24 14:01:42 +00:00
float location [ 2 ] ;
RNA_float_get_array ( op - > ptr , " location " , location ) ;
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
2012-02-24 14:01:42 +00:00
sima_zoom_set_factor ( sima , ar , 1.25f , location ) ;
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 ;
}
2012-02-24 14:01:42 +00:00
static int image_view_zoom_in_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2012-03-28 11:53:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2012-02-24 14:01:42 +00:00
float location [ 2 ] ;
UI_view2d_region_to_view ( & ar - > v2d , event - > mval [ 0 ] , event - > mval [ 1 ] , & location [ 0 ] , & location [ 1 ] ) ;
RNA_float_set_array ( op - > ptr , " location " , location ) ;
return image_view_zoom_in_exec ( 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
void IMAGE_OT_view_zoom_in ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " View Zoom In " ;
ot - > idname = " IMAGE_OT_view_zoom_in " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = image_view_zoom_in_invoke ;
ot - > exec = image_view_zoom_in_exec ;
ot - > poll = space_image_main_area_poll ;
2012-02-24 14:01:42 +00:00
/* properties */
RNA_def_float_vector ( ot - > srna , " location " , 2 , NULL , - FLT_MAX , FLT_MAX , " Location " , " Cursor location in screen coordinates " , - 10.0f , 10.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
}
2012-02-24 14:01:42 +00:00
static int image_view_zoom_out_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2012-02-24 14:01:42 +00:00
float location [ 2 ] ;
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
2012-02-24 14:01:42 +00:00
RNA_float_get_array ( op - > ptr , " location " , location ) ;
sima_zoom_set_factor ( sima , ar , 0.8f , location ) ;
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 ;
}
2012-02-24 14:01:42 +00:00
static int image_view_zoom_out_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
2012-03-28 11:53:18 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2012-02-24 14:01:42 +00:00
float location [ 2 ] ;
UI_view2d_region_to_view ( & ar - > v2d , event - > mval [ 0 ] , event - > mval [ 1 ] , & location [ 0 ] , & location [ 1 ] ) ;
RNA_float_set_array ( op - > ptr , " location " , location ) ;
return image_view_zoom_out_exec ( 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
void IMAGE_OT_view_zoom_out ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " View Zoom Out " ;
ot - > idname = " IMAGE_OT_view_zoom_out " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = image_view_zoom_out_invoke ;
ot - > exec = image_view_zoom_out_exec ;
ot - > poll = space_image_main_area_poll ;
2012-02-24 14:01:42 +00:00
/* properties */
RNA_def_float_vector ( ot - > srna , " location " , 2 , NULL , - FLT_MAX , FLT_MAX , " Location " , " Cursor location in screen coordinates " , - 10.0f , 10.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
}
/********************** view zoom ratio operator *********************/
2011-10-28 03:02:09 +00:00
static int image_view_zoom_ratio_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
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
2012-02-24 14:01:42 +00:00
sima_zoom_set ( sima , ar , RNA_float_get ( op - > ptr , " ratio " ) , NULL ) ;
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
/* ensure pixel exact locations for draw */
2012-03-28 11:53:18 +00:00
sima - > xof = ( int ) sima - > xof ;
sima - > yof = ( int ) sima - > yof ;
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
2012-03-24 06:38:07 +00:00
if ( image_preview_active ( curarea , NULL , NULL ) ) {
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
/* 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 */
2012-03-22 07:26:09 +00:00
ot - > name = " View Zoom Ratio " ;
ot - > idname = " IMAGE_OT_view_zoom_ratio " ;
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
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_view_zoom_ratio_exec ;
ot - > poll = space_image_main_area_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
/* properties */
2009-01-16 23:53:11 +00:00
RNA_def_float ( ot - > srna , " ratio " , 0.0f , 0.0f , FLT_MAX ,
2012-03-28 11:53:18 +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 ******************/
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 ********************/
2011-10-28 03:02:09 +00:00
static void image_open_init ( bContext * C , wmOperator * op )
2009-10-01 23:32:57 +00:00
{
PropertyPointerRNA * pprop ;
2012-03-28 11:53:18 +00:00
op - > customdata = pprop = MEM_callocN ( sizeof ( PropertyPointerRNA ) , " OpenPropertyPointerRNA " ) ;
2009-10-01 23:32:57 +00:00
uiIDContextProperty ( C , & pprop - > ptr , & pprop - > prop ) ;
}
2011-10-28 03:02:09 +00:00
static int image_open_cancel ( bContext * UNUSED ( C ) , wmOperator * op )
2009-10-01 23:32:57 +00:00
{
MEM_freeN ( op - > customdata ) ;
2012-03-28 11:53:18 +00:00
op - > customdata = NULL ;
2009-10-01 23:32:57 +00:00
return OPERATOR_CANCELLED ;
}
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ; /* XXX other space types can call */
Scene * scene = CTX_data_scene ( C ) ;
Object * obedit = CTX_data_edit_object ( C ) ;
ImageUser * iuser = NULL ;
2009-10-01 23:32:57 +00:00
PropertyPointerRNA * pprop ;
PointerRNA idptr ;
2012-03-28 11:53: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
2012-03-28 11:53:18 +00:00
errno = 0 ;
2010-07-03 17:47:06 +00:00
2012-03-28 11:53:18 +00:00
ima = BKE_add_image_file ( str ) ;
2009-02-10 23:17:58 +00:00
2012-03-24 06:38:07 +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
2012-03-24 06:38:07 +00:00
if ( ! op - > customdata )
2011-10-28 03:02:09 +00:00
image_open_init ( C , op ) ;
2009-10-01 23:32:57 +00:00
/* hook into UI */
2012-03-28 11:53:18 +00:00
pprop = op - > customdata ;
2009-10-01 23:32:57 +00:00
2012-03-24 06:38:07 +00:00
if ( pprop - > prop ) {
2009-10-01 23:32:57 +00:00
/* 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 ) ;
}
2012-03-24 06:38:07 +00:00
else if ( sima ) {
2011-11-10 13:39:25 +00:00
ED_space_image_set ( sima , scene , obedit , ima ) ;
2012-03-28 11:53:18 +00:00
iuser = & sima - > iuser ;
2010-11-08 19:03:42 +00:00
}
else {
2012-03-28 11:53:18 +00:00
Tex * tex = CTX_data_pointer_get_type ( C , " texture " , & RNA_Texture ) . data ;
if ( tex & & tex - > type = = TEX_IMAGE )
iuser = & tex - > iuser ;
2010-11-08 19:03:42 +00:00
}
/* initialize because of new image */
2012-03-24 06:38:07 +00:00
if ( iuser ) {
2012-03-28 11:53:18 +00:00
iuser - > sfra = 1 ;
iuser - > offset = 0 ;
iuser - > fie_ima = 2 ;
2010-11-08 19:03:42 +00:00
}
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 ) ;
2012-03-28 11:53:18 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2010-01-19 01:32:06 +00:00
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
}
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ; /* XXX other space types can call */
char * path = U . textudir ;
Image * ima = NULL ;
2010-08-11 03:31:56 +00:00
2012-03-24 06:38:07 +00:00
if ( sima ) {
2012-03-28 11:53:18 +00:00
ima = sima - > image ;
2010-08-11 03:31:56 +00:00
}
2012-03-28 11:53:18 +00:00
if ( ima = = NULL ) {
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
}
2012-03-24 06:38:07 +00:00
if ( ima )
2012-03-28 11:53:18 +00:00
path = ima - > name ;
2010-03-09 16:57:24 +00:00
2012-03-24 06:38:07 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " filepath " ) )
2011-10-28 03:02:09 +00:00
return image_open_exec ( C , op ) ;
2009-02-10 23:17:58 +00:00
2011-10-28 03:02:09 +00:00
image_open_init ( C , op ) ;
2009-10-01 23:32:57 +00:00
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Open Image " ;
ot - > description = " Open image " ;
ot - > idname = " IMAGE_OT_open " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_open_exec ;
ot - > invoke = image_open_invoke ;
ot - > cancel = image_open_cancel ;
2009-02-10 23:17:58 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2009-02-10 23:17:58 +00:00
/* properties */
2012-03-28 11:53:18 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE | MOVIEFILE , FILE_SPECIAL , FILE_OPENFILE , WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH , FILE_DEFAULTDISPLAY ) ;
2009-02-10 23:17:58 +00:00
}
/******************** replace image operator ********************/
2011-10-28 03:02:09 +00:00
static int image_replace_exec ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +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
2012-03-24 06:38:07 +00:00
if ( ! sima - > image )
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
2010-06-14 03:52:10 +00:00
RNA_string_get ( op - > ptr , " filepath " , str ) ;
2012-01-16 05:52:33 +00:00
/* we cant do much if the str is longer then FILE_MAX :/ */
BLI_strncpy ( sima - > image - > name , str , sizeof ( sima - > image - > name ) ) ;
2009-02-10 23:17:58 +00:00
2012-02-16 04:21:40 +00:00
if ( BLI_testextensie_array ( str , imb_ext_movie ) )
2012-03-28 11:53:18 +00:00
sima - > image - > source = IMA_SRC_MOVIE ;
2012-02-16 04:21:40 +00:00
else
2012-03-28 11:53:18 +00:00
sima - > image - > source = IMA_SRC_FILE ;
2012-02-16 04:21:40 +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 ) ;
2012-03-28 11:53:18 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , sima - > image ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
}
2011-10-28 03:02:09 +00:00
static int image_replace_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
2012-03-24 06:38:07 +00:00
if ( ! sima - > image )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2012-03-24 06:38:07 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " filepath " ) )
2011-10-28 03:02:09 +00:00
return image_replace_exec ( C , op ) ;
2009-02-10 23:17:58 +00:00
2012-03-24 06:38:07 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " relative_path " ) )
2012-03-28 11:53:18 +00:00
RNA_boolean_set ( op - > ptr , " relative_path " , ( strncmp ( sima - > image - > name , " // " , 2 ) ) = = 0 ) ;
2010-06-25 12:04:04 +00:00
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Replace Image " ;
ot - > idname = " IMAGE_OT_replace " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_replace_exec ;
ot - > invoke = image_replace_invoke ;
ot - > poll = space_image_poll ;
2009-02-10 23:17:58 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2009-02-10 23:17:58 +00:00
/* properties */
2012-03-28 11:53:18 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE | MOVIEFILE , FILE_SPECIAL , FILE_OPENFILE , WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH , FILE_DEFAULTDISPLAY ) ;
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 */
2011-11-21 23:56:32 +00:00
//short planes, imtype, subimtype, quality;
ImageFormatData im_format ;
2011-08-24 00:44:58 +00:00
char filepath [ FILE_MAX ] ; /* keep absolute */
} SaveImageOptions ;
static void save_image_options_defaults ( SaveImageOptions * simopts )
{
2011-11-21 23:56:32 +00:00
memset ( & simopts - > im_format , 0 , sizeof ( simopts - > im_format ) ) ;
2012-03-28 11:53:18 +00:00
simopts - > im_format . planes = R_IMF_PLANES_RGB ;
simopts - > im_format . imtype = R_IMF_IMTYPE_PNG ;
simopts - > im_format . quality = 90 ;
simopts - > im_format . compress = 90 ;
simopts - > filepath [ 0 ] = ' \0 ' ;
2011-08-24 00:44:58 +00:00
}
2011-11-21 23:56:32 +00:00
static char imtype_best_depth ( ImBuf * ibuf , const char imtype )
{
2012-03-28 11:53:18 +00:00
const char depth_ok = BKE_imtype_valid_depths ( imtype ) ;
2011-11-21 23:56:32 +00:00
if ( ibuf - > rect_float ) {
if ( depth_ok & R_IMF_CHAN_DEPTH_32 ) return R_IMF_CHAN_DEPTH_32 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_24 ) return R_IMF_CHAN_DEPTH_24 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_16 ) return R_IMF_CHAN_DEPTH_16 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_12 ) return R_IMF_CHAN_DEPTH_12 ;
return R_IMF_CHAN_DEPTH_8 ;
}
else {
if ( depth_ok & R_IMF_CHAN_DEPTH_8 ) return R_IMF_CHAN_DEPTH_8 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_12 ) return R_IMF_CHAN_DEPTH_12 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_16 ) return R_IMF_CHAN_DEPTH_16 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_24 ) return R_IMF_CHAN_DEPTH_24 ;
if ( depth_ok & R_IMF_CHAN_DEPTH_32 ) return R_IMF_CHAN_DEPTH_32 ;
return R_IMF_CHAN_DEPTH_8 ; /* fallback, should not get here */
}
}
2011-08-24 00:44:58 +00:00
static int save_image_options_init ( SaveImageOptions * simopts , SpaceImage * sima , Scene * scene , const short guess_path )
{
void * lock ;
2012-03-28 11:53:18 +00:00
ImBuf * ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
2011-08-24 00:44:58 +00:00
2012-03-24 06:38:07 +00:00
if ( ibuf ) {
2012-03-28 11:53:18 +00:00
Image * ima = sima - > image ;
short is_depth_set = FALSE ;
2011-08-24 00:44:58 +00:00
2012-03-28 11:53:18 +00:00
simopts - > im_format . planes = ibuf - > planes ;
2011-08-24 00:44:58 +00:00
2012-03-24 06:38:07 +00:00
if ( ELEM ( ima - > type , IMA_TYPE_R_RESULT , IMA_TYPE_COMPOSITE ) ) {
2011-11-21 23:56:32 +00:00
/* imtype */
2012-03-28 11:53:18 +00:00
simopts - > im_format = scene - > r . im_format ;
is_depth_set = TRUE ;
2011-08-30 23:37:46 +00:00
}
else if ( ima - > source = = IMA_SRC_GENERATED ) {
2012-03-28 11:53:18 +00:00
simopts - > im_format . imtype = R_IMF_IMTYPE_PNG ;
2011-08-30 23:37:46 +00:00
}
else {
2012-03-28 11:53:18 +00:00
simopts - > im_format . imtype = BKE_ftype_to_imtype ( ibuf - > ftype ) ;
2011-08-30 23:37:46 +00:00
}
2011-11-21 20:19:58 +00:00
//simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
2012-03-28 11:53:18 +00:00
simopts - > im_format . quality = ibuf - > ftype & 0xff ;
2011-08-24 00:44:58 +00:00
BLI_strncpy ( simopts - > filepath , ibuf - > name , sizeof ( simopts - > filepath ) ) ;
/* sanitize all settings */
2012-03-09 00:41:09 +00:00
/* unlikely but just in case */
2011-11-21 23:56:32 +00:00
if ( ELEM3 ( simopts - > im_format . planes , R_IMF_PLANES_BW , R_IMF_PLANES_RGB , R_IMF_PLANES_RGBA ) = = 0 ) {
2012-03-28 11:53:18 +00:00
simopts - > im_format . planes = R_IMF_PLANES_RGBA ;
2011-11-21 23:56:32 +00:00
}
/* depth, account for float buffer and format support */
if ( is_depth_set = = FALSE ) {
2012-03-28 11:53:18 +00:00
simopts - > im_format . depth = imtype_best_depth ( ibuf , simopts - > im_format . imtype ) ;
2011-08-24 00:44:58 +00:00
}
2012-03-18 07:38:51 +00:00
/* some formats don't use quality so fallback to scenes quality */
2011-11-21 23:56:32 +00:00
if ( simopts - > im_format . quality = = 0 ) {
2012-03-28 11:53:18 +00:00
simopts - > im_format . quality = scene - > r . im_format . quality ;
2011-08-24 00:44:58 +00:00
}
/* check for empty path */
2012-03-28 11:53:18 +00:00
if ( guess_path & & simopts - > filepath [ 0 ] = = 0 ) {
2011-08-24 00:44:58 +00:00
if ( ( G . ima [ 0 ] = = ' / ' ) & & ( G . ima [ 1 ] = = ' / ' ) & & ( G . ima [ 2 ] = = ' \0 ' ) ) {
BLI_strncpy ( simopts - > filepath , " //untitled " , FILE_MAX ) ;
2012-03-24 06:38:07 +00:00
}
else {
2011-08-24 00:44:58 +00:00
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 ) ;
}
2011-11-21 23:56:32 +00:00
static void save_image_options_from_op ( SaveImageOptions * simopts , wmOperator * op )
2011-08-24 00:44:58 +00:00
{
2011-11-21 23:56:32 +00:00
if ( op - > customdata ) {
2012-03-28 11:53:18 +00:00
simopts - > im_format = * ( ImageFormatData * ) op - > customdata ;
2011-11-21 23:56:32 +00:00
}
2011-08-24 00:44:58 +00:00
2012-01-11 16:32:12 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " filepath " ) ) {
2011-08-30 23:37:46 +00:00
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 )
{
2011-11-21 23:56:32 +00:00
if ( op - > customdata ) {
2012-03-28 11:53:18 +00:00
* ( ImageFormatData * ) op - > customdata = simopts - > im_format ;
2011-11-21 23:56:32 +00:00
}
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
{
2012-03-28 11:53:18 +00:00
Image * ima = ED_space_image ( sima ) ;
2009-09-30 18:18:32 +00:00
void * lock ;
2012-03-28 11:53:18 +00:00
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 ) {
2012-03-28 11:53:18 +00:00
const char * relbase = ID_BLEND_PATH ( CTX_data_main ( C ) , & ima - > id ) ;
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 ) ;
2012-03-24 06:38:07 +00:00
if ( ima - > type = = IMA_TYPE_R_RESULT ) {
2010-11-30 18:07:44 +00:00
/* enforce user setting for RGB or RGBA, but skip BW */
2012-03-28 11:53:18 +00:00
if ( simopts - > im_format . planes = = R_IMF_PLANES_RGBA ) {
ibuf - > planes = R_IMF_PLANES_RGBA ;
2010-11-30 18:07:44 +00:00
}
2012-03-28 11:53:18 +00:00
else if ( simopts - > im_format . planes = = R_IMF_PLANES_RGB ) {
ibuf - > planes = R_IMF_PLANES_RGB ;
2010-11-30 18:07:44 +00:00
}
}
2010-11-30 23:38:31 +00:00
else {
/* TODO, better solution, if a 24bit image is painted onto it may contain alpha */
2012-03-24 06:38:07 +00:00
if ( ibuf - > userflags & IB_BITMAPDIRTY ) { /* it has been painted onto */
2010-11-30 23:38:31 +00:00
/* checks each pixel, not ideal */
2012-03-28 11:53:18 +00:00
ibuf - > planes = BKE_alphatest_ibuf ( ibuf ) ? 32 : 24 ;
2010-11-30 23:38:31 +00:00
}
}
2010-11-16 13:08:24 +00:00
2012-03-28 11:53:18 +00:00
if ( simopts - > im_format . imtype = = R_IMF_IMTYPE_MULTILAYER ) {
Scene * scene = CTX_data_scene ( C ) ;
RenderResult * rr = BKE_image_acquire_renderresult ( scene , ima ) ;
2012-03-24 06:38:07 +00:00
if ( rr ) {
2011-11-21 23:56:32 +00:00
RE_WriteRenderResult ( op - > reports , rr , simopts - > filepath , simopts - > im_format . quality ) ;
2012-03-28 11:53:18 +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-11-21 20:19:58 +00:00
else {
2011-11-24 06:30:37 +00:00
if ( BKE_write_ibuf_as ( ibuf , simopts - > filepath , & simopts - > im_format , save_copy ) ) {
2012-03-28 11:53:18 +00:00
ok = TRUE ;
2011-11-21 20:19:58 +00:00
}
2010-11-16 13:08:24 +00:00
}
2010-03-09 16:57:24 +00:00
2012-03-28 11:53:18 +00:00
if ( ok ) {
2012-03-24 06:38:07 +00:00
if ( ! save_copy ) {
if ( do_newpath ) {
2011-08-24 00:44:58 +00:00
BLI_strncpy ( ibuf - > name , simopts - > filepath , sizeof ( ibuf - > name ) ) ;
2011-10-28 04:05:52 +00:00
BLI_strncpy ( ima - > name , simopts - > filepath , sizeof ( ima - > name ) ) ;
2010-09-06 13:28:57 +00:00
}
2010-04-21 19:14:20 +00:00
ibuf - > userflags & = ~ IB_BITMAPDIRTY ;
/* change type? */
2012-03-28 11:53:18 +00:00
if ( ima - > type = = IMA_TYPE_R_RESULT ) {
ima - > type = IMA_TYPE_IMAGE ;
2010-04-21 19:14:20 +00:00
/* workaround to ensure the render result buffer is no longer used
* by this image , otherwise can crash when a new render result is
* created . */
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect & & ! ( ibuf - > mall & IB_rect ) )
2010-04-21 19:14:20 +00:00
imb_freerectImBuf ( ibuf ) ;
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect_float & & ! ( ibuf - > mall & IB_rectfloat ) )
2010-04-21 19:14:20 +00:00
imb_freerectfloatImBuf ( ibuf ) ;
2012-03-24 06:38:07 +00:00
if ( ibuf - > zbuf & & ! ( ibuf - > mall & IB_zbuf ) )
2010-04-21 19:14:20 +00:00
IMB_freezbufImBuf ( ibuf ) ;
2012-03-24 06:38:07 +00:00
if ( ibuf - > zbuf_float & & ! ( ibuf - > mall & IB_zbuffloat ) )
2010-04-21 19:14:20 +00:00
IMB_freezbuffloatImBuf ( ibuf ) ;
}
2012-03-28 11:53:18 +00:00
if ( ELEM ( ima - > source , IMA_SRC_GENERATED , IMA_SRC_VIEWER ) ) {
ima - > source = IMA_SRC_FILE ;
ima - > type = IMA_TYPE_IMAGE ;
2010-04-21 19:14:20 +00:00
}
2011-10-28 04:05:52 +00:00
/* only image path, never ibuf */
2012-03-24 06:38:07 +00:00
if ( relative ) {
2011-10-28 04:05:52 +00:00
BLI_path_rel ( ima - > name , relbase ) ; /* only after saving */
}
2010-04-21 19:14:20 +00:00
}
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
2012-03-28 11:53:18 +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
}
2011-11-21 23:56:32 +00:00
static void image_save_as_free ( wmOperator * op )
{
if ( op - > customdata ) {
MEM_freeN ( op - > customdata ) ;
2012-03-28 11:53:18 +00:00
op - > customdata = NULL ;
2011-11-21 23:56:32 +00:00
}
}
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +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-11-21 23:56:32 +00:00
save_image_options_defaults ( & simopts ) ;
2012-03-09 00:41:09 +00:00
/* just in case to initialize values,
2011-08-24 00:44:58 +00:00
* these should be set on invoke or by the caller . */
2011-11-21 23:56:32 +00:00
save_image_options_init ( & simopts , sima , CTX_data_scene ( C ) , 0 ) ;
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
2011-11-21 23:56:32 +00:00
image_save_as_free ( op ) ;
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
2011-10-28 03:02:09 +00:00
static int image_save_as_check ( bContext * UNUSED ( C ) , wmOperator * op )
2010-09-17 09:27:31 +00:00
{
2012-03-28 11:53:18 +00:00
ImageFormatData * imf = op - > customdata ;
2010-09-17 09:27:31 +00:00
char filepath [ FILE_MAX ] ;
RNA_string_get ( op - > ptr , " filepath " , filepath ) ;
2012-03-24 06:38:07 +00:00
if ( BKE_add_image_extension ( filepath , imf - > imtype ) ) {
2010-09-17 09:27:31 +00:00
RNA_string_set ( op - > ptr , " filepath " , filepath ) ;
return TRUE ;
}
return FALSE ;
}
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2009-02-10 23:17:58 +00:00
Image * ima = ED_space_image ( sima ) ;
2012-03-28 11:53:18 +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
2012-03-24 06:38:07 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " filepath " ) )
2011-10-28 03:02:09 +00:00
return image_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 */
2012-03-24 06:38:07 +00:00
if ( ELEM ( ima - > type , IMA_TYPE_R_RESULT , IMA_TYPE_COMPOSITE ) & & ! RNA_struct_property_is_set ( op - > ptr , " copy " ) ) {
2011-08-24 00:44:58 +00:00
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
2012-03-28 11:53:18 +00:00
op - > customdata = MEM_mallocN ( sizeof ( simopts . im_format ) , __func__ ) ;
2011-11-21 23:56:32 +00:00
memcpy ( op - > customdata , & simopts . im_format , sizeof ( simopts . im_format ) ) ;
2011-08-24 00:44:58 +00:00
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
}
2011-11-21 23:56:32 +00:00
static int image_save_as_cancel ( bContext * UNUSED ( C ) , wmOperator * op )
2011-11-21 20:19:58 +00:00
{
2011-11-21 23:56:32 +00:00
image_save_as_free ( op ) ;
return OPERATOR_CANCELLED ;
}
static int image_save_as_draw_check_prop ( PointerRNA * ptr , PropertyRNA * prop )
{
2012-03-28 11:53:18 +00:00
const char * prop_id = RNA_property_identifier ( prop ) ;
2011-11-21 23:56:32 +00:00
return ! ( strcmp ( prop_id , " filepath " ) = = 0 | |
strcmp ( prop_id , " directory " ) = = 0 | |
strcmp ( prop_id , " filename " ) = = 0 | |
/* when saving a copy, relative path has no effect */
( ( strcmp ( prop_id , " relative_path " ) = = 0 ) & & RNA_boolean_get ( ptr , " copy " ) )
) ;
}
static void image_save_as_draw ( bContext * UNUSED ( C ) , wmOperator * op )
{
2012-03-28 11:53:18 +00:00
uiLayout * layout = op - > layout ;
ImageFormatData * imf = op - > customdata ;
2011-11-21 20:19:58 +00:00
PointerRNA ptr ;
/* image template */
RNA_pointer_create ( NULL , & RNA_ImageFormatSettings , imf , & ptr ) ;
uiTemplateImageSettings ( layout , & ptr ) ;
/* main draw call */
2011-11-21 23:56:32 +00:00
RNA_pointer_create ( NULL , op - > type - > srna , op - > properties , & ptr ) ;
uiDefAutoButsRNA ( layout , & ptr , image_save_as_draw_check_prop , ' \0 ' ) ;
2011-11-21 20:19:58 +00:00
}
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-11-21 23:56:32 +00:00
// PropertyRNA *prop;
2011-08-24 00:44:58 +00:00
2009-02-10 23:17:58 +00:00
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Save As Image " ;
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 */
2012-03-22 07:26:09 +00:00
ot - > exec = image_save_as_exec ;
ot - > check = image_save_as_check ;
ot - > invoke = image_save_as_invoke ;
ot - > cancel = image_save_as_cancel ;
ot - > ui = image_save_as_draw ;
ot - > poll = space_image_buffer_exists_poll ;
2009-02-10 23:17:58 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2009-02-10 23:17:58 +00:00
/* properties */
2011-11-21 23:56:32 +00:00
RNA_def_boolean ( ot - > srna , " copy " , 0 , " Copy " , " Create a new image file without modifying the current image in blender " ) ;
2011-08-24 00:44:58 +00:00
2012-03-28 11:53:18 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE | MOVIEFILE , FILE_SPECIAL , FILE_SAVE , WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH , FILE_DEFAULTDISPLAY ) ;
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 ********************/
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
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-11-21 23:56:32 +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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Save Image " ;
ot - > idname = " IMAGE_OT_save " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_save_exec ;
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 */
2012-03-28 11:53:18 +00:00
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 ********************/
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +00:00
Main * bmain = CTX_data_main ( 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
ImBuf * ibuf ;
2012-03-28 11:53:18 +00:00
int tot = 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
char di [ FILE_MAX ] , fi [ FILE_MAX ] ;
2012-03-28 11:53:18 +00:00
if ( sima - > image = = NULL )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2012-03-28 11:53:18 +00:00
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 ;
}
2012-03-28 11:53: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 */
2012-03-28 11:53:18 +00:00
for ( ibuf = sima - > image - > ibufs . first ; ibuf ; ibuf = ibuf - > next )
2012-03-24 06:38:07 +00:00
if ( 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
tot + + ;
2012-03-28 11:53:18 +00:00
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 */
2012-03-28 11:53:18 +00:00
for ( ibuf = sima - > image - > ibufs . first ; ibuf ; ibuf = ibuf - > next )
2012-03-24 06:38:07 +00:00
if ( 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
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
2012-03-28 11:53:18 +00:00
for ( ibuf = sima - > image - > ibufs . first ; ibuf ; ibuf = ibuf - > next ) {
2012-03-24 06:38:07 +00:00
if ( ibuf - > userflags & IB_BITMAPDIRTY ) {
2009-02-11 19:16:14 +00:00
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
2012-03-24 06:38:07 +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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Save Sequence " ;
ot - > idname = " IMAGE_OT_save_sequence " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_save_sequence_exec ;
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 */
2012-03-28 11:53:18 +00:00
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 ********************/
2011-10-28 03:02:09 +00:00
static int image_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
{
2012-03-28 11:53:18 +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
2012-03-24 06:38:07 +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?
2012-03-28 11:53:18 +00:00
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
2012-03-28 11:53:18 +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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Reload Image " ;
ot - > idname = " IMAGE_OT_reload " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_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 */
2012-03-22 07:26:09 +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 ;
2012-03-28 11:53:18 +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 */
2012-03-28 11:53:18 +00:00
sima = CTX_wm_space_image ( C ) ;
scene = CTX_data_scene ( C ) ;
obedit = CTX_data_edit_object ( C ) ;
2009-02-10 23:17:58 +00:00
RNA_string_get ( op - > ptr , " name " , name ) ;
2012-03-28 11:53:18 +00:00
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 " ) ;
2009-02-10 23:17:58 +00:00
RNA_float_get_array ( op - > ptr , " color " , color ) ;
2012-03-28 11:53:18 +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
2012-03-24 06:38:07 +00:00
if ( ! alpha )
2012-03-28 11:53:18 +00:00
color [ 3 ] = 1.0f ;
2010-06-29 22:07:27 +00:00
ima = BKE_add_image_size ( width , height , name , alpha ? 32 : 24 , floatbuf , uvtestgrid , color ) ;
2009-09-16 19:27:08 +00:00
2012-03-24 06:38:07 +00:00
if ( ! ima )
2009-10-01 23:32:57 +00:00
return OPERATOR_CANCELLED ;
/* hook into UI */
uiIDContextProperty ( C , & ptr , & prop ) ;
2012-03-24 06:38:07 +00:00
if ( prop ) {
2009-10-01 23:32:57 +00:00
/* 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
}
2012-03-24 06:38:07 +00:00
else if ( sima )
2011-11-10 13:39:25 +00:00
ED_space_image_set ( sima , scene , obedit , ima ) ;
2009-10-01 23:32:57 +00:00
// XXX other users?
2012-03-28 11:53:18 +00:00
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 ;
2012-03-28 11:53:18 +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 */
2012-03-22 07:26:09 +00:00
ot - > name = " New Image " ;
ot - > description = " Create a new image " ;
ot - > idname = " IMAGE_OT_new " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +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 */
2012-03-22 07:26:09 +00:00
ot - > flag = OPTYPE_UNDO ;
2009-02-10 23:17:58 +00:00
/* properties */
2012-03-28 11:53:18 +00:00
RNA_def_string ( ot - > srna , " name " , " untitled " , MAX_ID_NAME - 2 , " Name " , " Image datablock name " ) ;
2011-09-19 12:26:20 +00:00
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 ) ;
2012-03-28 11:53:18 +00:00
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 )
{
2012-03-28 11:53:18 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
ImBuf * ibuf = BKE_image_get_ibuf ( ima , NULL ) ;
2011-02-25 11:00:38 +00:00
2012-03-28 11:53:18 +00:00
if ( ibuf ! = NULL )
2011-02-25 11:00:38 +00:00
return 1 ;
return 0 ;
}
static int image_invert_exec ( bContext * C , wmOperator * op )
{
2012-03-28 11:53:18 +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
2012-03-28 11:53:18 +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 " ) ;
2011-02-28 03:17:20 +00:00
int i ;
2012-03-28 11:53:18 +00:00
if ( ibuf = = NULL ) // TODO: this should actually never happen, but does for render-results -> cleanup
2011-02-25 11:00:38 +00:00
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 ;
2012-03-28 11:53:18 +00:00
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-23 12:02:43 +00:00
}
2011-02-28 03:17:20 +00:00
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect ) {
2011-02-28 03:17:20 +00:00
IMB_rect_from_float ( ibuf ) ;
}
2011-02-23 12:02:43 +00:00
}
2012-03-24 06:38:07 +00:00
else if ( ibuf - > rect ) {
2011-02-23 12:02:43 +00:00
char * cp = ( char * ) ibuf - > rect ;
2012-03-28 11:53:18 +00:00
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-23 12:02:43 +00:00
}
}
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 ;
2012-03-24 06:38:07 +00:00
if ( ibuf - > mipmap [ 0 ] )
2011-05-08 20:21:31 +00:00
ibuf - > userflags | = IB_MIPMAP_INVALID ;
2012-03-28 11:53:18 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2011-02-23 12:02:43 +00:00
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Invert Channels " ;
ot - > idname = " IMAGE_OT_invert " ;
2011-02-23 12:02:43 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_invert_exec ;
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 */
2012-03-28 11:53:18 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-02-23 12:02:43 +00:00
}
2009-02-10 23:17:58 +00:00
/********************* pack operator *********************/
2011-10-28 03:02:09 +00:00
static int image_pack_test ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
int as_png = RNA_boolean_get ( op - > ptr , " as_png " ) ;
2009-02-10 23:17:58 +00:00
2012-03-24 06:38:07 +00:00
if ( ! ima )
2009-02-11 19:16:14 +00:00
return 0 ;
2012-03-24 06:38:07 +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
2012-03-28 11:53:18 +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 ;
}
2011-10-28 03:02:09 +00:00
static int image_pack_exec ( bContext * C , wmOperator * op )
2009-02-11 19:16:14 +00:00
{
2012-03-28 11:53:18 +00:00
struct Main * bmain = CTX_data_main ( C ) ;
Image * ima = CTX_data_edit_image ( C ) ;
ImBuf * ibuf = BKE_image_get_ibuf ( ima , NULL ) ;
int as_png = RNA_boolean_get ( op - > ptr , " as_png " ) ;
2009-02-11 19:16:14 +00:00
2012-03-24 06:38:07 +00:00
if ( ! image_pack_test ( C , op ) )
2009-02-11 19:16:14 +00:00
return OPERATOR_CANCELLED ;
2012-03-24 06:38:07 +00:00
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
2012-03-24 06:38:07 +00:00
if ( as_png )
2009-02-11 19:16:14 +00:00
BKE_image_memorypack ( ima ) ;
else
2012-03-28 11:53:18 +00:00
ima - > packedfile = newPackedFile ( op - > reports , ima - > name , ID_BLEND_PATH ( bmain , & ima - > id ) ) ;
2009-02-11 19:16:14 +00:00
2012-03-28 11:53:18 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , ima ) ;
2010-06-17 07:20:12 +00:00
2009-02-11 19:16:14 +00:00
return OPERATOR_FINISHED ;
}
2011-10-28 03:02:09 +00:00
static int image_pack_invoke ( bContext * C , wmOperator * op , wmEvent * UNUSED ( event ) )
2009-02-11 19:16:14 +00:00
{
2012-03-28 11:53:18 +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 ;
2012-03-28 11:53:18 +00:00
int as_png = RNA_boolean_get ( op - > ptr , " as_png " ) ;
2009-02-11 19:16:14 +00:00
2012-03-24 06:38:07 +00:00
if ( ! image_pack_test ( C , op ) )
2009-02-11 19:16:14 +00:00
return OPERATOR_CANCELLED ;
2012-03-24 06:38:07 +00:00
if ( ! as_png & & ( ibuf & & ( ibuf - > userflags & IB_BITMAPDIRTY ) ) ) {
2012-03-28 11:53:18 +00:00
pup = uiPupMenuBegin ( C , " OK " , ICON_QUESTION ) ;
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
}
2011-10-28 03:02:09 +00:00
return image_pack_exec ( C , op ) ;
2009-02-10 23:17:58 +00:00
}
void IMAGE_OT_pack ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Pack Image " ;
ot - > description = " Pack an image as embedded data into the .blend file " ;
ot - > idname = " IMAGE_OT_pack " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_pack_exec ;
ot - > invoke = image_pack_invoke ;
2009-02-10 23:17:58 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2009-02-10 23:17:58 +00:00
/* 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
{
2012-03-28 11:53:18 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
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 */
2012-01-11 16:32:12 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " id " ) ) {
2012-03-28 11:53:18 +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 ) ;
}
2012-03-24 06:38:07 +00:00
if ( ! ima | | ! ima - > packedfile )
2009-06-30 19:20:45 +00:00
return OPERATOR_CANCELLED ;
2012-03-28 11:53:18 +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 , " 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
}
2012-03-24 06:38:07 +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
2012-03-28 11:53:18 +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
{
2012-03-28 11:53:18 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
2009-06-30 19:20:45 +00:00
2012-03-24 06:38:07 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " id " ) )
2011-01-26 14:18:16 +00:00
return image_unpack_exec ( C , op ) ;
2010-06-17 07:20:12 +00:00
2012-03-24 06:38:07 +00:00
if ( ! ima | | ! ima - > packedfile )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2012-03-28 11:53:18 +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 , " Unpacking movies or image sequences not supported " ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
}
2012-03-24 06:38:07 +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-01-26 14:18:16 +00:00
2012-03-28 11:53:18 +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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Unpack Image " ;
ot - > description = " Save an image packed in the .blend file to disk " ;
ot - > idname = " IMAGE_OT_unpack " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_unpack_exec ;
ot - > invoke = image_unpack_invoke ;
2009-02-10 23:17:58 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
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 " ) ;
2012-03-28 11:53:18 +00:00
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
2012-01-20 14:33:03 +00:00
unsigned char col [ 4 ] ;
2009-02-10 23:17:58 +00:00
float colf [ 4 ] ;
int z ;
float zf ;
2012-01-20 14:33:03 +00:00
unsigned char * colp ;
2009-02-10 23:17:58 +00:00
float * colfp ;
int * zp ;
float * zfp ;
int draw ;
} ImageSampleInfo ;
2011-10-28 03:02:09 +00:00
static void image_sample_draw ( const bContext * UNUSED ( C ) , ARegion * ar , void * arg_info )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
ImageSampleInfo * info = arg_info ;
2012-03-24 06:38:07 +00:00
if ( info - > draw ) {
2011-04-23 08:30:28 +00:00
/* no color management needed for images (color_manage=0) */
2012-01-12 05:46:45 +00:00
ED_image_draw_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
}
2011-10-28 03:02:09 +00:00
static void image_sample_apply ( bContext * C , wmOperator * op , wmEvent * event )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2009-09-30 18:18:32 +00:00
void * lock ;
2012-03-28 11:53:18 +00:00
ImBuf * ibuf = ED_space_image_acquire_buffer ( sima , & lock ) ;
ImageSampleInfo * info = op - > customdata ;
2009-02-10 23:17:58 +00:00
float fx , fy ;
2012-03-24 06:38:07 +00:00
if ( ibuf = = NULL ) {
2009-09-30 18:18:32 +00:00
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
2012-03-28 11:53:18 +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 ;
2012-01-20 14:33:03 +00:00
unsigned char * cp ;
2012-03-28 11:53:18 +00:00
int x = ( int ) ( fx * ibuf - > x ) , y = ( int ) ( fy * ibuf - > y ) ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
CLAMP ( x , 0 , ibuf - > x - 1 ) ;
CLAMP ( y , 0 , ibuf - > y - 1 ) ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
info - > x = x ;
info - > y = y ;
info - > draw = 1 ;
info - > channels = ibuf - > channels ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
info - > colp = NULL ;
info - > colfp = NULL ;
info - > zp = NULL ;
info - > zfp = NULL ;
2009-02-10 23:17:58 +00:00
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect ) {
2012-03-28 11:53:18 +00:00
cp = ( unsigned 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 ;
2009-02-10 23:17:58 +00:00
}
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect_float ) {
2012-03-28 11:53:18 +00:00
fp = ( ibuf - > rect_float + ( ibuf - > channels ) * ( y * ibuf - > x + x ) ) ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
info - > colf [ 0 ] = fp [ 0 ] ;
info - > colf [ 1 ] = fp [ 1 ] ;
info - > colf [ 2 ] = fp [ 2 ] ;
info - > colf [ 3 ] = fp [ 3 ] ;
info - > colfp = info - > colf ;
2009-02-10 23:17:58 +00:00
}
2012-03-24 06:38:07 +00:00
if ( ibuf - > zbuf ) {
2012-03-28 11:53:18 +00:00
info - > z = ibuf - > zbuf [ y * ibuf - > x + x ] ;
info - > zp = & info - > z ;
2009-02-10 23:17:58 +00:00
}
2012-03-24 06:38:07 +00:00
if ( ibuf - > zbuf_float ) {
2012-03-28 11:53:18 +00:00
info - > zf = ibuf - > zbuf_float [ y * ibuf - > x + x ] ;
info - > zfp = & info - > zf ;
2009-02-10 23:17:58 +00:00
}
2012-03-28 11:53:18 +00:00
if ( sima - > cumap & & ibuf - > channels = = 4 ) {
2009-02-11 19:16:14 +00:00
/* we reuse this callback for set curves point operators */
2012-03-24 06:38:07 +00:00
if ( RNA_struct_find_property ( op - > ptr , " point " ) ) {
2012-03-28 11:53:18 +00:00
int point = RNA_enum_get ( op - > ptr , " point " ) ;
2009-02-11 19:16:14 +00:00
2012-03-24 06:38:07 +00:00
if ( point = = 1 ) {
2009-02-11 19:16:14 +00:00
curvemapping_set_black_white ( sima - > cumap , NULL , info - > colfp ) ;
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect_float )
2010-10-02 19:31:58 +00:00
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
}
2012-03-24 06:38:07 +00:00
else if ( point = = 0 ) {
2009-02-11 19:16:14 +00:00
curvemapping_set_black_white ( sima - > cumap , info - > colfp , NULL ) ;
2012-03-24 06:38:07 +00:00
if ( ibuf - > rect_float )
2010-10-02 19:31:58 +00:00
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
{
2012-03-28 11:53:18 +00:00
ScrArea * sa , * cur = curarea ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
node_curvemap_sample ( fp ) ; /* sends global to node editor */
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
if ( sa - > spacetype = = SPACE_NODE ) {
2009-02-10 23:17:58 +00:00
areawinset ( sa - > win ) ;
scrarea_do_windraw ( sa ) ;
}
}
2012-03-28 11:53:18 +00:00
node_curvemap_sample ( NULL ) ; /* clears global in node editor */
curarea = cur ;
2009-02-10 23:17:58 +00:00
}
# endif
}
else
2012-03-28 11:53:18 +00:00
info - > draw = 0 ;
2009-02-10 23:17:58 +00:00
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 ) ) ;
}
2011-10-28 03:02:09 +00:00
static void image_sample_exit ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
ImageSampleInfo * info = op - > customdata ;
2009-02-10 23:17:58 +00:00
ED_region_draw_cb_exit ( info - > art , info - > draw_handle ) ;
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
MEM_freeN ( info ) ;
}
2011-10-28 03:02:09 +00:00
static int image_sample_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2009-02-10 23:17:58 +00:00
ImageSampleInfo * info ;
2012-03-24 06:38:07 +00:00
if ( ! ED_space_image_has_buffer ( sima ) )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2012-03-28 11:53:18 +00:00
info = MEM_callocN ( sizeof ( ImageSampleInfo ) , " ImageSampleInfo " ) ;
info - > art = ar - > type ;
2011-10-28 03:02:09 +00:00
info - > draw_handle = ED_region_draw_cb_activate ( ar - > type , image_sample_draw , info , REGION_DRAW_POST_PIXEL ) ;
2012-03-28 11:53:18 +00:00
op - > customdata = info ;
2009-02-10 23:17:58 +00:00
2011-10-28 03:02:09 +00:00
image_sample_apply ( C , op , event ) ;
2009-02-10 23:17:58 +00:00
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 ;
}
2011-10-28 03:02:09 +00:00
static int image_sample_modal ( bContext * C , wmOperator * op , wmEvent * event )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
switch ( event - > type ) {
2009-02-10 23:17:58 +00:00
case LEFTMOUSE :
case RIGHTMOUSE : // XXX hardcoded
2011-10-28 03:02:09 +00:00
image_sample_exit ( C , op ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
case MOUSEMOVE :
2011-10-28 03:02:09 +00:00
image_sample_apply ( C , op , event ) ;
2009-02-10 23:17:58 +00:00
break ;
}
return OPERATOR_RUNNING_MODAL ;
}
2011-10-28 03:02:09 +00:00
static int image_sample_cancel ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2011-10-28 03:02:09 +00:00
image_sample_exit ( C , op ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
}
void IMAGE_OT_sample ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Sample Color " ;
ot - > idname = " IMAGE_OT_sample " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = image_sample_invoke ;
ot - > modal = image_sample_modal ;
ot - > cancel = image_sample_cancel ;
ot - > poll = space_image_image_sample_poll ;
2009-07-11 14:51:13 +00:00
/* flags */
2012-03-22 07:26:09 +00:00
ot - > flag = OPTYPE_BLOCKING ;
2009-02-10 23:17:58 +00:00
}
2010-03-23 01:22:33 +00:00
/******************** sample line operator ********************/
2011-10-28 03:02:09 +00:00
static int image_sample_line_exec ( bContext * C , wmOperator * op )
2010-03-23 01:22:33 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
Scene * scene = CTX_data_scene ( C ) ;
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-04-04 00:21:37 +00:00
2010-03-23 01:22:33 +00:00
void * lock ;
2012-03-28 11:53:18 +00:00
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 ) ;
2012-03-28 11:53:18 +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 ;
2010-03-23 01:22:33 +00:00
hist - > channels = 3 ;
hist - > x_resolution = 256 ;
hist - > xmax = 1.0f ;
hist - > ymax = 1.0f ;
2012-03-28 11:53:18 +00:00
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 ) ;
2010-03-23 01:22:33 +00:00
2012-03-28 11:53:18 +00:00
if ( x < 0 | | y < 0 | | x > = ibuf - > x | | y > = ibuf - > y ) {
hist - > data_luma [ i ] = hist - > data_r [ i ] = hist - > data_g [ i ] = hist - > data_b [ i ] = 0.0f ;
2012-03-24 06:38:07 +00:00
}
else {
2010-03-23 01:22:33 +00:00
if ( ibuf - > rect_float ) {
2012-03-28 11:53:18 +00:00
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 ] ;
2012-01-14 17:14:23 +00:00
hist - > data_luma [ i ] = rgb_to_luma ( rgb ) ;
2010-03-23 01:22:33 +00:00
}
else if ( ibuf - > rect ) {
2012-03-28 11:53:18 +00:00
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 ;
hist - > data_luma [ i ] = ( float ) rgb_to_luma_byte ( cp ) / 255.0f ;
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
}
2011-10-28 03:02:09 +00:00
static int image_sample_line_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2010-03-23 01:22:33 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
2010-04-04 00:21:37 +00:00
2012-03-24 06:38:07 +00:00
if ( ! ED_space_image_has_buffer ( sima ) )
2010-03-23 01:22:33 +00:00
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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Sample Line " ;
ot - > idname = " IMAGE_OT_sample_line " ;
2010-03-23 01:22:33 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = image_sample_line_invoke ;
ot - > modal = WM_gesture_straightline_modal ;
ot - > exec = image_sample_line_exec ;
ot - > poll = space_image_main_area_poll ;
ot - > cancel = WM_gesture_straightline_cancel ;
2010-04-04 00:21:37 +00:00
2010-03-23 01:22:33 +00:00
/* flags */
2012-03-22 07:26:09 +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
{
2012-03-28 11:53:18 +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 " , " " } ,
2012-03-28 11:53:18 +00:00
{ 0 , NULL , 0 , NULL , NULL }
} ;
2009-02-11 19:16:14 +00:00
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Curves Point " ;
ot - > idname = " IMAGE_OT_curves_point_set " ;
2009-02-11 19:16:14 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2009-02-11 19:16:14 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = image_sample_invoke ;
ot - > modal = image_sample_modal ;
ot - > cancel = image_sample_cancel ;
ot - > poll = space_image_main_area_not_uv_brush_poll ;
2009-02-11 19:16:14 +00:00
/* 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-10-28 03:02:09 +00:00
static int image_record_composite_apply ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
RecordCompositeData * rcd = op - > customdata ;
Scene * scene = CTX_data_scene ( C ) ;
2009-02-10 23:17:58 +00:00
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 ) ;
2012-03-28 11:53:18 +00:00
ntreeCompositExecTree ( scene - > nodetree , & scene - > r , scene - > r . cfra ! = rcd - > old_cfra ) ; /* 1 is no previews */
2009-02-10 23:17:58 +00:00
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
2012-03-28 11:53:18 +00:00
ibuf = BKE_image_get_ibuf ( sima - > image , & sima - > iuser ) ;
2009-02-10 23:17:58 +00:00
/* save memory in flipbooks */
2012-03-24 06:38:07 +00:00
if ( ibuf )
2009-02-10 23:17:58 +00:00
imb_freerectfloatImBuf ( ibuf ) ;
scene - > r . cfra + + ;
return ( scene - > r . cfra < = rcd - > efra ) ;
}
2011-10-28 03:02:09 +00:00
static int image_record_composite_init ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
SpaceImage * sima = CTX_wm_space_image ( C ) ;
Scene * scene = CTX_data_scene ( C ) ;
2009-02-10 23:17:58 +00:00
RecordCompositeData * rcd ;
2012-03-24 06:38:07 +00:00
if ( sima - > iuser . frames < 2 )
2009-02-10 23:17:58 +00:00
return 0 ;
2012-03-24 06:38:07 +00:00
if ( scene - > nodetree = = NULL )
2009-02-10 23:17:58 +00:00
return 0 ;
2012-03-28 11:53:18 +00:00
op - > customdata = rcd = MEM_callocN ( sizeof ( RecordCompositeData ) , " ImageRecordCompositeData " ) ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
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 ;
2009-02-10 23:17:58 +00:00
return 1 ;
}
2011-10-28 03:02:09 +00:00
static void image_record_composite_exit ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
Scene * scene = CTX_data_scene ( C ) ;
SpaceImage * sima = CTX_wm_space_image ( C ) ;
RecordCompositeData * rcd = op - > customdata ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
scene - > r . cfra = rcd - > old_cfra ;
2009-02-10 23:17:58 +00:00
2009-02-11 19:16:14 +00:00
WM_cursor_restore ( CTX_wm_window ( C ) ) ;
2009-02-10 23:17:58 +00:00
2012-03-24 06:38:07 +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
2012-03-28 11:53:18 +00:00
WM_event_add_notifier ( C , NC_IMAGE | NA_EDITED , sima - > image ) ;
2009-02-11 19:16:14 +00:00
2009-02-10 23:17:58 +00:00
// XXX play_anim(0);
// XXX allqueue(REDRAWNODE, 1);
MEM_freeN ( rcd ) ;
}
2011-10-28 03:02:09 +00:00
static int image_record_composite_exec ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2012-03-24 06:38:07 +00:00
if ( ! image_record_composite_init ( C , op ) )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2012-03-24 07:52:14 +00:00
while ( image_record_composite_apply ( C , op ) )
2009-02-10 23:17:58 +00:00
;
2011-10-28 03:02:09 +00:00
image_record_composite_exit ( C , op ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
}
2011-10-28 03:02:09 +00:00
static int image_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
2012-03-24 06:38:07 +00:00
if ( ! image_record_composite_init ( C , op ) )
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
2012-03-28 11:53:18 +00:00
rcd = op - > customdata ;
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
2012-03-24 06:38:07 +00:00
if ( ! image_record_composite_apply ( C , op ) )
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
return OPERATOR_RUNNING_MODAL ;
}
2011-10-28 03:02:09 +00:00
static int image_record_composite_modal ( bContext * C , wmOperator * op , wmEvent * event )
2009-02-10 23:17:58 +00:00
{
2012-03-28 11:53:18 +00:00
RecordCompositeData * rcd = op - > customdata ;
2009-02-10 23:17:58 +00:00
2012-03-28 11:53:18 +00:00
switch ( event - > type ) {
2009-02-10 23:17:58 +00:00
case TIMER :
2012-03-24 06:38:07 +00:00
if ( rcd - > timer = = event - > customdata ) {
if ( ! image_record_composite_apply ( C , op ) ) {
2011-10-28 03:02:09 +00:00
image_record_composite_exit ( C , op ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_FINISHED ;
}
}
break ;
case ESCKEY :
2011-10-28 03:02:09 +00:00
image_record_composite_exit ( C , op ) ;
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
return OPERATOR_RUNNING_MODAL ;
}
2011-10-28 03:02:09 +00:00
static int image_record_composite_cancel ( bContext * C , wmOperator * op )
2009-02-10 23:17:58 +00:00
{
2011-10-28 03:02:09 +00:00
image_record_composite_exit ( C , op ) ;
2009-02-10 23:17:58 +00:00
return OPERATOR_CANCELLED ;
}
void IMAGE_OT_record_composite ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Record Composite " ;
ot - > idname = " IMAGE_OT_record_composite " ;
2009-02-10 23:17:58 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_record_composite_exec ;
ot - > invoke = image_record_composite_invoke ;
ot - > modal = image_record_composite_modal ;
ot - > cancel = image_record_composite_cancel ;
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 *********************/
2011-10-28 03:02:09 +00:00
static int image_cycle_render_slot_poll ( bContext * C )
2010-02-09 19:37:37 +00:00
{
2012-03-28 11:53:18 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
2010-02-09 19:37:37 +00:00
return ( ima & & ima - > type = = IMA_TYPE_R_RESULT ) ;
}
2011-10-28 03:02:09 +00:00
static int image_cycle_render_slot_exec ( bContext * C , wmOperator * op )
2010-02-09 19:37:37 +00:00
{
2012-03-28 11:53:18 +00:00
Image * ima = CTX_data_edit_image ( C ) ;
int a , slot , cur = ima - > render_slot ;
const short use_reverse = RNA_boolean_get ( op - > ptr , " reverse " ) ;
2010-02-09 19:37:37 +00:00
2012-03-28 11:53:18 +00:00
for ( a = 1 ; a < IMA_MAX_RENDER_SLOT ; a + + ) {
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
2012-03-24 06:38:07 +00:00
if ( ima - > renders [ slot ] | | slot = = ima - > last_render_slot ) {
2012-03-28 11:53:18 +00:00
ima - > render_slot = slot ;
2010-02-09 19:37:37 +00:00
break ;
}
}
2012-03-24 06:38:07 +00:00
if ( a = = IMA_MAX_RENDER_SLOT )
2012-03-28 11:53:18 +00:00
ima - > render_slot = ( ( cur = = 1 ) ? 0 : 1 ) ;
2010-03-27 15:35:34 +00:00
2012-03-28 11:53:18 +00:00
WM_event_add_notifier ( C , NC_IMAGE | ND_DRAW , NULL ) ;
2010-02-09 19:37:37 +00:00
2011-03-10 17:34:27 +00:00
/* no undo push for browsing existing */
2012-03-28 11:53:18 +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 */
2012-03-22 07:26:09 +00:00
ot - > name = " Cycle Render Slot " ;
ot - > idname = " IMAGE_OT_cycle_render_slot " ;
2010-02-09 19:37:37 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = image_cycle_render_slot_exec ;
ot - > poll = image_cycle_render_slot_poll ;
2010-02-09 19:37:37 +00:00
2011-03-10 17:34:27 +00:00
/* flags */
2012-03-28 11:53:18 +00:00
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 */
2012-03-28 11:53:18 +00:00
for ( tex = mainp - > tex . first ; tex ; tex = tex - > id . next ) {
if ( tex - > type = = TEX_IMAGE & & tex - > ima ) {
2012-03-24 06:38:07 +00:00
if ( ELEM ( tex - > ima - > source , IMA_SRC_MOVIE , IMA_SRC_SEQUENCE ) ) {
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 */
2012-03-28 11:53:18 +00:00
for ( wm = mainp - > wm . first ; wm ; wm = wm - > id . next ) { /* only 1 wm */
for ( win = wm - > windows . first ; win ; win = win - > next ) {
2010-07-23 14:34:43 +00:00
ScrArea * sa ;
2012-03-28 11:53:18 +00:00
for ( sa = win - > screen - > areabase . first ; sa ; sa = sa - > next ) {
if ( sa - > spacetype = = SPACE_VIEW3D ) {
View3D * v3d = sa - > spacedata . first ;
2010-07-23 14:34:43 +00:00
BGpic * bgpic ;
2012-03-28 11:53:18 +00:00
for ( bgpic = v3d - > bgpicbase . first ; bgpic ; bgpic = bgpic - > next )
2012-03-24 06:38:07 +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
}
2012-03-28 11:53:18 +00:00
else if ( sa - > spacetype = = SPACE_IMAGE ) {
SpaceImage * sima = sa - > spacedata . first ;
2012-03-24 06:38:07 +00:00
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
}
2012-03-28 11:53:18 +00:00
else if ( sa - > spacetype = = SPACE_NODE ) {
SpaceNode * snode = sa - > spacedata . first ;
if ( ( snode - > treetype = = NTREE_COMPOSIT ) & & ( snode - > nodetree ) ) {
2010-07-23 14:34:43 +00:00
bNode * node ;
2012-03-28 11:53:18 +00:00
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 ;
2012-03-24 06:38:07 +00:00
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
}