From 8b78a8791bc539bcffe7159f9d9714d577cb3d7d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 23 May 2021 20:48:35 +0900 Subject: [PATCH] Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- chalk/Makefile.am | 12 +- chalk/chalk_part_init.cc | 23 - chalk/chalk_part_init.cpp | 23 + chalk/chalkcolor/Makefile.am | 12 +- chalk/chalkcolor/colorspaces/Makefile.am | 4 +- ...colorspace.cc => kis_alpha_colorspace.cpp} | 0 ...b_colorspace.cc => kis_lab_colorspace.cpp} | 0 ...z_colorspace.cc => kis_xyz_colorspace.cpp} | 0 ...orspace.cc => kis_abstract_colorspace.cpp} | 0 ...s.cc => kis_basic_histogram_producers.cpp} | 0 .../{kis_color.cc => kis_color.cpp} | 0 ...nversions.cc => kis_color_conversions.cpp} | 0 .../{kis_colorspace.cc => kis_colorspace.cpp} | 0 ...cc => kis_colorspace_factory_registry.cpp} | 0 ...pace_iface.cc => kis_colorspace_iface.cpp} | 0 ...s_composite_op.cc => kis_composite_op.cpp} | 0 ...ace.cc => kis_f16half_base_colorspace.cpp} | 0 ...orspace.cc => kis_f32_base_colorspace.cpp} | 0 ...producer.cc => kis_histogram_producer.cpp} | 0 chalk/chalkcolor/kis_profile.cc | 208 - chalk/chalkcolor/kis_profile.cpp | 208 + ...orspace.cc => kis_u16_base_colorspace.cpp} | 0 ...lorspace.cc => kis_u8_base_colorspace.cpp} | 0 chalk/colorspaces/cmyk_u16/Makefile.am | 4 +- chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cc | 61 - .../colorspaces/cmyk_u16/cmyk_u16_plugin.cpp | 61 + ...orspace.cc => kis_cmyk_u16_colorspace.cpp} | 0 chalk/colorspaces/cmyk_u8/Makefile.am | 2 +- chalk/colorspaces/cmyk_u8/cmyk_plugin.cc | 66 - chalk/colorspaces/cmyk_u8/cmyk_plugin.cpp | 66 + ..._colorspace.cc => kis_cmyk_colorspace.cpp} | 0 chalk/colorspaces/gray_u16/Makefile.am | 4 +- chalk/colorspaces/gray_u16/gray_u16_plugin.cc | 63 - .../colorspaces/gray_u16/gray_u16_plugin.cpp | 63 + ...orspace.cc => kis_gray_u16_colorspace.cpp} | 0 chalk/colorspaces/gray_u8/Makefile.am | 4 +- chalk/colorspaces/gray_u8/gray_plugin.cc | 77 - chalk/colorspaces/gray_u8/gray_plugin.cpp | 77 + ..._colorspace.cc => kis_gray_colorspace.cpp} | 0 chalk/colorspaces/lms_f32/Makefile.am | 4 +- ...lorspace.cc => kis_lms_f32_colorspace.cpp} | 0 chalk/colorspaces/lms_f32/lms_f32_plugin.cc | 64 - chalk/colorspaces/lms_f32/lms_f32_plugin.cpp | 64 + chalk/colorspaces/rgb_f16half/Makefile.am | 4 +- ...pace.cc => kis_rgb_f16half_colorspace.cpp} | 0 .../rgb_f16half/rgb_f16half_plugin.cc | 63 - .../rgb_f16half/rgb_f16half_plugin.cpp | 63 + .../colorspaces/rgb_f16half/tests/Makefile.am | 2 +- ... => kis_rgb_f16half_colorspace_tester.cpp} | 0 chalk/colorspaces/rgb_f32/Makefile.am | 4 +- ...lorspace.cc => kis_rgb_f32_colorspace.cpp} | 0 .../rgb_f32/kis_rgb_f32_colorspace.h | 2 +- chalk/colorspaces/rgb_f32/rgb_f32_plugin.cc | 63 - chalk/colorspaces/rgb_f32/rgb_f32_plugin.cpp | 63 + chalk/colorspaces/rgb_f32/tests/Makefile.am | 2 +- ...is_strategy_colorspace_rgb_f32_tester.cpp} | 0 chalk/colorspaces/rgb_u16/Makefile.am | 4 +- ...lorspace.cc => kis_rgb_u16_colorspace.cpp} | 0 chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc | 61 - chalk/colorspaces/rgb_u16/rgb_u16_plugin.cpp | 61 + chalk/colorspaces/rgb_u16/tests/Makefile.am | 2 +- ...is_strategy_colorspace_rgb_u16_tester.cpp} | 0 chalk/colorspaces/rgb_u8/Makefile.am | 4 +- ...b_colorspace.cc => kis_rgb_colorspace.cpp} | 0 chalk/colorspaces/rgb_u8/rgb_plugin.cc | 74 - chalk/colorspaces/rgb_u8/rgb_plugin.cpp | 74 + chalk/colorspaces/wet/Makefile.am | 4 +- chalk/colorspaces/wet/kis_texture_filter.cc | 43 - chalk/colorspaces/wet/kis_texture_filter.cpp | 43 + ...ure_painter.cc => kis_texture_painter.cpp} | 0 ...t_colorspace.cc => kis_wet_colorspace.cpp} | 0 ...e_widget.cc => kis_wet_palette_widget.cpp} | 0 .../wet/kis_wetness_visualisation_filter.cc | 77 - .../wet/kis_wetness_visualisation_filter.cpp | 77 + .../wet/{kis_wetop.cc => kis_wetop.cpp} | 0 chalk/colorspaces/wet/wet_plugin.cc | 128 - chalk/colorspaces/wet/wet_plugin.cpp | 128 + ...tphysicsfilter.cc => wetphysicsfilter.cpp} | 0 chalk/colorspaces/wetsticky/Makefile.am | 2 +- .../colorspaces/wetsticky/brushop/Makefile.am | 4 +- .../{kis_wsbrushop.cc => kis_wsbrushop.cpp} | 0 .../brushop/wsbrushpaintop_plugin.cc | 56 - .../brushop/wsbrushpaintop_plugin.cpp | 56 + ...space.cc => kis_wet_sticky_colorspace.cpp} | 0 ...ine_filter.cc => kis_ws_engine_filter.cpp} | 0 .../wetsticky/wet_sticky_plugin.cc | 60 - .../wetsticky/wet_sticky_plugin.cpp | 60 + chalk/colorspaces/ycbcr_u16/Makefile.am | 4 +- ...rspace.cc => kis_ycbcr_u16_colorspace.cpp} | 0 .../colorspaces/ycbcr_u16/ycbcr_u16_plugin.cc | 60 - .../ycbcr_u16/ycbcr_u16_plugin.cpp | 60 + chalk/colorspaces/ycbcr_u8/Makefile.am | 4 +- ...orspace.cc => kis_ycbcr_u8_colorspace.cpp} | 0 chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc | 62 - .../colorspaces/ycbcr_u8/ycbcr_u8_plugin.cpp | 62 + chalk/core/Makefile.am | 28 +- chalk/core/createdcop.py | 2 +- ...ment_layer.cc => kis_adjustment_layer.cpp} | 0 .../{kis_alpha_mask.cc => kis_alpha_mask.cpp} | 0 ...resource.cc => kis_autobrush_resource.cpp} | 0 chalk/core/kis_autogradient_resource.cc | 221 - chalk/core/kis_autogradient_resource.cpp | 221 + .../{kis_background.cc => kis_background.cpp} | 0 .../{kis_boundary.cc => kis_boundary.cpp} | 0 chalk/core/{kis_brush.cc => kis_brush.cpp} | 0 .../core/{kis_command.cc => kis_command.cpp} | 0 ...painter.cc => kis_convolution_painter.cpp} | 0 .../{kis_exif_info.cc => kis_exif_info.cpp} | 0 .../{kis_exif_value.cc => kis_exif_value.cpp} | 0 ...s_fill_painter.cc => kis_fill_painter.cpp} | 0 chalk/core/{kis_filter.cc => kis_filter.cpp} | 0 ...widget.cc => kis_filter_config_widget.cpp} | 0 ...ration.cc => kis_filter_configuration.cpp} | 0 ...er_registry.cc => kis_filter_registry.cpp} | 0 ...er_strategy.cc => kis_filter_strategy.cpp} | 0 chalk/core/kis_gradient.cc | 639 --- chalk/core/kis_gradient.cpp | 639 +++ ...nt_painter.cc => kis_gradient_painter.cpp} | 0 ...kis_group_layer.cc => kis_group_layer.cpp} | 0 .../{kis_histogram.cc => kis_histogram.cpp} | 0 chalk/core/{kis_image.cc => kis_image.cpp} | 0 ...kis_image_iface.cc => kis_image_iface.cpp} | 0 ...epipe_brush.cc => kis_imagepipe_brush.cpp} | 0 .../{kis_iterator.cc => kis_iterator.cpp} | 0 ...ators_pixel.cc => kis_iterators_pixel.cpp} | 0 chalk/core/{kis_layer.cc => kis_layer.cpp} | 0 ...meta_registry.cc => kis_meta_registry.cpp} | 0 .../{kis_nameserver.cc => kis_nameserver.cpp} | 0 ...s_paint_device.cc => kis_paint_device.cpp} | 0 ...ce_iface.cc => kis_paint_device_iface.cpp} | 0 ...kis_paint_layer.cc => kis_paint_layer.cpp} | 0 .../core/{kis_painter.cc => kis_painter.cpp} | 0 .../core/{kis_paintop.cc => kis_paintop.cpp} | 0 ...p_registry.cc => kis_paintop_registry.cpp} | 0 .../core/{kis_palette.cc => kis_palette.cpp} | 0 chalk/core/kis_pattern.cc | 335 -- chalk/core/kis_pattern.cpp | 335 ++ chalk/core/{kis_rect.cc => kis_rect.cpp} | 0 .../{kis_resource.cc => kis_resource.cpp} | 0 ...tate_visitor.cc => kis_rotate_visitor.cpp} | 0 ...scale_visitor.cc => kis_scale_visitor.cpp} | 0 ...action.cc => kis_selected_transaction.cpp} | 0 .../{kis_selection.cc => kis_selection.cpp} | 0 ...strategy_move.cc => kis_strategy_move.cpp} | 0 ...kis_thread_pool.cc => kis_thread_pool.cpp} | 0 ...kis_transaction.cc => kis_transaction.cpp} | 0 ...orm_worker.cc => kis_transform_worker.cpp} | 0 chalk/core/kis_vec.cc | 67 - chalk/core/kis_vec.cpp | 67 + chalk/core/tests/Makefile.am | 2 +- ...cc => kis_filter_configuration_tester.cpp} | 0 chalk/core/tiles/Makefile.am | 6 +- .../tiles/{kis_memento.cc => kis_memento.cpp} | 0 .../core/tiles/{kis_tile.cc => kis_tile.cpp} | 0 ...essor.cc => kis_tiled_random_accessor.cpp} | 0 ...atamanager.cc => kis_tileddatamanager.cpp} | 0 ...iterator.cc => kis_tiledhlineiterator.cpp} | 0 ...tilediterator.cc => kis_tilediterator.cpp} | 0 ...titerator.cc => kis_tiledrectiterator.cpp} | 0 ...iterator.cc => kis_tiledvlineiterator.cpp} | 0 ...kis_tilemanager.cc => kis_tilemanager.cpp} | 0 chalk/doc/DESIGN.obsolete | 2 +- chalk/doc/brush.txt | 2 +- chalk/main.cc | 43 - chalk/main.cpp | 43 + chalk/plugins/filters/blur/Makefile.am | 2 +- .../filters/blur/{blur.cc => blur.cpp} | 0 ...kis_blur_filter.cc => kis_blur_filter.cpp} | 0 .../{kis_wdg_blur.cc => kis_wdg_blur.cpp} | 0 chalk/plugins/filters/bumpmap/Makefile.am | 2 +- .../bumpmap/{bumpmap.cc => bumpmap.cpp} | 0 chalk/plugins/filters/cimg/Makefile.am | 6 +- ...kis_cimg_filter.cc => kis_cimg_filter.cpp} | 0 ...kis_cimg_plugin.cc => kis_cimg_plugin.cpp} | 0 ...ig_widget.cc => kis_cimgconfig_widget.cpp} | 0 chalk/plugins/filters/colors/Makefile.am | 2 +- .../filters/colors/{colors.cc => colors.cpp} | 0 ...lor_to_alpha.cc => kis_color_to_alpha.cpp} | 0 ...nmax_filters.cc => kis_minmax_filters.cpp} | 0 ...to_alpha.cc => kis_wdg_color_to_alpha.cpp} | 0 .../plugins/filters/colorsfilters/Makefile.am | 6 +- .../{colorsfilters.cc => colorsfilters.cpp} | 0 ....cc => kis_brightness_contrast_filter.cpp} | 0 ...el_filter.cc => kis_perchannel_filter.cpp} | 0 .../filters/convolutionfilters/Makefile.am | 8 +- ...utionfilters.cc => convolutionfilters.cpp} | 0 ...n_filter.cc => kis_convolution_filter.cpp} | 0 ...r.cc => kis_custom_convolution_filter.cpp} | 0 ...nvolution_filter_configuration_widget.cpp} | 0 .../plugins/filters/cubismfilter/Makefile.am | 6 +- ...cubism_filter.cc => kis_cubism_filter.cpp} | 0 ...plugin.cc => kis_cubism_filter_plugin.cpp} | 0 .../{kis_polygon.cc => kis_polygon.cpp} | 0 .../plugins/filters/embossfilter/Makefile.am | 4 +- ...emboss_filter.cc => kis_emboss_filter.cpp} | 0 ...plugin.cc => kis_emboss_filter_plugin.cpp} | 0 chalk/plugins/filters/example/Makefile.am | 2 +- .../example/{example.cc => example.cpp} | 0 .../filters/fastcolortransfer/Makefile.am | 2 +- ...colortransfer.cc => fastcolortransfer.cpp} | 0 .../filters/lenscorrectionfilter/Makefile.am | 2 +- ...tionfilter.cc => lenscorrectionfilter.cpp} | 0 chalk/plugins/filters/levelfilter/Makefile.am | 6 +- ...kgradientslider.cc => kgradientslider.cpp} | 0 ...s_level_filter.cc => kis_level_filter.cpp} | 0 .../{levelfilter.cc => levelfilter.cpp} | 0 chalk/plugins/filters/noisefilter/Makefile.am | 2 +- .../{noisefilter.cc => noisefilter.cpp} | 0 .../filters/oilpaintfilter/Makefile.am | 4 +- ...aint_filter.cc => kis_oilpaint_filter.cpp} | 0 ...ugin.cc => kis_oilpaint_filter_plugin.cpp} | 0 .../filters/pixelizefilter/Makefile.am | 4 +- ...lize_filter.cc => kis_pixelize_filter.cpp} | 0 ...ugin.cc => kis_pixelize_filter_plugin.cpp} | 0 .../filters/raindropsfilter/Makefile.am | 4 +- ...ops_filter.cc => kis_raindrops_filter.cpp} | 0 ...gin.cc => kis_raindrops_filter_plugin.cpp} | 0 .../filters/randompickfilter/Makefile.am | 2 +- ...ndompickfilter.cc => randompickfilter.cpp} | 0 .../plugins/filters/roundcorners/Makefile.am | 4 +- ...filter.cc => kis_round_corners_filter.cpp} | 0 ...cc => kis_round_corners_filter_plugin.cpp} | 0 .../filters/smalltilesfilter/Makefile.am | 4 +- ...s_filter.cc => kis_small_tiles_filter.cpp} | 0 ...n.cc => kis_small_tiles_filter_plugin.cpp} | 0 chalk/plugins/filters/sobelfilter/Makefile.am | 4 +- ...s_sobel_filter.cc => kis_sobel_filter.cpp} | 0 ..._plugin.cc => kis_sobel_filter_plugin.cpp} | 0 chalk/plugins/filters/threadtest/Makefile.am | 2 +- .../{threadtest.cc => threadtest.cpp} | 0 chalk/plugins/filters/unsharp/Makefile.am | 2 +- ...sharp_filter.cc => kis_unsharp_filter.cpp} | 0 ...kis_wdg_unsharp.cc => kis_wdg_unsharp.cpp} | 0 .../unsharp/{unsharp.cc => unsharp.cpp} | 0 chalk/plugins/filters/wavefilter/Makefile.am | 2 +- .../{wavefilter.cc => wavefilter.cpp} | 0 .../paintops/defaultpaintops/Makefile.am | 14 +- .../defaultpaintops/defaultpaintops_plugin.cc | 70 - .../defaultpaintops_plugin.cpp | 70 + .../{kis_airbrushop.cc => kis_airbrushop.cpp} | 0 .../{kis_brushop.cc => kis_brushop.cpp} | 0 .../{kis_convolveop.cc => kis_convolveop.cpp} | 0 ...kis_duplicateop.cc => kis_duplicateop.cpp} | 0 .../{kis_eraseop.cc => kis_eraseop.cpp} | 0 .../{kis_penop.cc => kis_penop.cpp} | 0 .../{kis_smudgeop.cc => kis_smudgeop.cpp} | 0 chalk/plugins/tools/defaulttools/Makefile.am | 26 +- .../tools/defaulttools/default_tools.cc | 88 - .../tools/defaulttools/default_tools.cpp | 88 + .../tools/defaulttools/kis_tool_brush.cc | 167 - .../tools/defaulttools/kis_tool_brush.cpp | 167 + ...olorpicker.cc => kis_tool_colorpicker.cpp} | 0 .../tools/defaulttools/kis_tool_duplicate.cc | 255 - .../tools/defaulttools/kis_tool_duplicate.cpp | 255 + .../tools/defaulttools/kis_tool_ellipse.cc | 186 - .../tools/defaulttools/kis_tool_ellipse.cpp | 186 + .../tools/defaulttools/kis_tool_fill.cc | 233 - .../tools/defaulttools/kis_tool_fill.cpp | 233 + .../tools/defaulttools/kis_tool_gradient.cc | 309 -- .../tools/defaulttools/kis_tool_gradient.cpp | 309 ++ .../tools/defaulttools/kis_tool_line.cc | 254 - .../tools/defaulttools/kis_tool_line.cpp | 254 + .../{kis_tool_move.cc => kis_tool_move.cpp} | 0 .../{kis_tool_pan.cc => kis_tool_pan.cpp} | 0 .../tools/defaulttools/kis_tool_rectangle.cc | 187 - .../tools/defaulttools/kis_tool_rectangle.cpp | 187 + .../{kis_tool_text.cc => kis_tool_text.cpp} | 0 .../{kis_tool_zoom.cc => kis_tool_zoom.cpp} | 0 .../plugins/tools/selectiontools/Makefile.am | 8 +- ...lection.cc => kis_tool_move_selection.cpp} | 0 .../selectiontools/kis_tool_select_brush.cc | 168 - .../selectiontools/kis_tool_select_brush.cpp | 168 + ...uous.cc => kis_tool_select_contiguous.cpp} | 0 .../kis_tool_select_elliptical.cc | 321 -- .../kis_tool_select_elliptical.cpp | 321 ++ .../selectiontools/kis_tool_select_eraser.cc | 156 - .../selectiontools/kis_tool_select_eraser.cpp | 156 + ...outline.cc => kis_tool_select_outline.cpp} | 0 ...gonal.cc => kis_tool_select_polygonal.cpp} | 0 .../kis_tool_select_rectangular.cc | 323 -- .../kis_tool_select_rectangular.cpp | 323 ++ .../tools/selectiontools/selection_tools.cc | 77 - .../tools/selectiontools/selection_tools.cpp | 77 + chalk/plugins/tools/tool_crop/Makefile.am | 4 +- .../plugins/tools/tool_crop/kis_tool_crop.cc | 925 ---- .../plugins/tools/tool_crop/kis_tool_crop.cpp | 925 ++++ chalk/plugins/tools/tool_crop/tool_crop.cc | 62 - chalk/plugins/tools/tool_crop/tool_crop.cpp | 62 + chalk/plugins/tools/tool_curves/Makefile.am | 16 +- ...e_framework.cc => kis_curve_framework.cpp} | 0 .../tools/tool_curves/kis_tool_bezier.cc | 366 -- .../tools/tool_curves/kis_tool_bezier.cpp | 366 ++ .../tool_curves/kis_tool_bezier_paint.cc | 115 - .../tool_curves/kis_tool_bezier_paint.cpp | 115 + .../tool_curves/kis_tool_bezier_select.cc | 104 - .../tool_curves/kis_tool_bezier_select.cpp | 104 + .../tools/tool_curves/kis_tool_curve.cc | 593 --- .../tools/tool_curves/kis_tool_curve.cpp | 593 +++ .../tools/tool_curves/kis_tool_example.cc | 108 - .../tools/tool_curves/kis_tool_example.cpp | 108 + .../tools/tool_curves/kis_tool_moutline.cc | 809 --- .../tools/tool_curves/kis_tool_moutline.cpp | 809 +++ .../plugins/tools/tool_curves/tool_curves.cc | 67 - .../plugins/tools/tool_curves/tool_curves.cpp | 67 + chalk/plugins/tools/tool_filter/Makefile.am | 6 +- .../{kis_filterop.cc => kis_filterop.cpp} | 0 .../tools/tool_filter/kis_tool_filter.cc | 154 - .../tools/tool_filter/kis_tool_filter.cpp | 154 + .../plugins/tools/tool_filter/tool_filter.cc | 68 - .../plugins/tools/tool_filter/tool_filter.cpp | 68 + .../tools/tool_perspectivegrid/Makefile.am | 4 +- .../kis_tool_perspectivegrid.cc | 499 -- .../kis_tool_perspectivegrid.cpp | 499 ++ .../tool_perspectivegrid.cc | 62 - .../tool_perspectivegrid.cpp | 62 + .../tool_perspectivetransform/Makefile.am | 4 +- .../kis_tool_perspectivetransform.cc | 742 --- .../kis_tool_perspectivetransform.cpp | 742 +++ .../tool_perspectivetransform.cc | 63 - .../tool_perspectivetransform.cpp | 63 + chalk/plugins/tools/tool_polygon/Makefile.am | 4 +- .../tools/tool_polygon/kis_tool_polygon.cc | 252 - .../tools/tool_polygon/kis_tool_polygon.cpp | 252 + .../tools/tool_polygon/tool_polygon.cc | 62 - .../tools/tool_polygon/tool_polygon.cpp | 62 + chalk/plugins/tools/tool_polyline/Makefile.am | 4 +- .../tools/tool_polyline/kis_tool_polyline.cc | 271 - .../tools/tool_polyline/kis_tool_polyline.cpp | 271 + .../tools/tool_polyline/tool_polyline.cc | 64 - .../tools/tool_polyline/tool_polyline.cpp | 64 + .../tools/tool_selectsimilar/Makefile.am | 2 +- ...tsimilar.cc => kis_tool_selectsimilar.cpp} | 0 .../{selectsimilar.cc => selectsimilar.cpp} | 0 chalk/plugins/tools/tool_star/Makefile.am | 4 +- .../plugins/tools/tool_star/kis_tool_star.cc | 245 - .../plugins/tools/tool_star/kis_tool_star.cpp | 245 + chalk/plugins/tools/tool_star/tool_star.cc | 62 - chalk/plugins/tools/tool_star/tool_star.cpp | 62 + .../plugins/tools/tool_transform/Makefile.am | 4 +- .../tool_transform/kis_tool_transform.cc | 916 ---- .../tool_transform/kis_tool_transform.cpp | 916 ++++ .../tools/tool_transform/tool_transform.cc | 64 - .../tools/tool_transform/tool_transform.cpp | 64 + .../viewplugins/colorrange/Makefile.am | 2 +- .../{colorrange.cc => colorrange.cpp} | 0 .../viewplugins/colorrange/dlg_colorrange.cc | 351 -- .../viewplugins/colorrange/dlg_colorrange.cpp | 351 ++ .../colorspaceconversion/Makefile.am | 2 +- .../colorspaceconversion.cc | 155 - .../colorspaceconversion.cpp | 155 + .../dlg_colorspaceconversion.cc | 91 - .../dlg_colorspaceconversion.cpp | 91 + .../viewplugins/dropshadow/Makefile.am | 4 +- .../viewplugins/dropshadow/dlg_dropshadow.cc | 117 - .../viewplugins/dropshadow/dlg_dropshadow.cpp | 117 + .../{kis_dropshadow.cc => kis_dropshadow.cpp} | 0 ...ow_plugin.cc => kis_dropshadow_plugin.cpp} | 0 .../viewplugins/filtersgallery/Makefile.am | 4 +- ...filters_gallery.cc => filters_gallery.cpp} | 0 ...sgallery.cc => kis_dlg_filtersgallery.cpp} | 0 .../plugins/viewplugins/histogram/Makefile.am | 2 +- .../viewplugins/histogram/dlg_histogram.cc | 68 - .../viewplugins/histogram/dlg_histogram.cpp | 68 + .../histogram/{histogram.cc => histogram.cpp} | 0 ...ram_widget.cc => kis_histogram_widget.cpp} | 0 .../viewplugins/histogram_docker/Makefile.am | 2 +- ...histogramdocker.cc => histogramdocker.cpp} | 0 ...ducer.cc => kis_accumulating_producer.cpp} | 0 ...edhistogram.cc => kis_cachedhistogram.cpp} | 0 ...redcache.cc => kis_imagerasteredcache.cpp} | 0 .../viewplugins/history_docker/Makefile.am | 2 +- .../{historydocker.cc => historydocker.cpp} | 0 .../plugins/viewplugins/imagesize/Makefile.am | 2 +- .../viewplugins/imagesize/dlg_imagesize.cc | 277 - .../viewplugins/imagesize/dlg_imagesize.cpp | 277 + .../viewplugins/imagesize/dlg_layersize.cc | 261 - .../viewplugins/imagesize/dlg_layersize.cpp | 261 + .../viewplugins/imagesize/imagesize.cc | 190 - .../viewplugins/imagesize/imagesize.cpp | 190 + .../viewplugins/modify_selection/Makefile.am | 2 +- .../modify_selection/dlg_border_selection.cc | 76 - .../modify_selection/dlg_border_selection.cpp | 76 + .../modify_selection/dlg_grow_selection.cc | 76 - .../modify_selection/dlg_grow_selection.cpp | 76 + .../modify_selection/dlg_shrink_selection.cc | 81 - .../modify_selection/dlg_shrink_selection.cpp | 81 + .../modify_selection/modify_selection.cc | 158 - .../modify_selection/modify_selection.cpp | 158 + .../viewplugins/performancetest/Makefile.am | 2 +- .../performancetest/dlg_perftest.cc | 110 - .../performancetest/dlg_perftest.cpp | 110 + .../viewplugins/performancetest/perftest.cc | 1198 ----- .../viewplugins/performancetest/perftest.cpp | 1198 +++++ .../viewplugins/rotateimage/Makefile.am | 2 +- .../rotateimage/dlg_rotateimage.cc | 147 - .../rotateimage/dlg_rotateimage.cpp | 147 + .../viewplugins/rotateimage/rotateimage.cc | 134 - .../viewplugins/rotateimage/rotateimage.cpp | 134 + .../plugins/viewplugins/scripting/Makefile.am | 2 +- .../scripting/{scripting.cc => scripting.cpp} | 0 .../viewplugins/selectopaque/Makefile.am | 2 +- .../{selectopaque.cc => selectopaque.cpp} | 0 .../viewplugins/separate_channels/Makefile.am | 4 +- .../separate_channels/dlg_separate.cc | 110 - .../separate_channels/dlg_separate.cpp | 110 + ...separator.cc => kis_channel_separator.cpp} | 0 ...in.cc => kis_separate_channels_plugin.cpp} | 0 .../viewplugins/shearimage/Makefile.am | 2 +- .../viewplugins/shearimage/dlg_shearimage.cc | 96 - .../viewplugins/shearimage/dlg_shearimage.cpp | 96 + .../viewplugins/shearimage/shearimage.cc | 113 - .../viewplugins/shearimage/shearimage.cpp | 113 + .../plugins/viewplugins/substrate/Makefile.am | 2 +- .../viewplugins/substrate/dlg_substrate.cc | 59 - .../viewplugins/substrate/dlg_substrate.cpp | 59 + ...bstrate.cc => kis_repeating_substrate.cpp} | 0 .../substrate/{substrate.cc => substrate.cpp} | 0 .../viewplugins/variations/Makefile.am | 2 +- .../viewplugins/variations/dlg_variations.cc | 58 - .../viewplugins/variations/dlg_variations.cpp | 58 + .../{variations.cc => variations.cpp} | 0 chalk/sdk/Makefile.am | 2 +- ...ss_subject.cc => kis_progress_subject.cpp} | 0 chalk/ui/Makefile.am | 44 +- chalk/ui/{imageviewer.cc => imageviewer.cpp} | 0 chalk/ui/{kcurve.cc => kcurve.cpp} | 0 .../{kis_autobrush.cc => kis_autobrush.cpp} | 0 ...s_autogradient.cc => kis_autogradient.cpp} | 0 ...kis_birdeye_box.cc => kis_birdeye_box.cpp} | 0 ...ry_painter.cc => kis_boundary_painter.cpp} | 0 ...brush_chooser.cc => kis_brush_chooser.cpp} | 0 chalk/ui/{kis_canvas.cc => kis_canvas.cpp} | 0 ...nvas_painter.cc => kis_canvas_painter.cpp} | 0 .../{kis_clipboard.cc => kis_clipboard.cpp} | 0 chalk/ui/kis_cmb_composite.cc | 88 - chalk/ui/kis_cmb_composite.cpp | 88 + chalk/ui/kis_cmb_idlist.cc | 97 - chalk/ui/kis_cmb_idlist.cpp | 97 + .../{kis_color_cup.cc => kis_color_cup.cpp} | 0 chalk/ui/{kis_config.cc => kis_config.cpp} | 0 chalk/ui/kis_controlframe.cc | 343 -- chalk/ui/kis_controlframe.cpp | 343 ++ chalk/ui/kis_cursor.cc | 374 -- chalk/ui/kis_cursor.cpp | 374 ++ ...s_custom_brush.cc => kis_custom_brush.cpp} | 0 ..._widget.cc => kis_custom_image_widget.cpp} | 0 ...stom_palette.cc => kis_custom_palette.cpp} | 0 ...stom_pattern.cc => kis_custom_pattern.cpp} | 0 ...r_props.cc => kis_dlg_adj_layer_props.cpp} | 0 ..._layer.cc => kis_dlg_adjustment_layer.cpp} | 0 ...y_profile.cc => kis_dlg_apply_profile.cpp} | 0 ...erties.cc => kis_dlg_image_properties.cpp} | 0 ...erties.cc => kis_dlg_layer_properties.cpp} | 0 ...dlg_new_layer.cc => kis_dlg_new_layer.cpp} | 0 chalk/ui/kis_dlg_preferences.cc | 821 --- chalk/ui/kis_dlg_preferences.cpp | 821 +++ chalk/ui/{kis_doc.cc => kis_doc.cpp} | 0 .../{kis_doc_iface.cc => kis_doc_iface.cpp} | 0 chalk/ui/kis_double_widget.cc | 147 - chalk/ui/kis_double_widget.cpp | 147 + chalk/ui/kis_factory.cc | 153 - chalk/ui/kis_factory.cpp | 153 + ...lter_manager.cc => kis_filter_manager.cpp} | 0 ...s_listview.cc => kis_filters_listview.cpp} | 0 ...nt_chooser.cc => kis_gradient_chooser.cpp} | 0 ...dget.cc => kis_gradient_slider_widget.cpp} | 0 ...stogram_view.cc => kis_histogram_view.cpp} | 0 .../{kis_icon_item.cc => kis_icon_item.cpp} | 0 .../{kis_iconwidget.cc => kis_iconwidget.cpp} | 0 ...port_catcher.cc => kis_import_catcher.cpp} | 0 ...s_input_device.cc => kis_input_device.cpp} | 0 ...kis_int_spinbox.cc => kis_int_spinbox.cpp} | 0 ...kis_itemchooser.cc => kis_itemchooser.cpp} | 0 ...cursor_pos.cc => kis_label_cursor_pos.cpp} | 0 ...bel_progress.cc => kis_label_progress.cpp} | 0 .../{kis_label_zoom.cc => kis_label_zoom.cpp} | 0 chalk/ui/kis_layerbox.cc | 675 --- chalk/ui/kis_layerbox.cpp | 675 +++ .../{kis_layerlist.cc => kis_layerlist.cpp} | 0 ...et.cc => kis_multi_bool_filter_widget.cpp} | 0 ....cc => kis_multi_double_filter_widget.cpp} | 0 ...cc => kis_multi_integer_filter_widget.cpp} | 0 ...opengl_canvas.cc => kis_opengl_canvas.cpp} | 0 ...inter.cc => kis_opengl_canvas_painter.cpp} | 0 ...ontext.cc => kis_opengl_image_context.cpp} | 0 chalk/ui/kis_paintop_box.cc | 249 - chalk/ui/kis_paintop_box.cpp | 249 + ...s_palette_view.cc => kis_palette_view.cpp} | 0 ...lette_widget.cc => kis_palette_widget.cpp} | 0 .../{kis_part_layer.cc => kis_part_layer.cpp} | 0 ..._handler.cc => kis_part_layer_handler.cpp} | 0 ...ern_chooser.cc => kis_pattern_chooser.cpp} | 0 chalk/ui/kis_previewdialog.cc | 46 - chalk/ui/kis_previewdialog.cpp | 46 + chalk/ui/kis_previewwidget.cc | 409 -- chalk/ui/kis_previewwidget.cpp | 409 ++ ..._canvas.cc => kis_qpaintdevice_canvas.cpp} | 0 ...cc => kis_qpaintdevice_canvas_painter.cpp} | 0 ..._mediator.cc => kis_resource_mediator.cpp} | 0 chalk/ui/kis_resourceserver.cc | 199 - chalk/ui/kis_resourceserver.cpp | 199 + chalk/ui/{kis_ruler.cc => kis_ruler.cpp} | 0 ...n_manager.cc => kis_selection_manager.cpp} | 0 ...n_options.cc => kis_selection_options.cpp} | 0 .../{kis_text_brush.cc => kis_text_brush.cpp} | 0 chalk/ui/{kis_tool.cc => kis_tool.cpp} | 0 .../{kis_tool_dummy.cc => kis_tool_dummy.cpp} | 0 chalk/ui/kis_tool_freehand.cc | 354 -- chalk/ui/kis_tool_freehand.cpp | 354 ++ ...s_tool_manager.cc => kis_tool_manager.cpp} | 0 ...ol_non_paint.cc => kis_tool_non_paint.cpp} | 0 .../{kis_tool_paint.cc => kis_tool_paint.cpp} | 0 ...tool_registry.cc => kis_tool_registry.cpp} | 0 .../{kis_tool_shape.cc => kis_tool_shape.cpp} | 0 chalk/ui/{kis_view.cc => kis_view.cpp} | 0 .../{kis_view_iface.cc => kis_view_iface.cpp} | 0 doc/chalk/developers-plugins.docbook | 8 +- example/Makefile.am | 8 +- ...example_factory.cc => example_factory.cpp} | 0 example/{example_part.cc => example_part.cpp} | 0 example/{example_view.cc => example_view.cpp} | 0 example/{main.cc => main.cpp} | 0 filters/Makefile.am | 2 +- filters/chalk/gmagick/Makefile.am | 4 +- ...rter.cc => kis_image_magick_converter.cpp} | 0 filters/chalk/jpeg/Makefile.am | 6 +- ...eg_converter.cc => kis_jpeg_converter.cpp} | 0 ...kis_jpeg_export.cc => kis_jpeg_export.cpp} | 0 ...kis_jpeg_import.cc => kis_jpeg_import.cpp} | 0 filters/chalk/magick/Makefile.am | 4 +- ...rter.cc => kis_image_magick_converter.cpp} | 0 filters/chalk/png/Makefile.am | 4 +- ...png_converter.cc => kis_png_converter.cpp} | 0 .../{kis_png_export.cc => kis_png_export.cpp} | 0 .../{kis_png_import.cc => kis_png_import.cpp} | 0 filters/chalk/tiff/Makefile.am | 8 +- ...ff_converter.cc => kis_tiff_converter.cpp} | 0 ...kis_tiff_export.cc => kis_tiff_export.cpp} | 0 ...kis_tiff_import.cc => kis_tiff_import.cpp} | 0 ...kis_tiff_reader.cc => kis_tiff_reader.cpp} | 0 ...kis_tiff_stream.cc => kis_tiff_stream.cpp} | 0 ...cr_reader.cc => kis_tiff_ycbcr_reader.cpp} | 0 .../xcf/xcf/{xcf-load.cc => xcf-load.cpp} | 0 .../xcf/xcf/{xcf-read.cc => xcf-read.cpp} | 0 .../xcf/xcf/{xcf-save.cc => xcf-save.cpp} | 0 .../xcf/xcf/{xcf-seek.cc => xcf-seek.cpp} | 0 .../xcf/xcf/{xcf-write.cc => xcf-write.cpp} | 0 filters/generic_wrapper/Makefile.am | 2 +- .../{generic_filter.cc => generic_filter.cpp} | 0 filters/karbon/ai/Makefile.am | 16 +- .../ai/{ai3handler.cc => ai3handler.cpp} | 0 .../ai/{ai88handler.cc => ai88handler.cpp} | 0 filters/karbon/ai/{aicolor.cc => aicolor.cpp} | 0 .../karbon/ai/{aielement.cc => aielement.cpp} | 0 .../karbon/ai/{aiimport.cc => aiimport.cpp} | 0 filters/karbon/ai/{ailexer.cc => ailexer.cpp} | 0 .../ai/{aiparserbase.cc => aiparserbase.cpp} | 0 ...aiparserbase.cc => karbonaiparserbase.cpp} | 0 filters/karbon/applixgraphics/Makefile.am | 4 +- ...aphicimport.cc => applixgraphicimport.cpp} | 0 filters/karbon/eps/Makefile.am | 6 +- .../eps/{epsexport.cc => epsexport.cpp} | 0 .../eps/{epsexportdlg.cc => epsexportdlg.cpp} | 0 .../eps/{epsimport.cc => epsimport.cpp} | 0 .../{pscommentlexer.cc => pscommentlexer.cpp} | 0 filters/karbon/kontour/Makefile.am | 2 +- filters/karbon/msod/Makefile.am | 2 +- filters/karbon/msod/{msod.cc => msod.cpp} | 0 .../msod/{msodimport.cc => msodimport.cpp} | 0 filters/karbon/oodraw/Makefile.am | 2 +- .../{oodrawimport.cc => oodrawimport.cpp} | 0 filters/karbon/png/Makefile.am | 2 +- .../png/{pngexport.cc => pngexport.cpp} | 0 filters/karbon/svg/Makefile.am | 4 +- .../svg/{svgexport.cc => svgexport.cpp} | 0 .../svg/{svgimport.cc => svgimport.cpp} | 0 filters/karbon/wmf/Makefile.am | 4 +- .../wmf/{wmfexport.cc => wmfexport.cpp} | 0 .../wmf/{wmfimport.cc => wmfimport.cpp} | 0 ...wmfimportparser.cc => wmfimportparser.cpp} | 0 filters/karbon/xaml/Makefile.am | 4 +- .../xaml/{xamlexport.cc => xamlexport.cpp} | 0 .../xaml/{xamlimport.cc => xamlimport.cpp} | 0 filters/karbon/xcf/Makefile.am | 2 +- .../xcf/{xcfexport.cc => xcfexport.cpp} | 0 .../xfig/{xfigimport.cc => xfigimport.cpp} | 0 ...port_factory.cc => xfigimport_factory.cpp} | 0 filters/kchart/svg/Makefile.am | 2 +- .../svg/{svgexport.cc => svgexport.cpp} | 0 filters/kformula/latex/Makefile.am | 4 +- .../latex/{latexexport.cc => latexexport.cpp} | 0 filters/kformula/mathml/Makefile.am | 4 +- .../{mathmlexport.cc => mathmlexport.cpp} | 0 .../{mathmlimport.cc => mathmlimport.cpp} | 0 filters/kformula/png/Makefile.am | 4 +- .../png/{pngexport.cc => pngexport.cpp} | 0 .../png/{pngexportdia.cc => pngexportdia.cpp} | 0 filters/kformula/svg/Makefile.am | 4 +- .../svg/{svgexport.cc => svgexport.cpp} | 0 filters/kpresenter/kword/Makefile.am | 2 +- .../kword/{kprkword.cc => kprkword.cpp} | 0 filters/kpresenter/ooimpress/Makefile.am | 4 +- ...ooimpressexport.cc => ooimpressexport.cpp} | 0 ...ooimpressimport.cc => ooimpressimport.cpp} | 0 .../{stylefactory.cc => stylefactory.cpp} | 0 .../kpresenter/powerpoint/import/Makefile.am | 2 +- ...werpointimport.cc => powerpointimport.cpp} | 0 filters/kpresenter/svg/Makefile.am | 2 +- filters/kpresenter/svg/svgexport.cc | 100 - filters/kpresenter/svg/svgexport.cpp | 100 + filters/kpresenter/svg/svgexport.h | 2 +- filters/kspread/applixspread/Makefile.am | 2 +- ...spreadimport.cc => applixspreadimport.cpp} | 0 filters/kspread/applixspread/status.html | 2 +- filters/kspread/csv/DESIGN | 2 +- filters/kspread/csv/Makefile.am | 4 +- .../csv/{csvexport.cc => csvexport.cpp} | 0 .../csv/{csvimport.cc => csvimport.cpp} | 0 filters/kspread/csv/status.html | 2 +- .../kspread/csv/{xmltree.cc => xmltree.cpp} | 0 filters/kspread/dbase/Makefile.am | 2 +- .../dbase/{dbaseimport.cc => dbaseimport.cpp} | 0 filters/kspread/excel/Makefile.am | 2 +- .../excel/{excelexport.cc => excelexport.cpp} | 0 filters/kspread/excel/import/Makefile.am | 2 +- .../{excelimport.cc => excelimport.cpp} | 0 filters/kspread/gnumeric/Makefile.am | 4 +- .../{gnumericexport.cc => gnumericexport.cpp} | 0 .../{gnumericimport.cc => gnumericimport.cpp} | 0 filters/kspread/html/Makefile.am | 2 +- .../{exportdialog.cc => exportdialog.cpp} | 0 .../html/{htmlexport.cc => htmlexport.cpp} | 0 filters/kspread/kexi/Makefile.am | 4 +- ...d_kexiimport.cc => kspread_kexiimport.cpp} | 0 ...dialog.cc => kspread_kexiimportdialog.cpp} | 0 filters/kspread/latex/export/Makefile.am | 12 +- .../latex/export/{cell.cc => cell.cpp} | 0 .../latex/export/{column.cc => column.cpp} | 0 .../latex/export/{config.cc => config.cpp} | 0 .../export/{document.cc => document.cpp} | 0 .../export/{fileheader.cc => fileheader.cpp} | 0 .../latex/export/{format.cc => format.cpp} | 0 .../latex/export/{formula.cc => formula.cpp} | 0 ...aImpl.cc => kspreadlatexexportdiaImpl.cpp} | 0 .../{latexexport.cc => latexexport.cpp} | 0 ...texexportIface.cc => latexexportIface.cpp} | 0 .../kspread/latex/export/{map.cc => map.cpp} | 0 .../kspread/latex/export/{pen.cc => pen.cpp} | 0 .../kspread/latex/export/{row.cc => row.cpp} | 0 .../{spreadsheet.cc => spreadsheet.cpp} | 0 .../latex/export/{table.cc => table.cpp} | 0 .../export/{xmlparser.cc => xmlparser.cpp} | 0 ...eadBaseWorker.cc => KSpreadBaseWorker.cpp} | 0 .../{KSpreadLeader.cc => KSpreadLeader.cpp} | 0 filters/kspread/libkspreadexport/Makefile.am | 2 +- filters/kspread/opencalc/Makefile.am | 4 +- .../{opencalcexport.cc => opencalcexport.cpp} | 0 .../{opencalcimport.cc => opencalcimport.cpp} | 0 ...styleexport.cc => opencalcstyleexport.cpp} | 0 filters/kspread/qpro/Makefile.am | 2 +- filters/kspread/qpro/libqpro/ChangeLog | 8 +- filters/kspread/qpro/libqpro/src/Makefile.am | 2 +- .../libqpro/src/{formula.cc => formula.cpp} | 0 .../libqpro/src/{record.cc => record.cpp} | 0 .../{record_factory.cc => record_factory.cpp} | 0 .../libqpro/src/{stream.cc => stream.cpp} | 0 .../src/{tablenames.cc => tablenames.cpp} | 0 .../qpro/{qproformula.cc => qproformula.cpp} | 0 .../qpro/{qproimport.cc => qproimport.cpp} | 0 .../{ImportField.cc => ImportField.cpp} | 0 ...portFormatting.cc => ImportFormatting.cpp} | 0 .../{ImportHelpers.cc => ImportHelpers.cpp} | 0 .../{ImportStyle.cc => ImportStyle.cpp} | 0 filters/kword/abiword/Makefile.am | 6 +- filters/kword/abiword/abiwordexport.cc | 1261 ----- filters/kword/abiword/abiwordexport.cpp | 1261 +++++ .../{abiwordimport.cc => abiwordimport.cpp} | 0 filters/kword/amipro/Makefile.am | 4 +- .../{amiproexport.cc => amiproexport.cpp} | 0 .../{amiproimport.cc => amiproimport.cpp} | 0 filters/kword/applixword/Makefile.am | 2 +- ...plixwordimport.cc => applixwordimport.cpp} | 0 .../{ExportDialog.cc => ExportDialog.cpp} | 0 .../{ImportDialog.cc => ImportDialog.cpp} | 0 filters/kword/ascii/Makefile.am | 4 +- .../ascii/{asciiexport.cc => asciiexport.cpp} | 0 .../ascii/{asciiimport.cc => asciiimport.cpp} | 0 filters/kword/docbook/Makefile.am | 2 +- .../{docbookexport.cc => docbookexport.cpp} | 0 .../{ExportBasic.cc => ExportBasic.cpp} | 0 .../export/{ExportCss.cc => ExportCss.cpp} | 0 .../{ExportDialog.cc => ExportDialog.cpp} | 0 ...ExportDocStruct.cc => ExportDocStruct.cpp} | 0 .../{ExportFilter.cc => ExportFilter.cpp} | 0 filters/kword/html/export/Makefile.am | 4 +- filters/kword/html/export/htmlexport.cc | 127 - filters/kword/html/export/htmlexport.cpp | 127 + filters/kword/latex/export/Makefile.am | 16 +- .../latex/export/{anchor.cc => anchor.cpp} | 0 .../latex/export/{config.cc => config.cpp} | 0 .../export/{document.cc => document.cpp} | 0 .../latex/export/{element.cc => element.cpp} | 0 .../export/{fileheader.cc => fileheader.cpp} | 0 .../export/{footnote.cc => footnote.cpp} | 0 .../latex/export/{format.cc => format.cpp} | 0 .../latex/export/{formula.cc => formula.cpp} | 0 .../kword/latex/export/{key.cc => key.cpp} | 0 ...exexportdia.cc => kwordlatexexportdia.cpp} | 0 .../{latexexport.cc => latexexport.cpp} | 0 ...texexportIface.cc => latexexportIface.cpp} | 0 .../latex/export/{layout.cc => layout.cpp} | 0 .../{listeformat.cc => listeformat.cpp} | 0 .../{listelement.cc => listelement.cpp} | 0 .../export/{listepara.cc => listepara.cpp} | 0 .../export/{listtable.cc => listtable.cpp} | 0 .../kword/latex/export/{para.cc => para.cpp} | 0 .../{pixmapFrame.cc => pixmapFrame.cpp} | 0 .../latex/export/{table.cc => table.cpp} | 0 .../{texlauncher.cc => texlauncher.cpp} | 0 .../export/{textFrame.cc => textFrame.cpp} | 0 .../export/{textformat.cc => textformat.cpp} | 0 .../export/{textzone.cc => textzone.cpp} | 0 .../{variableformat.cc => variableformat.cpp} | 0 .../{variablezone.cc => variablezone.cpp} | 0 ...xml2latexparser.cc => xml2latexparser.cpp} | 0 .../export/{xmlparser.cc => xmlparser.cpp} | 0 filters/kword/latex/import/Makefile.am | 6 +- .../latex/import/{config.cc => config.cpp} | 0 .../kword/latex/import/generator/Makefile.am | 2 +- .../import/generator/{body.cc => body.cpp} | 0 .../generator/{document.cc => document.cpp} | 0 .../{kwordgenerator.cc => kwordgenerator.cpp} | 0 .../import/generator/{latex.cc => latex.cpp} | 0 .../generator/{paragraph.cc => paragraph.cpp} | 0 .../{lateximport.cc => lateximport.cpp} | 0 filters/kword/latex/import/lateximportdia.cc | 170 - filters/kword/latex/import/lateximportdia.cpp | 170 + filters/kword/latex/import/parser/Makefile.am | 16 +- .../import/parser/{command.cc => command.cpp} | 0 .../import/parser/{comment.cc => comment.cpp} | 0 .../import/parser/{element.cc => element.cpp} | 0 .../latex/import/parser/{env.cc => env.cpp} | 0 .../import/parser/{group.cc => group.cpp} | 0 .../{latexparser.cc => latexparser.cpp} | 0 .../latex/import/parser/{main.cc => main.cpp} | 0 .../import/parser/{param.cc => param.cpp} | 0 filters/kword/latex/import/parser/texparser.l | 4 +- .../kword/latex/import/parser/texparser.lex | 4 +- .../latex/import/parser/{text.cc => text.cpp} | 0 .../{KWEFBaseWorker.cc => KWEFBaseWorker.cpp} | 0 filters/kword/libexport/KWEFKWordLeader.cc | 1430 ------ filters/kword/libexport/KWEFKWordLeader.cpp | 1430 ++++++ .../{KWEFStructures.cc => KWEFStructures.cpp} | 0 filters/kword/libexport/KWEFStructures.h | 4 +- .../libexport/{KWEFUtil.cc => KWEFUtil.cpp} | 0 filters/kword/libexport/Makefile.am | 4 +- filters/kword/libexport/ProcessDocument.cc | 1063 ---- filters/kword/libexport/ProcessDocument.cpp | 1063 ++++ filters/kword/libexport/TagProcessing.cc | 235 - filters/kword/libexport/TagProcessing.cpp | 235 + filters/kword/libexport/TagProcessing.h | 2 +- filters/kword/msword/document.cpp | 4 +- filters/kword/msword/texthandler.cpp | 2 +- .../{ImportDialog.cc => ImportDialog.cpp} | 0 filters/kword/mswrite/Makefile.am | 6 +- .../{mswriteexport.cc => mswriteexport.cpp} | 0 .../{mswriteimport.cc => mswriteimport.cpp} | 0 filters/kword/mswrite/status.html | 2 +- filters/kword/oowriter/ExportFilter.cc | 2229 -------- filters/kword/oowriter/ExportFilter.cpp | 2229 ++++++++ filters/kword/oowriter/ExportFilter.h | 2 +- filters/kword/oowriter/Makefile.am | 6 +- .../{conversion.cc => conversion.cpp} | 0 filters/kword/oowriter/oowriterexport.cc | 90 - filters/kword/oowriter/oowriterexport.cpp | 90 + .../{oowriterimport.cc => oowriterimport.cpp} | 0 filters/kword/palmdoc/Makefile.am | 4 +- .../{palmdocexport.cc => palmdocexport.cpp} | 0 .../{palmdocimport.cc => palmdocimport.cpp} | 0 filters/kword/pdf/diffs/goo_enable-final.diff | 24 +- filters/kword/pdf/diffs/goo_gfile.diff | 6 +- .../kword/pdf/diffs/xpdf_TextOutputDev.diff | 6 +- filters/kword/pdf/diffs/xpdf_includes.diff | 18 +- .../diffs/xpdf_security_integer_overflow.diff | 20 +- .../xpdf_security_integer_overflow_2.diff | 40 +- filters/kword/pdf/xpdf/CHANGES | 28 +- filters/kword/pdf/xpdf/goo/GHash.cc | 238 - filters/kword/pdf/xpdf/goo/GHash.cpp | 238 + filters/kword/pdf/xpdf/goo/GList.cc | 89 - filters/kword/pdf/xpdf/goo/GList.cpp | 89 + filters/kword/pdf/xpdf/goo/GString.cc | 233 - filters/kword/pdf/xpdf/goo/GString.cpp | 233 + filters/kword/pdf/xpdf/goo/Makefile.am | 2 +- filters/kword/pdf/xpdf/goo/gfile.cc | 700 --- filters/kword/pdf/xpdf/goo/gfile.cpp | 700 +++ filters/kword/pdf/xpdf/goo/gmempp.cc | 32 - filters/kword/pdf/xpdf/goo/gmempp.cpp | 32 + filters/kword/pdf/xpdf/xpdf/Annot.cc | 139 - filters/kword/pdf/xpdf/xpdf/Annot.cpp | 139 + filters/kword/pdf/xpdf/xpdf/Array.cc | 54 - filters/kword/pdf/xpdf/xpdf/Array.cpp | 54 + filters/kword/pdf/xpdf/xpdf/BuiltinFont.cc | 65 - filters/kword/pdf/xpdf/xpdf/BuiltinFont.cpp | 65 + .../kword/pdf/xpdf/xpdf/BuiltinFontTables.cc | 3367 ------------ .../kword/pdf/xpdf/xpdf/BuiltinFontTables.cpp | 3367 ++++++++++++ filters/kword/pdf/xpdf/xpdf/CMap.cc | 360 -- filters/kword/pdf/xpdf/xpdf/CMap.cpp | 360 ++ filters/kword/pdf/xpdf/xpdf/Catalog.cc | 371 -- filters/kword/pdf/xpdf/xpdf/Catalog.cpp | 371 ++ .../kword/pdf/xpdf/xpdf/CharCodeToUnicode.cc | 392 -- .../kword/pdf/xpdf/xpdf/CharCodeToUnicode.cpp | 392 ++ filters/kword/pdf/xpdf/xpdf/Decrypt.cc | 401 -- filters/kword/pdf/xpdf/xpdf/Decrypt.cpp | 401 ++ filters/kword/pdf/xpdf/xpdf/Dict.cc | 91 - filters/kword/pdf/xpdf/xpdf/Dict.cpp | 91 + filters/kword/pdf/xpdf/xpdf/Error.cc | 38 - filters/kword/pdf/xpdf/xpdf/Error.cpp | 38 + filters/kword/pdf/xpdf/xpdf/FTFont.cc | 685 --- filters/kword/pdf/xpdf/xpdf/FTFont.cpp | 685 +++ .../kword/pdf/xpdf/xpdf/FontEncodingTables.cc | 1824 ------- .../pdf/xpdf/xpdf/FontEncodingTables.cpp | 1824 +++++++ filters/kword/pdf/xpdf/xpdf/FontFile.cc | 3883 -------------- filters/kword/pdf/xpdf/xpdf/FontFile.cpp | 3883 ++++++++++++++ filters/kword/pdf/xpdf/xpdf/Function.cc | 1521 ------ filters/kword/pdf/xpdf/xpdf/Function.cpp | 1521 ++++++ filters/kword/pdf/xpdf/xpdf/Gfx.cc | 2782 ---------- filters/kword/pdf/xpdf/xpdf/Gfx.cpp | 2782 ++++++++++ filters/kword/pdf/xpdf/xpdf/GfxFont.cc | 1301 ----- filters/kword/pdf/xpdf/xpdf/GfxFont.cpp | 1301 +++++ filters/kword/pdf/xpdf/xpdf/GfxState.cc | 2338 --------- filters/kword/pdf/xpdf/xpdf/GfxState.cpp | 2338 +++++++++ filters/kword/pdf/xpdf/xpdf/GlobalParams.cc | 1112 ---- filters/kword/pdf/xpdf/xpdf/GlobalParams.cpp | 1112 ++++ filters/kword/pdf/xpdf/xpdf/ImageOutputDev.cc | 194 - .../kword/pdf/xpdf/xpdf/ImageOutputDev.cpp | 194 + filters/kword/pdf/xpdf/xpdf/JBIG2Stream.cc | 3513 ------------- filters/kword/pdf/xpdf/xpdf/JBIG2Stream.cpp | 3513 +++++++++++++ filters/kword/pdf/xpdf/xpdf/Lexer.cc | 474 -- filters/kword/pdf/xpdf/xpdf/Lexer.cpp | 474 ++ filters/kword/pdf/xpdf/xpdf/Link.cc | 735 --- filters/kword/pdf/xpdf/xpdf/Link.cpp | 735 +++ filters/kword/pdf/xpdf/xpdf/Makefile.am | 16 +- filters/kword/pdf/xpdf/xpdf/NameToCharCode.cc | 116 - .../kword/pdf/xpdf/xpdf/NameToCharCode.cpp | 116 + filters/kword/pdf/xpdf/xpdf/Object.cc | 225 - filters/kword/pdf/xpdf/xpdf/Object.cpp | 225 + filters/kword/pdf/xpdf/xpdf/Outline.cc | 140 - filters/kword/pdf/xpdf/xpdf/Outline.cpp | 140 + filters/kword/pdf/xpdf/xpdf/OutputDev.cc | 103 - filters/kword/pdf/xpdf/xpdf/OutputDev.cpp | 103 + filters/kword/pdf/xpdf/xpdf/PBMOutputDev.cc | 162 - filters/kword/pdf/xpdf/xpdf/PBMOutputDev.cpp | 162 + filters/kword/pdf/xpdf/xpdf/PDFDoc.cc | 288 -- filters/kword/pdf/xpdf/xpdf/PDFDoc.cpp | 288 ++ .../{PDFDocEncoding.cc => PDFDocEncoding.cpp} | 0 filters/kword/pdf/xpdf/xpdf/PSOutputDev.cc | 3325 ------------ filters/kword/pdf/xpdf/xpdf/PSOutputDev.cpp | 3325 ++++++++++++ filters/kword/pdf/xpdf/xpdf/PSTokenizer.cc | 135 - filters/kword/pdf/xpdf/xpdf/PSTokenizer.cpp | 135 + filters/kword/pdf/xpdf/xpdf/Page.cc | 341 -- filters/kword/pdf/xpdf/xpdf/Page.cpp | 341 ++ filters/kword/pdf/xpdf/xpdf/Parser.cc | 223 - filters/kword/pdf/xpdf/xpdf/Parser.cpp | 223 + filters/kword/pdf/xpdf/xpdf/SFont.cc | 81 - filters/kword/pdf/xpdf/xpdf/SFont.cpp | 81 + filters/kword/pdf/xpdf/xpdf/Stream.cc | 4544 ----------------- filters/kword/pdf/xpdf/xpdf/Stream.cpp | 4544 +++++++++++++++++ filters/kword/pdf/xpdf/xpdf/T1Font.cc | 535 -- filters/kword/pdf/xpdf/xpdf/T1Font.cpp | 535 ++ filters/kword/pdf/xpdf/xpdf/TTFont.cc | 480 -- filters/kword/pdf/xpdf/xpdf/TTFont.cpp | 480 ++ filters/kword/pdf/xpdf/xpdf/TextOutputDev.cc | 1243 ----- filters/kword/pdf/xpdf/xpdf/TextOutputDev.cpp | 1243 +++++ filters/kword/pdf/xpdf/xpdf/UnicodeMap.cc | 268 - filters/kword/pdf/xpdf/xpdf/UnicodeMap.cpp | 268 + filters/kword/pdf/xpdf/xpdf/XOutputDev.cc | 3690 ------------- filters/kword/pdf/xpdf/xpdf/XOutputDev.cpp | 3690 +++++++++++++ filters/kword/pdf/xpdf/xpdf/XPDFApp.cc | 386 -- filters/kword/pdf/xpdf/xpdf/XPDFApp.cpp | 386 ++ filters/kword/pdf/xpdf/xpdf/XPDFCore.cc | 1913 ------- filters/kword/pdf/xpdf/xpdf/XPDFCore.cpp | 1913 +++++++ filters/kword/pdf/xpdf/xpdf/XPDFTree.cc | 929 ---- filters/kword/pdf/xpdf/xpdf/XPDFTree.cpp | 929 ++++ filters/kword/pdf/xpdf/xpdf/XPDFViewer.cc | 2318 --------- filters/kword/pdf/xpdf/xpdf/XPDFViewer.cpp | 2318 +++++++++ .../kword/pdf/xpdf/xpdf/XPixmapOutputDev.cc | 84 - .../kword/pdf/xpdf/xpdf/XPixmapOutputDev.cpp | 84 + filters/kword/pdf/xpdf/xpdf/XRef.cc | 693 --- filters/kword/pdf/xpdf/xpdf/XRef.cpp | 693 +++ filters/kword/pdf/xpdf/xpdf/pdffonts.cc | 281 - filters/kword/pdf/xpdf/xpdf/pdffonts.cpp | 281 + filters/kword/pdf/xpdf/xpdf/pdfimages.cc | 154 - filters/kword/pdf/xpdf/xpdf/pdfimages.cpp | 154 + filters/kword/pdf/xpdf/xpdf/pdfinfo.cc | 304 -- filters/kword/pdf/xpdf/xpdf/pdfinfo.cpp | 304 ++ filters/kword/pdf/xpdf/xpdf/pdftopbm.cc | 146 - filters/kword/pdf/xpdf/xpdf/pdftopbm.cpp | 146 + filters/kword/pdf/xpdf/xpdf/pdftops.cc | 306 -- filters/kword/pdf/xpdf/xpdf/pdftops.cpp | 306 ++ filters/kword/pdf/xpdf/xpdf/pdftotext.cc | 322 -- filters/kword/pdf/xpdf/xpdf/pdftotext.cpp | 322 ++ filters/kword/pdf/xpdf/xpdf/xpdf.cc | 289 -- filters/kword/pdf/xpdf/xpdf/xpdf.cpp | 289 ++ .../{ExportFilter.cc => ExportFilter.cpp} | 0 filters/kword/rtf/export/Makefile.am | 2 +- filters/kword/rtf/export/rtfexport.cc | 87 - filters/kword/rtf/export/rtfexport.cpp | 87 + filters/kword/starwriter/Makefile.am | 2 +- ...arwriterimport.cc => starwriterimport.cpp} | 0 filters/kword/wml/Makefile.am | 4 +- .../kword/wml/{wmlexport.cc => wmlexport.cpp} | 0 .../kword/wml/{wmlimport.cc => wmlimport.cpp} | 0 filters/kword/wordperfect/export/Makefile.am | 2 +- .../wordperfect/export/{wp5.cc => wp5.cpp} | 0 .../wordperfect/export/{wp6.cc => wp6.cpp} | 0 .../export/{wpexport.cc => wpexport.cpp} | 0 .../wordperfect/import/DocumentElement.cpp | 108 + .../wordperfect/import/DocumentElement.cxx | 108 - .../wordperfect/import/DocumentElement.h | 97 + .../wordperfect/import/DocumentElement.hxx | 97 - ...{DocumentHandler.hxx => DocumentHandler.h} | 0 .../kword/wordperfect/import/FilterInternal.h | 36 + .../wordperfect/import/FilterInternal.hxx | 36 - .../kword/wordperfect/import/FontStyle.cpp | 51 + .../kword/wordperfect/import/FontStyle.cxx | 51 - filters/kword/wordperfect/import/FontStyle.h | 48 + .../kword/wordperfect/import/FontStyle.hxx | 48 - .../kword/wordperfect/import/ListStyle.cpp | 162 + .../kword/wordperfect/import/ListStyle.cxx | 162 - filters/kword/wordperfect/import/ListStyle.h | 97 + .../kword/wordperfect/import/ListStyle.hxx | 97 - filters/kword/wordperfect/import/Makefile.am | 4 +- filters/kword/wordperfect/import/PageSpan.cpp | 180 + filters/kword/wordperfect/import/PageSpan.cxx | 180 - .../import/{PageSpan.hxx => PageSpan.h} | 0 .../kword/wordperfect/import/SectionStyle.cpp | 79 + .../kword/wordperfect/import/SectionStyle.cxx | 79 - .../kword/wordperfect/import/SectionStyle.h | 47 + .../kword/wordperfect/import/SectionStyle.hxx | 47 - filters/kword/wordperfect/import/Style.h | 60 + filters/kword/wordperfect/import/Style.hxx | 60 - .../kword/wordperfect/import/TableStyle.cpp | 161 + .../kword/wordperfect/import/TableStyle.cxx | 161 - filters/kword/wordperfect/import/TableStyle.h | 75 + .../kword/wordperfect/import/TableStyle.hxx | 75 - .../kword/wordperfect/import/TextRunStyle.cpp | 163 + .../kword/wordperfect/import/TextRunStyle.cxx | 163 - .../kword/wordperfect/import/TextRunStyle.h | 65 + .../kword/wordperfect/import/TextRunStyle.hxx | 65 - .../import/WordPerfectCollector.cpp | 973 ++++ .../import/WordPerfectCollector.cxx | 973 ---- .../wordperfect/import/WordPerfectCollector.h | 231 + .../import/WordPerfectCollector.hxx | 231 - ...riterProperties.hxx => WriterProperties.h} | 0 filters/kword/wordperfect/import/wpimport.cc | 391 -- filters/kword/wordperfect/import/wpimport.cpp | 391 ++ filters/liboofilter/Makefile.am | 2 +- .../{liststylestack.cc => liststylestack.cpp} | 0 .../liboofilter/{ooutils.cc => ooutils.cpp} | 0 filters/olefilters/Makefile.am | 2 +- filters/olefilters/lib/Makefile.am | 4 +- .../lib/{filterbase.cc => filterbase.cpp} | 0 .../olefilters/lib/{klaola.cc => klaola.cpp} | 0 .../{olefilter.cc => olefilter.cpp} | 0 filters/olefilters/powerpoint97/Makefile.am | 2 +- .../{powerpoint.cc => powerpoint.cpp} | 0 ...werpointfilter.cc => powerpointfilter.cpp} | 0 .../powerpoint97/{pptdoc.cc => pptdoc.cpp} | 0 .../powerpoint97/{pptxml.cc => pptxml.cpp} | 0 filters/xsltfilter/export/Makefile.am | 4 +- .../export/{xsltexport.cc => xsltexport.cpp} | 0 .../{xsltexportdia.cc => xsltexportdia.cpp} | 0 .../export/{xsltproc.cc => xsltproc.cpp} | 0 filters/xsltfilter/import/Makefile.am | 2 +- .../import/{xsltimport.cc => xsltimport.cpp} | 0 .../{xsltimportdia.cc => xsltimportdia.cpp} | 0 .../import/{xsltproc.cc => xsltproc.cpp} | 0 interfaces/Makefile.am | 2 +- interfaces/{koChart.cc => koChart.cpp} | 0 karbon/Makefile.am | 8 +- karbon/TODO | 2 +- karbon/commands/Makefile.am | 40 +- .../commands/{valigncmd.cc => valigncmd.cpp} | 0 .../{vbooleancmd.cc => vbooleancmd.cpp} | 0 .../{vcleanupcmd.cc => vcleanupcmd.cpp} | 0 .../{vclipartcmd.cc => vclipartcmd.cpp} | 0 .../{vclosepathcmd.cc => vclosepathcmd.cpp} | 0 karbon/commands/{vcommand.cc => vcommand.cpp} | 0 .../{vdeletecmd.cc => vdeletecmd.cpp} | 0 ...vdeletenodescmd.cc => vdeletenodescmd.cpp} | 0 .../{vdistributecmd.cc => vdistributecmd.cpp} | 0 karbon/commands/{vfillcmd.cc => vfillcmd.cpp} | 0 .../{vflattencmd.cc => vflattencmd.cpp} | 0 .../commands/{vgroupcmd.cc => vgroupcmd.cpp} | 0 .../{vinsertcmd.cc => vinsertcmd.cpp} | 0 .../commands/{vlayercmd.cc => vlayercmd.cpp} | 0 .../{vreplacingcmd.cc => vreplacingcmd.cpp} | 0 .../commands/{vshapecmd.cc => vshapecmd.cpp} | 0 .../{vstrokecmd.cc => vstrokecmd.cpp} | 0 karbon/commands/{vtextcmd.cc => vtextcmd.cpp} | 0 .../{vtransformcmd.cc => vtransformcmd.cpp} | 0 .../{vungroupcmd.cc => vungroupcmd.cpp} | 0 .../{vzordercmd.cc => vzordercmd.cpp} | 0 karbon/core/Makefile.am | 52 +- karbon/core/{vclipgroup.cc => vclipgroup.cpp} | 0 karbon/core/{vcolor.cc => vcolor.cpp} | 0 karbon/core/{vcomposite.cc => vcomposite.cpp} | 0 ...omposite_iface.cc => vcomposite_iface.cpp} | 0 karbon/core/{vcursor.cc => vcursor.cpp} | 0 .../{vdashpattern.cc => vdashpattern.cpp} | 0 karbon/core/{vdocument.cc => vdocument.cpp} | 0 karbon/core/{vfill.cc => vfill.cpp} | 0 karbon/core/{vglobal.cc => vglobal.cpp} | 0 karbon/core/{vgradient.cc => vgradient.cpp} | 0 karbon/core/{vgroup.cc => vgroup.cpp} | 0 .../{vgroup_iface.cc => vgroup_iface.cpp} | 0 karbon/core/{vimage.cc => vimage.cpp} | 0 .../{vkarbonplugin.cc => vkarbonplugin.cpp} | 0 karbon/core/{vlayer.cc => vlayer.cpp} | 0 .../{vlayer_iface.cc => vlayer_iface.cpp} | 0 karbon/core/{vobject.cc => vobject.cpp} | 0 .../{vobject_iface.cc => vobject_iface.cpp} | 0 karbon/core/{vpath.cc => vpath.cpp} | 0 karbon/core/{vpattern.cc => vpattern.cpp} | 0 karbon/core/{vsegment.cc => vsegment.cpp} | 0 karbon/core/{vselection.cc => vselection.cpp} | 0 karbon/core/{vstroke.cc => vstroke.cpp} | 0 karbon/core/{vtext.cc => vtext.cpp} | 0 .../core/{vtext_iface.cc => vtext_iface.cpp} | 0 karbon/core/{vvisitor.cc => vvisitor.cpp} | 0 karbon/dialogs/Makefile.am | 6 +- .../dialogs/{vcolordlg.cc => vcolordlg.cpp} | 0 .../dialogs/{vcolortab.cc => vcolortab.cpp} | 0 .../{vconfiguredlg.cc => vconfiguredlg.cpp} | 0 .../dialogs/{vstrokedlg.cc => vstrokedlg.cpp} | 0 karbon/dockers/Makefile.am | 18 +- .../{vcolordocker.cc => vcolordocker.cpp} | 0 ...vdocumentdocker.cc => vdocumentdocker.cpp} | 0 .../{vstrokedocker.cc => vstrokedocker.cpp} | 0 .../{vstyledocker.cc => vstyledocker.cpp} | 0 ...ransformdocker.cc => vtransformdocker.cpp} | 0 .../{karbon_factory.cc => karbon_factory.cpp} | 0 ...actory_init.cc => karbon_factory_init.cpp} | 0 karbon/{karbon_part.cc => karbon_part.cpp} | 0 ...on_part_iface.cc => karbon_part_iface.cpp} | 0 ...rceserver.cc => karbon_resourceserver.cpp} | 0 ...ool_factory.cc => karbon_tool_factory.cpp} | 0 ...l_registry.cc => karbon_tool_registry.cpp} | 0 karbon/{karbon_view.cc => karbon_view.cpp} | 0 ...on_view_iface.cc => karbon_view_iface.cpp} | 0 karbon/{main.cc => main.cpp} | 0 karbon/plugins/flattenpath/Makefile.am | 2 +- ...tenpathplugin.cc => flattenpathplugin.cpp} | 0 karbon/plugins/imagetool/Makefile.am | 2 +- ...imagetoolplugin.cc => imagetoolplugin.cpp} | 0 .../{vimagetool.cc => vimagetool.cpp} | 0 karbon/plugins/insertknots/Makefile.am | 2 +- ...rtknotsplugin.cc => insertknotsplugin.cpp} | 0 karbon/plugins/roundcorners/Makefile.am | 2 +- ...ornersplugin.cc => roundcornersplugin.cpp} | 0 karbon/plugins/shadoweffect/Makefile.am | 2 +- ...effectplugin.cc => shadoweffectplugin.cpp} | 0 ...hadowdecorator.cc => vshadowdecorator.cpp} | 0 karbon/plugins/whirlpinch/Makefile.am | 2 +- ...irlpinchplugin.cc => whirlpinchplugin.cpp} | 0 karbon/plugins/zoomtool/Makefile.am | 2 +- .../zoomtool/{vzoomtool.cc => vzoomtool.cpp} | 0 .../{zoomtoolplugin.cc => zoomtoolplugin.cpp} | 0 karbon/render/Makefile.am | 6 +- .../render/{vkopainter.cc => vkopainter.cpp} | 0 ...vpainterfactory.cc => vpainterfactory.cpp} | 0 karbon/render/{vqpainter.cc => vqpainter.cpp} | 0 karbon/shapes/Makefile.am | 14 +- karbon/shapes/{vellipse.cc => vellipse.cpp} | 0 karbon/shapes/{vpolygon.cc => vpolygon.cpp} | 0 karbon/shapes/{vpolyline.cc => vpolyline.cpp} | 0 .../shapes/{vrectangle.cc => vrectangle.cpp} | 0 karbon/shapes/{vsinus.cc => vsinus.cpp} | 0 karbon/shapes/{vspiral.cc => vspiral.cpp} | 0 karbon/shapes/{vstar.cc => vstar.cpp} | 0 karbon/tools/Makefile.am | 38 +- karbon/tools/{vcurvefit.cc => vcurvefit.cpp} | 0 .../{vdefaulttools.cc => vdefaulttools.cpp} | 0 .../{vellipsetool.cc => vellipsetool.cpp} | 0 .../{vgradienttool.cc => vgradienttool.cpp} | 0 .../{vpatterntool.cc => vpatterntool.cpp} | 0 .../tools/{vpenciltool.cc => vpenciltool.cpp} | 0 .../{vpolygontool.cc => vpolygontool.cpp} | 0 .../{vpolylinetool.cc => vpolylinetool.cpp} | 0 .../{vrectangletool.cc => vrectangletool.cpp} | 0 .../tools/{vrotatetool.cc => vrotatetool.cpp} | 0 .../{vroundrecttool.cc => vroundrecttool.cpp} | 0 ...electnodestool.cc => vselectnodestool.cpp} | 0 .../tools/{vselecttool.cc => vselecttool.cpp} | 0 .../tools/{vshapetool.cc => vshapetool.cpp} | 0 .../tools/{vsheartool.cc => vsheartool.cpp} | 0 .../tools/{vsinustool.cc => vsinustool.cpp} | 0 .../tools/{vspiraltool.cc => vspiraltool.cpp} | 0 karbon/tools/{vstartool.cc => vstartool.cpp} | 0 karbon/tools/{vtexttool.cc => vtexttool.cpp} | 0 karbon/usablity-review.txt | 2 +- karbon/visitors/Makefile.am | 12 +- ...boundingbox.cc => vcomputeboundingbox.cpp} | 0 .../{vdrawselection.cc => vdrawselection.cpp} | 0 .../{vselectiondesc.cc => vselectiondesc.cpp} | 0 .../{vselectnodes.cc => vselectnodes.cpp} | 0 .../{vselectobjects.cc => vselectobjects.cpp} | 0 ...vtransformnodes.cc => vtransformnodes.cpp} | 0 karbon/{vtool.cc => vtool.cpp} | 0 ...vtoolcontroller.cc => vtoolcontroller.cpp} | 0 karbon/widgets/Makefile.am | 34 +- karbon/widgets/{vcanvas.cc => vcanvas.cpp} | 0 karbon/widgets/vcolorslider.cc | 149 - karbon/widgets/vcolorslider.cpp | 149 + ...enttabwidget.cc => vgradienttabwidget.cpp} | 0 ...vgradientwidget.cc => vgradientwidget.cpp} | 0 karbon/widgets/vreference.cc | 74 - karbon/widgets/vreference.cpp | 74 + karbon/widgets/{vruler.cc => vruler.cpp} | 0 karbon/widgets/vselecttoolbar.cc | 124 - karbon/widgets/vselecttoolbar.cpp | 124 + karbon/widgets/vsmallpreview.cc | 282 - karbon/widgets/vsmallpreview.cpp | 282 + .../{vstatebutton.cc => vstatebutton.cpp} | 0 ...efillpreview.cc => vstrokefillpreview.cpp} | 0 karbon/widgets/{vtoolbox.cc => vtoolbox.cpp} | 0 .../widgets/{vtranslate.cc => vtranslate.cpp} | 0 .../{vtypebuttonbox.cc => vtypebuttonbox.cpp} | 0 kchart/ChangeLog | 182 +- ...rtParamsIface.cc => KChartParamsIface.cpp} | 0 ...KChartViewIface.cc => KChartViewIface.cpp} | 0 kchart/Makefile.am | 62 +- ...csvimportdialog.cc => csvimportdialog.cpp} | 0 kchart/kchartBackgroundPixmapConfigPage.cc | 548 -- kchart/kchartBackgroundPixmapConfigPage.cpp | 548 ++ ...onfigPage.cc => kchartColorConfigPage.cpp} | 0 ...onfigPage.cc => kchartComboConfigPage.cpp} | 0 ...ConfigDialog.cc => kchartConfigDialog.cpp} | 0 kchart/kchartDataConfigPage.cc | 149 - kchart/kchartDataConfigPage.cpp | 149 + ...hartDataEditor.cc => kchartDataEditor.cpp} | 0 ...ConfigPage.cc => kchartFontConfigPage.cpp} | 0 ...ge.cc => kchartHeaderFooterConfigPage.cpp} | 0 ...nfigPage.cc => kchartLegendConfigPage.cpp} | 0 ...nfigPage.cc => kchartLine3dConfigPage.cpp} | 0 ...hartPageLayout.cc => kchartPageLayout.cpp} | 0 ...age.cc => kchartParameter3dConfigPage.cpp} | 0 ...gPage.cc => kchartParameterConfigPage.cpp} | 0 ...ge.cc => kchartParameterPieConfigPage.cpp} | 0 ....cc => kchartParameterPolarConfigPage.cpp} | 0 ...eConfigPage.cc => kchartPieConfigPage.cpp} | 0 ...hartPrinterDlg.cc => kchartPrinterDlg.cpp} | 0 ...hartPage.cc => kchartSubTypeChartPage.cpp} | 0 kchart/{kchartWizard.cc => kchartWizard.cpp} | 0 ...ge.cc => kchartWizardLabelsLegendPage.cpp} | 0 ...=> kchartWizardSelectChartSubTypePage.cpp} | 0 ...cc => kchartWizardSelectChartTypePage.cpp} | 0 kchart/kchartWizardSelectChartTypePage.h | 2 +- ...c => kchartWizardSelectDataFormatPage.cpp} | 0 ...Page.cc => kchartWizardSelectDataPage.cpp} | 0 ...sPage.cc => kchartWizardSetupAxesPage.cpp} | 0 ...aPage.cc => kchartWizardSetupDataPage.cpp} | 0 kchart/kchart_factory.cc | 82 - kchart/kchart_factory.cpp | 82 + ...actory_init.cc => kchart_factory_init.cpp} | 0 .../{kchart_params.cc => kchart_params.cpp} | 0 kchart/{kchart_part.cc => kchart_part.cpp} | 0 kchart/{kchart_view.cc => kchart_view.cpp} | 0 kchart/{main.cc => main.cpp} | 0 kexi/3rdparty/kexisql/Makefile.msvc | 7 +- kexi/3rdparty/kolibs/Makefile.am | 8 +- .../kolibs/{koGlobal.cc => koGlobal.cpp} | 0 ...koPageLayoutDia.cc => koPageLayoutDia.cpp} | 0 .../3rdparty/kolibs/{koUnit.cc => koUnit.cpp} | 0 .../{koUnitWidgets.cc => koUnitWidgets.cpp} | 0 kexi/doc/dev/TODO-Kexi-js | 2 +- .../importexport/csv/kexicsvimportdialog.cpp | 2 +- .../importexport/csv/kexicsvimportdialog.h | 2 +- .../tools/build_tarball/build_kexi_tarball.sh | 2 +- kformula/Makefile.am | 10 +- .../{formulastring.cc => formulastring.cpp} | 0 kformula/{fsparser.cc => fsparser.cpp} | 0 kformula/{kfconfig.cc => kfconfig.cpp} | 0 .../{kformula_doc.cc => kformula_doc.cpp} | 0 ...ormula_factory.cc => kformula_factory.cpp} | 0 .../{kformula_view.cc => kformula_view.cpp} | 0 ..._view_iface.cc => kformula_view_iface.cpp} | 0 .../{kformulawidget.cc => kformulawidget.cpp} | 0 kformula/{main.cc => main.cpp} | 0 .../{KIvioDocIface.cc => KIvioDocIface.cpp} | 0 ...KIvioLayerIface.cc => KIvioLayerIface.cpp} | 0 .../{KIvioMapIface.cc => KIvioMapIface.cpp} | 0 .../{KIvioPageIface.cc => KIvioPageIface.cpp} | 0 ...oStencilIface.cc => KIvioStencilIface.cpp} | 0 .../{KIvioViewIface.cc => KIvioViewIface.cpp} | 0 kivio/kiviopart/Makefile.am | 10 +- .../{kivio_command.cc => kivio_command.cpp} | 0 ...kivio_part_init.cc => kivio_part_init.cpp} | 0 koshell/Makefile.am | 4 +- koshell/{koshell_main.cc => koshell_main.cpp} | 0 .../{koshell_shell.cc => koshell_shell.cpp} | 0 kounavail/Makefile.am | 4 +- kounavail/{kounavail.cc => kounavail.cpp} | 0 kplato/{KPtViewIface.cc => KPtViewIface.cpp} | 0 kplato/Makefile.am | 86 +- kplato/TODO | 2 +- kplato/kplato.tdevelop | 2 +- kplato/{kptaccount.cc => kptaccount.cpp} | 0 ...ccountsdialog.cc => kptaccountsdialog.cpp} | 0 ...taccountspanel.cc => kptaccountspanel.cpp} | 0 ...kptaccountsview.cc => kptaccountsview.cpp} | 0 ...log.cc => kptaccountsviewconfigdialog.cpp} | 0 .../{kptappointment.cc => kptappointment.cpp} | 0 kplato/{kptcalendar.cc => kptcalendar.cpp} | 0 ...kptcalendaredit.cc => kptcalendaredit.cpp} | 0 ...dareditbase.cc => kptcalendareditbase.cpp} | 0 ...istdialog.cc => kptcalendarlistdialog.cpp} | 0 ...gbase.cc => kptcalendarlistdialogbase.cpp} | 0 ...tcalendarpanel.cc => kptcalendarpanel.cpp} | 0 .../{kptcanvasitem.cc => kptcanvasitem.cpp} | 0 kplato/{kptcommand.cc => kptcommand.cpp} | 0 kplato/{kptconfig.cc => kptconfig.cpp} | 0 ...iorpanel.cc => kptconfigbehaviorpanel.cpp} | 0 ...kptconfigdialog.cc => kptconfigdialog.cpp} | 0 kplato/{kptcontext.cc => kptcontext.cpp} | 0 kplato/{kptdatetable.cc => kptdatetable.cpp} | 0 kplato/{kptdatetime.cc => kptdatetime.cpp} | 0 ...tviewbase.cc => kptdoublelistviewbase.cpp} | 0 kplato/{kptduration.cc => kptduration.cpp} | 0 kplato/{kptfactory.cc => kptfactory.cpp} | 0 kplato/{kptganttview.cc => kptganttview.cpp} | 0 ...kptintervaledit.cc => kptintervaledit.cpp} | 0 ...jectdialog.cc => kptmainprojectdialog.cpp} | 0 ...rojectpanel.cc => kptmainprojectpanel.cpp} | 0 ...alog.cc => kptmilestoneprogressdialog.cpp} | 0 ...panel.cc => kptmilestoneprogresspanel.cpp} | 0 kplato/{kptnode.cc => kptnode.cpp} | 0 kplato/{kptpart.cc => kptpart.cpp} | 0 .../{kptpertcanvas.cc => kptpertcanvas.cpp} | 0 kplato/{kptpertview.cc => kptpertview.cpp} | 0 kplato/{kptproject.cc => kptproject.cpp} | 0 ...tprojectdialog.cc => kptprojectdialog.cpp} | 0 kplato/{kptrelation.cc => kptrelation.cpp} | 0 ...elationdialog.cc => kptrelationdialog.cpp} | 0 .../{kptreportview.cc => kptreportview.cpp} | 0 ...spanel.cc => kptrequestresourcespanel.cpp} | 0 kplato/{kptresource.cc => kptresource.cpp} | 0 ...iew.cc => kptresourceappointmentsview.cpp} | 0 ...esourcedialog.cc => kptresourcedialog.cpp} | 0 ...ourcesdialog.cc => kptresourcesdialog.cpp} | 0 ...esourcespanel.cc => kptresourcespanel.cpp} | 0 ...kptresourceview.cc => kptresourceview.cpp} | 0 kplato/{kptschedule.cc => kptschedule.cpp} | 0 ...ialog.cc => kptstandardworktimedialog.cpp} | 0 ...taskdialog.cc => kptsummarytaskdialog.cpp} | 0 ...anel.cc => kptsummarytaskgeneralpanel.cpp} | 0 kplato/{kpttask.cc => kpttask.cpp} | 0 ...ntsview.cc => kpttaskappointmentsview.cpp} | 0 ...ttaskcostpanel.cc => kpttaskcostpanel.cpp} | 0 ...efaultpanel.cc => kpttaskdefaultpanel.cpp} | 0 .../{kpttaskdialog.cc => kpttaskdialog.cpp} | 0 ...eneralpanel.cc => kpttaskgeneralpanel.cpp} | 0 ...essdialog.cc => kpttaskprogressdialog.cpp} | 0 ...gresspanel.cc => kpttaskprogresspanel.cpp} | 0 kplato/{kptview.cc => kptview.cpp} | 0 kplato/kptwbsdefinition.cc | 188 - kplato/kptwbsdefinition.cpp | 188 + ...ondialog.cc => kptwbsdefinitiondialog.cpp} | 0 ...tionpanel.cc => kptwbsdefinitionpanel.cpp} | 0 kplato/{main.cc => main.cpp} | 0 kpresenter/KPrMSPresentationSetup.cpp | 2 +- kpresenter/KPrMarginWidget.cpp | 2 +- kpresenter/KPrSoundPlayer.cpp | 2 +- kpresenter/KPrSoundPlayer.h | 2 +- kpresenter/KPrTextObject.cpp | 2 +- kpresenter/KPrTextProperty.cpp | 2 +- kpresenter/KPrTextProperty.h | 2 +- kpresenter/KPrView.cpp | 2 +- kpresenter/KPrWebPresentation.cpp | 2 +- kspread/CHANGES | 2 +- kspread/DESIGN.html | 6 +- kspread/Doxyfile | 3 +- ...KSpreadAppIface.cc => KSpreadAppIface.cpp} | 0 ...preadCellIface.cc => KSpreadCellIface.cpp} | 0 ...dColumnIface.cc => KSpreadColumnIface.cpp} | 0 ...KSpreadDocIface.cc => KSpreadDocIface.cpp} | 0 ...dLayoutIface.cc => KSpreadLayoutIface.cpp} | 0 ...KSpreadMapIface.cc => KSpreadMapIface.cpp} | 0 ...KSpreadRowIface.cc => KSpreadRowIface.cpp} | 0 ...eadTableIface.cc => KSpreadTableIface.cpp} | 0 ...preadViewIface.cc => KSpreadViewIface.cpp} | 0 kspread/Makefile.am | 46 +- kspread/TODO | 2 +- kspread/{commands.cc => commands.cpp} | 0 kspread/{damages.cc => damages.cpp} | 0 kspread/{dependencies.cc => dependencies.cpp} | 0 kspread/dialogs/Makefile.am | 60 +- ...ead_dlg_angle.cc => kspread_dlg_angle.cpp} | 0 ...pread_dlg_area.cc => kspread_dlg_area.cpp} | 0 ...dlg_comment.cc => kspread_dlg_comment.cpp} | 0 ...itional.cc => kspread_dlg_conditional.cpp} | 0 ...pread_dlg_cons.cc => kspread_dlg_cons.cpp} | 0 ...kspread_dlg_csv.cc => kspread_dlg_csv.cpp} | 0 ...g_database.cc => kspread_dlg_database.cpp} | 0 ...pread_dlg_find.cc => kspread_dlg_find.cpp} | 0 ...d_dlg_format.cc => kspread_dlg_format.cpp} | 0 ...dlg_formula.cc => kspread_dlg_formula.cpp} | 0 ...g_goalseek.cc => kspread_dlg_goalseek.cpp} | 0 ...pread_dlg_goto.cc => kspread_dlg_goto.cpp} | 0 ...d_dlg_insert.cc => kspread_dlg_insert.cpp} | 0 ...d_dlg_layout.cc => kspread_dlg_layout.cpp} | 0 ...pread_dlg_list.cc => kspread_dlg_list.cpp} | 0 ...rlayout.cc => kspread_dlg_paperlayout.cpp} | 0 ...einsert.cc => kspread_dlg_pasteinsert.cpp} | 0 ...eference.cc => kspread_dlg_preference.cpp} | 0 ...reference.cc => kspread_dlg_reference.cpp} | 0 ...dlg_resize2.cc => kspread_dlg_resize2.cpp} | 0 ...d_dlg_series.cc => kspread_dlg_series.cpp} | 0 ...pread_dlg_show.cc => kspread_dlg_show.cpp} | 0 ...owColRow.cc => kspread_dlg_showColRow.cpp} | 0 ...pread_dlg_sort.cc => kspread_dlg_sort.cpp} | 0 ...dlg_special.cc => kspread_dlg_special.cpp} | 0 ...d_dlg_styles.cc => kspread_dlg_styles.cpp} | 0 ...g_subtotal.cc => kspread_dlg_subtotal.cpp} | 0 ...g_validity.cc => kspread_dlg_validity.cpp} | 0 kspread/dialogs/{link.cc => link.cpp} | 0 ...eet_properties.cc => sheet_properties.cpp} | 0 kspread/{digest.cc => digest.cpp} | 0 kspread/{formula.cc => formula.cpp} | 0 kspread/functions.cc | 526 -- kspread/functions.cpp | 526 ++ ...pread_autofill.cc => kspread_autofill.cpp} | 0 .../{kspread_brush.cc => kspread_brush.cpp} | 0 .../{kspread_canvas.cc => kspread_canvas.cpp} | 0 kspread/{kspread_cell.cc => kspread_cell.cpp} | 0 ...kspread_cluster.cc => kspread_cluster.cpp} | 0 ...ead_condition.cc => kspread_condition.cpp} | 0 kspread/{kspread_doc.cc => kspread_doc.cpp} | 0 ...kspread_editors.cc => kspread_editors.cpp} | 0 .../{kspread_events.cc => kspread_events.cpp} | 0 ...kspread_factory.cc => kspread_factory.cpp} | 0 ...ctory_init.cc => kspread_factory_init.cpp} | 0 .../{kspread_format.cc => kspread_format.cpp} | 0 ...on.cc => kspread_functions_conversion.cpp} | 0 ...base.cc => kspread_functions_database.cpp} | 0 ...time.cc => kspread_functions_datetime.cpp} | 0 ...g.cc => kspread_functions_engineering.cpp} | 0 ...ial.cc => kspread_functions_financial.cpp} | 0 ...helper.cc => kspread_functions_helper.cpp} | 0 ...n.cc => kspread_functions_information.cpp} | 0 ...s_logic.cc => kspread_functions_logic.cpp} | 0 ...ons_math.cc => kspread_functions_math.cpp} | 0 ...nce.cc => kspread_functions_reference.cpp} | 0 ...l.cc => kspread_functions_statistical.cpp} | 0 ...ons_text.cc => kspread_functions_text.cpp} | 0 ...ons_trig.cc => kspread_functions_trig.cpp} | 0 ...tyle.cc => kspread_genvalidationstyle.cpp} | 0 ...kspread_handler.cc => kspread_handler.cpp} | 0 .../{kspread_locale.cc => kspread_locale.cpp} | 0 kspread/{kspread_map.cc => kspread_map.cpp} | 0 ...ead_numformat.cc => kspread_numformat.cpp} | 0 .../{kspread_object.cc => kspread_object.cpp} | 0 kspread/{kspread_pen.cc => kspread_pen.cpp} | 0 .../{kspread_sheet.cc => kspread_sheet.cpp} | 0 kspread/kspread_sheet.h | 4 +- kspread/kspread_sheetprint.cc | 1807 ------- kspread/kspread_sheetprint.cpp | 1807 +++++++ .../{kspread_style.cc => kspread_style.cpp} | 0 ...e_manager.cc => kspread_style_manager.cpp} | 0 ...kspread_toolbox.cc => kspread_toolbox.cpp} | 0 kspread/{kspread_undo.cc => kspread_undo.cpp} | 0 kspread/kspread_util.cc | 1218 ----- kspread/kspread_util.cpp | 1218 +++++ .../{kspread_value.cc => kspread_value.cpp} | 0 kspread/{kspread_view.cc => kspread_view.cpp} | 0 kspread/{main.cc => main.cpp} | 0 kspread/{manipulator.cc => manipulator.cpp} | 0 ...nipulator_data.cc => manipulator_data.cpp} | 0 kspread/plugins/insertcalendar/Makefile.am | 6 +- ...og.cc => kspread_insertcalendardialog.cpp} | 0 ...ar.cc => kspread_plugininsertcalendar.cpp} | 0 kspread/plugins/scripting/Makefile.am | 2 +- .../scripting/{scripting.cc => scripting.cpp} | 0 kspread/{region.cc => region.cpp} | 0 kspread/{selection.cc => selection.cpp} | 0 kspread/tests/Makefile.am | 12 +- .../{formula_tester.cc => formula_tester.cpp} | 0 kspread/tests/{inspector.cc => inspector.cpp} | 0 .../{test_formula.cc => test_formula.cpp} | 0 kspread/tests/{tester.cc => tester.cpp} | 0 .../tests/{testrunner.cc => testrunner.cpp} | 0 .../{value_tester.cc => value_tester.cpp} | 0 kspread/{valuecalc.cc => valuecalc.cpp} | 0 .../{valueconverter.cc => valueconverter.cpp} | 0 .../{valueformatter.cc => valueformatter.cpp} | 0 kspread/{valueparser.cc => valueparser.cpp} | 0 kword/DEBUG | 2 +- kword/HACKING | 12 +- kword/KWCommand.cpp | 2 +- kword/KWFrameSet.cpp | 2 +- kword/defs.h | 2 +- kword/mailmerge/KWClassicSerialDataSource.cpp | 2 +- lib/Makefile.am | 8 +- lib/kformula/Makefile.am | 34 +- .../{MatrixDialog.cc => MatrixDialog.cpp} | 0 .../{actionelement.cc => actionelement.cpp} | 0 .../{basicelement.cc => basicelement.cpp} | 0 .../{bracketelement.cc => bracketelement.cpp} | 0 .../{contextstyle.cc => contextstyle.cpp} | 0 ...eationstrategy.cc => creationstrategy.cpp} | 0 .../{elementtype.cc => elementtype.cpp} | 0 .../{encloseelement.cc => encloseelement.cpp} | 0 lib/kformula/{entities.cc => entities.cpp} | 0 .../{errorelement.cc => errorelement.cpp} | 0 lib/kformula/fontstyle.cc | 891 ---- lib/kformula/fontstyle.cpp | 891 ++++ .../{formulacursor.cc => formulacursor.cpp} | 0 .../{formulaelement.cc => formulaelement.cpp} | 0 ...fractionelement.cc => fractionelement.cpp} | 0 .../{glyphelement.cc => glyphelement.cpp} | 0 ...tifierelement.cc => identifierelement.cpp} | 0 .../{indexelement.cc => indexelement.cpp} | 0 ...kformulacommand.cc => kformulacommand.cpp} | 0 ...atibility.cc => kformulacompatibility.cpp} | 0 ...laconfigpage.cc => kformulaconfigpage.cpp} | 0 ...mulacontainer.cc => kformulacontainer.cpp} | 0 ...ormuladocument.cc => kformuladocument.cpp} | 0 ...inputfilter.cc => kformulainputfilter.cpp} | 0 ...lamathmlread.cc => kformulamathmlread.cpp} | 0 ...lamimesource.cc => kformulamimesource.cpp} | 0 .../{kformulaview.cc => kformulaview.cpp} | 0 .../{kformulawidget.cc => kformulawidget.cpp} | 0 lib/kformula/{main.cc => main.cpp} | 0 .../{matrixelement.cc => matrixelement.cpp} | 0 .../{numberelement.cc => numberelement.cpp} | 0 ...nstrategy.cc => oasiscreationstrategy.cpp} | 0 ...ordictionary.cc => operatordictionary.cpp} | 0 ...operatorelement.cc => operatorelement.cpp} | 0 .../{paddedelement.cc => paddedelement.cpp} | 0 .../{phantomelement.cc => phantomelement.cpp} | 0 lib/kformula/prototype/gensymbolfontmap.py | 8 +- .../{rootelement.cc => rootelement.cpp} | 0 lib/kformula/scripts/bynames.py | 2 +- lib/kformula/scripts/oper-dict.py | 2 +- ...sequenceelement.cc => sequenceelement.cpp} | 0 .../{sequenceparser.cc => sequenceparser.cpp} | 0 .../{spaceelement.cc => spaceelement.cpp} | 0 .../{stringelement.cc => stringelement.cpp} | 0 .../{styleelement.cc => styleelement.cpp} | 0 .../{symbolaction.cc => symbolaction.cpp} | 0 .../{symbolelement.cc => symbolelement.cpp} | 0 ...olfontmapping.cc => symbolfontmapping.cpp} | 0 lib/kformula/symboltable.cc | 152 - lib/kformula/symboltable.cpp | 152 + .../{textelement.cc => textelement.cpp} | 0 .../{tokenelement.cc => tokenelement.cpp} | 0 ...nstyleelement.cc => tokenstyleelement.cpp} | 0 .../{unicodetable.cc => unicodetable.cpp} | 0 ...icationIface.cc => KoApplicationIface.cpp} | 0 lib/kofficecore/KoDocument.cpp | 4 +- lib/kofficecore/KoDocumentChild.cpp | 2 +- ...KoDocumentIface.cc => KoDocumentIface.cpp} | 0 lib/kofficecore/KoMainWindowIface.cc | 65 - lib/kofficecore/KoMainWindowIface.cpp | 65 + lib/kofficecore/KoViewIface.cc | 76 - lib/kofficecore/KoViewIface.cpp | 76 + lib/kofficecore/Makefile.am | 6 +- .../{kofficeversion.cc => kofficeversion.cpp} | 0 lib/kofficeui/KoImageResource.cpp | 2 +- lib/kopainter/Makefile.am | 24 +- lib/kopainter/{koColor.cc => koColor.cpp} | 0 .../{koColorChooser.cc => koColorChooser.cpp} | 0 .../{koColorSlider.cc => koColorSlider.cpp} | 0 .../{koFrameButton.cc => koFrameButton.cpp} | 0 .../{koIconChooser.cc => koIconChooser.cpp} | 0 .../{ko_cmyk_widget.cc => ko_cmyk_widget.cpp} | 0 .../{ko_color_wheel.cc => ko_color_wheel.cpp} | 0 .../{ko_gray_widget.cc => ko_gray_widget.cpp} | 0 .../{ko_hsv_widget.cc => ko_hsv_widget.cpp} | 0 .../{ko_rgb_widget.cc => ko_rgb_widget.cpp} | 0 ...adientmanager.cc => kogradientmanager.cpp} | 0 .../{svgpathparser.cc => svgpathparser.cpp} | 0 lib/kopalette/Makefile.am | 8 +- lib/kopalette/{kopalette.cc => kopalette.cpp} | 0 ...palettemanager.cc => kopalettemanager.cpp} | 0 .../{kotabpalette.cc => kotabpalette.cpp} | 0 ...toolboxpalette.cc => kotoolboxpalette.cpp} | 0 lib/kotext/KoRichText.cpp | 2 +- lib/kotext/KoTextFormatter.cpp | 2 +- lib/kotext/KoTextParag.h | 2 +- ...KoTextViewIface.cc => KoTextViewIface.cpp} | 0 lib/kotext/Makefile.am | 2 +- lib/kotext/tests/kotextformattertest.cpp | 2 +- lib/kross/python/cxx/{Config.hxx => Config.h} | 0 lib/kross/python/cxx/Exception.h | 212 + lib/kross/python/cxx/Exception.hxx | 212 - lib/kross/python/cxx/Extensions.h | 756 +++ lib/kross/python/cxx/Extensions.hxx | 756 --- .../python/cxx/IndirectPythonInterface.cpp | 550 ++ .../python/cxx/IndirectPythonInterface.cxx | 550 -- .../python/cxx/IndirectPythonInterface.h | 156 + .../python/cxx/IndirectPythonInterface.hxx | 156 - lib/kross/python/cxx/Makefile.am | 6 +- lib/kross/python/cxx/Objects.h | 2804 ++++++++++ lib/kross/python/cxx/Objects.hxx | 2804 ---------- lib/kross/python/cxx/PyCXX.html | 26 +- lib/kross/python/cxx/README.html | 22 +- lib/kross/python/cxx/cxx_extensions.cpp | 1287 +++++ lib/kross/python/cxx/cxx_extensions.cxx | 1287 ----- lib/kross/python/cxx/cxxsupport.cpp | 142 + lib/kross/python/cxx/cxxsupport.cxx | 142 - lib/kross/python/pythonconfig.h | 6 +- lib/kwmf/Makefile.am | 4 +- lib/kwmf/{kowmfpaint.cc => kowmfpaint.cpp} | 0 lib/kwmf/{kowmfread.cc => kowmfread.cpp} | 0 ...wmfreadprivate.cc => kowmfreadprivate.cpp} | 0 lib/kwmf/{kowmfstack.cc => kowmfstack.cpp} | 0 lib/kwmf/{kowmfwrite.cc => kowmfwrite.cpp} | 0 lib/kwmf/{kwmf.cc => kwmf.cpp} | 0 lib/kwmf/{qwmf.cc => qwmf.cpp} | 0 tools/converter/koconverter.cpp | 2 +- tools/kthesaurus/Makefile.am | 4 +- tools/kthesaurus/main.cc | 87 - tools/kthesaurus/main.cpp | 87 + tools/spell/Makefile.am | 2 +- tools/spell/{main.cc => main.cpp} | 0 tools/thesaurus/Makefile.am | 4 +- tools/thesaurus/main.cc | 817 --- tools/thesaurus/main.cpp | 817 +++ 1529 files changed, 94813 insertions(+), 94819 deletions(-) delete mode 100644 chalk/chalk_part_init.cc create mode 100644 chalk/chalk_part_init.cpp rename chalk/chalkcolor/colorspaces/{kis_alpha_colorspace.cc => kis_alpha_colorspace.cpp} (100%) rename chalk/chalkcolor/colorspaces/{kis_lab_colorspace.cc => kis_lab_colorspace.cpp} (100%) rename chalk/chalkcolor/colorspaces/{kis_xyz_colorspace.cc => kis_xyz_colorspace.cpp} (100%) rename chalk/chalkcolor/{kis_abstract_colorspace.cc => kis_abstract_colorspace.cpp} (100%) rename chalk/chalkcolor/{kis_basic_histogram_producers.cc => kis_basic_histogram_producers.cpp} (100%) rename chalk/chalkcolor/{kis_color.cc => kis_color.cpp} (100%) rename chalk/chalkcolor/{kis_color_conversions.cc => kis_color_conversions.cpp} (100%) rename chalk/chalkcolor/{kis_colorspace.cc => kis_colorspace.cpp} (100%) rename chalk/chalkcolor/{kis_colorspace_factory_registry.cc => kis_colorspace_factory_registry.cpp} (100%) rename chalk/chalkcolor/{kis_colorspace_iface.cc => kis_colorspace_iface.cpp} (100%) rename chalk/chalkcolor/{kis_composite_op.cc => kis_composite_op.cpp} (100%) rename chalk/chalkcolor/{kis_f16half_base_colorspace.cc => kis_f16half_base_colorspace.cpp} (100%) rename chalk/chalkcolor/{kis_f32_base_colorspace.cc => kis_f32_base_colorspace.cpp} (100%) rename chalk/chalkcolor/{kis_histogram_producer.cc => kis_histogram_producer.cpp} (100%) delete mode 100644 chalk/chalkcolor/kis_profile.cc create mode 100644 chalk/chalkcolor/kis_profile.cpp rename chalk/chalkcolor/{kis_u16_base_colorspace.cc => kis_u16_base_colorspace.cpp} (100%) rename chalk/chalkcolor/{kis_u8_base_colorspace.cc => kis_u8_base_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cc create mode 100644 chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cpp rename chalk/colorspaces/cmyk_u16/{kis_cmyk_u16_colorspace.cc => kis_cmyk_u16_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/cmyk_u8/cmyk_plugin.cc create mode 100644 chalk/colorspaces/cmyk_u8/cmyk_plugin.cpp rename chalk/colorspaces/cmyk_u8/{kis_cmyk_colorspace.cc => kis_cmyk_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/gray_u16/gray_u16_plugin.cc create mode 100644 chalk/colorspaces/gray_u16/gray_u16_plugin.cpp rename chalk/colorspaces/gray_u16/{kis_gray_u16_colorspace.cc => kis_gray_u16_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/gray_u8/gray_plugin.cc create mode 100644 chalk/colorspaces/gray_u8/gray_plugin.cpp rename chalk/colorspaces/gray_u8/{kis_gray_colorspace.cc => kis_gray_colorspace.cpp} (100%) rename chalk/colorspaces/lms_f32/{kis_lms_f32_colorspace.cc => kis_lms_f32_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/lms_f32/lms_f32_plugin.cc create mode 100644 chalk/colorspaces/lms_f32/lms_f32_plugin.cpp rename chalk/colorspaces/rgb_f16half/{kis_rgb_f16half_colorspace.cc => kis_rgb_f16half_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cc create mode 100644 chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cpp rename chalk/colorspaces/rgb_f16half/tests/{kis_rgb_f16half_colorspace_tester.cc => kis_rgb_f16half_colorspace_tester.cpp} (100%) rename chalk/colorspaces/rgb_f32/{kis_rgb_f32_colorspace.cc => kis_rgb_f32_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/rgb_f32/rgb_f32_plugin.cc create mode 100644 chalk/colorspaces/rgb_f32/rgb_f32_plugin.cpp rename chalk/colorspaces/rgb_f32/tests/{kis_strategy_colorspace_rgb_f32_tester.cc => kis_strategy_colorspace_rgb_f32_tester.cpp} (100%) rename chalk/colorspaces/rgb_u16/{kis_rgb_u16_colorspace.cc => kis_rgb_u16_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc create mode 100644 chalk/colorspaces/rgb_u16/rgb_u16_plugin.cpp rename chalk/colorspaces/rgb_u16/tests/{kis_strategy_colorspace_rgb_u16_tester.cc => kis_strategy_colorspace_rgb_u16_tester.cpp} (100%) rename chalk/colorspaces/rgb_u8/{kis_rgb_colorspace.cc => kis_rgb_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/rgb_u8/rgb_plugin.cc create mode 100644 chalk/colorspaces/rgb_u8/rgb_plugin.cpp delete mode 100644 chalk/colorspaces/wet/kis_texture_filter.cc create mode 100644 chalk/colorspaces/wet/kis_texture_filter.cpp rename chalk/colorspaces/wet/{kis_texture_painter.cc => kis_texture_painter.cpp} (100%) rename chalk/colorspaces/wet/{kis_wet_colorspace.cc => kis_wet_colorspace.cpp} (100%) rename chalk/colorspaces/wet/{kis_wet_palette_widget.cc => kis_wet_palette_widget.cpp} (100%) delete mode 100644 chalk/colorspaces/wet/kis_wetness_visualisation_filter.cc create mode 100644 chalk/colorspaces/wet/kis_wetness_visualisation_filter.cpp rename chalk/colorspaces/wet/{kis_wetop.cc => kis_wetop.cpp} (100%) delete mode 100644 chalk/colorspaces/wet/wet_plugin.cc create mode 100644 chalk/colorspaces/wet/wet_plugin.cpp rename chalk/colorspaces/wet/{wetphysicsfilter.cc => wetphysicsfilter.cpp} (100%) rename chalk/colorspaces/wetsticky/brushop/{kis_wsbrushop.cc => kis_wsbrushop.cpp} (100%) delete mode 100644 chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc create mode 100644 chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp rename chalk/colorspaces/wetsticky/{kis_wet_sticky_colorspace.cc => kis_wet_sticky_colorspace.cpp} (100%) rename chalk/colorspaces/wetsticky/{kis_ws_engine_filter.cc => kis_ws_engine_filter.cpp} (100%) delete mode 100644 chalk/colorspaces/wetsticky/wet_sticky_plugin.cc create mode 100644 chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp rename chalk/colorspaces/ycbcr_u16/{kis_ycbcr_u16_colorspace.cc => kis_ycbcr_u16_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cc create mode 100644 chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cpp rename chalk/colorspaces/ycbcr_u8/{kis_ycbcr_u8_colorspace.cc => kis_ycbcr_u8_colorspace.cpp} (100%) delete mode 100644 chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc create mode 100644 chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cpp rename chalk/core/{kis_adjustment_layer.cc => kis_adjustment_layer.cpp} (100%) rename chalk/core/{kis_alpha_mask.cc => kis_alpha_mask.cpp} (100%) rename chalk/core/{kis_autobrush_resource.cc => kis_autobrush_resource.cpp} (100%) delete mode 100644 chalk/core/kis_autogradient_resource.cc create mode 100644 chalk/core/kis_autogradient_resource.cpp rename chalk/core/{kis_background.cc => kis_background.cpp} (100%) rename chalk/core/{kis_boundary.cc => kis_boundary.cpp} (100%) rename chalk/core/{kis_brush.cc => kis_brush.cpp} (100%) rename chalk/core/{kis_command.cc => kis_command.cpp} (100%) rename chalk/core/{kis_convolution_painter.cc => kis_convolution_painter.cpp} (100%) rename chalk/core/{kis_exif_info.cc => kis_exif_info.cpp} (100%) rename chalk/core/{kis_exif_value.cc => kis_exif_value.cpp} (100%) rename chalk/core/{kis_fill_painter.cc => kis_fill_painter.cpp} (100%) rename chalk/core/{kis_filter.cc => kis_filter.cpp} (100%) rename chalk/core/{kis_filter_config_widget.cc => kis_filter_config_widget.cpp} (100%) rename chalk/core/{kis_filter_configuration.cc => kis_filter_configuration.cpp} (100%) rename chalk/core/{kis_filter_registry.cc => kis_filter_registry.cpp} (100%) rename chalk/core/{kis_filter_strategy.cc => kis_filter_strategy.cpp} (100%) delete mode 100644 chalk/core/kis_gradient.cc create mode 100644 chalk/core/kis_gradient.cpp rename chalk/core/{kis_gradient_painter.cc => kis_gradient_painter.cpp} (100%) rename chalk/core/{kis_group_layer.cc => kis_group_layer.cpp} (100%) rename chalk/core/{kis_histogram.cc => kis_histogram.cpp} (100%) rename chalk/core/{kis_image.cc => kis_image.cpp} (100%) rename chalk/core/{kis_image_iface.cc => kis_image_iface.cpp} (100%) rename chalk/core/{kis_imagepipe_brush.cc => kis_imagepipe_brush.cpp} (100%) rename chalk/core/{kis_iterator.cc => kis_iterator.cpp} (100%) rename chalk/core/{kis_iterators_pixel.cc => kis_iterators_pixel.cpp} (100%) rename chalk/core/{kis_layer.cc => kis_layer.cpp} (100%) rename chalk/core/{kis_meta_registry.cc => kis_meta_registry.cpp} (100%) rename chalk/core/{kis_nameserver.cc => kis_nameserver.cpp} (100%) rename chalk/core/{kis_paint_device.cc => kis_paint_device.cpp} (100%) rename chalk/core/{kis_paint_device_iface.cc => kis_paint_device_iface.cpp} (100%) rename chalk/core/{kis_paint_layer.cc => kis_paint_layer.cpp} (100%) rename chalk/core/{kis_painter.cc => kis_painter.cpp} (100%) rename chalk/core/{kis_paintop.cc => kis_paintop.cpp} (100%) rename chalk/core/{kis_paintop_registry.cc => kis_paintop_registry.cpp} (100%) rename chalk/core/{kis_palette.cc => kis_palette.cpp} (100%) delete mode 100644 chalk/core/kis_pattern.cc create mode 100644 chalk/core/kis_pattern.cpp rename chalk/core/{kis_rect.cc => kis_rect.cpp} (100%) rename chalk/core/{kis_resource.cc => kis_resource.cpp} (100%) rename chalk/core/{kis_rotate_visitor.cc => kis_rotate_visitor.cpp} (100%) rename chalk/core/{kis_scale_visitor.cc => kis_scale_visitor.cpp} (100%) rename chalk/core/{kis_selected_transaction.cc => kis_selected_transaction.cpp} (100%) rename chalk/core/{kis_selection.cc => kis_selection.cpp} (100%) rename chalk/core/{kis_strategy_move.cc => kis_strategy_move.cpp} (100%) rename chalk/core/{kis_thread_pool.cc => kis_thread_pool.cpp} (100%) rename chalk/core/{kis_transaction.cc => kis_transaction.cpp} (100%) rename chalk/core/{kis_transform_worker.cc => kis_transform_worker.cpp} (100%) delete mode 100644 chalk/core/kis_vec.cc create mode 100644 chalk/core/kis_vec.cpp rename chalk/core/tests/{kis_filter_configuration_tester.cc => kis_filter_configuration_tester.cpp} (100%) rename chalk/core/tiles/{kis_memento.cc => kis_memento.cpp} (100%) rename chalk/core/tiles/{kis_tile.cc => kis_tile.cpp} (100%) rename chalk/core/tiles/{kis_tiled_random_accessor.cc => kis_tiled_random_accessor.cpp} (100%) rename chalk/core/tiles/{kis_tileddatamanager.cc => kis_tileddatamanager.cpp} (100%) rename chalk/core/tiles/{kis_tiledhlineiterator.cc => kis_tiledhlineiterator.cpp} (100%) rename chalk/core/tiles/{kis_tilediterator.cc => kis_tilediterator.cpp} (100%) rename chalk/core/tiles/{kis_tiledrectiterator.cc => kis_tiledrectiterator.cpp} (100%) rename chalk/core/tiles/{kis_tiledvlineiterator.cc => kis_tiledvlineiterator.cpp} (100%) rename chalk/core/tiles/{kis_tilemanager.cc => kis_tilemanager.cpp} (100%) delete mode 100644 chalk/main.cc create mode 100644 chalk/main.cpp rename chalk/plugins/filters/blur/{blur.cc => blur.cpp} (100%) rename chalk/plugins/filters/blur/{kis_blur_filter.cc => kis_blur_filter.cpp} (100%) rename chalk/plugins/filters/blur/{kis_wdg_blur.cc => kis_wdg_blur.cpp} (100%) rename chalk/plugins/filters/bumpmap/{bumpmap.cc => bumpmap.cpp} (100%) rename chalk/plugins/filters/cimg/{kis_cimg_filter.cc => kis_cimg_filter.cpp} (100%) rename chalk/plugins/filters/cimg/{kis_cimg_plugin.cc => kis_cimg_plugin.cpp} (100%) rename chalk/plugins/filters/cimg/{kis_cimgconfig_widget.cc => kis_cimgconfig_widget.cpp} (100%) rename chalk/plugins/filters/colors/{colors.cc => colors.cpp} (100%) rename chalk/plugins/filters/colors/{kis_color_to_alpha.cc => kis_color_to_alpha.cpp} (100%) rename chalk/plugins/filters/colors/{kis_minmax_filters.cc => kis_minmax_filters.cpp} (100%) rename chalk/plugins/filters/colors/{kis_wdg_color_to_alpha.cc => kis_wdg_color_to_alpha.cpp} (100%) rename chalk/plugins/filters/colorsfilters/{colorsfilters.cc => colorsfilters.cpp} (100%) rename chalk/plugins/filters/colorsfilters/{kis_brightness_contrast_filter.cc => kis_brightness_contrast_filter.cpp} (100%) rename chalk/plugins/filters/colorsfilters/{kis_perchannel_filter.cc => kis_perchannel_filter.cpp} (100%) rename chalk/plugins/filters/convolutionfilters/{convolutionfilters.cc => convolutionfilters.cpp} (100%) rename chalk/plugins/filters/convolutionfilters/{kis_convolution_filter.cc => kis_convolution_filter.cpp} (100%) rename chalk/plugins/filters/convolutionfilters/{kis_custom_convolution_filter.cc => kis_custom_convolution_filter.cpp} (100%) rename chalk/plugins/filters/convolutionfilters/{kis_custom_convolution_filter_configuration_widget.cc => kis_custom_convolution_filter_configuration_widget.cpp} (100%) rename chalk/plugins/filters/cubismfilter/{kis_cubism_filter.cc => kis_cubism_filter.cpp} (100%) rename chalk/plugins/filters/cubismfilter/{kis_cubism_filter_plugin.cc => kis_cubism_filter_plugin.cpp} (100%) rename chalk/plugins/filters/cubismfilter/{kis_polygon.cc => kis_polygon.cpp} (100%) rename chalk/plugins/filters/embossfilter/{kis_emboss_filter.cc => kis_emboss_filter.cpp} (100%) rename chalk/plugins/filters/embossfilter/{kis_emboss_filter_plugin.cc => kis_emboss_filter_plugin.cpp} (100%) rename chalk/plugins/filters/example/{example.cc => example.cpp} (100%) rename chalk/plugins/filters/fastcolortransfer/{fastcolortransfer.cc => fastcolortransfer.cpp} (100%) rename chalk/plugins/filters/lenscorrectionfilter/{lenscorrectionfilter.cc => lenscorrectionfilter.cpp} (100%) rename chalk/plugins/filters/levelfilter/{kgradientslider.cc => kgradientslider.cpp} (100%) rename chalk/plugins/filters/levelfilter/{kis_level_filter.cc => kis_level_filter.cpp} (100%) rename chalk/plugins/filters/levelfilter/{levelfilter.cc => levelfilter.cpp} (100%) rename chalk/plugins/filters/noisefilter/{noisefilter.cc => noisefilter.cpp} (100%) rename chalk/plugins/filters/oilpaintfilter/{kis_oilpaint_filter.cc => kis_oilpaint_filter.cpp} (100%) rename chalk/plugins/filters/oilpaintfilter/{kis_oilpaint_filter_plugin.cc => kis_oilpaint_filter_plugin.cpp} (100%) rename chalk/plugins/filters/pixelizefilter/{kis_pixelize_filter.cc => kis_pixelize_filter.cpp} (100%) rename chalk/plugins/filters/pixelizefilter/{kis_pixelize_filter_plugin.cc => kis_pixelize_filter_plugin.cpp} (100%) rename chalk/plugins/filters/raindropsfilter/{kis_raindrops_filter.cc => kis_raindrops_filter.cpp} (100%) rename chalk/plugins/filters/raindropsfilter/{kis_raindrops_filter_plugin.cc => kis_raindrops_filter_plugin.cpp} (100%) rename chalk/plugins/filters/randompickfilter/{randompickfilter.cc => randompickfilter.cpp} (100%) rename chalk/plugins/filters/roundcorners/{kis_round_corners_filter.cc => kis_round_corners_filter.cpp} (100%) rename chalk/plugins/filters/roundcorners/{kis_round_corners_filter_plugin.cc => kis_round_corners_filter_plugin.cpp} (100%) rename chalk/plugins/filters/smalltilesfilter/{kis_small_tiles_filter.cc => kis_small_tiles_filter.cpp} (100%) rename chalk/plugins/filters/smalltilesfilter/{kis_small_tiles_filter_plugin.cc => kis_small_tiles_filter_plugin.cpp} (100%) rename chalk/plugins/filters/sobelfilter/{kis_sobel_filter.cc => kis_sobel_filter.cpp} (100%) rename chalk/plugins/filters/sobelfilter/{kis_sobel_filter_plugin.cc => kis_sobel_filter_plugin.cpp} (100%) rename chalk/plugins/filters/threadtest/{threadtest.cc => threadtest.cpp} (100%) rename chalk/plugins/filters/unsharp/{kis_unsharp_filter.cc => kis_unsharp_filter.cpp} (100%) rename chalk/plugins/filters/unsharp/{kis_wdg_unsharp.cc => kis_wdg_unsharp.cpp} (100%) rename chalk/plugins/filters/unsharp/{unsharp.cc => unsharp.cpp} (100%) rename chalk/plugins/filters/wavefilter/{wavefilter.cc => wavefilter.cpp} (100%) delete mode 100644 chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cc create mode 100644 chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cpp rename chalk/plugins/paintops/defaultpaintops/{kis_airbrushop.cc => kis_airbrushop.cpp} (100%) rename chalk/plugins/paintops/defaultpaintops/{kis_brushop.cc => kis_brushop.cpp} (100%) rename chalk/plugins/paintops/defaultpaintops/{kis_convolveop.cc => kis_convolveop.cpp} (100%) rename chalk/plugins/paintops/defaultpaintops/{kis_duplicateop.cc => kis_duplicateop.cpp} (100%) rename chalk/plugins/paintops/defaultpaintops/{kis_eraseop.cc => kis_eraseop.cpp} (100%) rename chalk/plugins/paintops/defaultpaintops/{kis_penop.cc => kis_penop.cpp} (100%) rename chalk/plugins/paintops/defaultpaintops/{kis_smudgeop.cc => kis_smudgeop.cpp} (100%) delete mode 100644 chalk/plugins/tools/defaulttools/default_tools.cc create mode 100644 chalk/plugins/tools/defaulttools/default_tools.cpp delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_brush.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_brush.cpp rename chalk/plugins/tools/defaulttools/{kis_tool_colorpicker.cc => kis_tool_colorpicker.cpp} (100%) delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_duplicate.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_duplicate.cpp delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_ellipse.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_ellipse.cpp delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_fill.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_fill.cpp delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_gradient.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_gradient.cpp delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_line.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_line.cpp rename chalk/plugins/tools/defaulttools/{kis_tool_move.cc => kis_tool_move.cpp} (100%) rename chalk/plugins/tools/defaulttools/{kis_tool_pan.cc => kis_tool_pan.cpp} (100%) delete mode 100644 chalk/plugins/tools/defaulttools/kis_tool_rectangle.cc create mode 100644 chalk/plugins/tools/defaulttools/kis_tool_rectangle.cpp rename chalk/plugins/tools/defaulttools/{kis_tool_text.cc => kis_tool_text.cpp} (100%) rename chalk/plugins/tools/defaulttools/{kis_tool_zoom.cc => kis_tool_zoom.cpp} (100%) rename chalk/plugins/tools/selectiontools/{kis_tool_move_selection.cc => kis_tool_move_selection.cpp} (100%) delete mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_brush.cpp rename chalk/plugins/tools/selectiontools/{kis_tool_select_contiguous.cc => kis_tool_select_contiguous.cpp} (100%) delete mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cpp delete mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cpp rename chalk/plugins/tools/selectiontools/{kis_tool_select_outline.cc => kis_tool_select_outline.cpp} (100%) rename chalk/plugins/tools/selectiontools/{kis_tool_select_polygonal.cc => kis_tool_select_polygonal.cpp} (100%) delete mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cpp delete mode 100644 chalk/plugins/tools/selectiontools/selection_tools.cc create mode 100644 chalk/plugins/tools/selectiontools/selection_tools.cpp delete mode 100644 chalk/plugins/tools/tool_crop/kis_tool_crop.cc create mode 100644 chalk/plugins/tools/tool_crop/kis_tool_crop.cpp delete mode 100644 chalk/plugins/tools/tool_crop/tool_crop.cc create mode 100644 chalk/plugins/tools/tool_crop/tool_crop.cpp rename chalk/plugins/tools/tool_curves/{kis_curve_framework.cc => kis_curve_framework.cpp} (100%) delete mode 100644 chalk/plugins/tools/tool_curves/kis_tool_bezier.cc create mode 100644 chalk/plugins/tools/tool_curves/kis_tool_bezier.cpp delete mode 100644 chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cc create mode 100644 chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cpp delete mode 100644 chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cc create mode 100644 chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cpp delete mode 100644 chalk/plugins/tools/tool_curves/kis_tool_curve.cc create mode 100644 chalk/plugins/tools/tool_curves/kis_tool_curve.cpp delete mode 100644 chalk/plugins/tools/tool_curves/kis_tool_example.cc create mode 100644 chalk/plugins/tools/tool_curves/kis_tool_example.cpp delete mode 100644 chalk/plugins/tools/tool_curves/kis_tool_moutline.cc create mode 100644 chalk/plugins/tools/tool_curves/kis_tool_moutline.cpp delete mode 100644 chalk/plugins/tools/tool_curves/tool_curves.cc create mode 100644 chalk/plugins/tools/tool_curves/tool_curves.cpp rename chalk/plugins/tools/tool_filter/{kis_filterop.cc => kis_filterop.cpp} (100%) delete mode 100644 chalk/plugins/tools/tool_filter/kis_tool_filter.cc create mode 100644 chalk/plugins/tools/tool_filter/kis_tool_filter.cpp delete mode 100644 chalk/plugins/tools/tool_filter/tool_filter.cc create mode 100644 chalk/plugins/tools/tool_filter/tool_filter.cpp delete mode 100644 chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc create mode 100644 chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cpp delete mode 100644 chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc create mode 100644 chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cpp delete mode 100644 chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cc create mode 100644 chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cpp delete mode 100644 chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cc create mode 100644 chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cpp delete mode 100644 chalk/plugins/tools/tool_polygon/kis_tool_polygon.cc create mode 100644 chalk/plugins/tools/tool_polygon/kis_tool_polygon.cpp delete mode 100644 chalk/plugins/tools/tool_polygon/tool_polygon.cc create mode 100644 chalk/plugins/tools/tool_polygon/tool_polygon.cpp delete mode 100644 chalk/plugins/tools/tool_polyline/kis_tool_polyline.cc create mode 100644 chalk/plugins/tools/tool_polyline/kis_tool_polyline.cpp delete mode 100644 chalk/plugins/tools/tool_polyline/tool_polyline.cc create mode 100644 chalk/plugins/tools/tool_polyline/tool_polyline.cpp rename chalk/plugins/tools/tool_selectsimilar/{kis_tool_selectsimilar.cc => kis_tool_selectsimilar.cpp} (100%) rename chalk/plugins/tools/tool_selectsimilar/{selectsimilar.cc => selectsimilar.cpp} (100%) delete mode 100644 chalk/plugins/tools/tool_star/kis_tool_star.cc create mode 100644 chalk/plugins/tools/tool_star/kis_tool_star.cpp delete mode 100644 chalk/plugins/tools/tool_star/tool_star.cc create mode 100644 chalk/plugins/tools/tool_star/tool_star.cpp delete mode 100644 chalk/plugins/tools/tool_transform/kis_tool_transform.cc create mode 100644 chalk/plugins/tools/tool_transform/kis_tool_transform.cpp delete mode 100644 chalk/plugins/tools/tool_transform/tool_transform.cc create mode 100644 chalk/plugins/tools/tool_transform/tool_transform.cpp rename chalk/plugins/viewplugins/colorrange/{colorrange.cc => colorrange.cpp} (100%) delete mode 100644 chalk/plugins/viewplugins/colorrange/dlg_colorrange.cc create mode 100644 chalk/plugins/viewplugins/colorrange/dlg_colorrange.cpp delete mode 100644 chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cc create mode 100644 chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cpp delete mode 100644 chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cc create mode 100644 chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cpp delete mode 100644 chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cc create mode 100644 chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cpp rename chalk/plugins/viewplugins/dropshadow/{kis_dropshadow.cc => kis_dropshadow.cpp} (100%) rename chalk/plugins/viewplugins/dropshadow/{kis_dropshadow_plugin.cc => kis_dropshadow_plugin.cpp} (100%) rename chalk/plugins/viewplugins/filtersgallery/{filters_gallery.cc => filters_gallery.cpp} (100%) rename chalk/plugins/viewplugins/filtersgallery/{kis_dlg_filtersgallery.cc => kis_dlg_filtersgallery.cpp} (100%) delete mode 100644 chalk/plugins/viewplugins/histogram/dlg_histogram.cc create mode 100644 chalk/plugins/viewplugins/histogram/dlg_histogram.cpp rename chalk/plugins/viewplugins/histogram/{histogram.cc => histogram.cpp} (100%) rename chalk/plugins/viewplugins/histogram/{kis_histogram_widget.cc => kis_histogram_widget.cpp} (100%) rename chalk/plugins/viewplugins/histogram_docker/{histogramdocker.cc => histogramdocker.cpp} (100%) rename chalk/plugins/viewplugins/histogram_docker/{kis_accumulating_producer.cc => kis_accumulating_producer.cpp} (100%) rename chalk/plugins/viewplugins/histogram_docker/{kis_cachedhistogram.cc => kis_cachedhistogram.cpp} (100%) rename chalk/plugins/viewplugins/histogram_docker/{kis_imagerasteredcache.cc => kis_imagerasteredcache.cpp} (100%) rename chalk/plugins/viewplugins/history_docker/{historydocker.cc => historydocker.cpp} (100%) delete mode 100644 chalk/plugins/viewplugins/imagesize/dlg_imagesize.cc create mode 100644 chalk/plugins/viewplugins/imagesize/dlg_imagesize.cpp delete mode 100644 chalk/plugins/viewplugins/imagesize/dlg_layersize.cc create mode 100644 chalk/plugins/viewplugins/imagesize/dlg_layersize.cpp delete mode 100644 chalk/plugins/viewplugins/imagesize/imagesize.cc create mode 100644 chalk/plugins/viewplugins/imagesize/imagesize.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/modify_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/modify_selection.cpp delete mode 100644 chalk/plugins/viewplugins/performancetest/dlg_perftest.cc create mode 100644 chalk/plugins/viewplugins/performancetest/dlg_perftest.cpp delete mode 100644 chalk/plugins/viewplugins/performancetest/perftest.cc create mode 100644 chalk/plugins/viewplugins/performancetest/perftest.cpp delete mode 100644 chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cc create mode 100644 chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cpp delete mode 100644 chalk/plugins/viewplugins/rotateimage/rotateimage.cc create mode 100644 chalk/plugins/viewplugins/rotateimage/rotateimage.cpp rename chalk/plugins/viewplugins/scripting/{scripting.cc => scripting.cpp} (100%) rename chalk/plugins/viewplugins/selectopaque/{selectopaque.cc => selectopaque.cpp} (100%) delete mode 100644 chalk/plugins/viewplugins/separate_channels/dlg_separate.cc create mode 100644 chalk/plugins/viewplugins/separate_channels/dlg_separate.cpp rename chalk/plugins/viewplugins/separate_channels/{kis_channel_separator.cc => kis_channel_separator.cpp} (100%) rename chalk/plugins/viewplugins/separate_channels/{kis_separate_channels_plugin.cc => kis_separate_channels_plugin.cpp} (100%) delete mode 100644 chalk/plugins/viewplugins/shearimage/dlg_shearimage.cc create mode 100644 chalk/plugins/viewplugins/shearimage/dlg_shearimage.cpp delete mode 100644 chalk/plugins/viewplugins/shearimage/shearimage.cc create mode 100644 chalk/plugins/viewplugins/shearimage/shearimage.cpp delete mode 100644 chalk/plugins/viewplugins/substrate/dlg_substrate.cc create mode 100644 chalk/plugins/viewplugins/substrate/dlg_substrate.cpp rename chalk/plugins/viewplugins/substrate/{kis_repeating_substrate.cc => kis_repeating_substrate.cpp} (100%) rename chalk/plugins/viewplugins/substrate/{substrate.cc => substrate.cpp} (100%) delete mode 100644 chalk/plugins/viewplugins/variations/dlg_variations.cc create mode 100644 chalk/plugins/viewplugins/variations/dlg_variations.cpp rename chalk/plugins/viewplugins/variations/{variations.cc => variations.cpp} (100%) rename chalk/sdk/{kis_progress_subject.cc => kis_progress_subject.cpp} (100%) rename chalk/ui/{imageviewer.cc => imageviewer.cpp} (100%) rename chalk/ui/{kcurve.cc => kcurve.cpp} (100%) rename chalk/ui/{kis_autobrush.cc => kis_autobrush.cpp} (100%) rename chalk/ui/{kis_autogradient.cc => kis_autogradient.cpp} (100%) rename chalk/ui/{kis_birdeye_box.cc => kis_birdeye_box.cpp} (100%) rename chalk/ui/{kis_boundary_painter.cc => kis_boundary_painter.cpp} (100%) rename chalk/ui/{kis_brush_chooser.cc => kis_brush_chooser.cpp} (100%) rename chalk/ui/{kis_canvas.cc => kis_canvas.cpp} (100%) rename chalk/ui/{kis_canvas_painter.cc => kis_canvas_painter.cpp} (100%) rename chalk/ui/{kis_clipboard.cc => kis_clipboard.cpp} (100%) delete mode 100644 chalk/ui/kis_cmb_composite.cc create mode 100644 chalk/ui/kis_cmb_composite.cpp delete mode 100644 chalk/ui/kis_cmb_idlist.cc create mode 100644 chalk/ui/kis_cmb_idlist.cpp rename chalk/ui/{kis_color_cup.cc => kis_color_cup.cpp} (100%) rename chalk/ui/{kis_config.cc => kis_config.cpp} (100%) delete mode 100644 chalk/ui/kis_controlframe.cc create mode 100644 chalk/ui/kis_controlframe.cpp delete mode 100644 chalk/ui/kis_cursor.cc create mode 100644 chalk/ui/kis_cursor.cpp rename chalk/ui/{kis_custom_brush.cc => kis_custom_brush.cpp} (100%) rename chalk/ui/{kis_custom_image_widget.cc => kis_custom_image_widget.cpp} (100%) rename chalk/ui/{kis_custom_palette.cc => kis_custom_palette.cpp} (100%) rename chalk/ui/{kis_custom_pattern.cc => kis_custom_pattern.cpp} (100%) rename chalk/ui/{kis_dlg_adj_layer_props.cc => kis_dlg_adj_layer_props.cpp} (100%) rename chalk/ui/{kis_dlg_adjustment_layer.cc => kis_dlg_adjustment_layer.cpp} (100%) rename chalk/ui/{kis_dlg_apply_profile.cc => kis_dlg_apply_profile.cpp} (100%) rename chalk/ui/{kis_dlg_image_properties.cc => kis_dlg_image_properties.cpp} (100%) rename chalk/ui/{kis_dlg_layer_properties.cc => kis_dlg_layer_properties.cpp} (100%) rename chalk/ui/{kis_dlg_new_layer.cc => kis_dlg_new_layer.cpp} (100%) delete mode 100644 chalk/ui/kis_dlg_preferences.cc create mode 100644 chalk/ui/kis_dlg_preferences.cpp rename chalk/ui/{kis_doc.cc => kis_doc.cpp} (100%) rename chalk/ui/{kis_doc_iface.cc => kis_doc_iface.cpp} (100%) delete mode 100644 chalk/ui/kis_double_widget.cc create mode 100644 chalk/ui/kis_double_widget.cpp delete mode 100644 chalk/ui/kis_factory.cc create mode 100644 chalk/ui/kis_factory.cpp rename chalk/ui/{kis_filter_manager.cc => kis_filter_manager.cpp} (100%) rename chalk/ui/{kis_filters_listview.cc => kis_filters_listview.cpp} (100%) rename chalk/ui/{kis_gradient_chooser.cc => kis_gradient_chooser.cpp} (100%) rename chalk/ui/{kis_gradient_slider_widget.cc => kis_gradient_slider_widget.cpp} (100%) rename chalk/ui/{kis_histogram_view.cc => kis_histogram_view.cpp} (100%) rename chalk/ui/{kis_icon_item.cc => kis_icon_item.cpp} (100%) rename chalk/ui/{kis_iconwidget.cc => kis_iconwidget.cpp} (100%) rename chalk/ui/{kis_import_catcher.cc => kis_import_catcher.cpp} (100%) rename chalk/ui/{kis_input_device.cc => kis_input_device.cpp} (100%) rename chalk/ui/{kis_int_spinbox.cc => kis_int_spinbox.cpp} (100%) rename chalk/ui/{kis_itemchooser.cc => kis_itemchooser.cpp} (100%) rename chalk/ui/{kis_label_cursor_pos.cc => kis_label_cursor_pos.cpp} (100%) rename chalk/ui/{kis_label_progress.cc => kis_label_progress.cpp} (100%) rename chalk/ui/{kis_label_zoom.cc => kis_label_zoom.cpp} (100%) delete mode 100644 chalk/ui/kis_layerbox.cc create mode 100644 chalk/ui/kis_layerbox.cpp rename chalk/ui/{kis_layerlist.cc => kis_layerlist.cpp} (100%) rename chalk/ui/{kis_multi_bool_filter_widget.cc => kis_multi_bool_filter_widget.cpp} (100%) rename chalk/ui/{kis_multi_double_filter_widget.cc => kis_multi_double_filter_widget.cpp} (100%) rename chalk/ui/{kis_multi_integer_filter_widget.cc => kis_multi_integer_filter_widget.cpp} (100%) rename chalk/ui/{kis_opengl_canvas.cc => kis_opengl_canvas.cpp} (100%) rename chalk/ui/{kis_opengl_canvas_painter.cc => kis_opengl_canvas_painter.cpp} (100%) rename chalk/ui/{kis_opengl_image_context.cc => kis_opengl_image_context.cpp} (100%) delete mode 100644 chalk/ui/kis_paintop_box.cc create mode 100644 chalk/ui/kis_paintop_box.cpp rename chalk/ui/{kis_palette_view.cc => kis_palette_view.cpp} (100%) rename chalk/ui/{kis_palette_widget.cc => kis_palette_widget.cpp} (100%) rename chalk/ui/{kis_part_layer.cc => kis_part_layer.cpp} (100%) rename chalk/ui/{kis_part_layer_handler.cc => kis_part_layer_handler.cpp} (100%) rename chalk/ui/{kis_pattern_chooser.cc => kis_pattern_chooser.cpp} (100%) delete mode 100644 chalk/ui/kis_previewdialog.cc create mode 100644 chalk/ui/kis_previewdialog.cpp delete mode 100644 chalk/ui/kis_previewwidget.cc create mode 100644 chalk/ui/kis_previewwidget.cpp rename chalk/ui/{kis_qpaintdevice_canvas.cc => kis_qpaintdevice_canvas.cpp} (100%) rename chalk/ui/{kis_qpaintdevice_canvas_painter.cc => kis_qpaintdevice_canvas_painter.cpp} (100%) rename chalk/ui/{kis_resource_mediator.cc => kis_resource_mediator.cpp} (100%) delete mode 100644 chalk/ui/kis_resourceserver.cc create mode 100644 chalk/ui/kis_resourceserver.cpp rename chalk/ui/{kis_ruler.cc => kis_ruler.cpp} (100%) rename chalk/ui/{kis_selection_manager.cc => kis_selection_manager.cpp} (100%) rename chalk/ui/{kis_selection_options.cc => kis_selection_options.cpp} (100%) rename chalk/ui/{kis_text_brush.cc => kis_text_brush.cpp} (100%) rename chalk/ui/{kis_tool.cc => kis_tool.cpp} (100%) rename chalk/ui/{kis_tool_dummy.cc => kis_tool_dummy.cpp} (100%) delete mode 100644 chalk/ui/kis_tool_freehand.cc create mode 100644 chalk/ui/kis_tool_freehand.cpp rename chalk/ui/{kis_tool_manager.cc => kis_tool_manager.cpp} (100%) rename chalk/ui/{kis_tool_non_paint.cc => kis_tool_non_paint.cpp} (100%) rename chalk/ui/{kis_tool_paint.cc => kis_tool_paint.cpp} (100%) rename chalk/ui/{kis_tool_registry.cc => kis_tool_registry.cpp} (100%) rename chalk/ui/{kis_tool_shape.cc => kis_tool_shape.cpp} (100%) rename chalk/ui/{kis_view.cc => kis_view.cpp} (100%) rename chalk/ui/{kis_view_iface.cc => kis_view_iface.cpp} (100%) rename example/{example_factory.cc => example_factory.cpp} (100%) rename example/{example_part.cc => example_part.cpp} (100%) rename example/{example_view.cc => example_view.cpp} (100%) rename example/{main.cc => main.cpp} (100%) rename filters/chalk/gmagick/{kis_image_magick_converter.cc => kis_image_magick_converter.cpp} (100%) rename filters/chalk/jpeg/{kis_jpeg_converter.cc => kis_jpeg_converter.cpp} (100%) rename filters/chalk/jpeg/{kis_jpeg_export.cc => kis_jpeg_export.cpp} (100%) rename filters/chalk/jpeg/{kis_jpeg_import.cc => kis_jpeg_import.cpp} (100%) rename filters/chalk/magick/{kis_image_magick_converter.cc => kis_image_magick_converter.cpp} (100%) rename filters/chalk/png/{kis_png_converter.cc => kis_png_converter.cpp} (100%) rename filters/chalk/png/{kis_png_export.cc => kis_png_export.cpp} (100%) rename filters/chalk/png/{kis_png_import.cc => kis_png_import.cpp} (100%) rename filters/chalk/tiff/{kis_tiff_converter.cc => kis_tiff_converter.cpp} (100%) rename filters/chalk/tiff/{kis_tiff_export.cc => kis_tiff_export.cpp} (100%) rename filters/chalk/tiff/{kis_tiff_import.cc => kis_tiff_import.cpp} (100%) rename filters/chalk/tiff/{kis_tiff_reader.cc => kis_tiff_reader.cpp} (100%) rename filters/chalk/tiff/{kis_tiff_stream.cc => kis_tiff_stream.cpp} (100%) rename filters/chalk/tiff/{kis_tiff_ycbcr_reader.cc => kis_tiff_ycbcr_reader.cpp} (100%) rename filters/chalk/xcf/xcf/{xcf-load.cc => xcf-load.cpp} (100%) rename filters/chalk/xcf/xcf/{xcf-read.cc => xcf-read.cpp} (100%) rename filters/chalk/xcf/xcf/{xcf-save.cc => xcf-save.cpp} (100%) rename filters/chalk/xcf/xcf/{xcf-seek.cc => xcf-seek.cpp} (100%) rename filters/chalk/xcf/xcf/{xcf-write.cc => xcf-write.cpp} (100%) rename filters/generic_wrapper/{generic_filter.cc => generic_filter.cpp} (100%) rename filters/karbon/ai/{ai3handler.cc => ai3handler.cpp} (100%) rename filters/karbon/ai/{ai88handler.cc => ai88handler.cpp} (100%) rename filters/karbon/ai/{aicolor.cc => aicolor.cpp} (100%) rename filters/karbon/ai/{aielement.cc => aielement.cpp} (100%) rename filters/karbon/ai/{aiimport.cc => aiimport.cpp} (100%) rename filters/karbon/ai/{ailexer.cc => ailexer.cpp} (100%) rename filters/karbon/ai/{aiparserbase.cc => aiparserbase.cpp} (100%) rename filters/karbon/ai/{karbonaiparserbase.cc => karbonaiparserbase.cpp} (100%) rename filters/karbon/applixgraphics/{applixgraphicimport.cc => applixgraphicimport.cpp} (100%) rename filters/karbon/eps/{epsexport.cc => epsexport.cpp} (100%) rename filters/karbon/eps/{epsexportdlg.cc => epsexportdlg.cpp} (100%) rename filters/karbon/eps/{epsimport.cc => epsimport.cpp} (100%) rename filters/karbon/eps/{pscommentlexer.cc => pscommentlexer.cpp} (100%) rename filters/karbon/msod/{msod.cc => msod.cpp} (100%) rename filters/karbon/msod/{msodimport.cc => msodimport.cpp} (100%) rename filters/karbon/oodraw/{oodrawimport.cc => oodrawimport.cpp} (100%) rename filters/karbon/png/{pngexport.cc => pngexport.cpp} (100%) rename filters/karbon/svg/{svgexport.cc => svgexport.cpp} (100%) rename filters/karbon/svg/{svgimport.cc => svgimport.cpp} (100%) rename filters/karbon/wmf/{wmfexport.cc => wmfexport.cpp} (100%) rename filters/karbon/wmf/{wmfimport.cc => wmfimport.cpp} (100%) rename filters/karbon/wmf/{wmfimportparser.cc => wmfimportparser.cpp} (100%) rename filters/karbon/xaml/{xamlexport.cc => xamlexport.cpp} (100%) rename filters/karbon/xaml/{xamlimport.cc => xamlimport.cpp} (100%) rename filters/karbon/xcf/{xcfexport.cc => xcfexport.cpp} (100%) rename filters/karbon/xfig/{xfigimport.cc => xfigimport.cpp} (100%) rename filters/karbon/xfig/{xfigimport_factory.cc => xfigimport_factory.cpp} (100%) rename filters/kchart/svg/{svgexport.cc => svgexport.cpp} (100%) rename filters/kformula/latex/{latexexport.cc => latexexport.cpp} (100%) rename filters/kformula/mathml/{mathmlexport.cc => mathmlexport.cpp} (100%) rename filters/kformula/mathml/{mathmlimport.cc => mathmlimport.cpp} (100%) rename filters/kformula/png/{pngexport.cc => pngexport.cpp} (100%) rename filters/kformula/png/{pngexportdia.cc => pngexportdia.cpp} (100%) rename filters/kformula/svg/{svgexport.cc => svgexport.cpp} (100%) rename filters/kpresenter/kword/{kprkword.cc => kprkword.cpp} (100%) rename filters/kpresenter/ooimpress/{ooimpressexport.cc => ooimpressexport.cpp} (100%) rename filters/kpresenter/ooimpress/{ooimpressimport.cc => ooimpressimport.cpp} (100%) rename filters/kpresenter/ooimpress/{stylefactory.cc => stylefactory.cpp} (100%) rename filters/kpresenter/powerpoint/import/{powerpointimport.cc => powerpointimport.cpp} (100%) delete mode 100644 filters/kpresenter/svg/svgexport.cc create mode 100644 filters/kpresenter/svg/svgexport.cpp rename filters/kspread/applixspread/{applixspreadimport.cc => applixspreadimport.cpp} (100%) rename filters/kspread/csv/{csvexport.cc => csvexport.cpp} (100%) rename filters/kspread/csv/{csvimport.cc => csvimport.cpp} (100%) rename filters/kspread/csv/{xmltree.cc => xmltree.cpp} (100%) rename filters/kspread/dbase/{dbaseimport.cc => dbaseimport.cpp} (100%) rename filters/kspread/excel/{excelexport.cc => excelexport.cpp} (100%) rename filters/kspread/excel/import/{excelimport.cc => excelimport.cpp} (100%) rename filters/kspread/gnumeric/{gnumericexport.cc => gnumericexport.cpp} (100%) rename filters/kspread/gnumeric/{gnumericimport.cc => gnumericimport.cpp} (100%) rename filters/kspread/html/{exportdialog.cc => exportdialog.cpp} (100%) rename filters/kspread/html/{htmlexport.cc => htmlexport.cpp} (100%) rename filters/kspread/kexi/{kspread_kexiimport.cc => kspread_kexiimport.cpp} (100%) rename filters/kspread/kexi/{kspread_kexiimportdialog.cc => kspread_kexiimportdialog.cpp} (100%) rename filters/kspread/latex/export/{cell.cc => cell.cpp} (100%) rename filters/kspread/latex/export/{column.cc => column.cpp} (100%) rename filters/kspread/latex/export/{config.cc => config.cpp} (100%) rename filters/kspread/latex/export/{document.cc => document.cpp} (100%) rename filters/kspread/latex/export/{fileheader.cc => fileheader.cpp} (100%) rename filters/kspread/latex/export/{format.cc => format.cpp} (100%) rename filters/kspread/latex/export/{formula.cc => formula.cpp} (100%) rename filters/kspread/latex/export/{kspreadlatexexportdiaImpl.cc => kspreadlatexexportdiaImpl.cpp} (100%) rename filters/kspread/latex/export/{latexexport.cc => latexexport.cpp} (100%) rename filters/kspread/latex/export/{latexexportIface.cc => latexexportIface.cpp} (100%) rename filters/kspread/latex/export/{map.cc => map.cpp} (100%) rename filters/kspread/latex/export/{pen.cc => pen.cpp} (100%) rename filters/kspread/latex/export/{row.cc => row.cpp} (100%) rename filters/kspread/latex/export/{spreadsheet.cc => spreadsheet.cpp} (100%) rename filters/kspread/latex/export/{table.cc => table.cpp} (100%) rename filters/kspread/latex/export/{xmlparser.cc => xmlparser.cpp} (100%) rename filters/kspread/libkspreadexport/{KSpreadBaseWorker.cc => KSpreadBaseWorker.cpp} (100%) rename filters/kspread/libkspreadexport/{KSpreadLeader.cc => KSpreadLeader.cpp} (100%) rename filters/kspread/opencalc/{opencalcexport.cc => opencalcexport.cpp} (100%) rename filters/kspread/opencalc/{opencalcimport.cc => opencalcimport.cpp} (100%) rename filters/kspread/opencalc/{opencalcstyleexport.cc => opencalcstyleexport.cpp} (100%) rename filters/kspread/qpro/libqpro/src/{formula.cc => formula.cpp} (100%) rename filters/kspread/qpro/libqpro/src/{record.cc => record.cpp} (100%) rename filters/kspread/qpro/libqpro/src/{record_factory.cc => record_factory.cpp} (100%) rename filters/kspread/qpro/libqpro/src/{stream.cc => stream.cpp} (100%) rename filters/kspread/qpro/libqpro/src/{tablenames.cc => tablenames.cpp} (100%) rename filters/kspread/qpro/{qproformula.cc => qproformula.cpp} (100%) rename filters/kspread/qpro/{qproimport.cc => qproimport.cpp} (100%) rename filters/kword/abiword/{ImportField.cc => ImportField.cpp} (100%) rename filters/kword/abiword/{ImportFormatting.cc => ImportFormatting.cpp} (100%) rename filters/kword/abiword/{ImportHelpers.cc => ImportHelpers.cpp} (100%) rename filters/kword/abiword/{ImportStyle.cc => ImportStyle.cpp} (100%) delete mode 100644 filters/kword/abiword/abiwordexport.cc create mode 100644 filters/kword/abiword/abiwordexport.cpp rename filters/kword/abiword/{abiwordimport.cc => abiwordimport.cpp} (100%) rename filters/kword/amipro/{amiproexport.cc => amiproexport.cpp} (100%) rename filters/kword/amipro/{amiproimport.cc => amiproimport.cpp} (100%) rename filters/kword/applixword/{applixwordimport.cc => applixwordimport.cpp} (100%) rename filters/kword/ascii/{ExportDialog.cc => ExportDialog.cpp} (100%) rename filters/kword/ascii/{ImportDialog.cc => ImportDialog.cpp} (100%) rename filters/kword/ascii/{asciiexport.cc => asciiexport.cpp} (100%) rename filters/kword/ascii/{asciiimport.cc => asciiimport.cpp} (100%) rename filters/kword/docbook/{docbookexport.cc => docbookexport.cpp} (100%) rename filters/kword/html/export/{ExportBasic.cc => ExportBasic.cpp} (100%) rename filters/kword/html/export/{ExportCss.cc => ExportCss.cpp} (100%) rename filters/kword/html/export/{ExportDialog.cc => ExportDialog.cpp} (100%) rename filters/kword/html/export/{ExportDocStruct.cc => ExportDocStruct.cpp} (100%) rename filters/kword/html/export/{ExportFilter.cc => ExportFilter.cpp} (100%) delete mode 100644 filters/kword/html/export/htmlexport.cc create mode 100644 filters/kword/html/export/htmlexport.cpp rename filters/kword/latex/export/{anchor.cc => anchor.cpp} (100%) rename filters/kword/latex/export/{config.cc => config.cpp} (100%) rename filters/kword/latex/export/{document.cc => document.cpp} (100%) rename filters/kword/latex/export/{element.cc => element.cpp} (100%) rename filters/kword/latex/export/{fileheader.cc => fileheader.cpp} (100%) rename filters/kword/latex/export/{footnote.cc => footnote.cpp} (100%) rename filters/kword/latex/export/{format.cc => format.cpp} (100%) rename filters/kword/latex/export/{formula.cc => formula.cpp} (100%) rename filters/kword/latex/export/{key.cc => key.cpp} (100%) rename filters/kword/latex/export/{kwordlatexexportdia.cc => kwordlatexexportdia.cpp} (100%) rename filters/kword/latex/export/{latexexport.cc => latexexport.cpp} (100%) rename filters/kword/latex/export/{latexexportIface.cc => latexexportIface.cpp} (100%) rename filters/kword/latex/export/{layout.cc => layout.cpp} (100%) rename filters/kword/latex/export/{listeformat.cc => listeformat.cpp} (100%) rename filters/kword/latex/export/{listelement.cc => listelement.cpp} (100%) rename filters/kword/latex/export/{listepara.cc => listepara.cpp} (100%) rename filters/kword/latex/export/{listtable.cc => listtable.cpp} (100%) rename filters/kword/latex/export/{para.cc => para.cpp} (100%) rename filters/kword/latex/export/{pixmapFrame.cc => pixmapFrame.cpp} (100%) rename filters/kword/latex/export/{table.cc => table.cpp} (100%) rename filters/kword/latex/export/{texlauncher.cc => texlauncher.cpp} (100%) rename filters/kword/latex/export/{textFrame.cc => textFrame.cpp} (100%) rename filters/kword/latex/export/{textformat.cc => textformat.cpp} (100%) rename filters/kword/latex/export/{textzone.cc => textzone.cpp} (100%) rename filters/kword/latex/export/{variableformat.cc => variableformat.cpp} (100%) rename filters/kword/latex/export/{variablezone.cc => variablezone.cpp} (100%) rename filters/kword/latex/export/{xml2latexparser.cc => xml2latexparser.cpp} (100%) rename filters/kword/latex/export/{xmlparser.cc => xmlparser.cpp} (100%) rename filters/kword/latex/import/{config.cc => config.cpp} (100%) rename filters/kword/latex/import/generator/{body.cc => body.cpp} (100%) rename filters/kword/latex/import/generator/{document.cc => document.cpp} (100%) rename filters/kword/latex/import/generator/{kwordgenerator.cc => kwordgenerator.cpp} (100%) rename filters/kword/latex/import/generator/{latex.cc => latex.cpp} (100%) rename filters/kword/latex/import/generator/{paragraph.cc => paragraph.cpp} (100%) rename filters/kword/latex/import/{lateximport.cc => lateximport.cpp} (100%) delete mode 100644 filters/kword/latex/import/lateximportdia.cc create mode 100644 filters/kword/latex/import/lateximportdia.cpp rename filters/kword/latex/import/parser/{command.cc => command.cpp} (100%) rename filters/kword/latex/import/parser/{comment.cc => comment.cpp} (100%) rename filters/kword/latex/import/parser/{element.cc => element.cpp} (100%) rename filters/kword/latex/import/parser/{env.cc => env.cpp} (100%) rename filters/kword/latex/import/parser/{group.cc => group.cpp} (100%) rename filters/kword/latex/import/parser/{latexparser.cc => latexparser.cpp} (100%) rename filters/kword/latex/import/parser/{main.cc => main.cpp} (100%) rename filters/kword/latex/import/parser/{param.cc => param.cpp} (100%) rename filters/kword/latex/import/parser/{text.cc => text.cpp} (100%) rename filters/kword/libexport/{KWEFBaseWorker.cc => KWEFBaseWorker.cpp} (100%) delete mode 100644 filters/kword/libexport/KWEFKWordLeader.cc create mode 100644 filters/kword/libexport/KWEFKWordLeader.cpp rename filters/kword/libexport/{KWEFStructures.cc => KWEFStructures.cpp} (100%) rename filters/kword/libexport/{KWEFUtil.cc => KWEFUtil.cpp} (100%) delete mode 100644 filters/kword/libexport/ProcessDocument.cc create mode 100644 filters/kword/libexport/ProcessDocument.cpp delete mode 100644 filters/kword/libexport/TagProcessing.cc create mode 100644 filters/kword/libexport/TagProcessing.cpp rename filters/kword/mswrite/{ImportDialog.cc => ImportDialog.cpp} (100%) rename filters/kword/mswrite/{mswriteexport.cc => mswriteexport.cpp} (100%) rename filters/kword/mswrite/{mswriteimport.cc => mswriteimport.cpp} (100%) delete mode 100644 filters/kword/oowriter/ExportFilter.cc create mode 100644 filters/kword/oowriter/ExportFilter.cpp rename filters/kword/oowriter/{conversion.cc => conversion.cpp} (100%) delete mode 100644 filters/kword/oowriter/oowriterexport.cc create mode 100644 filters/kword/oowriter/oowriterexport.cpp rename filters/kword/oowriter/{oowriterimport.cc => oowriterimport.cpp} (100%) rename filters/kword/palmdoc/{palmdocexport.cc => palmdocexport.cpp} (100%) rename filters/kword/palmdoc/{palmdocimport.cc => palmdocimport.cpp} (100%) delete mode 100644 filters/kword/pdf/xpdf/goo/GHash.cc create mode 100644 filters/kword/pdf/xpdf/goo/GHash.cpp delete mode 100644 filters/kword/pdf/xpdf/goo/GList.cc create mode 100644 filters/kword/pdf/xpdf/goo/GList.cpp delete mode 100644 filters/kword/pdf/xpdf/goo/GString.cc create mode 100644 filters/kword/pdf/xpdf/goo/GString.cpp delete mode 100644 filters/kword/pdf/xpdf/goo/gfile.cc create mode 100644 filters/kword/pdf/xpdf/goo/gfile.cpp delete mode 100644 filters/kword/pdf/xpdf/goo/gmempp.cc create mode 100644 filters/kword/pdf/xpdf/goo/gmempp.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Annot.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Annot.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Array.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Array.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/BuiltinFont.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/BuiltinFont.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/BuiltinFontTables.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/BuiltinFontTables.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/CMap.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/CMap.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Catalog.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Catalog.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/CharCodeToUnicode.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/CharCodeToUnicode.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Decrypt.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Decrypt.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Dict.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Dict.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Error.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Error.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/FTFont.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/FTFont.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/FontEncodingTables.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/FontEncodingTables.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/FontFile.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/FontFile.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Function.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Function.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Gfx.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Gfx.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/GfxFont.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/GfxFont.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/GfxState.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/GfxState.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/GlobalParams.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/GlobalParams.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/ImageOutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/ImageOutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/JBIG2Stream.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/JBIG2Stream.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Lexer.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Lexer.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Link.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Link.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/NameToCharCode.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/NameToCharCode.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Object.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Object.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Outline.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Outline.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/OutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/OutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/PBMOutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/PBMOutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/PDFDoc.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/PDFDoc.cpp rename filters/kword/pdf/xpdf/xpdf/{PDFDocEncoding.cc => PDFDocEncoding.cpp} (100%) delete mode 100644 filters/kword/pdf/xpdf/xpdf/PSOutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/PSOutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/PSTokenizer.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/PSTokenizer.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Page.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Page.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Parser.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Parser.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/SFont.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/SFont.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/Stream.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/Stream.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/T1Font.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/T1Font.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/TTFont.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/TTFont.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/TextOutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/TextOutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/UnicodeMap.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/UnicodeMap.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XOutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XOutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFApp.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFApp.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFCore.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFCore.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFTree.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFTree.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFViewer.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XPDFViewer.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XPixmapOutputDev.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XPixmapOutputDev.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/XRef.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/XRef.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/pdffonts.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/pdffonts.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/pdfimages.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/pdfimages.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/pdfinfo.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/pdfinfo.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/pdftopbm.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/pdftopbm.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/pdftops.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/pdftops.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/pdftotext.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/pdftotext.cpp delete mode 100644 filters/kword/pdf/xpdf/xpdf/xpdf.cc create mode 100644 filters/kword/pdf/xpdf/xpdf/xpdf.cpp rename filters/kword/rtf/export/{ExportFilter.cc => ExportFilter.cpp} (100%) delete mode 100644 filters/kword/rtf/export/rtfexport.cc create mode 100644 filters/kword/rtf/export/rtfexport.cpp rename filters/kword/starwriter/{starwriterimport.cc => starwriterimport.cpp} (100%) rename filters/kword/wml/{wmlexport.cc => wmlexport.cpp} (100%) rename filters/kword/wml/{wmlimport.cc => wmlimport.cpp} (100%) rename filters/kword/wordperfect/export/{wp5.cc => wp5.cpp} (100%) rename filters/kword/wordperfect/export/{wp6.cc => wp6.cpp} (100%) rename filters/kword/wordperfect/export/{wpexport.cc => wpexport.cpp} (100%) create mode 100644 filters/kword/wordperfect/import/DocumentElement.cpp delete mode 100644 filters/kword/wordperfect/import/DocumentElement.cxx create mode 100644 filters/kword/wordperfect/import/DocumentElement.h delete mode 100644 filters/kword/wordperfect/import/DocumentElement.hxx rename filters/kword/wordperfect/import/{DocumentHandler.hxx => DocumentHandler.h} (100%) create mode 100644 filters/kword/wordperfect/import/FilterInternal.h delete mode 100644 filters/kword/wordperfect/import/FilterInternal.hxx create mode 100644 filters/kword/wordperfect/import/FontStyle.cpp delete mode 100644 filters/kword/wordperfect/import/FontStyle.cxx create mode 100644 filters/kword/wordperfect/import/FontStyle.h delete mode 100644 filters/kword/wordperfect/import/FontStyle.hxx create mode 100644 filters/kword/wordperfect/import/ListStyle.cpp delete mode 100644 filters/kword/wordperfect/import/ListStyle.cxx create mode 100644 filters/kword/wordperfect/import/ListStyle.h delete mode 100644 filters/kword/wordperfect/import/ListStyle.hxx create mode 100644 filters/kword/wordperfect/import/PageSpan.cpp delete mode 100644 filters/kword/wordperfect/import/PageSpan.cxx rename filters/kword/wordperfect/import/{PageSpan.hxx => PageSpan.h} (100%) create mode 100644 filters/kword/wordperfect/import/SectionStyle.cpp delete mode 100644 filters/kword/wordperfect/import/SectionStyle.cxx create mode 100644 filters/kword/wordperfect/import/SectionStyle.h delete mode 100644 filters/kword/wordperfect/import/SectionStyle.hxx create mode 100644 filters/kword/wordperfect/import/Style.h delete mode 100644 filters/kword/wordperfect/import/Style.hxx create mode 100644 filters/kword/wordperfect/import/TableStyle.cpp delete mode 100644 filters/kword/wordperfect/import/TableStyle.cxx create mode 100644 filters/kword/wordperfect/import/TableStyle.h delete mode 100644 filters/kword/wordperfect/import/TableStyle.hxx create mode 100644 filters/kword/wordperfect/import/TextRunStyle.cpp delete mode 100644 filters/kword/wordperfect/import/TextRunStyle.cxx create mode 100644 filters/kword/wordperfect/import/TextRunStyle.h delete mode 100644 filters/kword/wordperfect/import/TextRunStyle.hxx create mode 100644 filters/kword/wordperfect/import/WordPerfectCollector.cpp delete mode 100644 filters/kword/wordperfect/import/WordPerfectCollector.cxx create mode 100644 filters/kword/wordperfect/import/WordPerfectCollector.h delete mode 100644 filters/kword/wordperfect/import/WordPerfectCollector.hxx rename filters/kword/wordperfect/import/{WriterProperties.hxx => WriterProperties.h} (100%) delete mode 100644 filters/kword/wordperfect/import/wpimport.cc create mode 100644 filters/kword/wordperfect/import/wpimport.cpp rename filters/liboofilter/{liststylestack.cc => liststylestack.cpp} (100%) rename filters/liboofilter/{ooutils.cc => ooutils.cpp} (100%) rename filters/olefilters/lib/{filterbase.cc => filterbase.cpp} (100%) rename filters/olefilters/lib/{klaola.cc => klaola.cpp} (100%) rename filters/olefilters/{olefilter.cc => olefilter.cpp} (100%) rename filters/olefilters/powerpoint97/{powerpoint.cc => powerpoint.cpp} (100%) rename filters/olefilters/powerpoint97/{powerpointfilter.cc => powerpointfilter.cpp} (100%) rename filters/olefilters/powerpoint97/{pptdoc.cc => pptdoc.cpp} (100%) rename filters/olefilters/powerpoint97/{pptxml.cc => pptxml.cpp} (100%) rename filters/xsltfilter/export/{xsltexport.cc => xsltexport.cpp} (100%) rename filters/xsltfilter/export/{xsltexportdia.cc => xsltexportdia.cpp} (100%) rename filters/xsltfilter/export/{xsltproc.cc => xsltproc.cpp} (100%) rename filters/xsltfilter/import/{xsltimport.cc => xsltimport.cpp} (100%) rename filters/xsltfilter/import/{xsltimportdia.cc => xsltimportdia.cpp} (100%) rename filters/xsltfilter/import/{xsltproc.cc => xsltproc.cpp} (100%) rename interfaces/{koChart.cc => koChart.cpp} (100%) rename karbon/commands/{valigncmd.cc => valigncmd.cpp} (100%) rename karbon/commands/{vbooleancmd.cc => vbooleancmd.cpp} (100%) rename karbon/commands/{vcleanupcmd.cc => vcleanupcmd.cpp} (100%) rename karbon/commands/{vclipartcmd.cc => vclipartcmd.cpp} (100%) rename karbon/commands/{vclosepathcmd.cc => vclosepathcmd.cpp} (100%) rename karbon/commands/{vcommand.cc => vcommand.cpp} (100%) rename karbon/commands/{vdeletecmd.cc => vdeletecmd.cpp} (100%) rename karbon/commands/{vdeletenodescmd.cc => vdeletenodescmd.cpp} (100%) rename karbon/commands/{vdistributecmd.cc => vdistributecmd.cpp} (100%) rename karbon/commands/{vfillcmd.cc => vfillcmd.cpp} (100%) rename karbon/commands/{vflattencmd.cc => vflattencmd.cpp} (100%) rename karbon/commands/{vgroupcmd.cc => vgroupcmd.cpp} (100%) rename karbon/commands/{vinsertcmd.cc => vinsertcmd.cpp} (100%) rename karbon/commands/{vlayercmd.cc => vlayercmd.cpp} (100%) rename karbon/commands/{vreplacingcmd.cc => vreplacingcmd.cpp} (100%) rename karbon/commands/{vshapecmd.cc => vshapecmd.cpp} (100%) rename karbon/commands/{vstrokecmd.cc => vstrokecmd.cpp} (100%) rename karbon/commands/{vtextcmd.cc => vtextcmd.cpp} (100%) rename karbon/commands/{vtransformcmd.cc => vtransformcmd.cpp} (100%) rename karbon/commands/{vungroupcmd.cc => vungroupcmd.cpp} (100%) rename karbon/commands/{vzordercmd.cc => vzordercmd.cpp} (100%) rename karbon/core/{vclipgroup.cc => vclipgroup.cpp} (100%) rename karbon/core/{vcolor.cc => vcolor.cpp} (100%) rename karbon/core/{vcomposite.cc => vcomposite.cpp} (100%) rename karbon/core/{vcomposite_iface.cc => vcomposite_iface.cpp} (100%) rename karbon/core/{vcursor.cc => vcursor.cpp} (100%) rename karbon/core/{vdashpattern.cc => vdashpattern.cpp} (100%) rename karbon/core/{vdocument.cc => vdocument.cpp} (100%) rename karbon/core/{vfill.cc => vfill.cpp} (100%) rename karbon/core/{vglobal.cc => vglobal.cpp} (100%) rename karbon/core/{vgradient.cc => vgradient.cpp} (100%) rename karbon/core/{vgroup.cc => vgroup.cpp} (100%) rename karbon/core/{vgroup_iface.cc => vgroup_iface.cpp} (100%) rename karbon/core/{vimage.cc => vimage.cpp} (100%) rename karbon/core/{vkarbonplugin.cc => vkarbonplugin.cpp} (100%) rename karbon/core/{vlayer.cc => vlayer.cpp} (100%) rename karbon/core/{vlayer_iface.cc => vlayer_iface.cpp} (100%) rename karbon/core/{vobject.cc => vobject.cpp} (100%) rename karbon/core/{vobject_iface.cc => vobject_iface.cpp} (100%) rename karbon/core/{vpath.cc => vpath.cpp} (100%) rename karbon/core/{vpattern.cc => vpattern.cpp} (100%) rename karbon/core/{vsegment.cc => vsegment.cpp} (100%) rename karbon/core/{vselection.cc => vselection.cpp} (100%) rename karbon/core/{vstroke.cc => vstroke.cpp} (100%) rename karbon/core/{vtext.cc => vtext.cpp} (100%) rename karbon/core/{vtext_iface.cc => vtext_iface.cpp} (100%) rename karbon/core/{vvisitor.cc => vvisitor.cpp} (100%) rename karbon/dialogs/{vcolordlg.cc => vcolordlg.cpp} (100%) rename karbon/dialogs/{vcolortab.cc => vcolortab.cpp} (100%) rename karbon/dialogs/{vconfiguredlg.cc => vconfiguredlg.cpp} (100%) rename karbon/dialogs/{vstrokedlg.cc => vstrokedlg.cpp} (100%) rename karbon/dockers/{vcolordocker.cc => vcolordocker.cpp} (100%) rename karbon/dockers/{vdocumentdocker.cc => vdocumentdocker.cpp} (100%) rename karbon/dockers/{vstrokedocker.cc => vstrokedocker.cpp} (100%) rename karbon/dockers/{vstyledocker.cc => vstyledocker.cpp} (100%) rename karbon/dockers/{vtransformdocker.cc => vtransformdocker.cpp} (100%) rename karbon/{karbon_factory.cc => karbon_factory.cpp} (100%) rename karbon/{karbon_factory_init.cc => karbon_factory_init.cpp} (100%) rename karbon/{karbon_part.cc => karbon_part.cpp} (100%) rename karbon/{karbon_part_iface.cc => karbon_part_iface.cpp} (100%) rename karbon/{karbon_resourceserver.cc => karbon_resourceserver.cpp} (100%) rename karbon/{karbon_tool_factory.cc => karbon_tool_factory.cpp} (100%) rename karbon/{karbon_tool_registry.cc => karbon_tool_registry.cpp} (100%) rename karbon/{karbon_view.cc => karbon_view.cpp} (100%) rename karbon/{karbon_view_iface.cc => karbon_view_iface.cpp} (100%) rename karbon/{main.cc => main.cpp} (100%) rename karbon/plugins/flattenpath/{flattenpathplugin.cc => flattenpathplugin.cpp} (100%) rename karbon/plugins/imagetool/{imagetoolplugin.cc => imagetoolplugin.cpp} (100%) rename karbon/plugins/imagetool/{vimagetool.cc => vimagetool.cpp} (100%) rename karbon/plugins/insertknots/{insertknotsplugin.cc => insertknotsplugin.cpp} (100%) rename karbon/plugins/roundcorners/{roundcornersplugin.cc => roundcornersplugin.cpp} (100%) rename karbon/plugins/shadoweffect/{shadoweffectplugin.cc => shadoweffectplugin.cpp} (100%) rename karbon/plugins/shadoweffect/{vshadowdecorator.cc => vshadowdecorator.cpp} (100%) rename karbon/plugins/whirlpinch/{whirlpinchplugin.cc => whirlpinchplugin.cpp} (100%) rename karbon/plugins/zoomtool/{vzoomtool.cc => vzoomtool.cpp} (100%) rename karbon/plugins/zoomtool/{zoomtoolplugin.cc => zoomtoolplugin.cpp} (100%) rename karbon/render/{vkopainter.cc => vkopainter.cpp} (100%) rename karbon/render/{vpainterfactory.cc => vpainterfactory.cpp} (100%) rename karbon/render/{vqpainter.cc => vqpainter.cpp} (100%) rename karbon/shapes/{vellipse.cc => vellipse.cpp} (100%) rename karbon/shapes/{vpolygon.cc => vpolygon.cpp} (100%) rename karbon/shapes/{vpolyline.cc => vpolyline.cpp} (100%) rename karbon/shapes/{vrectangle.cc => vrectangle.cpp} (100%) rename karbon/shapes/{vsinus.cc => vsinus.cpp} (100%) rename karbon/shapes/{vspiral.cc => vspiral.cpp} (100%) rename karbon/shapes/{vstar.cc => vstar.cpp} (100%) rename karbon/tools/{vcurvefit.cc => vcurvefit.cpp} (100%) rename karbon/tools/{vdefaulttools.cc => vdefaulttools.cpp} (100%) rename karbon/tools/{vellipsetool.cc => vellipsetool.cpp} (100%) rename karbon/tools/{vgradienttool.cc => vgradienttool.cpp} (100%) rename karbon/tools/{vpatterntool.cc => vpatterntool.cpp} (100%) rename karbon/tools/{vpenciltool.cc => vpenciltool.cpp} (100%) rename karbon/tools/{vpolygontool.cc => vpolygontool.cpp} (100%) rename karbon/tools/{vpolylinetool.cc => vpolylinetool.cpp} (100%) rename karbon/tools/{vrectangletool.cc => vrectangletool.cpp} (100%) rename karbon/tools/{vrotatetool.cc => vrotatetool.cpp} (100%) rename karbon/tools/{vroundrecttool.cc => vroundrecttool.cpp} (100%) rename karbon/tools/{vselectnodestool.cc => vselectnodestool.cpp} (100%) rename karbon/tools/{vselecttool.cc => vselecttool.cpp} (100%) rename karbon/tools/{vshapetool.cc => vshapetool.cpp} (100%) rename karbon/tools/{vsheartool.cc => vsheartool.cpp} (100%) rename karbon/tools/{vsinustool.cc => vsinustool.cpp} (100%) rename karbon/tools/{vspiraltool.cc => vspiraltool.cpp} (100%) rename karbon/tools/{vstartool.cc => vstartool.cpp} (100%) rename karbon/tools/{vtexttool.cc => vtexttool.cpp} (100%) rename karbon/visitors/{vcomputeboundingbox.cc => vcomputeboundingbox.cpp} (100%) rename karbon/visitors/{vdrawselection.cc => vdrawselection.cpp} (100%) rename karbon/visitors/{vselectiondesc.cc => vselectiondesc.cpp} (100%) rename karbon/visitors/{vselectnodes.cc => vselectnodes.cpp} (100%) rename karbon/visitors/{vselectobjects.cc => vselectobjects.cpp} (100%) rename karbon/visitors/{vtransformnodes.cc => vtransformnodes.cpp} (100%) rename karbon/{vtool.cc => vtool.cpp} (100%) rename karbon/{vtoolcontroller.cc => vtoolcontroller.cpp} (100%) rename karbon/widgets/{vcanvas.cc => vcanvas.cpp} (100%) delete mode 100644 karbon/widgets/vcolorslider.cc create mode 100644 karbon/widgets/vcolorslider.cpp rename karbon/widgets/{vgradienttabwidget.cc => vgradienttabwidget.cpp} (100%) rename karbon/widgets/{vgradientwidget.cc => vgradientwidget.cpp} (100%) delete mode 100644 karbon/widgets/vreference.cc create mode 100644 karbon/widgets/vreference.cpp rename karbon/widgets/{vruler.cc => vruler.cpp} (100%) delete mode 100644 karbon/widgets/vselecttoolbar.cc create mode 100644 karbon/widgets/vselecttoolbar.cpp delete mode 100644 karbon/widgets/vsmallpreview.cc create mode 100644 karbon/widgets/vsmallpreview.cpp rename karbon/widgets/{vstatebutton.cc => vstatebutton.cpp} (100%) rename karbon/widgets/{vstrokefillpreview.cc => vstrokefillpreview.cpp} (100%) rename karbon/widgets/{vtoolbox.cc => vtoolbox.cpp} (100%) rename karbon/widgets/{vtranslate.cc => vtranslate.cpp} (100%) rename karbon/widgets/{vtypebuttonbox.cc => vtypebuttonbox.cpp} (100%) rename kchart/{KChartParamsIface.cc => KChartParamsIface.cpp} (100%) rename kchart/{KChartViewIface.cc => KChartViewIface.cpp} (100%) rename kchart/{csvimportdialog.cc => csvimportdialog.cpp} (100%) delete mode 100644 kchart/kchartBackgroundPixmapConfigPage.cc create mode 100644 kchart/kchartBackgroundPixmapConfigPage.cpp rename kchart/{kchartColorConfigPage.cc => kchartColorConfigPage.cpp} (100%) rename kchart/{kchartComboConfigPage.cc => kchartComboConfigPage.cpp} (100%) rename kchart/{kchartConfigDialog.cc => kchartConfigDialog.cpp} (100%) delete mode 100644 kchart/kchartDataConfigPage.cc create mode 100644 kchart/kchartDataConfigPage.cpp rename kchart/{kchartDataEditor.cc => kchartDataEditor.cpp} (100%) rename kchart/{kchartFontConfigPage.cc => kchartFontConfigPage.cpp} (100%) rename kchart/{kchartHeaderFooterConfigPage.cc => kchartHeaderFooterConfigPage.cpp} (100%) rename kchart/{kchartLegendConfigPage.cc => kchartLegendConfigPage.cpp} (100%) rename kchart/{kchartLine3dConfigPage.cc => kchartLine3dConfigPage.cpp} (100%) rename kchart/{kchartPageLayout.cc => kchartPageLayout.cpp} (100%) rename kchart/{kchartParameter3dConfigPage.cc => kchartParameter3dConfigPage.cpp} (100%) rename kchart/{kchartParameterConfigPage.cc => kchartParameterConfigPage.cpp} (100%) rename kchart/{kchartParameterPieConfigPage.cc => kchartParameterPieConfigPage.cpp} (100%) rename kchart/{kchartParameterPolarConfigPage.cc => kchartParameterPolarConfigPage.cpp} (100%) rename kchart/{kchartPieConfigPage.cc => kchartPieConfigPage.cpp} (100%) rename kchart/{kchartPrinterDlg.cc => kchartPrinterDlg.cpp} (100%) rename kchart/{kchartSubTypeChartPage.cc => kchartSubTypeChartPage.cpp} (100%) rename kchart/{kchartWizard.cc => kchartWizard.cpp} (100%) rename kchart/{kchartWizardLabelsLegendPage.cc => kchartWizardLabelsLegendPage.cpp} (100%) rename kchart/{kchartWizardSelectChartSubTypePage.cc => kchartWizardSelectChartSubTypePage.cpp} (100%) rename kchart/{kchartWizardSelectChartTypePage.cc => kchartWizardSelectChartTypePage.cpp} (100%) rename kchart/{kchartWizardSelectDataFormatPage.cc => kchartWizardSelectDataFormatPage.cpp} (100%) rename kchart/{kchartWizardSelectDataPage.cc => kchartWizardSelectDataPage.cpp} (100%) rename kchart/{kchartWizardSetupAxesPage.cc => kchartWizardSetupAxesPage.cpp} (100%) rename kchart/{kchartWizardSetupDataPage.cc => kchartWizardSetupDataPage.cpp} (100%) delete mode 100644 kchart/kchart_factory.cc create mode 100644 kchart/kchart_factory.cpp rename kchart/{kchart_factory_init.cc => kchart_factory_init.cpp} (100%) rename kchart/{kchart_params.cc => kchart_params.cpp} (100%) rename kchart/{kchart_part.cc => kchart_part.cpp} (100%) rename kchart/{kchart_view.cc => kchart_view.cpp} (100%) rename kchart/{main.cc => main.cpp} (100%) rename kexi/3rdparty/kolibs/{koGlobal.cc => koGlobal.cpp} (100%) rename kexi/3rdparty/kolibs/{koPageLayoutDia.cc => koPageLayoutDia.cpp} (100%) rename kexi/3rdparty/kolibs/{koUnit.cc => koUnit.cpp} (100%) rename kexi/3rdparty/kolibs/{koUnitWidgets.cc => koUnitWidgets.cpp} (100%) rename kformula/{formulastring.cc => formulastring.cpp} (100%) rename kformula/{fsparser.cc => fsparser.cpp} (100%) rename kformula/{kfconfig.cc => kfconfig.cpp} (100%) rename kformula/{kformula_doc.cc => kformula_doc.cpp} (100%) rename kformula/{kformula_factory.cc => kformula_factory.cpp} (100%) rename kformula/{kformula_view.cc => kformula_view.cpp} (100%) rename kformula/{kformula_view_iface.cc => kformula_view_iface.cpp} (100%) rename kformula/{kformulawidget.cc => kformulawidget.cpp} (100%) rename kformula/{main.cc => main.cpp} (100%) rename kivio/kiviopart/{KIvioDocIface.cc => KIvioDocIface.cpp} (100%) rename kivio/kiviopart/{KIvioLayerIface.cc => KIvioLayerIface.cpp} (100%) rename kivio/kiviopart/{KIvioMapIface.cc => KIvioMapIface.cpp} (100%) rename kivio/kiviopart/{KIvioPageIface.cc => KIvioPageIface.cpp} (100%) rename kivio/kiviopart/{KIvioStencilIface.cc => KIvioStencilIface.cpp} (100%) rename kivio/kiviopart/{KIvioViewIface.cc => KIvioViewIface.cpp} (100%) rename kivio/kiviopart/{kivio_command.cc => kivio_command.cpp} (100%) rename kivio/kiviopart/{kivio_part_init.cc => kivio_part_init.cpp} (100%) rename koshell/{koshell_main.cc => koshell_main.cpp} (100%) rename koshell/{koshell_shell.cc => koshell_shell.cpp} (100%) rename kounavail/{kounavail.cc => kounavail.cpp} (100%) rename kplato/{KPtViewIface.cc => KPtViewIface.cpp} (100%) rename kplato/{kptaccount.cc => kptaccount.cpp} (100%) rename kplato/{kptaccountsdialog.cc => kptaccountsdialog.cpp} (100%) rename kplato/{kptaccountspanel.cc => kptaccountspanel.cpp} (100%) rename kplato/{kptaccountsview.cc => kptaccountsview.cpp} (100%) rename kplato/{kptaccountsviewconfigdialog.cc => kptaccountsviewconfigdialog.cpp} (100%) rename kplato/{kptappointment.cc => kptappointment.cpp} (100%) rename kplato/{kptcalendar.cc => kptcalendar.cpp} (100%) rename kplato/{kptcalendaredit.cc => kptcalendaredit.cpp} (100%) rename kplato/{kptcalendareditbase.cc => kptcalendareditbase.cpp} (100%) rename kplato/{kptcalendarlistdialog.cc => kptcalendarlistdialog.cpp} (100%) rename kplato/{kptcalendarlistdialogbase.cc => kptcalendarlistdialogbase.cpp} (100%) rename kplato/{kptcalendarpanel.cc => kptcalendarpanel.cpp} (100%) rename kplato/{kptcanvasitem.cc => kptcanvasitem.cpp} (100%) rename kplato/{kptcommand.cc => kptcommand.cpp} (100%) rename kplato/{kptconfig.cc => kptconfig.cpp} (100%) rename kplato/{kptconfigbehaviorpanel.cc => kptconfigbehaviorpanel.cpp} (100%) rename kplato/{kptconfigdialog.cc => kptconfigdialog.cpp} (100%) rename kplato/{kptcontext.cc => kptcontext.cpp} (100%) rename kplato/{kptdatetable.cc => kptdatetable.cpp} (100%) rename kplato/{kptdatetime.cc => kptdatetime.cpp} (100%) rename kplato/{kptdoublelistviewbase.cc => kptdoublelistviewbase.cpp} (100%) rename kplato/{kptduration.cc => kptduration.cpp} (100%) rename kplato/{kptfactory.cc => kptfactory.cpp} (100%) rename kplato/{kptganttview.cc => kptganttview.cpp} (100%) rename kplato/{kptintervaledit.cc => kptintervaledit.cpp} (100%) rename kplato/{kptmainprojectdialog.cc => kptmainprojectdialog.cpp} (100%) rename kplato/{kptmainprojectpanel.cc => kptmainprojectpanel.cpp} (100%) rename kplato/{kptmilestoneprogressdialog.cc => kptmilestoneprogressdialog.cpp} (100%) rename kplato/{kptmilestoneprogresspanel.cc => kptmilestoneprogresspanel.cpp} (100%) rename kplato/{kptnode.cc => kptnode.cpp} (100%) rename kplato/{kptpart.cc => kptpart.cpp} (100%) rename kplato/{kptpertcanvas.cc => kptpertcanvas.cpp} (100%) rename kplato/{kptpertview.cc => kptpertview.cpp} (100%) rename kplato/{kptproject.cc => kptproject.cpp} (100%) rename kplato/{kptprojectdialog.cc => kptprojectdialog.cpp} (100%) rename kplato/{kptrelation.cc => kptrelation.cpp} (100%) rename kplato/{kptrelationdialog.cc => kptrelationdialog.cpp} (100%) rename kplato/{kptreportview.cc => kptreportview.cpp} (100%) rename kplato/{kptrequestresourcespanel.cc => kptrequestresourcespanel.cpp} (100%) rename kplato/{kptresource.cc => kptresource.cpp} (100%) rename kplato/{kptresourceappointmentsview.cc => kptresourceappointmentsview.cpp} (100%) rename kplato/{kptresourcedialog.cc => kptresourcedialog.cpp} (100%) rename kplato/{kptresourcesdialog.cc => kptresourcesdialog.cpp} (100%) rename kplato/{kptresourcespanel.cc => kptresourcespanel.cpp} (100%) rename kplato/{kptresourceview.cc => kptresourceview.cpp} (100%) rename kplato/{kptschedule.cc => kptschedule.cpp} (100%) rename kplato/{kptstandardworktimedialog.cc => kptstandardworktimedialog.cpp} (100%) rename kplato/{kptsummarytaskdialog.cc => kptsummarytaskdialog.cpp} (100%) rename kplato/{kptsummarytaskgeneralpanel.cc => kptsummarytaskgeneralpanel.cpp} (100%) rename kplato/{kpttask.cc => kpttask.cpp} (100%) rename kplato/{kpttaskappointmentsview.cc => kpttaskappointmentsview.cpp} (100%) rename kplato/{kpttaskcostpanel.cc => kpttaskcostpanel.cpp} (100%) rename kplato/{kpttaskdefaultpanel.cc => kpttaskdefaultpanel.cpp} (100%) rename kplato/{kpttaskdialog.cc => kpttaskdialog.cpp} (100%) rename kplato/{kpttaskgeneralpanel.cc => kpttaskgeneralpanel.cpp} (100%) rename kplato/{kpttaskprogressdialog.cc => kpttaskprogressdialog.cpp} (100%) rename kplato/{kpttaskprogresspanel.cc => kpttaskprogresspanel.cpp} (100%) rename kplato/{kptview.cc => kptview.cpp} (100%) delete mode 100644 kplato/kptwbsdefinition.cc create mode 100644 kplato/kptwbsdefinition.cpp rename kplato/{kptwbsdefinitiondialog.cc => kptwbsdefinitiondialog.cpp} (100%) rename kplato/{kptwbsdefinitionpanel.cc => kptwbsdefinitionpanel.cpp} (100%) rename kplato/{main.cc => main.cpp} (100%) rename kspread/{KSpreadAppIface.cc => KSpreadAppIface.cpp} (100%) rename kspread/{KSpreadCellIface.cc => KSpreadCellIface.cpp} (100%) rename kspread/{KSpreadColumnIface.cc => KSpreadColumnIface.cpp} (100%) rename kspread/{KSpreadDocIface.cc => KSpreadDocIface.cpp} (100%) rename kspread/{KSpreadLayoutIface.cc => KSpreadLayoutIface.cpp} (100%) rename kspread/{KSpreadMapIface.cc => KSpreadMapIface.cpp} (100%) rename kspread/{KSpreadRowIface.cc => KSpreadRowIface.cpp} (100%) rename kspread/{KSpreadTableIface.cc => KSpreadTableIface.cpp} (100%) rename kspread/{KSpreadViewIface.cc => KSpreadViewIface.cpp} (100%) rename kspread/{commands.cc => commands.cpp} (100%) rename kspread/{damages.cc => damages.cpp} (100%) rename kspread/{dependencies.cc => dependencies.cpp} (100%) rename kspread/dialogs/{kspread_dlg_angle.cc => kspread_dlg_angle.cpp} (100%) rename kspread/dialogs/{kspread_dlg_area.cc => kspread_dlg_area.cpp} (100%) rename kspread/dialogs/{kspread_dlg_comment.cc => kspread_dlg_comment.cpp} (100%) rename kspread/dialogs/{kspread_dlg_conditional.cc => kspread_dlg_conditional.cpp} (100%) rename kspread/dialogs/{kspread_dlg_cons.cc => kspread_dlg_cons.cpp} (100%) rename kspread/dialogs/{kspread_dlg_csv.cc => kspread_dlg_csv.cpp} (100%) rename kspread/dialogs/{kspread_dlg_database.cc => kspread_dlg_database.cpp} (100%) rename kspread/dialogs/{kspread_dlg_find.cc => kspread_dlg_find.cpp} (100%) rename kspread/dialogs/{kspread_dlg_format.cc => kspread_dlg_format.cpp} (100%) rename kspread/dialogs/{kspread_dlg_formula.cc => kspread_dlg_formula.cpp} (100%) rename kspread/dialogs/{kspread_dlg_goalseek.cc => kspread_dlg_goalseek.cpp} (100%) rename kspread/dialogs/{kspread_dlg_goto.cc => kspread_dlg_goto.cpp} (100%) rename kspread/dialogs/{kspread_dlg_insert.cc => kspread_dlg_insert.cpp} (100%) rename kspread/dialogs/{kspread_dlg_layout.cc => kspread_dlg_layout.cpp} (100%) rename kspread/dialogs/{kspread_dlg_list.cc => kspread_dlg_list.cpp} (100%) rename kspread/dialogs/{kspread_dlg_paperlayout.cc => kspread_dlg_paperlayout.cpp} (100%) rename kspread/dialogs/{kspread_dlg_pasteinsert.cc => kspread_dlg_pasteinsert.cpp} (100%) rename kspread/dialogs/{kspread_dlg_preference.cc => kspread_dlg_preference.cpp} (100%) rename kspread/dialogs/{kspread_dlg_reference.cc => kspread_dlg_reference.cpp} (100%) rename kspread/dialogs/{kspread_dlg_resize2.cc => kspread_dlg_resize2.cpp} (100%) rename kspread/dialogs/{kspread_dlg_series.cc => kspread_dlg_series.cpp} (100%) rename kspread/dialogs/{kspread_dlg_show.cc => kspread_dlg_show.cpp} (100%) rename kspread/dialogs/{kspread_dlg_showColRow.cc => kspread_dlg_showColRow.cpp} (100%) rename kspread/dialogs/{kspread_dlg_sort.cc => kspread_dlg_sort.cpp} (100%) rename kspread/dialogs/{kspread_dlg_special.cc => kspread_dlg_special.cpp} (100%) rename kspread/dialogs/{kspread_dlg_styles.cc => kspread_dlg_styles.cpp} (100%) rename kspread/dialogs/{kspread_dlg_subtotal.cc => kspread_dlg_subtotal.cpp} (100%) rename kspread/dialogs/{kspread_dlg_validity.cc => kspread_dlg_validity.cpp} (100%) rename kspread/dialogs/{link.cc => link.cpp} (100%) rename kspread/dialogs/{sheet_properties.cc => sheet_properties.cpp} (100%) rename kspread/{digest.cc => digest.cpp} (100%) rename kspread/{formula.cc => formula.cpp} (100%) delete mode 100644 kspread/functions.cc create mode 100644 kspread/functions.cpp rename kspread/{kspread_autofill.cc => kspread_autofill.cpp} (100%) rename kspread/{kspread_brush.cc => kspread_brush.cpp} (100%) rename kspread/{kspread_canvas.cc => kspread_canvas.cpp} (100%) rename kspread/{kspread_cell.cc => kspread_cell.cpp} (100%) rename kspread/{kspread_cluster.cc => kspread_cluster.cpp} (100%) rename kspread/{kspread_condition.cc => kspread_condition.cpp} (100%) rename kspread/{kspread_doc.cc => kspread_doc.cpp} (100%) rename kspread/{kspread_editors.cc => kspread_editors.cpp} (100%) rename kspread/{kspread_events.cc => kspread_events.cpp} (100%) rename kspread/{kspread_factory.cc => kspread_factory.cpp} (100%) rename kspread/{kspread_factory_init.cc => kspread_factory_init.cpp} (100%) rename kspread/{kspread_format.cc => kspread_format.cpp} (100%) rename kspread/{kspread_functions_conversion.cc => kspread_functions_conversion.cpp} (100%) rename kspread/{kspread_functions_database.cc => kspread_functions_database.cpp} (100%) rename kspread/{kspread_functions_datetime.cc => kspread_functions_datetime.cpp} (100%) rename kspread/{kspread_functions_engineering.cc => kspread_functions_engineering.cpp} (100%) rename kspread/{kspread_functions_financial.cc => kspread_functions_financial.cpp} (100%) rename kspread/{kspread_functions_helper.cc => kspread_functions_helper.cpp} (100%) rename kspread/{kspread_functions_information.cc => kspread_functions_information.cpp} (100%) rename kspread/{kspread_functions_logic.cc => kspread_functions_logic.cpp} (100%) rename kspread/{kspread_functions_math.cc => kspread_functions_math.cpp} (100%) rename kspread/{kspread_functions_reference.cc => kspread_functions_reference.cpp} (100%) rename kspread/{kspread_functions_statistical.cc => kspread_functions_statistical.cpp} (100%) rename kspread/{kspread_functions_text.cc => kspread_functions_text.cpp} (100%) rename kspread/{kspread_functions_trig.cc => kspread_functions_trig.cpp} (100%) rename kspread/{kspread_genvalidationstyle.cc => kspread_genvalidationstyle.cpp} (100%) rename kspread/{kspread_handler.cc => kspread_handler.cpp} (100%) rename kspread/{kspread_locale.cc => kspread_locale.cpp} (100%) rename kspread/{kspread_map.cc => kspread_map.cpp} (100%) rename kspread/{kspread_numformat.cc => kspread_numformat.cpp} (100%) rename kspread/{kspread_object.cc => kspread_object.cpp} (100%) rename kspread/{kspread_pen.cc => kspread_pen.cpp} (100%) rename kspread/{kspread_sheet.cc => kspread_sheet.cpp} (100%) delete mode 100644 kspread/kspread_sheetprint.cc create mode 100644 kspread/kspread_sheetprint.cpp rename kspread/{kspread_style.cc => kspread_style.cpp} (100%) rename kspread/{kspread_style_manager.cc => kspread_style_manager.cpp} (100%) rename kspread/{kspread_toolbox.cc => kspread_toolbox.cpp} (100%) rename kspread/{kspread_undo.cc => kspread_undo.cpp} (100%) delete mode 100644 kspread/kspread_util.cc create mode 100644 kspread/kspread_util.cpp rename kspread/{kspread_value.cc => kspread_value.cpp} (100%) rename kspread/{kspread_view.cc => kspread_view.cpp} (100%) rename kspread/{main.cc => main.cpp} (100%) rename kspread/{manipulator.cc => manipulator.cpp} (100%) rename kspread/{manipulator_data.cc => manipulator_data.cpp} (100%) rename kspread/plugins/insertcalendar/{kspread_insertcalendardialog.cc => kspread_insertcalendardialog.cpp} (100%) rename kspread/plugins/insertcalendar/{kspread_plugininsertcalendar.cc => kspread_plugininsertcalendar.cpp} (100%) rename kspread/plugins/scripting/{scripting.cc => scripting.cpp} (100%) rename kspread/{region.cc => region.cpp} (100%) rename kspread/{selection.cc => selection.cpp} (100%) rename kspread/tests/{formula_tester.cc => formula_tester.cpp} (100%) rename kspread/tests/{inspector.cc => inspector.cpp} (100%) rename kspread/tests/{test_formula.cc => test_formula.cpp} (100%) rename kspread/tests/{tester.cc => tester.cpp} (100%) rename kspread/tests/{testrunner.cc => testrunner.cpp} (100%) rename kspread/tests/{value_tester.cc => value_tester.cpp} (100%) rename kspread/{valuecalc.cc => valuecalc.cpp} (100%) rename kspread/{valueconverter.cc => valueconverter.cpp} (100%) rename kspread/{valueformatter.cc => valueformatter.cpp} (100%) rename kspread/{valueparser.cc => valueparser.cpp} (100%) rename lib/kformula/{MatrixDialog.cc => MatrixDialog.cpp} (100%) rename lib/kformula/{actionelement.cc => actionelement.cpp} (100%) rename lib/kformula/{basicelement.cc => basicelement.cpp} (100%) rename lib/kformula/{bracketelement.cc => bracketelement.cpp} (100%) rename lib/kformula/{contextstyle.cc => contextstyle.cpp} (100%) rename lib/kformula/{creationstrategy.cc => creationstrategy.cpp} (100%) rename lib/kformula/{elementtype.cc => elementtype.cpp} (100%) rename lib/kformula/{encloseelement.cc => encloseelement.cpp} (100%) rename lib/kformula/{entities.cc => entities.cpp} (100%) rename lib/kformula/{errorelement.cc => errorelement.cpp} (100%) delete mode 100644 lib/kformula/fontstyle.cc create mode 100644 lib/kformula/fontstyle.cpp rename lib/kformula/{formulacursor.cc => formulacursor.cpp} (100%) rename lib/kformula/{formulaelement.cc => formulaelement.cpp} (100%) rename lib/kformula/{fractionelement.cc => fractionelement.cpp} (100%) rename lib/kformula/{glyphelement.cc => glyphelement.cpp} (100%) rename lib/kformula/{identifierelement.cc => identifierelement.cpp} (100%) rename lib/kformula/{indexelement.cc => indexelement.cpp} (100%) rename lib/kformula/{kformulacommand.cc => kformulacommand.cpp} (100%) rename lib/kformula/{kformulacompatibility.cc => kformulacompatibility.cpp} (100%) rename lib/kformula/{kformulaconfigpage.cc => kformulaconfigpage.cpp} (100%) rename lib/kformula/{kformulacontainer.cc => kformulacontainer.cpp} (100%) rename lib/kformula/{kformuladocument.cc => kformuladocument.cpp} (100%) rename lib/kformula/{kformulainputfilter.cc => kformulainputfilter.cpp} (100%) rename lib/kformula/{kformulamathmlread.cc => kformulamathmlread.cpp} (100%) rename lib/kformula/{kformulamimesource.cc => kformulamimesource.cpp} (100%) rename lib/kformula/{kformulaview.cc => kformulaview.cpp} (100%) rename lib/kformula/{kformulawidget.cc => kformulawidget.cpp} (100%) rename lib/kformula/{main.cc => main.cpp} (100%) rename lib/kformula/{matrixelement.cc => matrixelement.cpp} (100%) rename lib/kformula/{numberelement.cc => numberelement.cpp} (100%) rename lib/kformula/{oasiscreationstrategy.cc => oasiscreationstrategy.cpp} (100%) rename lib/kformula/{operatordictionary.cc => operatordictionary.cpp} (100%) rename lib/kformula/{operatorelement.cc => operatorelement.cpp} (100%) rename lib/kformula/{paddedelement.cc => paddedelement.cpp} (100%) rename lib/kformula/{phantomelement.cc => phantomelement.cpp} (100%) rename lib/kformula/{rootelement.cc => rootelement.cpp} (100%) rename lib/kformula/{sequenceelement.cc => sequenceelement.cpp} (100%) rename lib/kformula/{sequenceparser.cc => sequenceparser.cpp} (100%) rename lib/kformula/{spaceelement.cc => spaceelement.cpp} (100%) rename lib/kformula/{stringelement.cc => stringelement.cpp} (100%) rename lib/kformula/{styleelement.cc => styleelement.cpp} (100%) rename lib/kformula/{symbolaction.cc => symbolaction.cpp} (100%) rename lib/kformula/{symbolelement.cc => symbolelement.cpp} (100%) rename lib/kformula/{symbolfontmapping.cc => symbolfontmapping.cpp} (100%) delete mode 100644 lib/kformula/symboltable.cc create mode 100644 lib/kformula/symboltable.cpp rename lib/kformula/{textelement.cc => textelement.cpp} (100%) rename lib/kformula/{tokenelement.cc => tokenelement.cpp} (100%) rename lib/kformula/{tokenstyleelement.cc => tokenstyleelement.cpp} (100%) rename lib/kformula/{unicodetable.cc => unicodetable.cpp} (100%) rename lib/kofficecore/{KoApplicationIface.cc => KoApplicationIface.cpp} (100%) rename lib/kofficecore/{KoDocumentIface.cc => KoDocumentIface.cpp} (100%) delete mode 100644 lib/kofficecore/KoMainWindowIface.cc create mode 100644 lib/kofficecore/KoMainWindowIface.cpp delete mode 100644 lib/kofficecore/KoViewIface.cc create mode 100644 lib/kofficecore/KoViewIface.cpp rename lib/kofficecore/{kofficeversion.cc => kofficeversion.cpp} (100%) rename lib/kopainter/{koColor.cc => koColor.cpp} (100%) rename lib/kopainter/{koColorChooser.cc => koColorChooser.cpp} (100%) rename lib/kopainter/{koColorSlider.cc => koColorSlider.cpp} (100%) rename lib/kopainter/{koFrameButton.cc => koFrameButton.cpp} (100%) rename lib/kopainter/{koIconChooser.cc => koIconChooser.cpp} (100%) rename lib/kopainter/{ko_cmyk_widget.cc => ko_cmyk_widget.cpp} (100%) rename lib/kopainter/{ko_color_wheel.cc => ko_color_wheel.cpp} (100%) rename lib/kopainter/{ko_gray_widget.cc => ko_gray_widget.cpp} (100%) rename lib/kopainter/{ko_hsv_widget.cc => ko_hsv_widget.cpp} (100%) rename lib/kopainter/{ko_rgb_widget.cc => ko_rgb_widget.cpp} (100%) rename lib/kopainter/{kogradientmanager.cc => kogradientmanager.cpp} (100%) rename lib/kopainter/{svgpathparser.cc => svgpathparser.cpp} (100%) rename lib/kopalette/{kopalette.cc => kopalette.cpp} (100%) rename lib/kopalette/{kopalettemanager.cc => kopalettemanager.cpp} (100%) rename lib/kopalette/{kotabpalette.cc => kotabpalette.cpp} (100%) rename lib/kopalette/{kotoolboxpalette.cc => kotoolboxpalette.cpp} (100%) rename lib/kotext/{KoTextViewIface.cc => KoTextViewIface.cpp} (100%) rename lib/kross/python/cxx/{Config.hxx => Config.h} (100%) create mode 100644 lib/kross/python/cxx/Exception.h delete mode 100644 lib/kross/python/cxx/Exception.hxx create mode 100644 lib/kross/python/cxx/Extensions.h delete mode 100644 lib/kross/python/cxx/Extensions.hxx create mode 100644 lib/kross/python/cxx/IndirectPythonInterface.cpp delete mode 100644 lib/kross/python/cxx/IndirectPythonInterface.cxx create mode 100644 lib/kross/python/cxx/IndirectPythonInterface.h delete mode 100644 lib/kross/python/cxx/IndirectPythonInterface.hxx create mode 100644 lib/kross/python/cxx/Objects.h delete mode 100644 lib/kross/python/cxx/Objects.hxx create mode 100644 lib/kross/python/cxx/cxx_extensions.cpp delete mode 100644 lib/kross/python/cxx/cxx_extensions.cxx create mode 100644 lib/kross/python/cxx/cxxsupport.cpp delete mode 100644 lib/kross/python/cxx/cxxsupport.cxx rename lib/kwmf/{kowmfpaint.cc => kowmfpaint.cpp} (100%) rename lib/kwmf/{kowmfread.cc => kowmfread.cpp} (100%) rename lib/kwmf/{kowmfreadprivate.cc => kowmfreadprivate.cpp} (100%) rename lib/kwmf/{kowmfstack.cc => kowmfstack.cpp} (100%) rename lib/kwmf/{kowmfwrite.cc => kowmfwrite.cpp} (100%) rename lib/kwmf/{kwmf.cc => kwmf.cpp} (100%) rename lib/kwmf/{qwmf.cc => qwmf.cpp} (100%) delete mode 100644 tools/kthesaurus/main.cc create mode 100644 tools/kthesaurus/main.cpp rename tools/spell/{main.cc => main.cpp} (100%) delete mode 100644 tools/thesaurus/main.cc create mode 100644 tools/thesaurus/main.cpp diff --git a/chalk/Makefile.am b/chalk/Makefile.am index 0940e393..3a8f3513 100644 --- a/chalk/Makefile.am +++ b/chalk/Makefile.am @@ -2,13 +2,13 @@ INCLUDES = $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) $(all_includes) ## The common lib, shared between the part, the plugins, and the filters lib_LTLIBRARIES = libchalkcommon.la -libchalkcommon_la_SOURCES = dummy.cc +libchalkcommon_la_SOURCES = dummy.cpp libchalkcommon_la_LDFLAGS = $(all_libraries) $(LIB_TQT) -version-info 1:0 -no-undefined libchalkcommon_la_LIBADD = sdk/libchalksdk.la core/libchalkimage.la ui/libchalkui.la chalkcolor/libchalkcolor.la $(LCMS_LIBS) $(LIB_KOFFICEUI) $(LIB_KOPAINTER) $(LIB_KOPALETTE) $(LIB_XINPUTEXT) ## The part kde_module_LTLIBRARIES = libchalkpart.la -libchalkpart_la_SOURCES = chalk_part_init.cc +libchalkpart_la_SOURCES = chalk_part_init.cpp libchalkpart_la_LDFLAGS = $(all_libraries) $(LIB_TQT) -module $(KDE_PLUGIN) libchalkpart_la_LIBADD = $(KOFFICE_LIBS) libchalkcommon.la ../chalk/ui/libchalkui.la @@ -17,7 +17,7 @@ METASOURCES = AUTO ## The tdeinit loadable module and executable tdeinit_LTLIBRARIES = chalk.la bin_PROGRAMS = -chalk_la_SOURCES = main.cc +chalk_la_SOURCES = main.cpp chalk_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) chalk_la_LIBADD = $(LIB_KOFFICECORE) @@ -30,14 +30,14 @@ rc_DATA = chalk.rc chalk_readonly.rc SUBDIRS = sdk chalkcolor core ui . dtd colorspaces plugins data pics # Needed to compile libchalkcommon.la, which has no source files to itself # but everything in static libs. -dummy.cc: - echo > dummy.cc +dummy.cpp: + echo > dummy.cpp messages: rc.cpp $(EXTRACTRC) `find . -name \*.ui` >> rc.cpp $(EXTRACTRC) `find . -name \*.rc` >> rc.cpp perl extracti18n.pl > i18ndata - $(XGETTEXT) i18ndata rc.cpp `find . -name \*.cc -o -name \*.h -o -name \*.cpp` ui/kis_aboutdata.h -o $(podir)/chalk.pot + $(XGETTEXT) i18ndata rc.cpp `find . -name \*.cpp -o -name \*.h -o -name \*.cpp` ui/kis_aboutdata.h -o $(podir)/chalk.pot rm -f i18ndata DOXYGEN_EXCLUDE = CImg.h colorspaces plugins chalkcolor/colorspaces core/tiles diff --git a/chalk/chalk_part_init.cc b/chalk/chalk_part_init.cc deleted file mode 100644 index b5691974..00000000 --- a/chalk/chalk_part_init.cc +++ /dev/null @@ -1,23 +0,0 @@ -/* - * kis_part_init.cc - part of Krayon - * - * Copyright (c) 1999 Matthias Elter - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include "ui/kis_factory.h" - - -K_EXPORT_COMPONENT_FACTORY( libchalkpart, KisFactory ) diff --git a/chalk/chalk_part_init.cpp b/chalk/chalk_part_init.cpp new file mode 100644 index 00000000..1915112e --- /dev/null +++ b/chalk/chalk_part_init.cpp @@ -0,0 +1,23 @@ +/* + * kis_part_init.cpp - part of Krayon + * + * Copyright (c) 1999 Matthias Elter + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "ui/kis_factory.h" + + +K_EXPORT_COMPONENT_FACTORY( libchalkpart, KisFactory ) diff --git a/chalk/chalkcolor/Makefile.am b/chalk/chalkcolor/Makefile.am index 1fee3836..d31ea1c5 100644 --- a/chalk/chalkcolor/Makefile.am +++ b/chalk/chalkcolor/Makefile.am @@ -11,14 +11,14 @@ CXXFLAGS += $(OPENEXR_CXXFLAGS) lib_LTLIBRARIES = libchalkcolor.la if have_openexr -OPENEXR_SOURCES=kis_f16half_base_colorspace.cc +OPENEXR_SOURCES=kis_f16half_base_colorspace.cpp endif -libchalkcolor_la_SOURCES = kis_color.cc kis_colorspace.cc \ - kis_colorspace_iface.cc kis_colorspace_iface.skel kis_composite_op.cc kis_profile.cc \ - kis_histogram_producer.cc kis_basic_histogram_producers.cc kis_abstract_colorspace.cc \ - kis_colorspace_factory_registry.cc kis_color_conversions.cc kis_u8_base_colorspace.cc \ - kis_u16_base_colorspace.cc kis_f32_base_colorspace.cc $(OPENEXR_SOURCES) +libchalkcolor_la_SOURCES = kis_color.cpp kis_colorspace.cpp \ + kis_colorspace_iface.cpp kis_colorspace_iface.skel kis_composite_op.cpp kis_profile.cpp \ + kis_histogram_producer.cpp kis_basic_histogram_producers.cpp kis_abstract_colorspace.cpp \ + kis_colorspace_factory_registry.cpp kis_color_conversions.cpp kis_u8_base_colorspace.cpp \ + kis_u16_base_colorspace.cpp kis_f32_base_colorspace.cpp $(OPENEXR_SOURCES) libchalkcolor_la_LDFLAGS = -version-info 1:0:0 -no-undefined $(all_libraries) libchalkcolor_la_LIBADD = colorspaces/libchalkcolorspaces.la $(LCMS_LIBS) $(LIB_TDEPARTS) $(LIB_TDECORE) $(LIB_TQT) $(OPENEXR_LIBS) diff --git a/chalk/chalkcolor/colorspaces/Makefile.am b/chalk/chalkcolor/colorspaces/Makefile.am index 90f75d29..18bd587b 100644 --- a/chalk/chalkcolor/colorspaces/Makefile.am +++ b/chalk/chalkcolor/colorspaces/Makefile.am @@ -6,8 +6,8 @@ INCLUDES = -I$(srcdir)/.. \ noinst_LTLIBRARIES = libchalkcolorspaces.la libchalkcolorspaces_la_SOURCES = \ - kis_alpha_colorspace.cc \ - kis_lab_colorspace.cc + kis_alpha_colorspace.cpp \ + kis_lab_colorspace.cpp noinst_HEADERS = \ kis_alpha_colorspace.h \ diff --git a/chalk/chalkcolor/colorspaces/kis_alpha_colorspace.cc b/chalk/chalkcolor/colorspaces/kis_alpha_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/colorspaces/kis_alpha_colorspace.cc rename to chalk/chalkcolor/colorspaces/kis_alpha_colorspace.cpp diff --git a/chalk/chalkcolor/colorspaces/kis_lab_colorspace.cc b/chalk/chalkcolor/colorspaces/kis_lab_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/colorspaces/kis_lab_colorspace.cc rename to chalk/chalkcolor/colorspaces/kis_lab_colorspace.cpp diff --git a/chalk/chalkcolor/colorspaces/kis_xyz_colorspace.cc b/chalk/chalkcolor/colorspaces/kis_xyz_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/colorspaces/kis_xyz_colorspace.cc rename to chalk/chalkcolor/colorspaces/kis_xyz_colorspace.cpp diff --git a/chalk/chalkcolor/kis_abstract_colorspace.cc b/chalk/chalkcolor/kis_abstract_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/kis_abstract_colorspace.cc rename to chalk/chalkcolor/kis_abstract_colorspace.cpp diff --git a/chalk/chalkcolor/kis_basic_histogram_producers.cc b/chalk/chalkcolor/kis_basic_histogram_producers.cpp similarity index 100% rename from chalk/chalkcolor/kis_basic_histogram_producers.cc rename to chalk/chalkcolor/kis_basic_histogram_producers.cpp diff --git a/chalk/chalkcolor/kis_color.cc b/chalk/chalkcolor/kis_color.cpp similarity index 100% rename from chalk/chalkcolor/kis_color.cc rename to chalk/chalkcolor/kis_color.cpp diff --git a/chalk/chalkcolor/kis_color_conversions.cc b/chalk/chalkcolor/kis_color_conversions.cpp similarity index 100% rename from chalk/chalkcolor/kis_color_conversions.cc rename to chalk/chalkcolor/kis_color_conversions.cpp diff --git a/chalk/chalkcolor/kis_colorspace.cc b/chalk/chalkcolor/kis_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/kis_colorspace.cc rename to chalk/chalkcolor/kis_colorspace.cpp diff --git a/chalk/chalkcolor/kis_colorspace_factory_registry.cc b/chalk/chalkcolor/kis_colorspace_factory_registry.cpp similarity index 100% rename from chalk/chalkcolor/kis_colorspace_factory_registry.cc rename to chalk/chalkcolor/kis_colorspace_factory_registry.cpp diff --git a/chalk/chalkcolor/kis_colorspace_iface.cc b/chalk/chalkcolor/kis_colorspace_iface.cpp similarity index 100% rename from chalk/chalkcolor/kis_colorspace_iface.cc rename to chalk/chalkcolor/kis_colorspace_iface.cpp diff --git a/chalk/chalkcolor/kis_composite_op.cc b/chalk/chalkcolor/kis_composite_op.cpp similarity index 100% rename from chalk/chalkcolor/kis_composite_op.cc rename to chalk/chalkcolor/kis_composite_op.cpp diff --git a/chalk/chalkcolor/kis_f16half_base_colorspace.cc b/chalk/chalkcolor/kis_f16half_base_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/kis_f16half_base_colorspace.cc rename to chalk/chalkcolor/kis_f16half_base_colorspace.cpp diff --git a/chalk/chalkcolor/kis_f32_base_colorspace.cc b/chalk/chalkcolor/kis_f32_base_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/kis_f32_base_colorspace.cc rename to chalk/chalkcolor/kis_f32_base_colorspace.cpp diff --git a/chalk/chalkcolor/kis_histogram_producer.cc b/chalk/chalkcolor/kis_histogram_producer.cpp similarity index 100% rename from chalk/chalkcolor/kis_histogram_producer.cc rename to chalk/chalkcolor/kis_histogram_producer.cpp diff --git a/chalk/chalkcolor/kis_profile.cc b/chalk/chalkcolor/kis_profile.cc deleted file mode 100644 index 61b2ad32..00000000 --- a/chalk/chalkcolor/kis_profile.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * kis_profile.cc - part of Krayon - * - * Copyright (c) 2000 Matthias Elter - * 2001 John Califf - * 2004 Boudewijn Rempt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include -#include -#include LCMS_HEADER - -#include -#include -#include - -#include - -#include "kis_profile.h" -#include "kis_global.h" - -#include "ksharedptr.h" - -#include -#include -#include - -KisProfile::KisProfile(TQByteArray rawData) - : m_rawData(rawData), - m_filename( TQString() ), - m_valid( false ), - m_suitableForOutput(false) -{ - m_profile = cmsOpenProfileFromMem(rawData.data(), (DWORD)rawData.size()); - init(); -} - -KisProfile::KisProfile(const TQString& file) - : m_filename(file), - m_valid( false ), - m_suitableForOutput( false ) -{ -} - -KisProfile::KisProfile(const cmsHPROFILE profile) - : m_profile(profile), - m_filename( TQString() ), - m_valid( true ) -{ - size_t bytesNeeded=0; - - // Make a raw data image ready for saving - _cmsSaveProfileToMem(m_profile, 0, &bytesNeeded); // calc size - if(m_rawData.resize(bytesNeeded)) - { - _cmsSaveProfileToMem(m_profile, m_rawData.data(), &bytesNeeded); // fill buffer - cmsHPROFILE newprofile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD) bytesNeeded); - cmsCloseProfile(m_profile); - m_profile = newprofile; - } - else - m_rawData.resize(0); - - init(); -} - -KisProfile::~KisProfile() -{ - cmsCloseProfile(m_profile); -} - - -bool KisProfile::load() -{ - TQFile file(m_filename); - file.open(IO_ReadOnly); - m_rawData = file.readAll(); - m_profile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD)m_rawData.size()); - file.close(); - - if (m_profile == 0) { - kdWarning() << "Failed to load profile from " << m_filename << endl; - } - - return init(); - -} - -bool KisProfile::init() -{ - if (m_profile) { - m_colorSpaceSignature = cmsGetColorSpace(m_profile); - m_deviceClass = cmsGetDeviceClass(m_profile); - m_productName = cmsTakeProductName(m_profile); - m_productDescription = cmsTakeProductDesc(m_profile); - m_productInfo = cmsTakeProductInfo(m_profile); - m_valid = true; - - // Check if the profile can convert (something->this) -// LPMATSHAPER OutMatShaper = cmsBuildOutputMatrixShaper(m_profile); -// if( OutMatShaper ) -// { -// m_suitableForOutput = true; -// } - cmsCIEXYZTRIPLE Primaries; - - if (cmsTakeColorants(&Primaries, m_profile)) - { - m_suitableForOutput = true; - } - -#if 0 - // XXX: It wasn't that easy to save a little memory: thsi gives an lcms error - // Okay, we know enough. Free the memory; we'll load it again if needed. - - cmsCloseProfile(m_profile); - m_profile = 0; - -#endif - return true; - } - return false; -} - -cmsHPROFILE KisProfile::profile() -{ -#if 0 - if (m_profile = 0) { - TQFile file(m_filename); - file.open(IO_ReadOnly); - m_rawData = file.readAll(); - m_profile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD)m_rawData.size()); - file.close(); - } -#endif - return m_profile; -} - -bool KisProfile::save() -{ - return false; -} - -KisAnnotationSP KisProfile::annotation() const -{ - // XXX we hardcode icc, this is correct for lcms? - // XXX productName(), or just "ICC Profile"? - if (!m_rawData.isEmpty()) - return new KisAnnotation("icc", productName(), m_rawData); - else - return 0; -} - -KisProfile * KisProfile::getScreenProfile (int screen) -{ - -#ifdef Q_WS_X11 - - Atom type; - int format; - unsigned long nitems; - unsigned long bytes_after; - TQ_UINT8 * str; - - static Atom icc_atom = XInternAtom( tqt_xdisplay(), "_ICC_PROFILE", False ); - - if ( XGetWindowProperty ( tqt_xdisplay(), - tqt_xrootwin( screen ), - icc_atom, - 0, - INT_MAX, - False, - XA_CARDINAL, - &type, - &format, - &nitems, - &bytes_after, - (unsigned char **) &str) - ) { - - TQByteArray bytes (nitems); - bytes.assign((char*)str, (TQ_UINT32)nitems); - - return new KisProfile(bytes); - } else { - return NULL; - } -#else - return NULL; - -#endif -} - - diff --git a/chalk/chalkcolor/kis_profile.cpp b/chalk/chalkcolor/kis_profile.cpp new file mode 100644 index 00000000..df98a750 --- /dev/null +++ b/chalk/chalkcolor/kis_profile.cpp @@ -0,0 +1,208 @@ +/* + * kis_profile.cpp - part of Krayon + * + * Copyright (c) 2000 Matthias Elter + * 2001 John Califf + * 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include LCMS_HEADER + +#include +#include +#include + +#include + +#include "kis_profile.h" +#include "kis_global.h" + +#include "ksharedptr.h" + +#include +#include +#include + +KisProfile::KisProfile(TQByteArray rawData) + : m_rawData(rawData), + m_filename( TQString() ), + m_valid( false ), + m_suitableForOutput(false) +{ + m_profile = cmsOpenProfileFromMem(rawData.data(), (DWORD)rawData.size()); + init(); +} + +KisProfile::KisProfile(const TQString& file) + : m_filename(file), + m_valid( false ), + m_suitableForOutput( false ) +{ +} + +KisProfile::KisProfile(const cmsHPROFILE profile) + : m_profile(profile), + m_filename( TQString() ), + m_valid( true ) +{ + size_t bytesNeeded=0; + + // Make a raw data image ready for saving + _cmsSaveProfileToMem(m_profile, 0, &bytesNeeded); // calc size + if(m_rawData.resize(bytesNeeded)) + { + _cmsSaveProfileToMem(m_profile, m_rawData.data(), &bytesNeeded); // fill buffer + cmsHPROFILE newprofile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD) bytesNeeded); + cmsCloseProfile(m_profile); + m_profile = newprofile; + } + else + m_rawData.resize(0); + + init(); +} + +KisProfile::~KisProfile() +{ + cmsCloseProfile(m_profile); +} + + +bool KisProfile::load() +{ + TQFile file(m_filename); + file.open(IO_ReadOnly); + m_rawData = file.readAll(); + m_profile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD)m_rawData.size()); + file.close(); + + if (m_profile == 0) { + kdWarning() << "Failed to load profile from " << m_filename << endl; + } + + return init(); + +} + +bool KisProfile::init() +{ + if (m_profile) { + m_colorSpaceSignature = cmsGetColorSpace(m_profile); + m_deviceClass = cmsGetDeviceClass(m_profile); + m_productName = cmsTakeProductName(m_profile); + m_productDescription = cmsTakeProductDesc(m_profile); + m_productInfo = cmsTakeProductInfo(m_profile); + m_valid = true; + + // Check if the profile can convert (something->this) +// LPMATSHAPER OutMatShaper = cmsBuildOutputMatrixShaper(m_profile); +// if( OutMatShaper ) +// { +// m_suitableForOutput = true; +// } + cmsCIEXYZTRIPLE Primaries; + + if (cmsTakeColorants(&Primaries, m_profile)) + { + m_suitableForOutput = true; + } + +#if 0 + // XXX: It wasn't that easy to save a little memory: thsi gives an lcms error + // Okay, we know enough. Free the memory; we'll load it again if needed. + + cmsCloseProfile(m_profile); + m_profile = 0; + +#endif + return true; + } + return false; +} + +cmsHPROFILE KisProfile::profile() +{ +#if 0 + if (m_profile = 0) { + TQFile file(m_filename); + file.open(IO_ReadOnly); + m_rawData = file.readAll(); + m_profile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD)m_rawData.size()); + file.close(); + } +#endif + return m_profile; +} + +bool KisProfile::save() +{ + return false; +} + +KisAnnotationSP KisProfile::annotation() const +{ + // XXX we hardcode icc, this is correct for lcms? + // XXX productName(), or just "ICC Profile"? + if (!m_rawData.isEmpty()) + return new KisAnnotation("icc", productName(), m_rawData); + else + return 0; +} + +KisProfile * KisProfile::getScreenProfile (int screen) +{ + +#ifdef Q_WS_X11 + + Atom type; + int format; + unsigned long nitems; + unsigned long bytes_after; + TQ_UINT8 * str; + + static Atom icc_atom = XInternAtom( tqt_xdisplay(), "_ICC_PROFILE", False ); + + if ( XGetWindowProperty ( tqt_xdisplay(), + tqt_xrootwin( screen ), + icc_atom, + 0, + INT_MAX, + False, + XA_CARDINAL, + &type, + &format, + &nitems, + &bytes_after, + (unsigned char **) &str) + ) { + + TQByteArray bytes (nitems); + bytes.assign((char*)str, (TQ_UINT32)nitems); + + return new KisProfile(bytes); + } else { + return NULL; + } +#else + return NULL; + +#endif +} + + diff --git a/chalk/chalkcolor/kis_u16_base_colorspace.cc b/chalk/chalkcolor/kis_u16_base_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/kis_u16_base_colorspace.cc rename to chalk/chalkcolor/kis_u16_base_colorspace.cpp diff --git a/chalk/chalkcolor/kis_u8_base_colorspace.cc b/chalk/chalkcolor/kis_u8_base_colorspace.cpp similarity index 100% rename from chalk/chalkcolor/kis_u8_base_colorspace.cc rename to chalk/chalkcolor/kis_u8_base_colorspace.cpp diff --git a/chalk/colorspaces/cmyk_u16/Makefile.am b/chalk/colorspaces/cmyk_u16/Makefile.am index 00cdd32d..7f5ec9ca 100644 --- a/chalk/colorspaces/cmyk_u16/Makefile.am +++ b/chalk/colorspaces/cmyk_u16/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ $(all_includes) lib_LTLIBRARIES = libchalk_cmyk_u16.la -libchalk_cmyk_u16_la_SOURCES = kis_cmyk_u16_colorspace.cc +libchalk_cmyk_u16_la_SOURCES = kis_cmyk_u16_colorspace.cpp libchalk_cmyk_u16_la_LDFLAGS = $(all_libraries) libchalk_cmyk_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -15,7 +15,7 @@ libchalk_cmyk_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_cmyk_u16_plugin.la # Srcs for the plugin -chalk_cmyk_u16_plugin_la_SOURCES = cmyk_u16_plugin.cc +chalk_cmyk_u16_plugin_la_SOURCES = cmyk_u16_plugin.cpp noinst_HEADERS = cmyk_u16_plugin.h kis_cmyk_u16_colorspace.h chalk_cmyk_u16_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cc b/chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cc deleted file mode 100644 index 4b3afa29..00000000 --- a/chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -* cmyk_u16_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* Copyright (c) 2005 Adrian Page -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include "cmyk_u16_plugin.h" -#include "kis_cmyk_u16_colorspace.h" - -typedef KGenericFactory CMYKU16PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_cmyk_u16_plugin, CMYKU16PluginFactory( "chalk" ) ) - - -CMYKU16Plugin::CMYKU16Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(CMYKU16PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceCMYKU16 = new KisCmykU16ColorSpace(f, 0); - KisColorSpaceFactory * csf = new KisCmykU16ColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceCMYKU16); - f->add(csf); - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("CMYK16HISTO", i18n("CMYK16")), colorSpaceCMYKU16) ); - } - -} - -CMYKU16Plugin::~CMYKU16Plugin() -{ -} - -#include "cmyk_u16_plugin.moc" diff --git a/chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cpp b/chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cpp new file mode 100644 index 00000000..4195ff22 --- /dev/null +++ b/chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cpp @@ -0,0 +1,61 @@ +/* +* cmyk_u16_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* Copyright (c) 2005 Adrian Page +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include "cmyk_u16_plugin.h" +#include "kis_cmyk_u16_colorspace.h" + +typedef KGenericFactory CMYKU16PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_cmyk_u16_plugin, CMYKU16PluginFactory( "chalk" ) ) + + +CMYKU16Plugin::CMYKU16Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(CMYKU16PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceCMYKU16 = new KisCmykU16ColorSpace(f, 0); + KisColorSpaceFactory * csf = new KisCmykU16ColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceCMYKU16); + f->add(csf); + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("CMYK16HISTO", i18n("CMYK16")), colorSpaceCMYKU16) ); + } + +} + +CMYKU16Plugin::~CMYKU16Plugin() +{ +} + +#include "cmyk_u16_plugin.moc" diff --git a/chalk/colorspaces/cmyk_u16/kis_cmyk_u16_colorspace.cc b/chalk/colorspaces/cmyk_u16/kis_cmyk_u16_colorspace.cpp similarity index 100% rename from chalk/colorspaces/cmyk_u16/kis_cmyk_u16_colorspace.cc rename to chalk/colorspaces/cmyk_u16/kis_cmyk_u16_colorspace.cpp diff --git a/chalk/colorspaces/cmyk_u8/Makefile.am b/chalk/colorspaces/cmyk_u8/Makefile.am index 90ab3869..97554d24 100644 --- a/chalk/colorspaces/cmyk_u8/Makefile.am +++ b/chalk/colorspaces/cmyk_u8/Makefile.am @@ -8,7 +8,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ kde_module_LTLIBRARIES = chalkcmykplugin.la -chalkcmykplugin_la_SOURCES = cmyk_plugin.cc kis_cmyk_colorspace.cc +chalkcmykplugin_la_SOURCES = cmyk_plugin.cpp kis_cmyk_colorspace.cpp noinst_HEADERS = cmyk_plugin.h kis_cmyk_colorspace.h chalkcmykplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/cmyk_u8/cmyk_plugin.cc b/chalk/colorspaces/cmyk_u8/cmyk_plugin.cc deleted file mode 100644 index 7b09ecca..00000000 --- a/chalk/colorspaces/cmyk_u8/cmyk_plugin.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - * cmyk_plugin.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "cmyk_plugin.h" - -#include "kis_cmyk_colorspace.h" - -typedef KGenericFactory CMYKPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkcmykplugin, CMYKPluginFactory( "chalk" ) ) - - -CMYKPlugin::CMYKPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(CMYKPluginFactory::instance()); - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceCMYK = new KisCmykColorSpace(f, 0); - KisColorSpaceFactory * csf = new KisCmykColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceCMYK); - f->add(csf); - - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("CMYKHISTO", i18n("CMYK")), colorSpaceCMYK) ); - } - -} - -CMYKPlugin::~CMYKPlugin() -{ -} - -#include "cmyk_plugin.moc" diff --git a/chalk/colorspaces/cmyk_u8/cmyk_plugin.cpp b/chalk/colorspaces/cmyk_u8/cmyk_plugin.cpp new file mode 100644 index 00000000..588e286c --- /dev/null +++ b/chalk/colorspaces/cmyk_u8/cmyk_plugin.cpp @@ -0,0 +1,66 @@ +/* + * cmyk_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "cmyk_plugin.h" + +#include "kis_cmyk_colorspace.h" + +typedef KGenericFactory CMYKPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkcmykplugin, CMYKPluginFactory( "chalk" ) ) + + +CMYKPlugin::CMYKPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(CMYKPluginFactory::instance()); + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceCMYK = new KisCmykColorSpace(f, 0); + KisColorSpaceFactory * csf = new KisCmykColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceCMYK); + f->add(csf); + + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("CMYKHISTO", i18n("CMYK")), colorSpaceCMYK) ); + } + +} + +CMYKPlugin::~CMYKPlugin() +{ +} + +#include "cmyk_plugin.moc" diff --git a/chalk/colorspaces/cmyk_u8/kis_cmyk_colorspace.cc b/chalk/colorspaces/cmyk_u8/kis_cmyk_colorspace.cpp similarity index 100% rename from chalk/colorspaces/cmyk_u8/kis_cmyk_colorspace.cc rename to chalk/colorspaces/cmyk_u8/kis_cmyk_colorspace.cpp diff --git a/chalk/colorspaces/gray_u16/Makefile.am b/chalk/colorspaces/gray_u16/Makefile.am index 8ee4314c..d77d32d2 100644 --- a/chalk/colorspaces/gray_u16/Makefile.am +++ b/chalk/colorspaces/gray_u16/Makefile.am @@ -8,7 +8,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ $(all_includes) lib_LTLIBRARIES = libchalk_gray_u16.la -libchalk_gray_u16_la_SOURCES = kis_gray_u16_colorspace.cc +libchalk_gray_u16_la_SOURCES = kis_gray_u16_colorspace.cpp libchalk_gray_u16_la_LDFLAGS = $(all_libraries) libchalk_gray_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -16,7 +16,7 @@ libchalk_gray_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_gray_u16_plugin.la # Srcs for the plugin -chalk_gray_u16_plugin_la_SOURCES = gray_u16_plugin.cc +chalk_gray_u16_plugin_la_SOURCES = gray_u16_plugin.cpp noinst_HEADERS = gray_u16_plugin.h kis_gray_u16_colorspace.h chalk_gray_u16_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/gray_u16/gray_u16_plugin.cc b/chalk/colorspaces/gray_u16/gray_u16_plugin.cc deleted file mode 100644 index 5e9e17f9..00000000 --- a/chalk/colorspaces/gray_u16/gray_u16_plugin.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* -* gray_u16_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* Copyright (c) 2005 Adrian Page -* -* This program is free software; you can grayistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include - -#include -#include - -#include "gray_u16_plugin.h" -#include "kis_gray_u16_colorspace.h" - -typedef KGenericFactory GRAYU16PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_gray_u16_plugin, GRAYU16PluginFactory( "chalk" ) ) - - -GRAYU16Plugin::GRAYU16Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(GRAYU16PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceGRAYU16 = new KisGrayU16ColorSpace(f, 0); - KisColorSpaceFactory * csf = new KisGrayU16ColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceGRAYU16); - f->add(csf); - - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("GRAYA16HISTO", i18n("GRAY/Alpha16")), colorSpaceGRAYU16) ); - } - -} - -GRAYU16Plugin::~GRAYU16Plugin() -{ -} - -#include "gray_u16_plugin.moc" diff --git a/chalk/colorspaces/gray_u16/gray_u16_plugin.cpp b/chalk/colorspaces/gray_u16/gray_u16_plugin.cpp new file mode 100644 index 00000000..7c1896f9 --- /dev/null +++ b/chalk/colorspaces/gray_u16/gray_u16_plugin.cpp @@ -0,0 +1,63 @@ +/* +* gray_u16_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* Copyright (c) 2005 Adrian Page +* +* This program is free software; you can grayistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include + +#include +#include + +#include "gray_u16_plugin.h" +#include "kis_gray_u16_colorspace.h" + +typedef KGenericFactory GRAYU16PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_gray_u16_plugin, GRAYU16PluginFactory( "chalk" ) ) + + +GRAYU16Plugin::GRAYU16Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(GRAYU16PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceGRAYU16 = new KisGrayU16ColorSpace(f, 0); + KisColorSpaceFactory * csf = new KisGrayU16ColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceGRAYU16); + f->add(csf); + + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("GRAYA16HISTO", i18n("GRAY/Alpha16")), colorSpaceGRAYU16) ); + } + +} + +GRAYU16Plugin::~GRAYU16Plugin() +{ +} + +#include "gray_u16_plugin.moc" diff --git a/chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc b/chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cpp similarity index 100% rename from chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc rename to chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cpp diff --git a/chalk/colorspaces/gray_u8/Makefile.am b/chalk/colorspaces/gray_u8/Makefile.am index fda7f56a..1282ef00 100644 --- a/chalk/colorspaces/gray_u8/Makefile.am +++ b/chalk/colorspaces/gray_u8/Makefile.am @@ -9,13 +9,13 @@ INCLUDES = -I$(srcdir)/../../sdk \ lib_LTLIBRARIES = libchalkgrayscale.la -libchalkgrayscale_la_SOURCES = kis_gray_colorspace.cc +libchalkgrayscale_la_SOURCES = kis_gray_colorspace.cpp libchalkgrayscale_la_LDFLAGS = $(all_libraries) libchalkgrayscale_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalkgrayplugin.la -chalkgrayplugin_la_SOURCES = gray_plugin.cc +chalkgrayplugin_la_SOURCES = gray_plugin.cpp noinst_HEADERS = gray_plugin.h kis_gray_colorspace.h chalkgrayplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/gray_u8/gray_plugin.cc b/chalk/colorspaces/gray_u8/gray_plugin.cc deleted file mode 100644 index 7d03d5f6..00000000 --- a/chalk/colorspaces/gray_u8/gray_plugin.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * gray_plugin.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "gray_plugin.h" -#include "kis_gray_colorspace.h" - -typedef KGenericFactory GrayPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkgrayplugin, GrayPluginFactory( "chalkcore" ) ) - - -GrayPlugin::GrayPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(GrayPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - // .22 gamma grayscale or something like that. Taken from the lcms tutorial... - LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2); - cmsHPROFILE hProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma); - cmsFreeGamma(Gamma); - KisProfile *defProfile = new KisProfile(hProfile); - - f->addProfile(defProfile); - - KisColorSpace * colorSpaceGrayA = new KisGrayColorSpace(f, 0); - - KisColorSpaceFactory * csf = new KisGrayColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceGrayA); - - f->add(csf); - - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("GRAYA8HISTO", i18n("GRAY/Alpha8")), colorSpaceGrayA) ); - } - -} - -GrayPlugin::~GrayPlugin() -{ -} - -#include "gray_plugin.moc" diff --git a/chalk/colorspaces/gray_u8/gray_plugin.cpp b/chalk/colorspaces/gray_u8/gray_plugin.cpp new file mode 100644 index 00000000..7f177eea --- /dev/null +++ b/chalk/colorspaces/gray_u8/gray_plugin.cpp @@ -0,0 +1,77 @@ +/* + * gray_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gray_plugin.h" +#include "kis_gray_colorspace.h" + +typedef KGenericFactory GrayPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkgrayplugin, GrayPluginFactory( "chalkcore" ) ) + + +GrayPlugin::GrayPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(GrayPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + // .22 gamma grayscale or something like that. Taken from the lcms tutorial... + LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2); + cmsHPROFILE hProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma); + cmsFreeGamma(Gamma); + KisProfile *defProfile = new KisProfile(hProfile); + + f->addProfile(defProfile); + + KisColorSpace * colorSpaceGrayA = new KisGrayColorSpace(f, 0); + + KisColorSpaceFactory * csf = new KisGrayColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceGrayA); + + f->add(csf); + + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("GRAYA8HISTO", i18n("GRAY/Alpha8")), colorSpaceGrayA) ); + } + +} + +GrayPlugin::~GrayPlugin() +{ +} + +#include "gray_plugin.moc" diff --git a/chalk/colorspaces/gray_u8/kis_gray_colorspace.cc b/chalk/colorspaces/gray_u8/kis_gray_colorspace.cpp similarity index 100% rename from chalk/colorspaces/gray_u8/kis_gray_colorspace.cc rename to chalk/colorspaces/gray_u8/kis_gray_colorspace.cpp diff --git a/chalk/colorspaces/lms_f32/Makefile.am b/chalk/colorspaces/lms_f32/Makefile.am index bf8c65ec..b7eedf99 100644 --- a/chalk/colorspaces/lms_f32/Makefile.am +++ b/chalk/colorspaces/lms_f32/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = \ lib_LTLIBRARIES = libchalk_lms_f32.la -libchalk_lms_f32_la_SOURCES = kis_lms_f32_colorspace.cc +libchalk_lms_f32_la_SOURCES = kis_lms_f32_colorspace.cpp libchalk_lms_f32_la_LDFLAGS = $(all_libraries) libchalk_lms_f32_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -18,7 +18,7 @@ libchalk_lms_f32_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_lms_f32_plugin.la # Srcs for the plugin -chalk_lms_f32_plugin_la_SOURCES = lms_f32_plugin.cc +chalk_lms_f32_plugin_la_SOURCES = lms_f32_plugin.cpp noinst_HEADERS = lms_f32_plugin.h kis_lms_f32_colorspace.h chalk_lms_f32_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/lms_f32/kis_lms_f32_colorspace.cc b/chalk/colorspaces/lms_f32/kis_lms_f32_colorspace.cpp similarity index 100% rename from chalk/colorspaces/lms_f32/kis_lms_f32_colorspace.cc rename to chalk/colorspaces/lms_f32/kis_lms_f32_colorspace.cpp diff --git a/chalk/colorspaces/lms_f32/lms_f32_plugin.cc b/chalk/colorspaces/lms_f32/lms_f32_plugin.cc deleted file mode 100644 index f7e581ac..00000000 --- a/chalk/colorspaces/lms_f32/lms_f32_plugin.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -* lms_f32_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* Copyright (c) 2005 Adrian Page -* Copyright (c) 2005 Cyrille Berger -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include -#include -#include - -#include "lms_f32_plugin.h" -#include "kis_lms_f32_colorspace.h" - -typedef KGenericFactory LMSF32PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_lms_f32_plugin, LMSF32PluginFactory( "chalk" ) ) - - -LMSF32Plugin::LMSF32Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(LMSF32PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); - - KisColorSpace * colorSpaceLMSF32 = new KisLmsF32ColorSpace(f, 0); - - KisColorSpaceFactory * csf = new KisLmsF32ColorSpaceFactory(); - f->add(csf); - - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("LMSF32HISTO", i18n("Float32")), colorSpaceLMSF32) ); - } - -} - -LMSF32Plugin::~LMSF32Plugin() -{ -} - -#include "lms_f32_plugin.moc" diff --git a/chalk/colorspaces/lms_f32/lms_f32_plugin.cpp b/chalk/colorspaces/lms_f32/lms_f32_plugin.cpp new file mode 100644 index 00000000..2c83ccd6 --- /dev/null +++ b/chalk/colorspaces/lms_f32/lms_f32_plugin.cpp @@ -0,0 +1,64 @@ +/* +* lms_f32_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* Copyright (c) 2005 Adrian Page +* Copyright (c) 2005 Cyrille Berger +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include +#include +#include + +#include "lms_f32_plugin.h" +#include "kis_lms_f32_colorspace.h" + +typedef KGenericFactory LMSF32PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_lms_f32_plugin, LMSF32PluginFactory( "chalk" ) ) + + +LMSF32Plugin::LMSF32Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(LMSF32PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); + + KisColorSpace * colorSpaceLMSF32 = new KisLmsF32ColorSpace(f, 0); + + KisColorSpaceFactory * csf = new KisLmsF32ColorSpaceFactory(); + f->add(csf); + + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("LMSF32HISTO", i18n("Float32")), colorSpaceLMSF32) ); + } + +} + +LMSF32Plugin::~LMSF32Plugin() +{ +} + +#include "lms_f32_plugin.moc" diff --git a/chalk/colorspaces/rgb_f16half/Makefile.am b/chalk/colorspaces/rgb_f16half/Makefile.am index 52f0c583..cea86b4c 100644 --- a/chalk/colorspaces/rgb_f16half/Makefile.am +++ b/chalk/colorspaces/rgb_f16half/Makefile.am @@ -13,7 +13,7 @@ CXXFLAGS += $(OPENEXR_CXXFLAGS) lib_LTLIBRARIES = libchalk_rgb_f16half.la -libchalk_rgb_f16half_la_SOURCES = kis_rgb_f16half_colorspace.cc +libchalk_rgb_f16half_la_SOURCES = kis_rgb_f16half_colorspace.cpp libchalk_rgb_f16half_la_LDFLAGS = $(all_libraries) libchalk_rgb_f16half_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -21,7 +21,7 @@ libchalk_rgb_f16half_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_rgb_f16half_plugin.la # Srcs for the plugin -chalk_rgb_f16half_plugin_la_SOURCES = rgb_f16half_plugin.cc +chalk_rgb_f16half_plugin_la_SOURCES = rgb_f16half_plugin.cpp noinst_HEADERS = rgb_f16half_plugin.h kis_rgb_f16half_colorspace.h chalk_rgb_f16half_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/rgb_f16half/kis_rgb_f16half_colorspace.cc b/chalk/colorspaces/rgb_f16half/kis_rgb_f16half_colorspace.cpp similarity index 100% rename from chalk/colorspaces/rgb_f16half/kis_rgb_f16half_colorspace.cc rename to chalk/colorspaces/rgb_f16half/kis_rgb_f16half_colorspace.cpp diff --git a/chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cc b/chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cc deleted file mode 100644 index 911da6a0..00000000 --- a/chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* -* rgb_f32_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* Copyright (c) 2005 Adrian Page -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include -#include -#include - -#include "rgb_f16half_plugin.h" -#include "kis_rgb_f16half_colorspace.h" - -typedef KGenericFactory RGBF16HalfPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_rgb_f16half_plugin, RGBF16HalfPluginFactory( "chalk" ) ) - - -RGBF16HalfPlugin::RGBF16HalfPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(RGBF16HalfPluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceRGBF16Half = new KisRgbF16HalfColorSpace(f, 0); - KisColorSpaceFactory *csf = new KisRgbF16HalfColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceRGBF16Half); - f->add(csf); - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("RGBF16HALFHISTO", i18n("Float16 Half")), colorSpaceRGBF16Half) ); - } - -} - -RGBF16HalfPlugin::~RGBF16HalfPlugin() -{ -} - -#include "rgb_f16half_plugin.moc" - diff --git a/chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cpp b/chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cpp new file mode 100644 index 00000000..32505bc8 --- /dev/null +++ b/chalk/colorspaces/rgb_f16half/rgb_f16half_plugin.cpp @@ -0,0 +1,63 @@ +/* +* rgb_f32_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* Copyright (c) 2005 Adrian Page +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include +#include +#include + +#include "rgb_f16half_plugin.h" +#include "kis_rgb_f16half_colorspace.h" + +typedef KGenericFactory RGBF16HalfPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_rgb_f16half_plugin, RGBF16HalfPluginFactory( "chalk" ) ) + + +RGBF16HalfPlugin::RGBF16HalfPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(RGBF16HalfPluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceRGBF16Half = new KisRgbF16HalfColorSpace(f, 0); + KisColorSpaceFactory *csf = new KisRgbF16HalfColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceRGBF16Half); + f->add(csf); + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("RGBF16HALFHISTO", i18n("Float16 Half")), colorSpaceRGBF16Half) ); + } + +} + +RGBF16HalfPlugin::~RGBF16HalfPlugin() +{ +} + +#include "rgb_f16half_plugin.moc" + diff --git a/chalk/colorspaces/rgb_f16half/tests/Makefile.am b/chalk/colorspaces/rgb_f16half/tests/Makefile.am index cdb3f06c..ae1cfc82 100644 --- a/chalk/colorspaces/rgb_f16half/tests/Makefile.am +++ b/chalk/colorspaces/rgb_f16half/tests/Makefile.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = -I$(srcdir)/.. \ # $(KDE_CHECK_PLUGIN) assures a shared library is created. check_LTLIBRARIES = tdeunittest_kis_rgb_f16half_colorspace_tester.la -tdeunittest_kis_rgb_f16half_colorspace_tester_la_SOURCES = kis_rgb_f16half_colorspace_tester.cc +tdeunittest_kis_rgb_f16half_colorspace_tester_la_SOURCES = kis_rgb_f16half_colorspace_tester.cpp tdeunittest_kis_rgb_f16half_colorspace_tester_la_LIBADD = -ltdeunittest ../libchalk_rgb_f16half.la tdeunittest_kis_rgb_f16half_colorspace_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries) diff --git a/chalk/colorspaces/rgb_f16half/tests/kis_rgb_f16half_colorspace_tester.cc b/chalk/colorspaces/rgb_f16half/tests/kis_rgb_f16half_colorspace_tester.cpp similarity index 100% rename from chalk/colorspaces/rgb_f16half/tests/kis_rgb_f16half_colorspace_tester.cc rename to chalk/colorspaces/rgb_f16half/tests/kis_rgb_f16half_colorspace_tester.cpp diff --git a/chalk/colorspaces/rgb_f32/Makefile.am b/chalk/colorspaces/rgb_f32/Makefile.am index 0d206a3e..0fd090c9 100644 --- a/chalk/colorspaces/rgb_f32/Makefile.am +++ b/chalk/colorspaces/rgb_f32/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = \ lib_LTLIBRARIES = libchalk_rgb_f32.la -libchalk_rgb_f32_la_SOURCES = kis_rgb_f32_colorspace.cc +libchalk_rgb_f32_la_SOURCES = kis_rgb_f32_colorspace.cpp libchalk_rgb_f32_la_LDFLAGS = $(all_libraries) libchalk_rgb_f32_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -18,7 +18,7 @@ libchalk_rgb_f32_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_rgb_f32_plugin.la # Srcs for the plugin -chalk_rgb_f32_plugin_la_SOURCES = rgb_f32_plugin.cc +chalk_rgb_f32_plugin_la_SOURCES = rgb_f32_plugin.cpp noinst_HEADERS = rgb_f32_plugin.h kis_rgb_f32_colorspace.h chalk_rgb_f32_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.cc b/chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.cpp similarity index 100% rename from chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.cc rename to chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.cpp diff --git a/chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.h b/chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.h index c6551a4c..785009e0 100644 --- a/chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.h +++ b/chalk/colorspaces/rgb_f32/kis_rgb_f32_colorspace.h @@ -132,7 +132,7 @@ private: }; struct F32OpacityTest { inline bool operator()(const float& opacity) const { - return opacity > F32_OPACITY_TRANSPARENT + 1e-6; // #define EPSILON in the .cc + return opacity > F32_OPACITY_TRANSPARENT + 1e-6; // #define EPSILON in the .cpp } }; }; diff --git a/chalk/colorspaces/rgb_f32/rgb_f32_plugin.cc b/chalk/colorspaces/rgb_f32/rgb_f32_plugin.cc deleted file mode 100644 index 7c114971..00000000 --- a/chalk/colorspaces/rgb_f32/rgb_f32_plugin.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* -* rgb_f32_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* Copyright (c) 2005 Adrian Page -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include -#include -#include - -#include "rgb_f32_plugin.h" -#include "kis_rgb_f32_colorspace.h" - -typedef KGenericFactory RGBF32PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_rgb_f32_plugin, RGBF32PluginFactory( "chalk" ) ) - - -RGBF32Plugin::RGBF32Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(RGBF32PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); - - KisColorSpace * colorSpaceRGBF32 = new KisRgbF32ColorSpace(f, 0); - - KisColorSpaceFactory * csf = new KisRgbF32ColorSpaceFactory(); - f->add(csf); - - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("RGBF32HISTO", i18n("Float32")), colorSpaceRGBF32) ); - } - -} - -RGBF32Plugin::~RGBF32Plugin() -{ -} - -#include "rgb_f32_plugin.moc" diff --git a/chalk/colorspaces/rgb_f32/rgb_f32_plugin.cpp b/chalk/colorspaces/rgb_f32/rgb_f32_plugin.cpp new file mode 100644 index 00000000..adc540ac --- /dev/null +++ b/chalk/colorspaces/rgb_f32/rgb_f32_plugin.cpp @@ -0,0 +1,63 @@ +/* +* rgb_f32_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* Copyright (c) 2005 Adrian Page +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include +#include +#include + +#include "rgb_f32_plugin.h" +#include "kis_rgb_f32_colorspace.h" + +typedef KGenericFactory RGBF32PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_rgb_f32_plugin, RGBF32PluginFactory( "chalk" ) ) + + +RGBF32Plugin::RGBF32Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(RGBF32PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); + + KisColorSpace * colorSpaceRGBF32 = new KisRgbF32ColorSpace(f, 0); + + KisColorSpaceFactory * csf = new KisRgbF32ColorSpaceFactory(); + f->add(csf); + + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("RGBF32HISTO", i18n("Float32")), colorSpaceRGBF32) ); + } + +} + +RGBF32Plugin::~RGBF32Plugin() +{ +} + +#include "rgb_f32_plugin.moc" diff --git a/chalk/colorspaces/rgb_f32/tests/Makefile.am b/chalk/colorspaces/rgb_f32/tests/Makefile.am index 9ad10271..073c5da7 100644 --- a/chalk/colorspaces/rgb_f32/tests/Makefile.am +++ b/chalk/colorspaces/rgb_f32/tests/Makefile.am @@ -8,7 +8,7 @@ AM_CPPFLAGS = -I$(srcdir)/.. \ # $(KDE_CHECK_PLUGIN) assures a shared library is created. check_LTLIBRARIES = tdeunittest_kis_strategy_colorspace_rgb_f32_tester.la -tdeunittest_kis_strategy_colorspace_rgb_f32_tester_la_SOURCES = kis_strategy_colorspace_rgb_f32_tester.cc +tdeunittest_kis_strategy_colorspace_rgb_f32_tester_la_SOURCES = kis_strategy_colorspace_rgb_f32_tester.cpp tdeunittest_kis_strategy_colorspace_rgb_f32_tester_la_LIBADD = -ltdeunittest ../libchalk_rgb_f32.la tdeunittest_kis_strategy_colorspace_rgb_f32_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries) diff --git a/chalk/colorspaces/rgb_f32/tests/kis_strategy_colorspace_rgb_f32_tester.cc b/chalk/colorspaces/rgb_f32/tests/kis_strategy_colorspace_rgb_f32_tester.cpp similarity index 100% rename from chalk/colorspaces/rgb_f32/tests/kis_strategy_colorspace_rgb_f32_tester.cc rename to chalk/colorspaces/rgb_f32/tests/kis_strategy_colorspace_rgb_f32_tester.cpp diff --git a/chalk/colorspaces/rgb_u16/Makefile.am b/chalk/colorspaces/rgb_u16/Makefile.am index 41711c55..283c54e0 100644 --- a/chalk/colorspaces/rgb_u16/Makefile.am +++ b/chalk/colorspaces/rgb_u16/Makefile.am @@ -8,7 +8,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ $(all_includes) lib_LTLIBRARIES = libchalk_rgb_u16.la -libchalk_rgb_u16_la_SOURCES = kis_rgb_u16_colorspace.cc +libchalk_rgb_u16_la_SOURCES = kis_rgb_u16_colorspace.cpp libchalk_rgb_u16_la_LDFLAGS = $(all_libraries) libchalk_rgb_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -16,7 +16,7 @@ libchalk_rgb_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_rgb_u16_plugin.la # Srcs for the plugin -chalk_rgb_u16_plugin_la_SOURCES = rgb_u16_plugin.cc +chalk_rgb_u16_plugin_la_SOURCES = rgb_u16_plugin.cpp noinst_HEADERS = rgb_u16_plugin.h kis_rgb_u16_colorspace.h chalk_rgb_u16_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cpp similarity index 100% rename from chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc rename to chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cpp diff --git a/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc deleted file mode 100644 index bc362a83..00000000 --- a/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -* rgb_u16_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* Copyright (c) 2005 Adrian Page -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include - -#include -#include - -#include "rgb_u16_plugin.h" -#include "kis_rgb_u16_colorspace.h" -#include "kis_basic_histogram_producers.h" - -typedef KGenericFactory RGBU16PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_rgb_u16_plugin, RGBU16PluginFactory( "chalk" ) ) - - -RGBU16Plugin::RGBU16Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(RGBU16PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceRGBU16 = new KisRgbU16ColorSpace(f, 0); - KisColorSpaceFactory * csFactory = new KisRgbU16ColorSpaceFactory(); - f->add( csFactory ); - - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("RGB16HISTO", i18n("RGB16")), colorSpaceRGBU16) ); - } - -} - -RGBU16Plugin::~RGBU16Plugin() -{ -} - -#include "rgb_u16_plugin.moc" diff --git a/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cpp b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cpp new file mode 100644 index 00000000..da6e6e42 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cpp @@ -0,0 +1,61 @@ +/* +* rgb_u16_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* Copyright (c) 2005 Adrian Page +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include +#include + +#include "rgb_u16_plugin.h" +#include "kis_rgb_u16_colorspace.h" +#include "kis_basic_histogram_producers.h" + +typedef KGenericFactory RGBU16PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_rgb_u16_plugin, RGBU16PluginFactory( "chalk" ) ) + + +RGBU16Plugin::RGBU16Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(RGBU16PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceRGBU16 = new KisRgbU16ColorSpace(f, 0); + KisColorSpaceFactory * csFactory = new KisRgbU16ColorSpaceFactory(); + f->add( csFactory ); + + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("RGB16HISTO", i18n("RGB16")), colorSpaceRGBU16) ); + } + +} + +RGBU16Plugin::~RGBU16Plugin() +{ +} + +#include "rgb_u16_plugin.moc" diff --git a/chalk/colorspaces/rgb_u16/tests/Makefile.am b/chalk/colorspaces/rgb_u16/tests/Makefile.am index 76c4d175..5bed7dfa 100644 --- a/chalk/colorspaces/rgb_u16/tests/Makefile.am +++ b/chalk/colorspaces/rgb_u16/tests/Makefile.am @@ -8,7 +8,7 @@ AM_CPPFLAGS = -I$(srcdir)/.. \ # $(KDE_CHECK_PLUGIN) assures a shared library is created. check_LTLIBRARIES = tdeunittest_kis_strategy_colorspace_rgb_u16_tester.la -tdeunittest_kis_strategy_colorspace_rgb_u16_tester_la_SOURCES = kis_strategy_colorspace_rgb_u16_tester.cc +tdeunittest_kis_strategy_colorspace_rgb_u16_tester_la_SOURCES = kis_strategy_colorspace_rgb_u16_tester.cpp tdeunittest_kis_strategy_colorspace_rgb_u16_tester_la_LIBADD = -ltdeunittest ../libchalk_rgb_u16.la tdeunittest_kis_strategy_colorspace_rgb_u16_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries) diff --git a/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc b/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cpp similarity index 100% rename from chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc rename to chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cpp diff --git a/chalk/colorspaces/rgb_u8/Makefile.am b/chalk/colorspaces/rgb_u8/Makefile.am index c82abaa1..9b27665f 100644 --- a/chalk/colorspaces/rgb_u8/Makefile.am +++ b/chalk/colorspaces/rgb_u8/Makefile.am @@ -8,7 +8,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ $(all_includes) lib_LTLIBRARIES = libchalkrgb.la -libchalkrgb_la_SOURCES = kis_rgb_colorspace.cc +libchalkrgb_la_SOURCES = kis_rgb_colorspace.cpp libchalkrgb_la_LDFLAGS = $(all_libraries) $(LIB_TQT) libchalkrgb_la_LIBADD = ../../chalkcolor/libchalkcolor.la @@ -16,7 +16,7 @@ libchalkrgb_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalkrgbplugin.la # Srcs for the plugin -chalkrgbplugin_la_SOURCES = rgb_plugin.cc +chalkrgbplugin_la_SOURCES = rgb_plugin.cpp noinst_HEADERS = rgb_plugin.h kis_rgb_colorspace.h chalkrgbplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms diff --git a/chalk/colorspaces/rgb_u8/kis_rgb_colorspace.cc b/chalk/colorspaces/rgb_u8/kis_rgb_colorspace.cpp similarity index 100% rename from chalk/colorspaces/rgb_u8/kis_rgb_colorspace.cc rename to chalk/colorspaces/rgb_u8/kis_rgb_colorspace.cpp diff --git a/chalk/colorspaces/rgb_u8/rgb_plugin.cc b/chalk/colorspaces/rgb_u8/rgb_plugin.cc deleted file mode 100644 index 26310125..00000000 --- a/chalk/colorspaces/rgb_u8/rgb_plugin.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -* rgb_plugin.cc -- Part of Chalk -* -* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "rgb_plugin.h" -#include "kis_rgb_colorspace.h" - -typedef KGenericFactory RGBPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkrgbplugin, RGBPluginFactory( "chalk" ) ) - - -RGBPlugin::RGBPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(RGBPluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); - - KisProfile *defProfile = new KisProfile(cmsCreate_sRGBProfile()); - f->addProfile(defProfile); - - - KisColorSpaceFactory * csFactory = new KisRgbColorSpaceFactory(); - f->add(csFactory); - - KisColorSpace * colorSpaceRGBA = new KisRgbColorSpace(f, 0); - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("RGB8HISTO", i18n("RGB8")), colorSpaceRGBA) ); - } - -} - -RGBPlugin::~RGBPlugin() -{ -} - -#include "rgb_plugin.moc" diff --git a/chalk/colorspaces/rgb_u8/rgb_plugin.cpp b/chalk/colorspaces/rgb_u8/rgb_plugin.cpp new file mode 100644 index 00000000..33f18b17 --- /dev/null +++ b/chalk/colorspaces/rgb_u8/rgb_plugin.cpp @@ -0,0 +1,74 @@ +/* +* rgb_plugin.cpp -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "rgb_plugin.h" +#include "kis_rgb_colorspace.h" + +typedef KGenericFactory RGBPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkrgbplugin, RGBPluginFactory( "chalk" ) ) + + +RGBPlugin::RGBPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(RGBPluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); + + KisProfile *defProfile = new KisProfile(cmsCreate_sRGBProfile()); + f->addProfile(defProfile); + + + KisColorSpaceFactory * csFactory = new KisRgbColorSpaceFactory(); + f->add(csFactory); + + KisColorSpace * colorSpaceRGBA = new KisRgbColorSpace(f, 0); + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("RGB8HISTO", i18n("RGB8")), colorSpaceRGBA) ); + } + +} + +RGBPlugin::~RGBPlugin() +{ +} + +#include "rgb_plugin.moc" diff --git a/chalk/colorspaces/wet/Makefile.am b/chalk/colorspaces/wet/Makefile.am index 6d4bacab..bd7c307f 100644 --- a/chalk/colorspaces/wet/Makefile.am +++ b/chalk/colorspaces/wet/Makefile.am @@ -17,8 +17,8 @@ INCLUDES = -I$(srcdir)/../../sdk \ kde_module_LTLIBRARIES = chalkwetplugin.la -chalkwetplugin_la_SOURCES = kis_wet_colorspace.cc wet_plugin.cc kis_wetop.cc kis_wet_palette_widget.cc kis_wetness_visualisation_filter.cc kis_texture_painter.cc kis_texture_filter.cc wetphysicsfilter.cc wdgpressure.ui -noinst_HEADERS = kis_wet_colorspace.h wet_plugin.h wetphysicsfilter.h kis_wetop.cc kis_wet_palette_widget.h kis_texture_painter.h kis_wetness_visualisation_filter.h kis_texture_filter.h wetphysicsfilter.h +chalkwetplugin_la_SOURCES = kis_wet_colorspace.cpp wet_plugin.cpp kis_wetop.cpp kis_wet_palette_widget.cpp kis_wetness_visualisation_filter.cpp kis_texture_painter.cpp kis_texture_filter.cpp wetphysicsfilter.cpp wdgpressure.ui +noinst_HEADERS = kis_wet_colorspace.h wet_plugin.h wetphysicsfilter.h kis_wetop.cpp kis_wet_palette_widget.h kis_texture_painter.h kis_wetness_visualisation_filter.h kis_texture_filter.h wetphysicsfilter.h chalkwetplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms chalkwetplugin_la_LIBADD = ../../libchalkcommon.la $(LIB_KOPAINTER) $(LIB_KOFFICECORE) \ diff --git a/chalk/colorspaces/wet/kis_texture_filter.cc b/chalk/colorspaces/wet/kis_texture_filter.cc deleted file mode 100644 index 6f58cd14..00000000 --- a/chalk/colorspaces/wet/kis_texture_filter.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * kis_texture_filter.cc -- Part of Chalk - * - * Copyright (c) 2005 Bart Coppens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include "kis_texture_painter.h" -#include "kis_texture_filter.h" - -void WetPaintDevAction::act(KisPaintDeviceSP device, TQ_INT32 w, TQ_INT32 h) const { - KisColorSpace * cs = device->colorSpace(); - - if (cs->id() != KisID("WET","")) { - kdDebug(DBG_AREA_CMS) << "You set this kind of texture on non-wet layers!.\n"; - return; - } else { - kdDebug(DBG_AREA_CMS) << "Wet Paint Action activated!\n"; - } - - // XXX if params of the painter get configurable, make them here configurable as well? - KisTexturePainter painter(device); - painter.createTexture(0, 0, w, h); - painter.end(); -} - diff --git a/chalk/colorspaces/wet/kis_texture_filter.cpp b/chalk/colorspaces/wet/kis_texture_filter.cpp new file mode 100644 index 00000000..f70272db --- /dev/null +++ b/chalk/colorspaces/wet/kis_texture_filter.cpp @@ -0,0 +1,43 @@ +/* + * kis_texture_filter.cpp -- Part of Chalk + * + * Copyright (c) 2005 Bart Coppens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include "kis_texture_painter.h" +#include "kis_texture_filter.h" + +void WetPaintDevAction::act(KisPaintDeviceSP device, TQ_INT32 w, TQ_INT32 h) const { + KisColorSpace * cs = device->colorSpace(); + + if (cs->id() != KisID("WET","")) { + kdDebug(DBG_AREA_CMS) << "You set this kind of texture on non-wet layers!.\n"; + return; + } else { + kdDebug(DBG_AREA_CMS) << "Wet Paint Action activated!\n"; + } + + // XXX if params of the painter get configurable, make them here configurable as well? + KisTexturePainter painter(device); + painter.createTexture(0, 0, w, h); + painter.end(); +} + diff --git a/chalk/colorspaces/wet/kis_texture_painter.cc b/chalk/colorspaces/wet/kis_texture_painter.cpp similarity index 100% rename from chalk/colorspaces/wet/kis_texture_painter.cc rename to chalk/colorspaces/wet/kis_texture_painter.cpp diff --git a/chalk/colorspaces/wet/kis_wet_colorspace.cc b/chalk/colorspaces/wet/kis_wet_colorspace.cpp similarity index 100% rename from chalk/colorspaces/wet/kis_wet_colorspace.cc rename to chalk/colorspaces/wet/kis_wet_colorspace.cpp diff --git a/chalk/colorspaces/wet/kis_wet_palette_widget.cc b/chalk/colorspaces/wet/kis_wet_palette_widget.cpp similarity index 100% rename from chalk/colorspaces/wet/kis_wet_palette_widget.cc rename to chalk/colorspaces/wet/kis_wet_palette_widget.cpp diff --git a/chalk/colorspaces/wet/kis_wetness_visualisation_filter.cc b/chalk/colorspaces/wet/kis_wetness_visualisation_filter.cc deleted file mode 100644 index f17f4e1c..00000000 --- a/chalk/colorspaces/wet/kis_wetness_visualisation_filter.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * kis_wetness_visualisation_filter.cc -- Part of Chalk - * - * Copyright (c) 2005 Bart Coppens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include - -#include -#include "kis_meta_registry.h" -#include -#include -#include -#include -#include "kis_wet_colorspace.h" -#include -#include "kis_wetness_visualisation_filter.h" - -WetnessVisualisationFilter::WetnessVisualisationFilter(KisView* view) - : m_view(view), m_action(0) { - connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout())); -} - -// XXX this needs to work on a per-layer basis! - -void WetnessVisualisationFilter::setAction(TDEToggleAction* action) { - m_action = action; - if (!m_action) - return; - KisWetColorSpace* cs = dynamic_cast( - KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") ); - Q_ASSERT(cs); - m_action->setChecked(cs->paintWetness()); -} - -void WetnessVisualisationFilter::slotActivated() { - kdDebug(DBG_AREA_CMS) << "activated" << endl; - if (!m_action) { - kdDebug(DBG_AREA_CMS) << "no action" << endl; - return; - } - KisWetColorSpace* cs = dynamic_cast( - KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") ); - Q_ASSERT(cs); - if (!m_action->isChecked()) { - m_timer.stop(); - cs->setPaintWetness(false); - } else { - m_timer.start(500); - cs->setPaintWetness(true); - } -} - -void WetnessVisualisationFilter::slotTimeout() { - KisWetColorSpace* cs = dynamic_cast( - KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") ); - Q_ASSERT(cs); - if (!cs) return; - cs->resetPhase(); - -} - -#include "kis_wetness_visualisation_filter.moc" diff --git a/chalk/colorspaces/wet/kis_wetness_visualisation_filter.cpp b/chalk/colorspaces/wet/kis_wetness_visualisation_filter.cpp new file mode 100644 index 00000000..63442446 --- /dev/null +++ b/chalk/colorspaces/wet/kis_wetness_visualisation_filter.cpp @@ -0,0 +1,77 @@ +/* + * kis_wetness_visualisation_filter.cpp -- Part of Chalk + * + * Copyright (c) 2005 Bart Coppens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include "kis_meta_registry.h" +#include +#include +#include +#include +#include "kis_wet_colorspace.h" +#include +#include "kis_wetness_visualisation_filter.h" + +WetnessVisualisationFilter::WetnessVisualisationFilter(KisView* view) + : m_view(view), m_action(0) { + connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout())); +} + +// XXX this needs to work on a per-layer basis! + +void WetnessVisualisationFilter::setAction(TDEToggleAction* action) { + m_action = action; + if (!m_action) + return; + KisWetColorSpace* cs = dynamic_cast( + KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") ); + Q_ASSERT(cs); + m_action->setChecked(cs->paintWetness()); +} + +void WetnessVisualisationFilter::slotActivated() { + kdDebug(DBG_AREA_CMS) << "activated" << endl; + if (!m_action) { + kdDebug(DBG_AREA_CMS) << "no action" << endl; + return; + } + KisWetColorSpace* cs = dynamic_cast( + KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") ); + Q_ASSERT(cs); + if (!m_action->isChecked()) { + m_timer.stop(); + cs->setPaintWetness(false); + } else { + m_timer.start(500); + cs->setPaintWetness(true); + } +} + +void WetnessVisualisationFilter::slotTimeout() { + KisWetColorSpace* cs = dynamic_cast( + KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") ); + Q_ASSERT(cs); + if (!cs) return; + cs->resetPhase(); + +} + +#include "kis_wetness_visualisation_filter.moc" diff --git a/chalk/colorspaces/wet/kis_wetop.cc b/chalk/colorspaces/wet/kis_wetop.cpp similarity index 100% rename from chalk/colorspaces/wet/kis_wetop.cc rename to chalk/colorspaces/wet/kis_wetop.cpp diff --git a/chalk/colorspaces/wet/wet_plugin.cc b/chalk/colorspaces/wet/wet_plugin.cc deleted file mode 100644 index b919a289..00000000 --- a/chalk/colorspaces/wet/wet_plugin.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * wet_plugin.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include "kis_meta_registry.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "wet_plugin.h" -#include "kis_wet_palette_widget.h" -#include "kis_wet_colorspace.h" -#include "kis_wetop.h" -#include "kis_wetness_visualisation_filter.h" -#include "kis_texture_filter.h" -#include "wetphysicsfilter.h" - -typedef KGenericFactory WetPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkwetplugin, WetPluginFactory( "chalkcore" ) ) - - -WetPlugin::WetPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(WetPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) { - KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); - - KisColorSpace* colorSpaceWet = new KisWetColorSpace(f, 0); - - KisColorSpaceFactory * csf = new KisWetColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceWet); - - // colorspace - f->add(csf); - - // histogram producer - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("WETHISTO", i18n("Wet")), colorSpaceWet) ); - - // wet brush op - KisPaintOpRegistry::instance()->add(new KisWetOpFactory); - - // Dry filter - KisFilterRegistry::instance()->add( new WetPhysicsFilter() ); - - // Texture Action: - f->addPaintDeviceAction(colorSpaceWet, new WetPaintDevAction); - } - else if (parent->inherits("KisView")) - { - setInstance(WetPluginFactory::instance()); - setXMLFile(locate("data","chalkplugins/wetplugin.rc"), true); - - m_view = dynamic_cast(parent); - // Wetness visualisation - WetnessVisualisationFilter * wf = new WetnessVisualisationFilter(m_view); - wf->setAction(new TDEToggleAction(i18n("Wetness Visualisation"), 0, 0, wf, - TQT_SLOT(slotActivated()), actionCollection(), "wetnessvisualisation")); - - // Create the wet palette - KisWetPaletteWidget * w = new KisWetPaletteWidget(m_view); - TQ_CHECK_PTR(w); - - w->setCaption(i18n("Watercolors")); - - m_view->canvasSubject()->paletteManager()->addWidget(w, "watercolor docker", chalk::COLORBOX, INT_MAX, PALETTE_DOCKER, false); - m_view->canvasSubject()->attach(w); - } - - -} - -WetPlugin::~WetPlugin() -{ -} - -#include "wet_plugin.moc" diff --git a/chalk/colorspaces/wet/wet_plugin.cpp b/chalk/colorspaces/wet/wet_plugin.cpp new file mode 100644 index 00000000..259fe5d1 --- /dev/null +++ b/chalk/colorspaces/wet/wet_plugin.cpp @@ -0,0 +1,128 @@ +/* + * wet_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include "kis_meta_registry.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wet_plugin.h" +#include "kis_wet_palette_widget.h" +#include "kis_wet_colorspace.h" +#include "kis_wetop.h" +#include "kis_wetness_visualisation_filter.h" +#include "kis_texture_filter.h" +#include "wetphysicsfilter.h" + +typedef KGenericFactory WetPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkwetplugin, WetPluginFactory( "chalkcore" ) ) + + +WetPlugin::WetPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(WetPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) { + KisColorSpaceFactoryRegistry * f = dynamic_cast(parent); + + KisColorSpace* colorSpaceWet = new KisWetColorSpace(f, 0); + + KisColorSpaceFactory * csf = new KisWetColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceWet); + + // colorspace + f->add(csf); + + // histogram producer + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("WETHISTO", i18n("Wet")), colorSpaceWet) ); + + // wet brush op + KisPaintOpRegistry::instance()->add(new KisWetOpFactory); + + // Dry filter + KisFilterRegistry::instance()->add( new WetPhysicsFilter() ); + + // Texture Action: + f->addPaintDeviceAction(colorSpaceWet, new WetPaintDevAction); + } + else if (parent->inherits("KisView")) + { + setInstance(WetPluginFactory::instance()); + setXMLFile(locate("data","chalkplugins/wetplugin.rc"), true); + + m_view = dynamic_cast(parent); + // Wetness visualisation + WetnessVisualisationFilter * wf = new WetnessVisualisationFilter(m_view); + wf->setAction(new TDEToggleAction(i18n("Wetness Visualisation"), 0, 0, wf, + TQT_SLOT(slotActivated()), actionCollection(), "wetnessvisualisation")); + + // Create the wet palette + KisWetPaletteWidget * w = new KisWetPaletteWidget(m_view); + TQ_CHECK_PTR(w); + + w->setCaption(i18n("Watercolors")); + + m_view->canvasSubject()->paletteManager()->addWidget(w, "watercolor docker", chalk::COLORBOX, INT_MAX, PALETTE_DOCKER, false); + m_view->canvasSubject()->attach(w); + } + + +} + +WetPlugin::~WetPlugin() +{ +} + +#include "wet_plugin.moc" diff --git a/chalk/colorspaces/wet/wetphysicsfilter.cc b/chalk/colorspaces/wet/wetphysicsfilter.cpp similarity index 100% rename from chalk/colorspaces/wet/wetphysicsfilter.cc rename to chalk/colorspaces/wet/wetphysicsfilter.cpp diff --git a/chalk/colorspaces/wetsticky/Makefile.am b/chalk/colorspaces/wetsticky/Makefile.am index 4ade368a..5d4e0289 100644 --- a/chalk/colorspaces/wetsticky/Makefile.am +++ b/chalk/colorspaces/wetsticky/Makefile.am @@ -12,7 +12,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ kde_module_LTLIBRARIES = chalkwsplugin.la -chalkwsplugin_la_SOURCES = wet_sticky_plugin.cc kis_wet_sticky_colorspace.cc kis_ws_engine_filter.cc +chalkwsplugin_la_SOURCES = wet_sticky_plugin.cpp kis_wet_sticky_colorspace.cpp kis_ws_engine_filter.cpp noinst_HEADERS = wet_sticky_plugin.h kis_wet_sticky_colorspace.h kis_ws_engine_filter.h chalkwsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) diff --git a/chalk/colorspaces/wetsticky/brushop/Makefile.am b/chalk/colorspaces/wetsticky/brushop/Makefile.am index 8df4d61e..eae064f8 100644 --- a/chalk/colorspaces/wetsticky/brushop/Makefile.am +++ b/chalk/colorspaces/wetsticky/brushop/Makefile.am @@ -13,8 +13,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalkwsbrushpaintop_la_SOURCES = \ - wsbrushpaintop_plugin.cc \ - kis_wsbrushop.cc + wsbrushpaintop_plugin.cpp \ + kis_wsbrushop.cpp noinst_HEADERS= \ wsbrushpaintop_plugin.h \ diff --git a/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cc b/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cpp similarity index 100% rename from chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cc rename to chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cpp diff --git a/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc b/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc deleted file mode 100644 index 1f141bb4..00000000 --- a/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * wsbrushpaintop_plugin.cc -- Part of Chalk - * - * Copyright (c) 2005 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "kis_wsbrushop.h" - -#include "wsbrushpaintop_plugin.h" - -typedef KGenericFactory WSBrushPaintOpPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkwsbrushpaintop, WSBrushPaintOpPluginFactory( "chalkcore" ) ) - - -WSBrushPaintOpPlugin::WSBrushPaintOpPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(WSBrushPaintOpPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisFactory") ) - { - KisPaintOpRegistry::instance() -> add ( new KisWSBrushOpFactory ); - } - -} - -WSBrushPaintOpPlugin::~WSBrushPaintOpPlugin() -{ -} - -#include "wsbrushpaintop_plugin.moc" diff --git a/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp b/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp new file mode 100644 index 00000000..97c892b2 --- /dev/null +++ b/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp @@ -0,0 +1,56 @@ +/* + * wsbrushpaintop_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2005 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "kis_wsbrushop.h" + +#include "wsbrushpaintop_plugin.h" + +typedef KGenericFactory WSBrushPaintOpPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkwsbrushpaintop, WSBrushPaintOpPluginFactory( "chalkcore" ) ) + + +WSBrushPaintOpPlugin::WSBrushPaintOpPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(WSBrushPaintOpPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisFactory") ) + { + KisPaintOpRegistry::instance() -> add ( new KisWSBrushOpFactory ); + } + +} + +WSBrushPaintOpPlugin::~WSBrushPaintOpPlugin() +{ +} + +#include "wsbrushpaintop_plugin.moc" diff --git a/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cc b/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp similarity index 100% rename from chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cc rename to chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp diff --git a/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cc b/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cpp similarity index 100% rename from chalk/colorspaces/wetsticky/kis_ws_engine_filter.cc rename to chalk/colorspaces/wetsticky/kis_ws_engine_filter.cpp diff --git a/chalk/colorspaces/wetsticky/wet_sticky_plugin.cc b/chalk/colorspaces/wetsticky/wet_sticky_plugin.cc deleted file mode 100644 index 76dee20e..00000000 --- a/chalk/colorspaces/wetsticky/wet_sticky_plugin.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * wet_sticky_plugin.cc -- Part of Chalk - * - * Copyright (c) 2005 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "wet_sticky_plugin.h" - -#include "kis_wet_sticky_colorspace.h" -#include "kis_ws_engine_filter.h" - -typedef KGenericFactory WetStickyPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkwsplugin, WetStickyPluginFactory( "chalkcore" ) ) - - -WetStickyPlugin::WetStickyPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(WetStickyPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisFactory") ) - { - KisColorSpace * colorSpaceWS = new KisWetStickyColorSpace(); - TQ_CHECK_PTR(colorSpaceWS); - KisColorSpaceRegistry::instance() -> add(colorSpaceWS); - KisFilterRegistry::instance()->add(new KisWSEngineFilter()); - } - -} - -WetStickyPlugin::~WetStickyPlugin() -{ -} - -#include "wet_sticky_plugin.moc" diff --git a/chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp b/chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp new file mode 100644 index 00000000..e56e4cc8 --- /dev/null +++ b/chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp @@ -0,0 +1,60 @@ +/* + * wet_sticky_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2005 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "wet_sticky_plugin.h" + +#include "kis_wet_sticky_colorspace.h" +#include "kis_ws_engine_filter.h" + +typedef KGenericFactory WetStickyPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkwsplugin, WetStickyPluginFactory( "chalkcore" ) ) + + +WetStickyPlugin::WetStickyPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(WetStickyPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisFactory") ) + { + KisColorSpace * colorSpaceWS = new KisWetStickyColorSpace(); + TQ_CHECK_PTR(colorSpaceWS); + KisColorSpaceRegistry::instance() -> add(colorSpaceWS); + KisFilterRegistry::instance()->add(new KisWSEngineFilter()); + } + +} + +WetStickyPlugin::~WetStickyPlugin() +{ +} + +#include "wet_sticky_plugin.moc" diff --git a/chalk/colorspaces/ycbcr_u16/Makefile.am b/chalk/colorspaces/ycbcr_u16/Makefile.am index ab820020..e9c273b7 100644 --- a/chalk/colorspaces/ycbcr_u16/Makefile.am +++ b/chalk/colorspaces/ycbcr_u16/Makefile.am @@ -16,7 +16,7 @@ libchalk_ycbcr_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_ycbcr_u16_plugin.la # Srcs for the plugin -chalk_ycbcr_u16_plugin_la_SOURCES = ycbcr_u16_plugin.cc +chalk_ycbcr_u16_plugin_la_SOURCES = ycbcr_u16_plugin.cpp noinst_HEADERS = ycbcr_u16_plugin.h kis_ycbcr_u16_colorspace.h chalk_ycbcr_u16_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms @@ -24,6 +24,6 @@ chalk_ycbcr_u16_plugin_la_LIBADD = libchalk_ycbcr_u16.la ../../chalkcolor/libch METASOURCES = AUTO -libchalk_ycbcr_u16_la_SOURCES = kis_ycbcr_u16_colorspace.cc +libchalk_ycbcr_u16_la_SOURCES = kis_ycbcr_u16_colorspace.cpp .NOTPARALLEL: diff --git a/chalk/colorspaces/ycbcr_u16/kis_ycbcr_u16_colorspace.cc b/chalk/colorspaces/ycbcr_u16/kis_ycbcr_u16_colorspace.cpp similarity index 100% rename from chalk/colorspaces/ycbcr_u16/kis_ycbcr_u16_colorspace.cc rename to chalk/colorspaces/ycbcr_u16/kis_ycbcr_u16_colorspace.cpp diff --git a/chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cc b/chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cc deleted file mode 100644 index fdfb2310..00000000 --- a/chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ycbcr_u16_plugin.cc -- Part of Chalk - * - * Copyright (c) 2006 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include "ycbcr_u16_plugin.h" -#include "kis_ycbcr_u16_colorspace.h" - -typedef KGenericFactory YCbCrU16PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_ycbcr_u16_plugin, YCbCrU16PluginFactory( "chalk" ) ) - - -YCbCrU16Plugin::YCbCrU16Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(YCbCrU16PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceYCbCrU16 = new KisYCbCrU16ColorSpace(f, 0); - KisColorSpaceFactory * csf = new KisYCbCrU16ColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceYCbCrU16); - f->add(csf); - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("YCbCr16HISTO", i18n("YCbCr16")), colorSpaceYCbCrU16) ); - } - -} - -YCbCrU16Plugin::~YCbCrU16Plugin() -{ -} - -#include "ycbcr_u16_plugin.moc" diff --git a/chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cpp b/chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cpp new file mode 100644 index 00000000..4371a20a --- /dev/null +++ b/chalk/colorspaces/ycbcr_u16/ycbcr_u16_plugin.cpp @@ -0,0 +1,60 @@ +/* + * ycbcr_u16_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2006 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include "ycbcr_u16_plugin.h" +#include "kis_ycbcr_u16_colorspace.h" + +typedef KGenericFactory YCbCrU16PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_ycbcr_u16_plugin, YCbCrU16PluginFactory( "chalk" ) ) + + +YCbCrU16Plugin::YCbCrU16Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(YCbCrU16PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceYCbCrU16 = new KisYCbCrU16ColorSpace(f, 0); + KisColorSpaceFactory * csf = new KisYCbCrU16ColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceYCbCrU16); + f->add(csf); + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("YCbCr16HISTO", i18n("YCbCr16")), colorSpaceYCbCrU16) ); + } + +} + +YCbCrU16Plugin::~YCbCrU16Plugin() +{ +} + +#include "ycbcr_u16_plugin.moc" diff --git a/chalk/colorspaces/ycbcr_u8/Makefile.am b/chalk/colorspaces/ycbcr_u8/Makefile.am index 82f2942d..77c8c432 100644 --- a/chalk/colorspaces/ycbcr_u8/Makefile.am +++ b/chalk/colorspaces/ycbcr_u8/Makefile.am @@ -16,7 +16,7 @@ libchalk_ycbcr_u8_la_LIBADD = ../../chalkcolor/libchalkcolor.la kde_module_LTLIBRARIES = chalk_ycbcr_u8_plugin.la # Srcs for the plugin -chalk_ycbcr_u8_plugin_la_SOURCES = ycbcr_u8_plugin.cc +chalk_ycbcr_u8_plugin_la_SOURCES = ycbcr_u8_plugin.cpp noinst_HEADERS = ycbcr_u8_plugin.h kis_ycbcr_u8_colorspace.h chalk_ycbcr_u8_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_TQT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts -llcms @@ -25,7 +25,7 @@ chalk_ycbcr_u8_plugin_la_LIBADD = libchalk_ycbcr_u8.la ../../chalkcolor/libchal METASOURCES = AUTO -libchalk_ycbcr_u8_la_SOURCES = kis_ycbcr_u8_colorspace.cc +libchalk_ycbcr_u8_la_SOURCES = kis_ycbcr_u8_colorspace.cpp kde_services_DATA = chalk_ycbcr_u8_plugin.desktop .NOTPARALLEL: diff --git a/chalk/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cc b/chalk/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cpp similarity index 100% rename from chalk/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cc rename to chalk/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cpp diff --git a/chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc b/chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc deleted file mode 100644 index 34207432..00000000 --- a/chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ycbcr_u8_plugin.cc -- Part of Chalk - * - * Copyright (c) 2006 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "ycbcr_u8_plugin.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_ycbcr_u8_colorspace.h" - -typedef KGenericFactory YCbCrU8PluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalk_ycbcr_u8_plugin, YCbCrU8PluginFactory( "chalk" ) ) - - -YCbCrU8Plugin::YCbCrU8Plugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(YCbCrU8PluginFactory::instance()); - - if ( parent->inherits("KisColorSpaceFactoryRegistry") ) - { - KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); - - KisColorSpace * colorSpaceYCbCrU8 = new KisYCbCrU8ColorSpace(f, 0); - KisColorSpaceFactory * csf = new KisYCbCrU8ColorSpaceFactory(); - TQ_CHECK_PTR(colorSpaceYCbCrU8); - f->add(csf); - KisHistogramProducerFactoryRegistry::instance()->add( - new KisBasicHistogramProducerFactory - (KisID("YCBR8HISTO", i18n("YCBR8")), colorSpaceYCbCrU8) ); - } - -} - -YCbCrU8Plugin::~YCbCrU8Plugin() -{ -} - -#include "ycbcr_u8_plugin.moc" diff --git a/chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cpp b/chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cpp new file mode 100644 index 00000000..6c3ac243 --- /dev/null +++ b/chalk/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cpp @@ -0,0 +1,62 @@ +/* + * ycbcr_u8_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2006 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "ycbcr_u8_plugin.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_ycbcr_u8_colorspace.h" + +typedef KGenericFactory YCbCrU8PluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalk_ycbcr_u8_plugin, YCbCrU8PluginFactory( "chalk" ) ) + + +YCbCrU8Plugin::YCbCrU8Plugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(YCbCrU8PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast( parent ); + + KisColorSpace * colorSpaceYCbCrU8 = new KisYCbCrU8ColorSpace(f, 0); + KisColorSpaceFactory * csf = new KisYCbCrU8ColorSpaceFactory(); + TQ_CHECK_PTR(colorSpaceYCbCrU8); + f->add(csf); + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory + (KisID("YCBR8HISTO", i18n("YCBR8")), colorSpaceYCbCrU8) ); + } + +} + +YCbCrU8Plugin::~YCbCrU8Plugin() +{ +} + +#include "ycbcr_u8_plugin.moc" diff --git a/chalk/core/Makefile.am b/chalk/core/Makefile.am index 9370161a..ae67f2c0 100644 --- a/chalk/core/Makefile.am +++ b/chalk/core/Makefile.am @@ -13,21 +13,21 @@ CXXFLAGS += $(OPENEXR_CXXFLAGS) lib_LTLIBRARIES = libchalkimage.la -libchalkimage_la_SOURCES = kis_adjustment_layer.cc kis_alpha_mask.cc \ - kis_autobrush_resource.cc kis_autogradient_resource.cc kis_background.cc kis_boundary.cc \ - kis_brush.cc kis_command.cc kis_convolution_painter.cc kis_fill_painter.cc \ - kis_filter.cc kis_filter_registry.cc kis_filter_strategy.cc \ - kis_filter_configuration.cc kis_filter_config_widget.cc kis_gradient.cc kis_gradient_painter.cc \ - kis_histogram.cc kis_image.cc kis_imagepipe_brush.cc kis_iterator.cc \ - kis_iterators_pixel.cc kis_layer.cc kis_group_layer.cc kis_paint_layer.cc kis_meta_registry.cc \ - kis_nameserver.cc kis_painter.cc kis_paintop.cc kis_paintop_registry.cc kis_palette.cc \ - kis_pattern.cc kis_rect.cc kis_resource.cc kis_rotate_visitor.cc \ - kis_selected_transaction.cc kis_selection.cc kis_strategy_move.cc kis_transaction.cc \ - kis_transform_worker.cc kis_vec.cc kis_paint_device.cc kis_paint_device_iface.cc \ - kis_paint_device_iface.skel kis_image_iface.cc kis_image_iface.skel kis_basic_math_toolbox.cpp \ - kis_math_toolbox.cpp kis_exif_info.cc kis_thread_pool.cc kis_exif_value.cc \ +libchalkimage_la_SOURCES = kis_adjustment_layer.cpp kis_alpha_mask.cpp \ + kis_autobrush_resource.cpp kis_autogradient_resource.cpp kis_background.cpp kis_boundary.cpp \ + kis_brush.cpp kis_command.cpp kis_convolution_painter.cpp kis_fill_painter.cpp \ + kis_filter.cpp kis_filter_registry.cpp kis_filter_strategy.cpp \ + kis_filter_configuration.cpp kis_filter_config_widget.cpp kis_gradient.cpp kis_gradient_painter.cpp \ + kis_histogram.cpp kis_image.cpp kis_imagepipe_brush.cpp kis_iterator.cpp \ + kis_iterators_pixel.cpp kis_layer.cpp kis_group_layer.cpp kis_paint_layer.cpp kis_meta_registry.cpp \ + kis_nameserver.cpp kis_painter.cpp kis_paintop.cpp kis_paintop_registry.cpp kis_palette.cpp \ + kis_pattern.cpp kis_rect.cpp kis_resource.cpp kis_rotate_visitor.cpp \ + kis_selected_transaction.cpp kis_selection.cpp kis_strategy_move.cpp kis_transaction.cpp \ + kis_transform_worker.cpp kis_vec.cpp kis_paint_device.cpp kis_paint_device_iface.cpp \ + kis_paint_device_iface.skel kis_image_iface.cpp kis_image_iface.skel kis_basic_math_toolbox.cpp \ + kis_math_toolbox.cpp kis_exif_info.cpp kis_thread_pool.cpp kis_exif_value.cpp \ kis_filter_strategy.h kis_random_accessor.cpp kis_random_sub_accessor.cpp \ - kis_perspective_grid.cpp kis_perspectivetransform_worker.cpp kis_perspective_math.cpp kis_scale_visitor.cc + kis_perspective_grid.cpp kis_perspectivetransform_worker.cpp kis_perspective_math.cpp kis_scale_visitor.cpp noinst_HEADERS = kis_rotate_visitor.h kis_selected_transaction.h \ kis_strategy_move.h kis_transform_worker.h kis_datamanager.h kis_iteratorpixeltrait.h \ diff --git a/chalk/core/createdcop.py b/chalk/core/createdcop.py index ef7acc5e..337d9076 100755 --- a/chalk/core/createdcop.py +++ b/chalk/core/createdcop.py @@ -149,7 +149,7 @@ def createDCOP(header): classname = classname + part.capitalize() classname_upper = classname_upper + part.upper() + "_" ifaceheader = header[:-2] + "_iface.h" - ifaceimplementation = header[:-2] + "_iface.cc" + ifaceimplementation = header[:-2] + "_iface.cpp" ifaceclass = classname + "Iface" #print "with: ", implementation, classname, classname_upper, ifaceheader, ifaceimplementation, ifaceclass diff --git a/chalk/core/kis_adjustment_layer.cc b/chalk/core/kis_adjustment_layer.cpp similarity index 100% rename from chalk/core/kis_adjustment_layer.cc rename to chalk/core/kis_adjustment_layer.cpp diff --git a/chalk/core/kis_alpha_mask.cc b/chalk/core/kis_alpha_mask.cpp similarity index 100% rename from chalk/core/kis_alpha_mask.cc rename to chalk/core/kis_alpha_mask.cpp diff --git a/chalk/core/kis_autobrush_resource.cc b/chalk/core/kis_autobrush_resource.cpp similarity index 100% rename from chalk/core/kis_autobrush_resource.cc rename to chalk/core/kis_autobrush_resource.cpp diff --git a/chalk/core/kis_autogradient_resource.cc b/chalk/core/kis_autogradient_resource.cc deleted file mode 100644 index 671e8fc2..00000000 --- a/chalk/core/kis_autogradient_resource.cc +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2004 Cyrille Berger - * 2004 Sven Langkamp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kis_gradient.h" -#include "kis_autogradient_resource.h" - -// FIXME: use the same #define as in kis_gradient.cc, probably best customizable? -#define PREVIEW_WIDTH 64 -#define PREVIEW_HEIGHT 64 - - -void KisAutogradientResource::createSegment( int interpolation, int colorInterpolation, double startOffset, double endOffset, double middleOffset, TQColor left, TQColor right ) -{ - pushSegment(new KisGradientSegment(interpolation, colorInterpolation, startOffset, middleOffset, endOffset, Color( left, 1 ), Color( right, 1 ))); - -} - -const TQValueVector KisAutogradientResource::getHandlePositions() const -{ - TQValueVector handlePositions; - - handlePositions.push_back(m_segments[0]->startOffset()); - for (uint i = 0; i < m_segments.count(); i++) - { - handlePositions.push_back(m_segments[i]->endOffset()); - } - return handlePositions; -} - -const TQValueVector KisAutogradientResource::getMiddleHandlePositions() const -{ - TQValueVector middleHandlePositions; - - for (uint i = 0; i < m_segments.count(); i++) - { - middleHandlePositions.push_back(m_segments[i]->middleOffset()); - } - return middleHandlePositions; -} - -void KisAutogradientResource::moveSegmentStartOffset( KisGradientSegment* segment, double t) -{ - TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); - if ( it != m_segments.end() ) - { - if ( it == m_segments.begin() ) - { - segment->setStartOffset( 0.0 ); - return; - } - KisGradientSegment* previousSegment = (*(it-1)); - if ( t > segment->startOffset() ) - { - if( t > segment->middleOffset() ) - t = segment->middleOffset(); - } - else { - if( t < previousSegment->middleOffset() ) - t = previousSegment->middleOffset(); - } - previousSegment->setEndOffset( t ); - segment->setStartOffset( t ); - } -} - -void KisAutogradientResource::moveSegmentEndOffset( KisGradientSegment* segment, double t) -{ - TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); - if ( it != m_segments.end() ) - { - if ( it+1 == m_segments.end() ) - { - segment->setEndOffset( 1.0 ); - return; - } - KisGradientSegment* followingSegment = (*(it+1)); - if ( t < segment->endOffset() ) - { - if( t < segment->middleOffset() ) - t = segment->middleOffset(); - } - else { - if( t > followingSegment->middleOffset() ) - t = followingSegment->middleOffset(); - } - followingSegment->setStartOffset( t ); - segment->setEndOffset( t ); - } -} - -void KisAutogradientResource::moveSegmentMiddleOffset( KisGradientSegment* segment, double t) -{ - if( segment ) - { - if( t > segment->endOffset() ) - segment->setMiddleOffset( segment->endOffset() ); - else if( t < segment->startOffset() ) - segment->setMiddleOffset( segment->startOffset() ); - else - segment->setMiddleOffset( t ); - } -} - -void KisAutogradientResource::splitSegment( KisGradientSegment* segment ) -{ - Q_ASSERT(segment != 0); - TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); - if ( it != m_segments.end() ) - { - KisGradientSegment* newSegment = new KisGradientSegment( - segment->interpolation(), segment->colorInterpolation(), - segment ->startOffset(), - ( segment->middleOffset() - segment->startOffset() ) / 2 + segment->startOffset(), - segment->middleOffset(), - segment->startColor(), - segment->colorAt( segment->middleOffset() ) ); - m_segments.insert( it, newSegment ); - segment->setStartColor( segment->colorAt( segment->middleOffset() ) ); - segment->setStartOffset( segment->middleOffset() ); - segment->setMiddleOffset( ( segment->endOffset() - segment->startOffset() ) / 2 + segment->startOffset() ); - } -} - -void KisAutogradientResource::duplicateSegment( KisGradientSegment* segment ) -{ - Q_ASSERT(segment != 0); - TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); - if ( it != m_segments.end() ) - { - double middlePostionPercentage = ( segment->middleOffset() - segment->startOffset() ) / segment->length(); - double center = segment->startOffset() + segment->length() / 2; - KisGradientSegment* newSegment = new KisGradientSegment( - segment->interpolation(), segment->colorInterpolation(), - segment ->startOffset(), - segment->length() / 2 * middlePostionPercentage + segment->startOffset(), - center, segment->startColor(), - segment->endColor() ); - m_segments.insert( it, newSegment ); - segment->setStartOffset( center ); - segment->setMiddleOffset( segment->length() * middlePostionPercentage + segment->startOffset() ); - } -} - -void KisAutogradientResource::mirrorSegment( KisGradientSegment* segment ) -{ - Q_ASSERT(segment != 0); - Color tmpColor = segment->startColor(); - segment->setStartColor( segment->endColor() ); - segment->setEndColor( tmpColor ); - segment->setMiddleOffset( segment->endOffset() - ( segment->middleOffset() - segment->startOffset() ) ); - - if( segment->interpolation() == INTERP_SPHERE_INCREASING ) - segment->setInterpolation( INTERP_SPHERE_DECREASING ); - else if( segment->interpolation() == INTERP_SPHERE_DECREASING ) - segment->setInterpolation( INTERP_SPHERE_INCREASING ); - - if( segment->colorInterpolation() == COLOR_INTERP_HSV_CW ) - segment->setColorInterpolation( COLOR_INTERP_HSV_CCW ); - else if( segment->colorInterpolation() == COLOR_INTERP_HSV_CCW ) - segment->setColorInterpolation( COLOR_INTERP_HSV_CW ); -} - -KisGradientSegment* KisAutogradientResource::removeSegment( KisGradientSegment* segment ) -{ - Q_ASSERT(segment != 0); - if( m_segments.count() < 2 ) - return 0; - TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); - if ( it != m_segments.end() ) - { - double middlePostionPercentage; - KisGradientSegment* nextSegment; - if( it == m_segments.begin() ) - { - nextSegment = (*(it+1)); - middlePostionPercentage = ( nextSegment->middleOffset() - nextSegment->startOffset() ) / nextSegment->length(); - nextSegment->setStartOffset( segment->startOffset() ); - nextSegment->setMiddleOffset( middlePostionPercentage * nextSegment->length() + nextSegment->startOffset() ); - } - else - { - nextSegment = (*(it-1)); - middlePostionPercentage = ( nextSegment->middleOffset() - nextSegment->startOffset() ) / nextSegment->length(); - nextSegment->setEndOffset( segment->endOffset() ); - nextSegment->setMiddleOffset( middlePostionPercentage * nextSegment->length() + nextSegment->startOffset() ); - } - - delete segment; - m_segments.erase( it ); - return nextSegment; - } - return 0; -} - -bool KisAutogradientResource::removeSegmentPossible() const -{ - if( m_segments.count() < 2 ) - return false; - return true; -} - -void KisAutogradientResource::updatePreview() -{ - setImage( generatePreview( PREVIEW_WIDTH, PREVIEW_HEIGHT ) ); -} diff --git a/chalk/core/kis_autogradient_resource.cpp b/chalk/core/kis_autogradient_resource.cpp new file mode 100644 index 00000000..aaac54ef --- /dev/null +++ b/chalk/core/kis_autogradient_resource.cpp @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2004 Cyrille Berger + * 2004 Sven Langkamp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_gradient.h" +#include "kis_autogradient_resource.h" + +// FIXME: use the same #define as in kis_gradient.cpp, probably best customizable? +#define PREVIEW_WIDTH 64 +#define PREVIEW_HEIGHT 64 + + +void KisAutogradientResource::createSegment( int interpolation, int colorInterpolation, double startOffset, double endOffset, double middleOffset, TQColor left, TQColor right ) +{ + pushSegment(new KisGradientSegment(interpolation, colorInterpolation, startOffset, middleOffset, endOffset, Color( left, 1 ), Color( right, 1 ))); + +} + +const TQValueVector KisAutogradientResource::getHandlePositions() const +{ + TQValueVector handlePositions; + + handlePositions.push_back(m_segments[0]->startOffset()); + for (uint i = 0; i < m_segments.count(); i++) + { + handlePositions.push_back(m_segments[i]->endOffset()); + } + return handlePositions; +} + +const TQValueVector KisAutogradientResource::getMiddleHandlePositions() const +{ + TQValueVector middleHandlePositions; + + for (uint i = 0; i < m_segments.count(); i++) + { + middleHandlePositions.push_back(m_segments[i]->middleOffset()); + } + return middleHandlePositions; +} + +void KisAutogradientResource::moveSegmentStartOffset( KisGradientSegment* segment, double t) +{ + TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); + if ( it != m_segments.end() ) + { + if ( it == m_segments.begin() ) + { + segment->setStartOffset( 0.0 ); + return; + } + KisGradientSegment* previousSegment = (*(it-1)); + if ( t > segment->startOffset() ) + { + if( t > segment->middleOffset() ) + t = segment->middleOffset(); + } + else { + if( t < previousSegment->middleOffset() ) + t = previousSegment->middleOffset(); + } + previousSegment->setEndOffset( t ); + segment->setStartOffset( t ); + } +} + +void KisAutogradientResource::moveSegmentEndOffset( KisGradientSegment* segment, double t) +{ + TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); + if ( it != m_segments.end() ) + { + if ( it+1 == m_segments.end() ) + { + segment->setEndOffset( 1.0 ); + return; + } + KisGradientSegment* followingSegment = (*(it+1)); + if ( t < segment->endOffset() ) + { + if( t < segment->middleOffset() ) + t = segment->middleOffset(); + } + else { + if( t > followingSegment->middleOffset() ) + t = followingSegment->middleOffset(); + } + followingSegment->setStartOffset( t ); + segment->setEndOffset( t ); + } +} + +void KisAutogradientResource::moveSegmentMiddleOffset( KisGradientSegment* segment, double t) +{ + if( segment ) + { + if( t > segment->endOffset() ) + segment->setMiddleOffset( segment->endOffset() ); + else if( t < segment->startOffset() ) + segment->setMiddleOffset( segment->startOffset() ); + else + segment->setMiddleOffset( t ); + } +} + +void KisAutogradientResource::splitSegment( KisGradientSegment* segment ) +{ + Q_ASSERT(segment != 0); + TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); + if ( it != m_segments.end() ) + { + KisGradientSegment* newSegment = new KisGradientSegment( + segment->interpolation(), segment->colorInterpolation(), + segment ->startOffset(), + ( segment->middleOffset() - segment->startOffset() ) / 2 + segment->startOffset(), + segment->middleOffset(), + segment->startColor(), + segment->colorAt( segment->middleOffset() ) ); + m_segments.insert( it, newSegment ); + segment->setStartColor( segment->colorAt( segment->middleOffset() ) ); + segment->setStartOffset( segment->middleOffset() ); + segment->setMiddleOffset( ( segment->endOffset() - segment->startOffset() ) / 2 + segment->startOffset() ); + } +} + +void KisAutogradientResource::duplicateSegment( KisGradientSegment* segment ) +{ + Q_ASSERT(segment != 0); + TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); + if ( it != m_segments.end() ) + { + double middlePostionPercentage = ( segment->middleOffset() - segment->startOffset() ) / segment->length(); + double center = segment->startOffset() + segment->length() / 2; + KisGradientSegment* newSegment = new KisGradientSegment( + segment->interpolation(), segment->colorInterpolation(), + segment ->startOffset(), + segment->length() / 2 * middlePostionPercentage + segment->startOffset(), + center, segment->startColor(), + segment->endColor() ); + m_segments.insert( it, newSegment ); + segment->setStartOffset( center ); + segment->setMiddleOffset( segment->length() * middlePostionPercentage + segment->startOffset() ); + } +} + +void KisAutogradientResource::mirrorSegment( KisGradientSegment* segment ) +{ + Q_ASSERT(segment != 0); + Color tmpColor = segment->startColor(); + segment->setStartColor( segment->endColor() ); + segment->setEndColor( tmpColor ); + segment->setMiddleOffset( segment->endOffset() - ( segment->middleOffset() - segment->startOffset() ) ); + + if( segment->interpolation() == INTERP_SPHERE_INCREASING ) + segment->setInterpolation( INTERP_SPHERE_DECREASING ); + else if( segment->interpolation() == INTERP_SPHERE_DECREASING ) + segment->setInterpolation( INTERP_SPHERE_INCREASING ); + + if( segment->colorInterpolation() == COLOR_INTERP_HSV_CW ) + segment->setColorInterpolation( COLOR_INTERP_HSV_CCW ); + else if( segment->colorInterpolation() == COLOR_INTERP_HSV_CCW ) + segment->setColorInterpolation( COLOR_INTERP_HSV_CW ); +} + +KisGradientSegment* KisAutogradientResource::removeSegment( KisGradientSegment* segment ) +{ + Q_ASSERT(segment != 0); + if( m_segments.count() < 2 ) + return 0; + TQValueVector::iterator it = tqFind( m_segments.begin(), m_segments.end(), segment ); + if ( it != m_segments.end() ) + { + double middlePostionPercentage; + KisGradientSegment* nextSegment; + if( it == m_segments.begin() ) + { + nextSegment = (*(it+1)); + middlePostionPercentage = ( nextSegment->middleOffset() - nextSegment->startOffset() ) / nextSegment->length(); + nextSegment->setStartOffset( segment->startOffset() ); + nextSegment->setMiddleOffset( middlePostionPercentage * nextSegment->length() + nextSegment->startOffset() ); + } + else + { + nextSegment = (*(it-1)); + middlePostionPercentage = ( nextSegment->middleOffset() - nextSegment->startOffset() ) / nextSegment->length(); + nextSegment->setEndOffset( segment->endOffset() ); + nextSegment->setMiddleOffset( middlePostionPercentage * nextSegment->length() + nextSegment->startOffset() ); + } + + delete segment; + m_segments.erase( it ); + return nextSegment; + } + return 0; +} + +bool KisAutogradientResource::removeSegmentPossible() const +{ + if( m_segments.count() < 2 ) + return false; + return true; +} + +void KisAutogradientResource::updatePreview() +{ + setImage( generatePreview( PREVIEW_WIDTH, PREVIEW_HEIGHT ) ); +} diff --git a/chalk/core/kis_background.cc b/chalk/core/kis_background.cpp similarity index 100% rename from chalk/core/kis_background.cc rename to chalk/core/kis_background.cpp diff --git a/chalk/core/kis_boundary.cc b/chalk/core/kis_boundary.cpp similarity index 100% rename from chalk/core/kis_boundary.cc rename to chalk/core/kis_boundary.cpp diff --git a/chalk/core/kis_brush.cc b/chalk/core/kis_brush.cpp similarity index 100% rename from chalk/core/kis_brush.cc rename to chalk/core/kis_brush.cpp diff --git a/chalk/core/kis_command.cc b/chalk/core/kis_command.cpp similarity index 100% rename from chalk/core/kis_command.cc rename to chalk/core/kis_command.cpp diff --git a/chalk/core/kis_convolution_painter.cc b/chalk/core/kis_convolution_painter.cpp similarity index 100% rename from chalk/core/kis_convolution_painter.cc rename to chalk/core/kis_convolution_painter.cpp diff --git a/chalk/core/kis_exif_info.cc b/chalk/core/kis_exif_info.cpp similarity index 100% rename from chalk/core/kis_exif_info.cc rename to chalk/core/kis_exif_info.cpp diff --git a/chalk/core/kis_exif_value.cc b/chalk/core/kis_exif_value.cpp similarity index 100% rename from chalk/core/kis_exif_value.cc rename to chalk/core/kis_exif_value.cpp diff --git a/chalk/core/kis_fill_painter.cc b/chalk/core/kis_fill_painter.cpp similarity index 100% rename from chalk/core/kis_fill_painter.cc rename to chalk/core/kis_fill_painter.cpp diff --git a/chalk/core/kis_filter.cc b/chalk/core/kis_filter.cpp similarity index 100% rename from chalk/core/kis_filter.cc rename to chalk/core/kis_filter.cpp diff --git a/chalk/core/kis_filter_config_widget.cc b/chalk/core/kis_filter_config_widget.cpp similarity index 100% rename from chalk/core/kis_filter_config_widget.cc rename to chalk/core/kis_filter_config_widget.cpp diff --git a/chalk/core/kis_filter_configuration.cc b/chalk/core/kis_filter_configuration.cpp similarity index 100% rename from chalk/core/kis_filter_configuration.cc rename to chalk/core/kis_filter_configuration.cpp diff --git a/chalk/core/kis_filter_registry.cc b/chalk/core/kis_filter_registry.cpp similarity index 100% rename from chalk/core/kis_filter_registry.cc rename to chalk/core/kis_filter_registry.cpp diff --git a/chalk/core/kis_filter_strategy.cc b/chalk/core/kis_filter_strategy.cpp similarity index 100% rename from chalk/core/kis_filter_strategy.cc rename to chalk/core/kis_filter_strategy.cpp diff --git a/chalk/core/kis_gradient.cc b/chalk/core/kis_gradient.cc deleted file mode 100644 index 41541e80..00000000 --- a/chalk/core/kis_gradient.cc +++ /dev/null @@ -1,639 +0,0 @@ -/* - * kis_gradient.cc - part of Krayon - * - * Copyright (c) 2000 Matthias Elter - * 2001 John Califf - * 2004 Boudewijn Rempt - * 2004 Adrian Page - * 2004 Sven Langkamp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include "kis_gradient.h" - -#define PREVIEW_WIDTH 64 -#define PREVIEW_HEIGHT 64 - -KisGradientSegment::RGBColorInterpolationStrategy *KisGradientSegment::RGBColorInterpolationStrategy::m_instance = 0; -KisGradientSegment::HSVCWColorInterpolationStrategy *KisGradientSegment::HSVCWColorInterpolationStrategy::m_instance = 0; -KisGradientSegment::HSVCCWColorInterpolationStrategy *KisGradientSegment::HSVCCWColorInterpolationStrategy::m_instance = 0; - -KisGradientSegment::LinearInterpolationStrategy *KisGradientSegment::LinearInterpolationStrategy::m_instance = 0; -KisGradientSegment::CurvedInterpolationStrategy *KisGradientSegment::CurvedInterpolationStrategy::m_instance = 0; -KisGradientSegment::SineInterpolationStrategy *KisGradientSegment::SineInterpolationStrategy::m_instance = 0; -KisGradientSegment::SphereIncreasingInterpolationStrategy *KisGradientSegment::SphereIncreasingInterpolationStrategy::m_instance = 0; -KisGradientSegment::SphereDecreasingInterpolationStrategy *KisGradientSegment::SphereDecreasingInterpolationStrategy::m_instance = 0; - -KisGradient::KisGradient(const TQString& file) : super(file) -{ -} - -KisGradient::~KisGradient() -{ - for (uint i = 0; i < m_segments.count(); i++) { - delete m_segments[i]; - m_segments[i] = 0; - } -} - -bool KisGradient::load() -{ - return init(); -} - -bool KisGradient::save() -{ - return false; -} - -TQImage KisGradient::img() -{ - return m_img; -} - -bool KisGradient::init() -{ - KoGradientManager gradLoader; - KoGradient* grad = gradLoader.loadGradient(filename()); - - if( !grad ) - return false; - - m_segments.clear(); - - if( grad->colorStops.count() > 1 ) { - KoColorStop *colstop; - for(colstop = grad->colorStops.first(); colstop; colstop = grad->colorStops.next()) { - KoColorStop *colstopNext = grad->colorStops.next(); - - if(colstopNext) { - KoColor leftRgb((int)(colstop->color1 * 255 + 0.5), (int)(colstop->color2 * 255 + 0.5), (int)(colstop->color3 * 255 + 0.5)); - KoColor rightRgb((int)(colstopNext->color1 * 255 + 0.5), (int)(colstopNext->color2 * 255 + 0.5), (int)(colstopNext->color3 * 255 + 0.5)); - - double midp = colstop->midpoint; - midp = colstop->offset + ((colstopNext->offset - colstop->offset) * midp); - - Color leftColor(leftRgb.color(), colstop->opacity); - Color rightColor(rightRgb.color(), colstopNext->opacity); - - KisGradientSegment *segment = new KisGradientSegment(colstop->interpolation, colstop->colorType, colstop->offset, midp, colstopNext->offset, leftColor, rightColor); - TQ_CHECK_PTR(segment); - - if ( !segment->isValid() ) { - delete segment; - return false; - } - - m_segments.push_back(segment); - grad->colorStops.prev(); - } - else { - grad->colorStops.prev(); - break; - } - } - } - else - return false; - - if (!m_segments.isEmpty()) { - m_img = generatePreview(PREVIEW_WIDTH, PREVIEW_HEIGHT); - setValid(true); - return true; - } - else { - return false; - } -} - -void KisGradient::setImage(const TQImage& img) -{ - m_img = img; - m_img.detach(); - - setValid(true); -} - -KisGradientSegment *KisGradient::segmentAt(double t) const -{ - Q_ASSERT(t >= 0 || t <= 1); - Q_ASSERT(!m_segments.empty()); - - for(TQValueVector::const_iterator it = m_segments.begin(); it!= m_segments.end(); ++it) - { - if (t > (*it)->startOffset() - DBL_EPSILON && t < (*it)->endOffset() + DBL_EPSILON) { - return *it; - } - } - - return 0; -} - -void KisGradient::colorAt(double t, TQColor *color, TQ_UINT8 *opacity) const -{ - const KisGradientSegment *segment = segmentAt(t); - Q_ASSERT(segment != 0); - - if (segment) { - Color col = segment->colorAt(t); - *color = col.color(); - *opacity = static_cast(col.alpha() * OPACITY_OPAQUE + 0.5); - } -} - -TQImage KisGradient::generatePreview(int width, int height) const -{ - TQImage img(width, height, 32); - - for (int y = 0; y < img.height(); y++) { - for (int x = 0; x < img.width(); x++) { - - int backgroundRed = 128 + 63 * ((x / 4 + y / 4) % 2); - int backgroundGreen = backgroundRed; - int backgroundBlue = backgroundRed; - - TQColor color; - TQ_UINT8 opacity; - double t = static_cast(x) / (img.width() - 1); - - colorAt(t, &color, &opacity); - - double alpha = static_cast(opacity) / OPACITY_OPAQUE; - - int red = static_cast((1 - alpha) * backgroundRed + alpha * color.red() + 0.5); - int green = static_cast((1 - alpha) * backgroundGreen + alpha * color.green() + 0.5); - int blue = static_cast((1 - alpha) * backgroundBlue + alpha * color.blue() + 0.5); - - img.setPixel(x, y, tqRgb(red, green, blue)); - } - } - - return img; -} - -KisGradientSegment::KisGradientSegment(int interpolationType, int colorInterpolationType, double startOffset, double middleOffset, double endOffset, const Color& startColor, const Color& endColor) -{ - m_interpolator = 0; - - switch (interpolationType) { - case INTERP_LINEAR: - m_interpolator = LinearInterpolationStrategy::instance(); - break; - case INTERP_CURVED: - m_interpolator = CurvedInterpolationStrategy::instance(); - break; - case INTERP_SINE: - m_interpolator = SineInterpolationStrategy::instance(); - break; - case INTERP_SPHERE_INCREASING: - m_interpolator = SphereIncreasingInterpolationStrategy::instance(); - break; - case INTERP_SPHERE_DECREASING: - m_interpolator = SphereDecreasingInterpolationStrategy::instance(); - break; - } - - m_colorInterpolator = 0; - - switch (colorInterpolationType) { - case COLOR_INTERP_RGB: - m_colorInterpolator = RGBColorInterpolationStrategy::instance(); - break; - case COLOR_INTERP_HSV_CCW: - m_colorInterpolator = HSVCCWColorInterpolationStrategy::instance(); - break; - case COLOR_INTERP_HSV_CW: - m_colorInterpolator = HSVCWColorInterpolationStrategy::instance(); - break; - } - - if (startOffset < DBL_EPSILON) { - m_startOffset = 0; - } - else - if (startOffset > 1 - DBL_EPSILON) { - m_startOffset = 1; - } - else { - m_startOffset = startOffset; - } - - if (middleOffset < m_startOffset + DBL_EPSILON) { - m_middleOffset = m_startOffset; - } - else - if (middleOffset > 1 - DBL_EPSILON) { - m_middleOffset = 1; - } - else { - m_middleOffset = middleOffset; - } - - if (endOffset < m_middleOffset + DBL_EPSILON) { - m_endOffset = m_middleOffset; - } - else - if (endOffset > 1 - DBL_EPSILON) { - m_endOffset = 1; - } - else { - m_endOffset = endOffset; - } - - m_length = m_endOffset - m_startOffset; - - if (m_length < DBL_EPSILON) { - m_middleT = 0.5; - } - else { - m_middleT = (m_middleOffset - m_startOffset) / m_length; - } - - m_startColor = startColor; - m_endColor = endColor; -} - -const Color& KisGradientSegment::startColor() const -{ - return m_startColor; -} - -const Color& KisGradientSegment::endColor() const -{ - return m_endColor; -} - -double KisGradientSegment::startOffset() const -{ - return m_startOffset; -} - -double KisGradientSegment::middleOffset() const -{ - return m_middleOffset; -} - -double KisGradientSegment::endOffset() const -{ - return m_endOffset; -} - -void KisGradientSegment::setStartOffset(double t) -{ - m_startOffset = t; - m_length = m_endOffset - m_startOffset; - - if (m_length < DBL_EPSILON) { - m_middleT = 0.5; - } - else { - m_middleT = (m_middleOffset - m_startOffset) / m_length; - } -} -void KisGradientSegment::setMiddleOffset(double t) -{ - m_middleOffset = t; - - if (m_length < DBL_EPSILON) { - m_middleT = 0.5; - } - else { - m_middleT = (m_middleOffset - m_startOffset) / m_length; - } -} - -void KisGradientSegment::setEndOffset(double t) -{ - m_endOffset = t; - m_length = m_endOffset - m_startOffset; - - if (m_length < DBL_EPSILON) { - m_middleT = 0.5; - } - else { - m_middleT = (m_middleOffset - m_startOffset) / m_length; - } -} - -int KisGradientSegment::interpolation() const -{ - return m_interpolator->type(); -} - -void KisGradientSegment::setInterpolation(int interpolationType) -{ - switch (interpolationType) { - case INTERP_LINEAR: - m_interpolator = LinearInterpolationStrategy::instance(); - break; - case INTERP_CURVED: - m_interpolator = CurvedInterpolationStrategy::instance(); - break; - case INTERP_SINE: - m_interpolator = SineInterpolationStrategy::instance(); - break; - case INTERP_SPHERE_INCREASING: - m_interpolator = SphereIncreasingInterpolationStrategy::instance(); - break; - case INTERP_SPHERE_DECREASING: - m_interpolator = SphereDecreasingInterpolationStrategy::instance(); - break; - } -} - -int KisGradientSegment::colorInterpolation() const -{ - return m_colorInterpolator->type(); -} - -void KisGradientSegment::setColorInterpolation(int colorInterpolationType) -{ - switch (colorInterpolationType) { - case COLOR_INTERP_RGB: - m_colorInterpolator = RGBColorInterpolationStrategy::instance(); - break; - case COLOR_INTERP_HSV_CCW: - m_colorInterpolator = HSVCCWColorInterpolationStrategy::instance(); - break; - case COLOR_INTERP_HSV_CW: - m_colorInterpolator = HSVCWColorInterpolationStrategy::instance(); - break; - } -} - -Color KisGradientSegment::colorAt(double t) const -{ - Q_ASSERT(t > m_startOffset - DBL_EPSILON && t < m_endOffset + DBL_EPSILON); - - double segmentT; - - if (m_length < DBL_EPSILON) { - segmentT = 0.5; - } - else { - segmentT = (t - m_startOffset) / m_length; - } - - double colorT = m_interpolator->valueAt(segmentT, m_middleT); - - Color color = m_colorInterpolator->colorAt(colorT, m_startColor, m_endColor); - - return color; -} - -bool KisGradientSegment::isValid() const -{ - if (m_interpolator == 0 || m_colorInterpolator ==0) - return false; - return true; -} - -KisGradientSegment::RGBColorInterpolationStrategy *KisGradientSegment::RGBColorInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new RGBColorInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -Color KisGradientSegment::RGBColorInterpolationStrategy::colorAt(double t, Color start, Color end) const -{ - int startRed = start.color().red(); - int startGreen = start.color().green(); - int startBlue = start.color().blue(); - double startAlpha = start.alpha(); - int red = static_cast(startRed + t * (end.color().red() - startRed) + 0.5); - int green = static_cast(startGreen + t * (end.color().green() - startGreen) + 0.5); - int blue = static_cast(startBlue + t * (end.color().blue() - startBlue) + 0.5); - double alpha = startAlpha + t * (end.alpha() - startAlpha); - - return Color(TQColor(red, green, blue), alpha); -} - -KisGradientSegment::HSVCWColorInterpolationStrategy *KisGradientSegment::HSVCWColorInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new HSVCWColorInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -Color KisGradientSegment::HSVCWColorInterpolationStrategy::colorAt(double t, Color start, Color end) const -{ - KoColor sc = KoColor(start.color()); - KoColor ec = KoColor(end.color()); - - int s = static_cast(sc.S() + t * (ec.S() - sc.S()) + 0.5); - int v = static_cast(sc.V() + t * (ec.V() - sc.V()) + 0.5); - int h; - - if (ec.H() < sc.H()) { - h = static_cast(ec.H() + (1 - t) * (sc.H() - ec.H()) + 0.5); - } - else { - h = static_cast(ec.H() + (1 - t) * (360 - ec.H() + sc.H()) + 0.5); - - if (h > 359) { - h -= 360; - } - } - - double alpha = start.alpha() + t * (end.alpha() - start.alpha()); - - return Color(KoColor(h, s, v, KoColor::csHSV).color(), alpha); -} - -KisGradientSegment::HSVCCWColorInterpolationStrategy *KisGradientSegment::HSVCCWColorInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new HSVCCWColorInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -Color KisGradientSegment::HSVCCWColorInterpolationStrategy::colorAt(double t, Color start, Color end) const -{ - KoColor sc = KoColor(start.color()); - KoColor se = KoColor(end.color()); - - int s = static_cast(sc.S() + t * (se.S() - sc.S()) + 0.5); - int v = static_cast(sc.V() + t * (se.V() - sc.V()) + 0.5); - int h; - - if (sc.H() < se.H()) { - h = static_cast(sc.H() + t * (se.H() - sc.H()) + 0.5); - } - else { - h = static_cast(sc.H() + t * (360 - sc.H() + se.H()) + 0.5); - - if (h > 359) { - h -= 360; - } - } - - double alpha = start.alpha() + t * (end.alpha() - start.alpha()); - - return Color(KoColor(h, s, v, KoColor::csHSV).color(), alpha); -} - -KisGradientSegment::LinearInterpolationStrategy *KisGradientSegment::LinearInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new LinearInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -double KisGradientSegment::LinearInterpolationStrategy::calcValueAt(double t, double middle) -{ - Q_ASSERT(t > -DBL_EPSILON && t < 1 + DBL_EPSILON); - Q_ASSERT(middle > -DBL_EPSILON && middle < 1 + DBL_EPSILON); - - double value = 0; - - if (t <= middle) { - if (middle < DBL_EPSILON) { - value = 0; - } - else { - value = (t / middle) * 0.5; - } - } - else { - if (middle > 1 - DBL_EPSILON) { - value = 1; - } - else { - value = ((t - middle) / (1 - middle)) * 0.5 + 0.5; - } - } - - return value; -} - -double KisGradientSegment::LinearInterpolationStrategy::valueAt(double t, double middle) const -{ - return calcValueAt(t, middle); -} - -KisGradientSegment::CurvedInterpolationStrategy::CurvedInterpolationStrategy() -{ - m_logHalf = log(0.5); -} - -KisGradientSegment::CurvedInterpolationStrategy *KisGradientSegment::CurvedInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new CurvedInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -double KisGradientSegment::CurvedInterpolationStrategy::valueAt(double t, double middle) const -{ - Q_ASSERT(t > -DBL_EPSILON && t < 1 + DBL_EPSILON); - Q_ASSERT(middle > -DBL_EPSILON && middle < 1 + DBL_EPSILON); - - double value = 0; - - if (middle < DBL_EPSILON) { - middle = DBL_EPSILON; - } - - value = pow(t, m_logHalf / log(middle)); - - return value; -} - -KisGradientSegment::SineInterpolationStrategy *KisGradientSegment::SineInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new SineInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -double KisGradientSegment::SineInterpolationStrategy::valueAt(double t, double middle) const -{ - double lt = LinearInterpolationStrategy::calcValueAt(t, middle); - double value = (sin(-M_PI_2 + M_PI * lt) + 1.0) / 2.0; - - return value; -} - -KisGradientSegment::SphereIncreasingInterpolationStrategy *KisGradientSegment::SphereIncreasingInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new SphereIncreasingInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -double KisGradientSegment::SphereIncreasingInterpolationStrategy::valueAt(double t, double middle) const -{ - double lt = LinearInterpolationStrategy::calcValueAt(t, middle) - 1; - double value = sqrt(1 - lt * lt); - - return value; -} - -KisGradientSegment::SphereDecreasingInterpolationStrategy *KisGradientSegment::SphereDecreasingInterpolationStrategy::instance() -{ - if (m_instance == 0) { - m_instance = new SphereDecreasingInterpolationStrategy(); - TQ_CHECK_PTR(m_instance); - } - - return m_instance; -} - -double KisGradientSegment::SphereDecreasingInterpolationStrategy::valueAt(double t, double middle) const -{ - double lt = LinearInterpolationStrategy::calcValueAt(t, middle); - double value = 1 - sqrt(1 - lt * lt); - - return value; -} - -#include "kis_gradient.moc" - diff --git a/chalk/core/kis_gradient.cpp b/chalk/core/kis_gradient.cpp new file mode 100644 index 00000000..9b240cb0 --- /dev/null +++ b/chalk/core/kis_gradient.cpp @@ -0,0 +1,639 @@ +/* + * kis_gradient.cpp - part of Krayon + * + * Copyright (c) 2000 Matthias Elter + * 2001 John Califf + * 2004 Boudewijn Rempt + * 2004 Adrian Page + * 2004 Sven Langkamp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include "kis_gradient.h" + +#define PREVIEW_WIDTH 64 +#define PREVIEW_HEIGHT 64 + +KisGradientSegment::RGBColorInterpolationStrategy *KisGradientSegment::RGBColorInterpolationStrategy::m_instance = 0; +KisGradientSegment::HSVCWColorInterpolationStrategy *KisGradientSegment::HSVCWColorInterpolationStrategy::m_instance = 0; +KisGradientSegment::HSVCCWColorInterpolationStrategy *KisGradientSegment::HSVCCWColorInterpolationStrategy::m_instance = 0; + +KisGradientSegment::LinearInterpolationStrategy *KisGradientSegment::LinearInterpolationStrategy::m_instance = 0; +KisGradientSegment::CurvedInterpolationStrategy *KisGradientSegment::CurvedInterpolationStrategy::m_instance = 0; +KisGradientSegment::SineInterpolationStrategy *KisGradientSegment::SineInterpolationStrategy::m_instance = 0; +KisGradientSegment::SphereIncreasingInterpolationStrategy *KisGradientSegment::SphereIncreasingInterpolationStrategy::m_instance = 0; +KisGradientSegment::SphereDecreasingInterpolationStrategy *KisGradientSegment::SphereDecreasingInterpolationStrategy::m_instance = 0; + +KisGradient::KisGradient(const TQString& file) : super(file) +{ +} + +KisGradient::~KisGradient() +{ + for (uint i = 0; i < m_segments.count(); i++) { + delete m_segments[i]; + m_segments[i] = 0; + } +} + +bool KisGradient::load() +{ + return init(); +} + +bool KisGradient::save() +{ + return false; +} + +TQImage KisGradient::img() +{ + return m_img; +} + +bool KisGradient::init() +{ + KoGradientManager gradLoader; + KoGradient* grad = gradLoader.loadGradient(filename()); + + if( !grad ) + return false; + + m_segments.clear(); + + if( grad->colorStops.count() > 1 ) { + KoColorStop *colstop; + for(colstop = grad->colorStops.first(); colstop; colstop = grad->colorStops.next()) { + KoColorStop *colstopNext = grad->colorStops.next(); + + if(colstopNext) { + KoColor leftRgb((int)(colstop->color1 * 255 + 0.5), (int)(colstop->color2 * 255 + 0.5), (int)(colstop->color3 * 255 + 0.5)); + KoColor rightRgb((int)(colstopNext->color1 * 255 + 0.5), (int)(colstopNext->color2 * 255 + 0.5), (int)(colstopNext->color3 * 255 + 0.5)); + + double midp = colstop->midpoint; + midp = colstop->offset + ((colstopNext->offset - colstop->offset) * midp); + + Color leftColor(leftRgb.color(), colstop->opacity); + Color rightColor(rightRgb.color(), colstopNext->opacity); + + KisGradientSegment *segment = new KisGradientSegment(colstop->interpolation, colstop->colorType, colstop->offset, midp, colstopNext->offset, leftColor, rightColor); + TQ_CHECK_PTR(segment); + + if ( !segment->isValid() ) { + delete segment; + return false; + } + + m_segments.push_back(segment); + grad->colorStops.prev(); + } + else { + grad->colorStops.prev(); + break; + } + } + } + else + return false; + + if (!m_segments.isEmpty()) { + m_img = generatePreview(PREVIEW_WIDTH, PREVIEW_HEIGHT); + setValid(true); + return true; + } + else { + return false; + } +} + +void KisGradient::setImage(const TQImage& img) +{ + m_img = img; + m_img.detach(); + + setValid(true); +} + +KisGradientSegment *KisGradient::segmentAt(double t) const +{ + Q_ASSERT(t >= 0 || t <= 1); + Q_ASSERT(!m_segments.empty()); + + for(TQValueVector::const_iterator it = m_segments.begin(); it!= m_segments.end(); ++it) + { + if (t > (*it)->startOffset() - DBL_EPSILON && t < (*it)->endOffset() + DBL_EPSILON) { + return *it; + } + } + + return 0; +} + +void KisGradient::colorAt(double t, TQColor *color, TQ_UINT8 *opacity) const +{ + const KisGradientSegment *segment = segmentAt(t); + Q_ASSERT(segment != 0); + + if (segment) { + Color col = segment->colorAt(t); + *color = col.color(); + *opacity = static_cast(col.alpha() * OPACITY_OPAQUE + 0.5); + } +} + +TQImage KisGradient::generatePreview(int width, int height) const +{ + TQImage img(width, height, 32); + + for (int y = 0; y < img.height(); y++) { + for (int x = 0; x < img.width(); x++) { + + int backgroundRed = 128 + 63 * ((x / 4 + y / 4) % 2); + int backgroundGreen = backgroundRed; + int backgroundBlue = backgroundRed; + + TQColor color; + TQ_UINT8 opacity; + double t = static_cast(x) / (img.width() - 1); + + colorAt(t, &color, &opacity); + + double alpha = static_cast(opacity) / OPACITY_OPAQUE; + + int red = static_cast((1 - alpha) * backgroundRed + alpha * color.red() + 0.5); + int green = static_cast((1 - alpha) * backgroundGreen + alpha * color.green() + 0.5); + int blue = static_cast((1 - alpha) * backgroundBlue + alpha * color.blue() + 0.5); + + img.setPixel(x, y, tqRgb(red, green, blue)); + } + } + + return img; +} + +KisGradientSegment::KisGradientSegment(int interpolationType, int colorInterpolationType, double startOffset, double middleOffset, double endOffset, const Color& startColor, const Color& endColor) +{ + m_interpolator = 0; + + switch (interpolationType) { + case INTERP_LINEAR: + m_interpolator = LinearInterpolationStrategy::instance(); + break; + case INTERP_CURVED: + m_interpolator = CurvedInterpolationStrategy::instance(); + break; + case INTERP_SINE: + m_interpolator = SineInterpolationStrategy::instance(); + break; + case INTERP_SPHERE_INCREASING: + m_interpolator = SphereIncreasingInterpolationStrategy::instance(); + break; + case INTERP_SPHERE_DECREASING: + m_interpolator = SphereDecreasingInterpolationStrategy::instance(); + break; + } + + m_colorInterpolator = 0; + + switch (colorInterpolationType) { + case COLOR_INTERP_RGB: + m_colorInterpolator = RGBColorInterpolationStrategy::instance(); + break; + case COLOR_INTERP_HSV_CCW: + m_colorInterpolator = HSVCCWColorInterpolationStrategy::instance(); + break; + case COLOR_INTERP_HSV_CW: + m_colorInterpolator = HSVCWColorInterpolationStrategy::instance(); + break; + } + + if (startOffset < DBL_EPSILON) { + m_startOffset = 0; + } + else + if (startOffset > 1 - DBL_EPSILON) { + m_startOffset = 1; + } + else { + m_startOffset = startOffset; + } + + if (middleOffset < m_startOffset + DBL_EPSILON) { + m_middleOffset = m_startOffset; + } + else + if (middleOffset > 1 - DBL_EPSILON) { + m_middleOffset = 1; + } + else { + m_middleOffset = middleOffset; + } + + if (endOffset < m_middleOffset + DBL_EPSILON) { + m_endOffset = m_middleOffset; + } + else + if (endOffset > 1 - DBL_EPSILON) { + m_endOffset = 1; + } + else { + m_endOffset = endOffset; + } + + m_length = m_endOffset - m_startOffset; + + if (m_length < DBL_EPSILON) { + m_middleT = 0.5; + } + else { + m_middleT = (m_middleOffset - m_startOffset) / m_length; + } + + m_startColor = startColor; + m_endColor = endColor; +} + +const Color& KisGradientSegment::startColor() const +{ + return m_startColor; +} + +const Color& KisGradientSegment::endColor() const +{ + return m_endColor; +} + +double KisGradientSegment::startOffset() const +{ + return m_startOffset; +} + +double KisGradientSegment::middleOffset() const +{ + return m_middleOffset; +} + +double KisGradientSegment::endOffset() const +{ + return m_endOffset; +} + +void KisGradientSegment::setStartOffset(double t) +{ + m_startOffset = t; + m_length = m_endOffset - m_startOffset; + + if (m_length < DBL_EPSILON) { + m_middleT = 0.5; + } + else { + m_middleT = (m_middleOffset - m_startOffset) / m_length; + } +} +void KisGradientSegment::setMiddleOffset(double t) +{ + m_middleOffset = t; + + if (m_length < DBL_EPSILON) { + m_middleT = 0.5; + } + else { + m_middleT = (m_middleOffset - m_startOffset) / m_length; + } +} + +void KisGradientSegment::setEndOffset(double t) +{ + m_endOffset = t; + m_length = m_endOffset - m_startOffset; + + if (m_length < DBL_EPSILON) { + m_middleT = 0.5; + } + else { + m_middleT = (m_middleOffset - m_startOffset) / m_length; + } +} + +int KisGradientSegment::interpolation() const +{ + return m_interpolator->type(); +} + +void KisGradientSegment::setInterpolation(int interpolationType) +{ + switch (interpolationType) { + case INTERP_LINEAR: + m_interpolator = LinearInterpolationStrategy::instance(); + break; + case INTERP_CURVED: + m_interpolator = CurvedInterpolationStrategy::instance(); + break; + case INTERP_SINE: + m_interpolator = SineInterpolationStrategy::instance(); + break; + case INTERP_SPHERE_INCREASING: + m_interpolator = SphereIncreasingInterpolationStrategy::instance(); + break; + case INTERP_SPHERE_DECREASING: + m_interpolator = SphereDecreasingInterpolationStrategy::instance(); + break; + } +} + +int KisGradientSegment::colorInterpolation() const +{ + return m_colorInterpolator->type(); +} + +void KisGradientSegment::setColorInterpolation(int colorInterpolationType) +{ + switch (colorInterpolationType) { + case COLOR_INTERP_RGB: + m_colorInterpolator = RGBColorInterpolationStrategy::instance(); + break; + case COLOR_INTERP_HSV_CCW: + m_colorInterpolator = HSVCCWColorInterpolationStrategy::instance(); + break; + case COLOR_INTERP_HSV_CW: + m_colorInterpolator = HSVCWColorInterpolationStrategy::instance(); + break; + } +} + +Color KisGradientSegment::colorAt(double t) const +{ + Q_ASSERT(t > m_startOffset - DBL_EPSILON && t < m_endOffset + DBL_EPSILON); + + double segmentT; + + if (m_length < DBL_EPSILON) { + segmentT = 0.5; + } + else { + segmentT = (t - m_startOffset) / m_length; + } + + double colorT = m_interpolator->valueAt(segmentT, m_middleT); + + Color color = m_colorInterpolator->colorAt(colorT, m_startColor, m_endColor); + + return color; +} + +bool KisGradientSegment::isValid() const +{ + if (m_interpolator == 0 || m_colorInterpolator ==0) + return false; + return true; +} + +KisGradientSegment::RGBColorInterpolationStrategy *KisGradientSegment::RGBColorInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new RGBColorInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +Color KisGradientSegment::RGBColorInterpolationStrategy::colorAt(double t, Color start, Color end) const +{ + int startRed = start.color().red(); + int startGreen = start.color().green(); + int startBlue = start.color().blue(); + double startAlpha = start.alpha(); + int red = static_cast(startRed + t * (end.color().red() - startRed) + 0.5); + int green = static_cast(startGreen + t * (end.color().green() - startGreen) + 0.5); + int blue = static_cast(startBlue + t * (end.color().blue() - startBlue) + 0.5); + double alpha = startAlpha + t * (end.alpha() - startAlpha); + + return Color(TQColor(red, green, blue), alpha); +} + +KisGradientSegment::HSVCWColorInterpolationStrategy *KisGradientSegment::HSVCWColorInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new HSVCWColorInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +Color KisGradientSegment::HSVCWColorInterpolationStrategy::colorAt(double t, Color start, Color end) const +{ + KoColor sc = KoColor(start.color()); + KoColor ec = KoColor(end.color()); + + int s = static_cast(sc.S() + t * (ec.S() - sc.S()) + 0.5); + int v = static_cast(sc.V() + t * (ec.V() - sc.V()) + 0.5); + int h; + + if (ec.H() < sc.H()) { + h = static_cast(ec.H() + (1 - t) * (sc.H() - ec.H()) + 0.5); + } + else { + h = static_cast(ec.H() + (1 - t) * (360 - ec.H() + sc.H()) + 0.5); + + if (h > 359) { + h -= 360; + } + } + + double alpha = start.alpha() + t * (end.alpha() - start.alpha()); + + return Color(KoColor(h, s, v, KoColor::csHSV).color(), alpha); +} + +KisGradientSegment::HSVCCWColorInterpolationStrategy *KisGradientSegment::HSVCCWColorInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new HSVCCWColorInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +Color KisGradientSegment::HSVCCWColorInterpolationStrategy::colorAt(double t, Color start, Color end) const +{ + KoColor sc = KoColor(start.color()); + KoColor se = KoColor(end.color()); + + int s = static_cast(sc.S() + t * (se.S() - sc.S()) + 0.5); + int v = static_cast(sc.V() + t * (se.V() - sc.V()) + 0.5); + int h; + + if (sc.H() < se.H()) { + h = static_cast(sc.H() + t * (se.H() - sc.H()) + 0.5); + } + else { + h = static_cast(sc.H() + t * (360 - sc.H() + se.H()) + 0.5); + + if (h > 359) { + h -= 360; + } + } + + double alpha = start.alpha() + t * (end.alpha() - start.alpha()); + + return Color(KoColor(h, s, v, KoColor::csHSV).color(), alpha); +} + +KisGradientSegment::LinearInterpolationStrategy *KisGradientSegment::LinearInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new LinearInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +double KisGradientSegment::LinearInterpolationStrategy::calcValueAt(double t, double middle) +{ + Q_ASSERT(t > -DBL_EPSILON && t < 1 + DBL_EPSILON); + Q_ASSERT(middle > -DBL_EPSILON && middle < 1 + DBL_EPSILON); + + double value = 0; + + if (t <= middle) { + if (middle < DBL_EPSILON) { + value = 0; + } + else { + value = (t / middle) * 0.5; + } + } + else { + if (middle > 1 - DBL_EPSILON) { + value = 1; + } + else { + value = ((t - middle) / (1 - middle)) * 0.5 + 0.5; + } + } + + return value; +} + +double KisGradientSegment::LinearInterpolationStrategy::valueAt(double t, double middle) const +{ + return calcValueAt(t, middle); +} + +KisGradientSegment::CurvedInterpolationStrategy::CurvedInterpolationStrategy() +{ + m_logHalf = log(0.5); +} + +KisGradientSegment::CurvedInterpolationStrategy *KisGradientSegment::CurvedInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new CurvedInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +double KisGradientSegment::CurvedInterpolationStrategy::valueAt(double t, double middle) const +{ + Q_ASSERT(t > -DBL_EPSILON && t < 1 + DBL_EPSILON); + Q_ASSERT(middle > -DBL_EPSILON && middle < 1 + DBL_EPSILON); + + double value = 0; + + if (middle < DBL_EPSILON) { + middle = DBL_EPSILON; + } + + value = pow(t, m_logHalf / log(middle)); + + return value; +} + +KisGradientSegment::SineInterpolationStrategy *KisGradientSegment::SineInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new SineInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +double KisGradientSegment::SineInterpolationStrategy::valueAt(double t, double middle) const +{ + double lt = LinearInterpolationStrategy::calcValueAt(t, middle); + double value = (sin(-M_PI_2 + M_PI * lt) + 1.0) / 2.0; + + return value; +} + +KisGradientSegment::SphereIncreasingInterpolationStrategy *KisGradientSegment::SphereIncreasingInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new SphereIncreasingInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +double KisGradientSegment::SphereIncreasingInterpolationStrategy::valueAt(double t, double middle) const +{ + double lt = LinearInterpolationStrategy::calcValueAt(t, middle) - 1; + double value = sqrt(1 - lt * lt); + + return value; +} + +KisGradientSegment::SphereDecreasingInterpolationStrategy *KisGradientSegment::SphereDecreasingInterpolationStrategy::instance() +{ + if (m_instance == 0) { + m_instance = new SphereDecreasingInterpolationStrategy(); + TQ_CHECK_PTR(m_instance); + } + + return m_instance; +} + +double KisGradientSegment::SphereDecreasingInterpolationStrategy::valueAt(double t, double middle) const +{ + double lt = LinearInterpolationStrategy::calcValueAt(t, middle); + double value = 1 - sqrt(1 - lt * lt); + + return value; +} + +#include "kis_gradient.moc" + diff --git a/chalk/core/kis_gradient_painter.cc b/chalk/core/kis_gradient_painter.cpp similarity index 100% rename from chalk/core/kis_gradient_painter.cc rename to chalk/core/kis_gradient_painter.cpp diff --git a/chalk/core/kis_group_layer.cc b/chalk/core/kis_group_layer.cpp similarity index 100% rename from chalk/core/kis_group_layer.cc rename to chalk/core/kis_group_layer.cpp diff --git a/chalk/core/kis_histogram.cc b/chalk/core/kis_histogram.cpp similarity index 100% rename from chalk/core/kis_histogram.cc rename to chalk/core/kis_histogram.cpp diff --git a/chalk/core/kis_image.cc b/chalk/core/kis_image.cpp similarity index 100% rename from chalk/core/kis_image.cc rename to chalk/core/kis_image.cpp diff --git a/chalk/core/kis_image_iface.cc b/chalk/core/kis_image_iface.cpp similarity index 100% rename from chalk/core/kis_image_iface.cc rename to chalk/core/kis_image_iface.cpp diff --git a/chalk/core/kis_imagepipe_brush.cc b/chalk/core/kis_imagepipe_brush.cpp similarity index 100% rename from chalk/core/kis_imagepipe_brush.cc rename to chalk/core/kis_imagepipe_brush.cpp diff --git a/chalk/core/kis_iterator.cc b/chalk/core/kis_iterator.cpp similarity index 100% rename from chalk/core/kis_iterator.cc rename to chalk/core/kis_iterator.cpp diff --git a/chalk/core/kis_iterators_pixel.cc b/chalk/core/kis_iterators_pixel.cpp similarity index 100% rename from chalk/core/kis_iterators_pixel.cc rename to chalk/core/kis_iterators_pixel.cpp diff --git a/chalk/core/kis_layer.cc b/chalk/core/kis_layer.cpp similarity index 100% rename from chalk/core/kis_layer.cc rename to chalk/core/kis_layer.cpp diff --git a/chalk/core/kis_meta_registry.cc b/chalk/core/kis_meta_registry.cpp similarity index 100% rename from chalk/core/kis_meta_registry.cc rename to chalk/core/kis_meta_registry.cpp diff --git a/chalk/core/kis_nameserver.cc b/chalk/core/kis_nameserver.cpp similarity index 100% rename from chalk/core/kis_nameserver.cc rename to chalk/core/kis_nameserver.cpp diff --git a/chalk/core/kis_paint_device.cc b/chalk/core/kis_paint_device.cpp similarity index 100% rename from chalk/core/kis_paint_device.cc rename to chalk/core/kis_paint_device.cpp diff --git a/chalk/core/kis_paint_device_iface.cc b/chalk/core/kis_paint_device_iface.cpp similarity index 100% rename from chalk/core/kis_paint_device_iface.cc rename to chalk/core/kis_paint_device_iface.cpp diff --git a/chalk/core/kis_paint_layer.cc b/chalk/core/kis_paint_layer.cpp similarity index 100% rename from chalk/core/kis_paint_layer.cc rename to chalk/core/kis_paint_layer.cpp diff --git a/chalk/core/kis_painter.cc b/chalk/core/kis_painter.cpp similarity index 100% rename from chalk/core/kis_painter.cc rename to chalk/core/kis_painter.cpp diff --git a/chalk/core/kis_paintop.cc b/chalk/core/kis_paintop.cpp similarity index 100% rename from chalk/core/kis_paintop.cc rename to chalk/core/kis_paintop.cpp diff --git a/chalk/core/kis_paintop_registry.cc b/chalk/core/kis_paintop_registry.cpp similarity index 100% rename from chalk/core/kis_paintop_registry.cc rename to chalk/core/kis_paintop_registry.cpp diff --git a/chalk/core/kis_palette.cc b/chalk/core/kis_palette.cpp similarity index 100% rename from chalk/core/kis_palette.cc rename to chalk/core/kis_palette.cpp diff --git a/chalk/core/kis_pattern.cc b/chalk/core/kis_pattern.cc deleted file mode 100644 index 654449b8..00000000 --- a/chalk/core/kis_pattern.cc +++ /dev/null @@ -1,335 +0,0 @@ -/* - * kis_pattern.cc - part of Krayon - * - * Copyright (c) 2000 Matthias Elter - * 2001 John Califf - * 2004 Boudewijn Rempt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include "kis_pattern.h" - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "kis_color.h" -#include "kis_layer.h" -#include "kis_paint_device.h" - -namespace { - struct GimpPatternHeader { - TQ_UINT32 header_size; /* header_size = sizeof (PatternHeader) + brush name */ - TQ_UINT32 version; /* pattern file version # */ - TQ_UINT32 width; /* width of pattern */ - TQ_UINT32 height; /* height of pattern */ - TQ_UINT32 bytes; /* depth of pattern in bytes : 1, 2, 3 or 4*/ - TQ_UINT32 magic_number; /* GIMP brush magic number */ - }; - - // Yes! This is _NOT_ what my pat.txt file says. It's really not 'GIMP', but 'GPAT' - TQ_UINT32 const GimpPatternMagic = (('G' << 24) + ('P' << 16) + ('A' << 8) + ('T' << 0)); -} - -KisPattern::KisPattern(const TQString& file) : super(file), m_hasFile(true) -{ -} - -KisPattern::KisPattern(KisPaintDevice* image, int x, int y, int w, int h) - : super(""), m_hasFile(false) -{ - // Forcefully convert to RGBA8 - // XXX profile and exposure? - setImage(image->convertToTQImage(0, x, y, w, h)); - setName(image->name()); -} - -KisPattern::~KisPattern() -{ -} - -bool KisPattern::load() -{ - if (!m_hasFile) - return true; - - TQFile file(filename()); - file.open(IO_ReadOnly); - TQByteArray data = file.readAll(); - if (!data.isEmpty()) { - TQ_INT32 startPos = m_data.size(); - - m_data.resize(m_data.size() + data.count()); - memcpy(&m_data[startPos], data.data(), data.count()); - } - file.close(); - return init(); -} - -bool KisPattern::save() -{ - TQFile file(filename()); - file.open(IO_WriteOnly | IO_Truncate); - - TQTextStream stream(&file); - // Header: header_size (24+name length),version,width,height,colourdepth of brush,magic,name - // depth: 1 = greyscale, 2 = greyscale + A, 3 = RGB, 4 = RGBA - // magic = "GPAT", as a single uint32, the docs are wrong here! - // name is UTF-8 (\0-terminated! The docs say nothing about this!) - // _All_ data in network order, it seems! (not mentioned in gimp-2.2.8/devel-docs/pat.txt!!) - // We only save RGBA at the moment - // Version is 1 for now... - - GimpPatternHeader ph; - TQCString utf8Name = name().utf8(); - char const* name = utf8Name.data(); - int nameLength = tqstrlen(name); - - ph.header_size = htonl(sizeof(GimpPatternHeader) + nameLength + 1); // trailing 0 - ph.version = htonl(1); - ph.width = htonl(width()); - ph.height = htonl(height()); - ph.bytes = htonl(4); - ph.magic_number = htonl(GimpPatternMagic); - - TQByteArray bytes; - bytes.setRawData(reinterpret_cast(&ph), sizeof(GimpPatternHeader)); - int wrote = file.writeBlock(bytes); - bytes.resetRawData(reinterpret_cast(&ph), sizeof(GimpPatternHeader)); - - if (wrote == -1) - return false; - - wrote = file.writeBlock(name, nameLength + 1); // Trailing 0 apparantly! - if (wrote == -1) - return false; - - int k = 0; - bytes.resize(width() * height() * 4); - for (TQ_INT32 y = 0; y < height(); y++) { - for (TQ_INT32 x = 0; x < width(); x++) { - // RGBA only - TQRgb pixel = m_img.pixel(x,y); - bytes[k++] = static_cast(tqRed(pixel)); - bytes[k++] = static_cast(tqGreen(pixel)); - bytes[k++] = static_cast(tqBlue(pixel)); - bytes[k++] = static_cast(tqAlpha(pixel)); - } - } - - wrote = file.writeBlock(bytes); - if (wrote == -1) - return false; - - file.close(); - - return true; -} - -TQImage KisPattern::img() -{ - return m_img; -} - -bool KisPattern::init() -{ - // load Gimp patterns - GimpPatternHeader bh; - TQ_INT32 k; - TQValueVector name; - - if (sizeof(GimpPatternHeader) > m_data.size()) { - return false; - } - - memcpy(&bh, &m_data[0], sizeof(GimpPatternHeader)); - bh.header_size = ntohl(bh.header_size); - bh.version = ntohl(bh.version); - bh.width = ntohl(bh.width); - bh.height = ntohl(bh.height); - bh.bytes = ntohl(bh.bytes); - bh.magic_number = ntohl(bh.magic_number); - - if (bh.header_size > m_data.size() || bh.header_size == 0) { - return false; - } - - name.resize(bh.header_size - sizeof(GimpPatternHeader)); - memcpy(&name[0], &m_data[sizeof(GimpPatternHeader)], name.size()); - - if (name[name.size() - 1]) { - return false; - } - - setName(i18n(&name[0])); - - if (bh.width == 0 || bh.height == 0 || !m_img.create(bh.width, bh.height, 32)) { - return false; - } - - k = bh.header_size; - - if (bh.bytes == 1) { - // Grayscale - TQ_INT32 val; - - for (TQ_UINT32 y = 0; y < bh.height; y++) { - for (TQ_UINT32 x = 0; x < bh.width; x++, k++) { - if (static_cast(k) > m_data.size()) { - kdDebug(DBG_AREA_FILE) << "failed in gray\n"; - return false; - } - - val = m_data[k]; - m_img.setPixel(x, y, tqRgb(val, val, val)); - m_img.setAlphaBuffer(false); - } - } - } else if (bh.bytes == 2) { - // Grayscale + A - TQ_INT32 val; - TQ_INT32 alpha; - for (TQ_UINT32 y = 0; y < bh.height; y++) { - for (TQ_UINT32 x = 0; x < bh.width; x++, k++) { - if (static_cast(k + 2) > m_data.size()) { - kdDebug(DBG_AREA_FILE) << "failed in grayA\n"; - return false; - } - - val = m_data[k]; - alpha = m_data[k++]; - m_img.setPixel(x, y, tqRgba(val, val, val, alpha)); - m_img.setAlphaBuffer(true); - } - } - } else if (bh.bytes == 3) { - // RGB without alpha - for (TQ_UINT32 y = 0; y < bh.height; y++) { - for (TQ_UINT32 x = 0; x < bh.width; x++) { - if (static_cast(k + 3) > m_data.size()) { - kdDebug(DBG_AREA_FILE) << "failed in RGB\n"; - return false; - } - - m_img.setPixel(x, y, tqRgb(m_data[k], - m_data[k + 1], - m_data[k + 2])); - k += 3; - m_img.setAlphaBuffer(false); - } - } - } else if (bh.bytes == 4) { - // Has alpha - for (TQ_UINT32 y = 0; y < bh.height; y++) { - for (TQ_UINT32 x = 0; x < bh.width; x++) { - if (static_cast(k + 4) > m_data.size()) { - kdDebug(DBG_AREA_FILE) << "failed in RGBA\n"; - return false; - } - - m_img.setPixel(x, y, tqRgba(m_data[k], - m_data[k + 1], - m_data[k + 2], - m_data[k + 3])); - k += 4; - m_img.setAlphaBuffer(true); - } - } - } else { - return false; - } - - if (m_img.isNull()) { - return false; - } - - setWidth(m_img.width()); - setHeight(m_img.height()); - - setValid(true); - - return true; -} - -KisPaintDeviceSP KisPattern::image(KisColorSpace * colorSpace) { - // Check if there's already a pattern prepared for this colorspace - TQMap::const_iterator it = m_colorspaces.find(colorSpace->id().id()); - if (it != m_colorspaces.end()) - return (*it); - - // If not, create one - KisPaintDeviceSP layer = new KisPaintDevice(colorSpace, "pattern"); - - TQ_CHECK_PTR(layer); - - layer->convertFromTQImage(m_img,""); - - m_colorspaces[colorSpace->id().id()] = layer; - return layer; -} - -TQ_INT32 KisPattern::width() const -{ - return m_width; -} - -void KisPattern::setWidth(TQ_INT32 w) -{ - m_width = w; -} - -TQ_INT32 KisPattern::height() const -{ - return m_height; -} - -void KisPattern::setHeight(TQ_INT32 h) -{ - m_height = h; -} - -void KisPattern::setImage(const TQImage& img) -{ - m_hasFile = false; - m_img = img; - m_img.detach(); - - setWidth(img.width()); - setHeight(img.height()); - - setValid(true); -} - -KisPattern* KisPattern::clone() const -{ - KisPattern* pattern = new KisPattern(""); - pattern->setImage(m_img); - pattern->setName(name()); - return pattern; -} - -#include "kis_pattern.moc" diff --git a/chalk/core/kis_pattern.cpp b/chalk/core/kis_pattern.cpp new file mode 100644 index 00000000..b2a52995 --- /dev/null +++ b/chalk/core/kis_pattern.cpp @@ -0,0 +1,335 @@ +/* + * kis_pattern.cpp - part of Krayon + * + * Copyright (c) 2000 Matthias Elter + * 2001 John Califf + * 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "kis_pattern.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "kis_color.h" +#include "kis_layer.h" +#include "kis_paint_device.h" + +namespace { + struct GimpPatternHeader { + TQ_UINT32 header_size; /* header_size = sizeof (PatternHeader) + brush name */ + TQ_UINT32 version; /* pattern file version # */ + TQ_UINT32 width; /* width of pattern */ + TQ_UINT32 height; /* height of pattern */ + TQ_UINT32 bytes; /* depth of pattern in bytes : 1, 2, 3 or 4*/ + TQ_UINT32 magic_number; /* GIMP brush magic number */ + }; + + // Yes! This is _NOT_ what my pat.txt file says. It's really not 'GIMP', but 'GPAT' + TQ_UINT32 const GimpPatternMagic = (('G' << 24) + ('P' << 16) + ('A' << 8) + ('T' << 0)); +} + +KisPattern::KisPattern(const TQString& file) : super(file), m_hasFile(true) +{ +} + +KisPattern::KisPattern(KisPaintDevice* image, int x, int y, int w, int h) + : super(""), m_hasFile(false) +{ + // Forcefully convert to RGBA8 + // XXX profile and exposure? + setImage(image->convertToTQImage(0, x, y, w, h)); + setName(image->name()); +} + +KisPattern::~KisPattern() +{ +} + +bool KisPattern::load() +{ + if (!m_hasFile) + return true; + + TQFile file(filename()); + file.open(IO_ReadOnly); + TQByteArray data = file.readAll(); + if (!data.isEmpty()) { + TQ_INT32 startPos = m_data.size(); + + m_data.resize(m_data.size() + data.count()); + memcpy(&m_data[startPos], data.data(), data.count()); + } + file.close(); + return init(); +} + +bool KisPattern::save() +{ + TQFile file(filename()); + file.open(IO_WriteOnly | IO_Truncate); + + TQTextStream stream(&file); + // Header: header_size (24+name length),version,width,height,colourdepth of brush,magic,name + // depth: 1 = greyscale, 2 = greyscale + A, 3 = RGB, 4 = RGBA + // magic = "GPAT", as a single uint32, the docs are wrong here! + // name is UTF-8 (\0-terminated! The docs say nothing about this!) + // _All_ data in network order, it seems! (not mentioned in gimp-2.2.8/devel-docs/pat.txt!!) + // We only save RGBA at the moment + // Version is 1 for now... + + GimpPatternHeader ph; + TQCString utf8Name = name().utf8(); + char const* name = utf8Name.data(); + int nameLength = tqstrlen(name); + + ph.header_size = htonl(sizeof(GimpPatternHeader) + nameLength + 1); // trailing 0 + ph.version = htonl(1); + ph.width = htonl(width()); + ph.height = htonl(height()); + ph.bytes = htonl(4); + ph.magic_number = htonl(GimpPatternMagic); + + TQByteArray bytes; + bytes.setRawData(reinterpret_cast(&ph), sizeof(GimpPatternHeader)); + int wrote = file.writeBlock(bytes); + bytes.resetRawData(reinterpret_cast(&ph), sizeof(GimpPatternHeader)); + + if (wrote == -1) + return false; + + wrote = file.writeBlock(name, nameLength + 1); // Trailing 0 apparantly! + if (wrote == -1) + return false; + + int k = 0; + bytes.resize(width() * height() * 4); + for (TQ_INT32 y = 0; y < height(); y++) { + for (TQ_INT32 x = 0; x < width(); x++) { + // RGBA only + TQRgb pixel = m_img.pixel(x,y); + bytes[k++] = static_cast(tqRed(pixel)); + bytes[k++] = static_cast(tqGreen(pixel)); + bytes[k++] = static_cast(tqBlue(pixel)); + bytes[k++] = static_cast(tqAlpha(pixel)); + } + } + + wrote = file.writeBlock(bytes); + if (wrote == -1) + return false; + + file.close(); + + return true; +} + +TQImage KisPattern::img() +{ + return m_img; +} + +bool KisPattern::init() +{ + // load Gimp patterns + GimpPatternHeader bh; + TQ_INT32 k; + TQValueVector name; + + if (sizeof(GimpPatternHeader) > m_data.size()) { + return false; + } + + memcpy(&bh, &m_data[0], sizeof(GimpPatternHeader)); + bh.header_size = ntohl(bh.header_size); + bh.version = ntohl(bh.version); + bh.width = ntohl(bh.width); + bh.height = ntohl(bh.height); + bh.bytes = ntohl(bh.bytes); + bh.magic_number = ntohl(bh.magic_number); + + if (bh.header_size > m_data.size() || bh.header_size == 0) { + return false; + } + + name.resize(bh.header_size - sizeof(GimpPatternHeader)); + memcpy(&name[0], &m_data[sizeof(GimpPatternHeader)], name.size()); + + if (name[name.size() - 1]) { + return false; + } + + setName(i18n(&name[0])); + + if (bh.width == 0 || bh.height == 0 || !m_img.create(bh.width, bh.height, 32)) { + return false; + } + + k = bh.header_size; + + if (bh.bytes == 1) { + // Grayscale + TQ_INT32 val; + + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++, k++) { + if (static_cast(k) > m_data.size()) { + kdDebug(DBG_AREA_FILE) << "failed in gray\n"; + return false; + } + + val = m_data[k]; + m_img.setPixel(x, y, tqRgb(val, val, val)); + m_img.setAlphaBuffer(false); + } + } + } else if (bh.bytes == 2) { + // Grayscale + A + TQ_INT32 val; + TQ_INT32 alpha; + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++, k++) { + if (static_cast(k + 2) > m_data.size()) { + kdDebug(DBG_AREA_FILE) << "failed in grayA\n"; + return false; + } + + val = m_data[k]; + alpha = m_data[k++]; + m_img.setPixel(x, y, tqRgba(val, val, val, alpha)); + m_img.setAlphaBuffer(true); + } + } + } else if (bh.bytes == 3) { + // RGB without alpha + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++) { + if (static_cast(k + 3) > m_data.size()) { + kdDebug(DBG_AREA_FILE) << "failed in RGB\n"; + return false; + } + + m_img.setPixel(x, y, tqRgb(m_data[k], + m_data[k + 1], + m_data[k + 2])); + k += 3; + m_img.setAlphaBuffer(false); + } + } + } else if (bh.bytes == 4) { + // Has alpha + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++) { + if (static_cast(k + 4) > m_data.size()) { + kdDebug(DBG_AREA_FILE) << "failed in RGBA\n"; + return false; + } + + m_img.setPixel(x, y, tqRgba(m_data[k], + m_data[k + 1], + m_data[k + 2], + m_data[k + 3])); + k += 4; + m_img.setAlphaBuffer(true); + } + } + } else { + return false; + } + + if (m_img.isNull()) { + return false; + } + + setWidth(m_img.width()); + setHeight(m_img.height()); + + setValid(true); + + return true; +} + +KisPaintDeviceSP KisPattern::image(KisColorSpace * colorSpace) { + // Check if there's already a pattern prepared for this colorspace + TQMap::const_iterator it = m_colorspaces.find(colorSpace->id().id()); + if (it != m_colorspaces.end()) + return (*it); + + // If not, create one + KisPaintDeviceSP layer = new KisPaintDevice(colorSpace, "pattern"); + + TQ_CHECK_PTR(layer); + + layer->convertFromTQImage(m_img,""); + + m_colorspaces[colorSpace->id().id()] = layer; + return layer; +} + +TQ_INT32 KisPattern::width() const +{ + return m_width; +} + +void KisPattern::setWidth(TQ_INT32 w) +{ + m_width = w; +} + +TQ_INT32 KisPattern::height() const +{ + return m_height; +} + +void KisPattern::setHeight(TQ_INT32 h) +{ + m_height = h; +} + +void KisPattern::setImage(const TQImage& img) +{ + m_hasFile = false; + m_img = img; + m_img.detach(); + + setWidth(img.width()); + setHeight(img.height()); + + setValid(true); +} + +KisPattern* KisPattern::clone() const +{ + KisPattern* pattern = new KisPattern(""); + pattern->setImage(m_img); + pattern->setName(name()); + return pattern; +} + +#include "kis_pattern.moc" diff --git a/chalk/core/kis_rect.cc b/chalk/core/kis_rect.cpp similarity index 100% rename from chalk/core/kis_rect.cc rename to chalk/core/kis_rect.cpp diff --git a/chalk/core/kis_resource.cc b/chalk/core/kis_resource.cpp similarity index 100% rename from chalk/core/kis_resource.cc rename to chalk/core/kis_resource.cpp diff --git a/chalk/core/kis_rotate_visitor.cc b/chalk/core/kis_rotate_visitor.cpp similarity index 100% rename from chalk/core/kis_rotate_visitor.cc rename to chalk/core/kis_rotate_visitor.cpp diff --git a/chalk/core/kis_scale_visitor.cc b/chalk/core/kis_scale_visitor.cpp similarity index 100% rename from chalk/core/kis_scale_visitor.cc rename to chalk/core/kis_scale_visitor.cpp diff --git a/chalk/core/kis_selected_transaction.cc b/chalk/core/kis_selected_transaction.cpp similarity index 100% rename from chalk/core/kis_selected_transaction.cc rename to chalk/core/kis_selected_transaction.cpp diff --git a/chalk/core/kis_selection.cc b/chalk/core/kis_selection.cpp similarity index 100% rename from chalk/core/kis_selection.cc rename to chalk/core/kis_selection.cpp diff --git a/chalk/core/kis_strategy_move.cc b/chalk/core/kis_strategy_move.cpp similarity index 100% rename from chalk/core/kis_strategy_move.cc rename to chalk/core/kis_strategy_move.cpp diff --git a/chalk/core/kis_thread_pool.cc b/chalk/core/kis_thread_pool.cpp similarity index 100% rename from chalk/core/kis_thread_pool.cc rename to chalk/core/kis_thread_pool.cpp diff --git a/chalk/core/kis_transaction.cc b/chalk/core/kis_transaction.cpp similarity index 100% rename from chalk/core/kis_transaction.cc rename to chalk/core/kis_transaction.cpp diff --git a/chalk/core/kis_transform_worker.cc b/chalk/core/kis_transform_worker.cpp similarity index 100% rename from chalk/core/kis_transform_worker.cc rename to chalk/core/kis_transform_worker.cpp diff --git a/chalk/core/kis_vec.cc b/chalk/core/kis_vec.cc deleted file mode 100644 index fa54e1f9..00000000 --- a/chalk/core/kis_vec.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * kis_vec.cc - part of KImageShop - * - * Copyright (c) 1999 Matthias Elter - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kis_vec.h" - -KisVector2D& KisVector2D::normalize() -{ - double length, ilength; - - length = m_x*m_x + m_y*m_y; - length = sqrt (length); - - if (length > epsilon) - { - ilength = 1/length; - m_x *= ilength; - m_y *= ilength; - } - return *this; -} - -KisVector3D& KisVector3D::normalize() -{ - double length, ilength; - - length = m_x*m_x + m_y*m_y + m_z*m_z; - length = sqrt (length); - - if (length > epsilon) - { - ilength = 1/length; - m_x *= ilength; - m_y *= ilength; - m_z *= ilength; - } - return *this; -} - -KisVector3D& KisVector3D::crossProduct(const KisVector3D &v) -{ - double x,y,z; - - x = m_y*v.m_z - m_z*v.m_y; - y = m_z*v.m_x - m_x*v.m_z; - z = m_x*v.m_y - m_y*v.m_x; - m_x=x; m_y=y; m_z=z; - - return *this; -} - diff --git a/chalk/core/kis_vec.cpp b/chalk/core/kis_vec.cpp new file mode 100644 index 00000000..9bd6ada9 --- /dev/null +++ b/chalk/core/kis_vec.cpp @@ -0,0 +1,67 @@ +/* + * kis_vec.cpp - part of KImageShop + * + * Copyright (c) 1999 Matthias Elter + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_vec.h" + +KisVector2D& KisVector2D::normalize() +{ + double length, ilength; + + length = m_x*m_x + m_y*m_y; + length = sqrt (length); + + if (length > epsilon) + { + ilength = 1/length; + m_x *= ilength; + m_y *= ilength; + } + return *this; +} + +KisVector3D& KisVector3D::normalize() +{ + double length, ilength; + + length = m_x*m_x + m_y*m_y + m_z*m_z; + length = sqrt (length); + + if (length > epsilon) + { + ilength = 1/length; + m_x *= ilength; + m_y *= ilength; + m_z *= ilength; + } + return *this; +} + +KisVector3D& KisVector3D::crossProduct(const KisVector3D &v) +{ + double x,y,z; + + x = m_y*v.m_z - m_z*v.m_y; + y = m_z*v.m_x - m_x*v.m_z; + z = m_x*v.m_y - m_y*v.m_x; + m_x=x; m_y=y; m_z=z; + + return *this; +} + diff --git a/chalk/core/tests/Makefile.am b/chalk/core/tests/Makefile.am index 97316685..9b78866a 100644 --- a/chalk/core/tests/Makefile.am +++ b/chalk/core/tests/Makefile.am @@ -21,7 +21,7 @@ tdeunittest_kis_image_tester_la_LIBADD = -ltdeunittest ../../libchalkcommon.la tdeunittest_kis_image_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries) -tdeunittest_kis_filter_configuration_tester_la_SOURCES = kis_filter_configuration_tester.cc +tdeunittest_kis_filter_configuration_tester_la_SOURCES = kis_filter_configuration_tester.cpp tdeunittest_kis_filter_configuration_tester_la_LIBADD = -ltdeunittest ../../libchalkcommon.la tdeunittest_kis_filter_configuration_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries) diff --git a/chalk/core/tests/kis_filter_configuration_tester.cc b/chalk/core/tests/kis_filter_configuration_tester.cpp similarity index 100% rename from chalk/core/tests/kis_filter_configuration_tester.cc rename to chalk/core/tests/kis_filter_configuration_tester.cpp diff --git a/chalk/core/tiles/Makefile.am b/chalk/core/tiles/Makefile.am index 7fad1ab9..9ebe93ec 100644 --- a/chalk/core/tiles/Makefile.am +++ b/chalk/core/tiles/Makefile.am @@ -12,9 +12,9 @@ INCLUDES = -I$(srcdir)/../ \ noinst_LTLIBRARIES = libchalktile.la -libchalktile_la_SOURCES = kis_tiledvlineiterator.cc kis_tiledhlineiterator.cc \ - kis_tileddatamanager.cc kis_tile.cc kis_tilediterator.cc kis_tiledrectiterator.cc \ - kis_memento.cc kis_tilemanager.cc kis_tiled_random_accessor.cc +libchalktile_la_SOURCES = kis_tiledvlineiterator.cpp kis_tiledhlineiterator.cpp \ + kis_tileddatamanager.cpp kis_tile.cpp kis_tilediterator.cpp kis_tiledrectiterator.cpp \ + kis_memento.cpp kis_tilemanager.cpp kis_tiled_random_accessor.cpp libchalktile_la_METASOURCES = AUTO diff --git a/chalk/core/tiles/kis_memento.cc b/chalk/core/tiles/kis_memento.cpp similarity index 100% rename from chalk/core/tiles/kis_memento.cc rename to chalk/core/tiles/kis_memento.cpp diff --git a/chalk/core/tiles/kis_tile.cc b/chalk/core/tiles/kis_tile.cpp similarity index 100% rename from chalk/core/tiles/kis_tile.cc rename to chalk/core/tiles/kis_tile.cpp diff --git a/chalk/core/tiles/kis_tiled_random_accessor.cc b/chalk/core/tiles/kis_tiled_random_accessor.cpp similarity index 100% rename from chalk/core/tiles/kis_tiled_random_accessor.cc rename to chalk/core/tiles/kis_tiled_random_accessor.cpp diff --git a/chalk/core/tiles/kis_tileddatamanager.cc b/chalk/core/tiles/kis_tileddatamanager.cpp similarity index 100% rename from chalk/core/tiles/kis_tileddatamanager.cc rename to chalk/core/tiles/kis_tileddatamanager.cpp diff --git a/chalk/core/tiles/kis_tiledhlineiterator.cc b/chalk/core/tiles/kis_tiledhlineiterator.cpp similarity index 100% rename from chalk/core/tiles/kis_tiledhlineiterator.cc rename to chalk/core/tiles/kis_tiledhlineiterator.cpp diff --git a/chalk/core/tiles/kis_tilediterator.cc b/chalk/core/tiles/kis_tilediterator.cpp similarity index 100% rename from chalk/core/tiles/kis_tilediterator.cc rename to chalk/core/tiles/kis_tilediterator.cpp diff --git a/chalk/core/tiles/kis_tiledrectiterator.cc b/chalk/core/tiles/kis_tiledrectiterator.cpp similarity index 100% rename from chalk/core/tiles/kis_tiledrectiterator.cc rename to chalk/core/tiles/kis_tiledrectiterator.cpp diff --git a/chalk/core/tiles/kis_tiledvlineiterator.cc b/chalk/core/tiles/kis_tiledvlineiterator.cpp similarity index 100% rename from chalk/core/tiles/kis_tiledvlineiterator.cc rename to chalk/core/tiles/kis_tiledvlineiterator.cpp diff --git a/chalk/core/tiles/kis_tilemanager.cc b/chalk/core/tiles/kis_tilemanager.cpp similarity index 100% rename from chalk/core/tiles/kis_tilemanager.cc rename to chalk/core/tiles/kis_tilemanager.cpp diff --git a/chalk/doc/DESIGN.obsolete b/chalk/doc/DESIGN.obsolete index a1b8e58d..2f0d25ca 100644 --- a/chalk/doc/DESIGN.obsolete +++ b/chalk/doc/DESIGN.obsolete @@ -169,7 +169,7 @@ Random head-scratchings - I take it that the two tests that are present in chalk/test are obsolete? - - what with the dummmmmy.cc? + - what with the dummmmmy.cpp? - which bits of the chalk/ui files are still relevant? diff --git a/chalk/doc/brush.txt b/chalk/doc/brush.txt index e2373258..afadadc5 100644 --- a/chalk/doc/brush.txt +++ b/chalk/doc/brush.txt @@ -4,7 +4,7 @@ Painting with brushes when I started working on Chalk, I felt I needed examples. I used the following sources: -* The old Chalk brush code (http://webcvs.kde.org/cgi-bin/cvsweb.cgi/koffice/chalk/tools/kis_tool_brush.cc?rev=1.58&content-type=text/x-cvsweb-markup) +* The old Chalk brush code (http://webcvs.kde.org/cgi-bin/cvsweb.cgi/koffice/chalk/tools/kis_tool_brush.cpp?rev=1.58&content-type=text/x-cvsweb-markup) * Peter Jodda's Perico (http://software.jodda.de/perico.html) * The source of the Gimp (both current and 0.99.11 -- the oldest version I could find) (http://www.gimp.org) * David Hodson's article on Gimp brushes (http://members.ozemail.com.au/~hodsond/gimpbrush.html) diff --git a/chalk/main.cc b/chalk/main.cc deleted file mode 100644 index 592c1368..00000000 --- a/chalk/main.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * main.cc - part of KImageShop - * - * Copyright (c) 1999 Matthias Elter - * Copyright (c) 2002 Patrick Julien - * - * 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 - */ -#include -#include -#include - -#include "ui/kis_aboutdata.h" - -static const TDECmdLineOptions options[] = { - { "+[file(s)]", I18N_NOOP("File(s) or URL(s) to open"), 0 }, - TDECmdLineLastOption -}; - -extern "C" KRITA_EXPORT int kdemain(int argc, char **argv) -{ - TDECmdLineArgs::init(argc, argv, newChalkAboutData()); - TDECmdLineArgs::addCmdLineOptions(options); - - KoApplication app; - - if (!app.start()) - return 1; - - return app.exec(); -} - diff --git a/chalk/main.cpp b/chalk/main.cpp new file mode 100644 index 00000000..6d6b1781 --- /dev/null +++ b/chalk/main.cpp @@ -0,0 +1,43 @@ +/* + * main.cpp - part of KImageShop + * + * Copyright (c) 1999 Matthias Elter + * Copyright (c) 2002 Patrick Julien + * + * 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 + */ +#include +#include +#include + +#include "ui/kis_aboutdata.h" + +static const TDECmdLineOptions options[] = { + { "+[file(s)]", I18N_NOOP("File(s) or URL(s) to open"), 0 }, + TDECmdLineLastOption +}; + +extern "C" KRITA_EXPORT int kdemain(int argc, char **argv) +{ + TDECmdLineArgs::init(argc, argv, newChalkAboutData()); + TDECmdLineArgs::addCmdLineOptions(options); + + KoApplication app; + + if (!app.start()) + return 1; + + return app.exec(); +} + diff --git a/chalk/plugins/filters/blur/Makefile.am b/chalk/plugins/filters/blur/Makefile.am index d4de7545..53f86c33 100644 --- a/chalk/plugins/filters/blur/Makefile.am +++ b/chalk/plugins/filters/blur/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkblurfilter_la_SOURCES = wdgblur.ui blur.cc kis_blur_filter.cc kis_wdg_blur.cc +chalkblurfilter_la_SOURCES = wdgblur.ui blur.cpp kis_blur_filter.cpp kis_wdg_blur.cpp kde_module_LTLIBRARIES = chalkblurfilter.la noinst_HEADERS = blur.h kis_blur_filter.h diff --git a/chalk/plugins/filters/blur/blur.cc b/chalk/plugins/filters/blur/blur.cpp similarity index 100% rename from chalk/plugins/filters/blur/blur.cc rename to chalk/plugins/filters/blur/blur.cpp diff --git a/chalk/plugins/filters/blur/kis_blur_filter.cc b/chalk/plugins/filters/blur/kis_blur_filter.cpp similarity index 100% rename from chalk/plugins/filters/blur/kis_blur_filter.cc rename to chalk/plugins/filters/blur/kis_blur_filter.cpp diff --git a/chalk/plugins/filters/blur/kis_wdg_blur.cc b/chalk/plugins/filters/blur/kis_wdg_blur.cpp similarity index 100% rename from chalk/plugins/filters/blur/kis_wdg_blur.cc rename to chalk/plugins/filters/blur/kis_wdg_blur.cpp diff --git a/chalk/plugins/filters/bumpmap/Makefile.am b/chalk/plugins/filters/bumpmap/Makefile.am index 2b208b33..9f003aa3 100644 --- a/chalk/plugins/filters/bumpmap/Makefile.am +++ b/chalk/plugins/filters/bumpmap/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ -I$(srcdir)/../../../../lib/kofficecore \ $(all_includes) -chalkbumpmap_la_SOURCES = bumpmap.cc wdgbumpmap.ui +chalkbumpmap_la_SOURCES = bumpmap.cpp wdgbumpmap.ui kde_module_LTLIBRARIES = chalkbumpmap.la noinst_HEADERS = bumpmap.h diff --git a/chalk/plugins/filters/bumpmap/bumpmap.cc b/chalk/plugins/filters/bumpmap/bumpmap.cpp similarity index 100% rename from chalk/plugins/filters/bumpmap/bumpmap.cc rename to chalk/plugins/filters/bumpmap/bumpmap.cpp diff --git a/chalk/plugins/filters/cimg/Makefile.am b/chalk/plugins/filters/cimg/Makefile.am index 4a180a28..d82def81 100644 --- a/chalk/plugins/filters/cimg/Makefile.am +++ b/chalk/plugins/filters/cimg/Makefile.am @@ -12,9 +12,9 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalkcimg_la_SOURCES = \ wdg_cimg.ui\ - kis_cimg_filter.cc\ - kis_cimg_plugin.cc\ - kis_cimgconfig_widget.cc + kis_cimg_filter.cpp\ + kis_cimg_plugin.cpp\ + kis_cimgconfig_widget.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalkcimg.la diff --git a/chalk/plugins/filters/cimg/kis_cimg_filter.cc b/chalk/plugins/filters/cimg/kis_cimg_filter.cpp similarity index 100% rename from chalk/plugins/filters/cimg/kis_cimg_filter.cc rename to chalk/plugins/filters/cimg/kis_cimg_filter.cpp diff --git a/chalk/plugins/filters/cimg/kis_cimg_plugin.cc b/chalk/plugins/filters/cimg/kis_cimg_plugin.cpp similarity index 100% rename from chalk/plugins/filters/cimg/kis_cimg_plugin.cc rename to chalk/plugins/filters/cimg/kis_cimg_plugin.cpp diff --git a/chalk/plugins/filters/cimg/kis_cimgconfig_widget.cc b/chalk/plugins/filters/cimg/kis_cimgconfig_widget.cpp similarity index 100% rename from chalk/plugins/filters/cimg/kis_cimgconfig_widget.cc rename to chalk/plugins/filters/cimg/kis_cimgconfig_widget.cpp diff --git a/chalk/plugins/filters/colors/Makefile.am b/chalk/plugins/filters/colors/Makefile.am index 29380649..8f54c2ed 100644 --- a/chalk/plugins/filters/colors/Makefile.am +++ b/chalk/plugins/filters/colors/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkextensioncolorsfilters_la_SOURCES = colors.cc kis_minmax_filters.cc kis_color_to_alpha.cc wdgcolortoalphabase.ui kis_wdg_color_to_alpha.cc +chalkextensioncolorsfilters_la_SOURCES = colors.cpp kis_minmax_filters.cpp kis_color_to_alpha.cpp wdgcolortoalphabase.ui kis_wdg_color_to_alpha.cpp kde_module_LTLIBRARIES = chalkextensioncolorsfilters.la noinst_HEADERS = colors.h diff --git a/chalk/plugins/filters/colors/colors.cc b/chalk/plugins/filters/colors/colors.cpp similarity index 100% rename from chalk/plugins/filters/colors/colors.cc rename to chalk/plugins/filters/colors/colors.cpp diff --git a/chalk/plugins/filters/colors/kis_color_to_alpha.cc b/chalk/plugins/filters/colors/kis_color_to_alpha.cpp similarity index 100% rename from chalk/plugins/filters/colors/kis_color_to_alpha.cc rename to chalk/plugins/filters/colors/kis_color_to_alpha.cpp diff --git a/chalk/plugins/filters/colors/kis_minmax_filters.cc b/chalk/plugins/filters/colors/kis_minmax_filters.cpp similarity index 100% rename from chalk/plugins/filters/colors/kis_minmax_filters.cc rename to chalk/plugins/filters/colors/kis_minmax_filters.cpp diff --git a/chalk/plugins/filters/colors/kis_wdg_color_to_alpha.cc b/chalk/plugins/filters/colors/kis_wdg_color_to_alpha.cpp similarity index 100% rename from chalk/plugins/filters/colors/kis_wdg_color_to_alpha.cc rename to chalk/plugins/filters/colors/kis_wdg_color_to_alpha.cpp diff --git a/chalk/plugins/filters/colorsfilters/Makefile.am b/chalk/plugins/filters/colorsfilters/Makefile.am index 8e0be13e..e7459d7d 100644 --- a/chalk/plugins/filters/colorsfilters/Makefile.am +++ b/chalk/plugins/filters/colorsfilters/Makefile.am @@ -7,11 +7,11 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkcolorsfilters_la_SOURCES = colorsfilters.cc \ - kis_perchannel_filter.cc \ +chalkcolorsfilters_la_SOURCES = colorsfilters.cpp \ + kis_perchannel_filter.cpp \ wdg_perchannel.ui \ wdg_brightness_contrast.ui \ - kis_brightness_contrast_filter.cc + kis_brightness_contrast_filter.cpp noinst_HEADERS = colorsfilters.h \ kis_perchannel_filter.h \ diff --git a/chalk/plugins/filters/colorsfilters/colorsfilters.cc b/chalk/plugins/filters/colorsfilters/colorsfilters.cpp similarity index 100% rename from chalk/plugins/filters/colorsfilters/colorsfilters.cc rename to chalk/plugins/filters/colorsfilters/colorsfilters.cpp diff --git a/chalk/plugins/filters/colorsfilters/kis_brightness_contrast_filter.cc b/chalk/plugins/filters/colorsfilters/kis_brightness_contrast_filter.cpp similarity index 100% rename from chalk/plugins/filters/colorsfilters/kis_brightness_contrast_filter.cc rename to chalk/plugins/filters/colorsfilters/kis_brightness_contrast_filter.cpp diff --git a/chalk/plugins/filters/colorsfilters/kis_perchannel_filter.cc b/chalk/plugins/filters/colorsfilters/kis_perchannel_filter.cpp similarity index 100% rename from chalk/plugins/filters/colorsfilters/kis_perchannel_filter.cc rename to chalk/plugins/filters/colorsfilters/kis_perchannel_filter.cpp diff --git a/chalk/plugins/filters/convolutionfilters/Makefile.am b/chalk/plugins/filters/convolutionfilters/Makefile.am index 6e4242f2..cd4582e9 100644 --- a/chalk/plugins/filters/convolutionfilters/Makefile.am +++ b/chalk/plugins/filters/convolutionfilters/Makefile.am @@ -12,10 +12,10 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkconvolutionfilters.la chalkconvolutionfilters_la_SOURCES = kis_custom_convolution_filter_configuration_base_widget.ui \ - kis_custom_convolution_filter_configuration_widget.cc \ - kis_custom_convolution_filter.cc \ - convolutionfilters.cc \ - kis_convolution_filter.cc + kis_custom_convolution_filter_configuration_widget.cpp \ + kis_custom_convolution_filter.cpp \ + convolutionfilters.cpp \ + kis_convolution_filter.cpp noinst_HEADERS = convolutionfilters.h \ kis_custom_convolution_filter_configuration_widget.h \ diff --git a/chalk/plugins/filters/convolutionfilters/convolutionfilters.cc b/chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp similarity index 100% rename from chalk/plugins/filters/convolutionfilters/convolutionfilters.cc rename to chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp diff --git a/chalk/plugins/filters/convolutionfilters/kis_convolution_filter.cc b/chalk/plugins/filters/convolutionfilters/kis_convolution_filter.cpp similarity index 100% rename from chalk/plugins/filters/convolutionfilters/kis_convolution_filter.cc rename to chalk/plugins/filters/convolutionfilters/kis_convolution_filter.cpp diff --git a/chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter.cc b/chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter.cpp similarity index 100% rename from chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter.cc rename to chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter.cpp diff --git a/chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter_configuration_widget.cc b/chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter_configuration_widget.cpp similarity index 100% rename from chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter_configuration_widget.cc rename to chalk/plugins/filters/convolutionfilters/kis_custom_convolution_filter_configuration_widget.cpp diff --git a/chalk/plugins/filters/cubismfilter/Makefile.am b/chalk/plugins/filters/cubismfilter/Makefile.am index e281360e..a26a8e80 100644 --- a/chalk/plugins/filters/cubismfilter/Makefile.am +++ b/chalk/plugins/filters/cubismfilter/Makefile.am @@ -10,9 +10,9 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkcubismfilter.la -chalkcubismfilter_la_SOURCES = kis_cubism_filter_plugin.cc \ - kis_cubism_filter.cc \ - kis_polygon.cc +chalkcubismfilter_la_SOURCES = kis_cubism_filter_plugin.cpp \ + kis_cubism_filter.cpp \ + kis_polygon.cpp noinst_HEADERS = kis_cubism_filter_plugin.h \ kis_cubism_filter.h \ diff --git a/chalk/plugins/filters/cubismfilter/kis_cubism_filter.cc b/chalk/plugins/filters/cubismfilter/kis_cubism_filter.cpp similarity index 100% rename from chalk/plugins/filters/cubismfilter/kis_cubism_filter.cc rename to chalk/plugins/filters/cubismfilter/kis_cubism_filter.cpp diff --git a/chalk/plugins/filters/cubismfilter/kis_cubism_filter_plugin.cc b/chalk/plugins/filters/cubismfilter/kis_cubism_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/cubismfilter/kis_cubism_filter_plugin.cc rename to chalk/plugins/filters/cubismfilter/kis_cubism_filter_plugin.cpp diff --git a/chalk/plugins/filters/cubismfilter/kis_polygon.cc b/chalk/plugins/filters/cubismfilter/kis_polygon.cpp similarity index 100% rename from chalk/plugins/filters/cubismfilter/kis_polygon.cc rename to chalk/plugins/filters/cubismfilter/kis_polygon.cpp diff --git a/chalk/plugins/filters/embossfilter/Makefile.am b/chalk/plugins/filters/embossfilter/Makefile.am index 8bb9cdeb..69b5cb61 100644 --- a/chalk/plugins/filters/embossfilter/Makefile.am +++ b/chalk/plugins/filters/embossfilter/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkembossfilter.la -chalkembossfilter_la_SOURCES = kis_emboss_filter_plugin.cc \ - kis_emboss_filter.cc +chalkembossfilter_la_SOURCES = kis_emboss_filter_plugin.cpp \ + kis_emboss_filter.cpp noinst_HEADERS = kis_emboss_filter_plugin.h \ kis_emboss_filter.h diff --git a/chalk/plugins/filters/embossfilter/kis_emboss_filter.cc b/chalk/plugins/filters/embossfilter/kis_emboss_filter.cpp similarity index 100% rename from chalk/plugins/filters/embossfilter/kis_emboss_filter.cc rename to chalk/plugins/filters/embossfilter/kis_emboss_filter.cpp diff --git a/chalk/plugins/filters/embossfilter/kis_emboss_filter_plugin.cc b/chalk/plugins/filters/embossfilter/kis_emboss_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/embossfilter/kis_emboss_filter_plugin.cc rename to chalk/plugins/filters/embossfilter/kis_emboss_filter_plugin.cpp diff --git a/chalk/plugins/filters/example/Makefile.am b/chalk/plugins/filters/example/Makefile.am index fcb56751..c39558f7 100644 --- a/chalk/plugins/filters/example/Makefile.am +++ b/chalk/plugins/filters/example/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkexample_la_SOURCES = example.cc +chalkexample_la_SOURCES = example.cpp kde_module_LTLIBRARIES = chalkexample.la noinst_HEADERS = example.h diff --git a/chalk/plugins/filters/example/example.cc b/chalk/plugins/filters/example/example.cpp similarity index 100% rename from chalk/plugins/filters/example/example.cc rename to chalk/plugins/filters/example/example.cpp diff --git a/chalk/plugins/filters/fastcolortransfer/Makefile.am b/chalk/plugins/filters/fastcolortransfer/Makefile.am index e923ce22..e9a17184 100644 --- a/chalk/plugins/filters/fastcolortransfer/Makefile.am +++ b/chalk/plugins/filters/fastcolortransfer/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkfastcolortransfer_la_SOURCES = wdgfastcolortransfer.ui fastcolortransfer.cc \ +chalkfastcolortransfer_la_SOURCES = wdgfastcolortransfer.ui fastcolortransfer.cpp \ kis_wdg_fastcolortransfer.cpp kde_module_LTLIBRARIES = chalkfastcolortransfer.la diff --git a/chalk/plugins/filters/fastcolortransfer/fastcolortransfer.cc b/chalk/plugins/filters/fastcolortransfer/fastcolortransfer.cpp similarity index 100% rename from chalk/plugins/filters/fastcolortransfer/fastcolortransfer.cc rename to chalk/plugins/filters/fastcolortransfer/fastcolortransfer.cpp diff --git a/chalk/plugins/filters/lenscorrectionfilter/Makefile.am b/chalk/plugins/filters/lenscorrectionfilter/Makefile.am index a0e2e5b4..e36e7d00 100644 --- a/chalk/plugins/filters/lenscorrectionfilter/Makefile.am +++ b/chalk/plugins/filters/lenscorrectionfilter/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalklenscorrectionfilter_la_SOURCES = lenscorrectionfilter.cc \ +chalklenscorrectionfilter_la_SOURCES = lenscorrectionfilter.cpp \ wdglenscorrectionoptions.ui kis_wdg_lens_correction.cpp kde_module_LTLIBRARIES = chalklenscorrectionfilter.la diff --git a/chalk/plugins/filters/lenscorrectionfilter/lenscorrectionfilter.cc b/chalk/plugins/filters/lenscorrectionfilter/lenscorrectionfilter.cpp similarity index 100% rename from chalk/plugins/filters/lenscorrectionfilter/lenscorrectionfilter.cc rename to chalk/plugins/filters/lenscorrectionfilter/lenscorrectionfilter.cpp diff --git a/chalk/plugins/filters/levelfilter/Makefile.am b/chalk/plugins/filters/levelfilter/Makefile.am index 7dc49964..897779e1 100644 --- a/chalk/plugins/filters/levelfilter/Makefile.am +++ b/chalk/plugins/filters/levelfilter/Makefile.am @@ -7,10 +7,10 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalklevelfilter_la_SOURCES = levelfilter.cc \ +chalklevelfilter_la_SOURCES = levelfilter.cpp \ wdg_level.ui \ - kis_level_filter.cc \ - kgradientslider.cc + kis_level_filter.cpp \ + kgradientslider.cpp noinst_HEADERS = levelfilter.h \ kis_level_filter.h \ diff --git a/chalk/plugins/filters/levelfilter/kgradientslider.cc b/chalk/plugins/filters/levelfilter/kgradientslider.cpp similarity index 100% rename from chalk/plugins/filters/levelfilter/kgradientslider.cc rename to chalk/plugins/filters/levelfilter/kgradientslider.cpp diff --git a/chalk/plugins/filters/levelfilter/kis_level_filter.cc b/chalk/plugins/filters/levelfilter/kis_level_filter.cpp similarity index 100% rename from chalk/plugins/filters/levelfilter/kis_level_filter.cc rename to chalk/plugins/filters/levelfilter/kis_level_filter.cpp diff --git a/chalk/plugins/filters/levelfilter/levelfilter.cc b/chalk/plugins/filters/levelfilter/levelfilter.cpp similarity index 100% rename from chalk/plugins/filters/levelfilter/levelfilter.cc rename to chalk/plugins/filters/levelfilter/levelfilter.cpp diff --git a/chalk/plugins/filters/noisefilter/Makefile.am b/chalk/plugins/filters/noisefilter/Makefile.am index 8c06406f..119039f0 100644 --- a/chalk/plugins/filters/noisefilter/Makefile.am +++ b/chalk/plugins/filters/noisefilter/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalknoisefilter_la_SOURCES = noisefilter.cc wdgnoiseoptions.ui \ +chalknoisefilter_la_SOURCES = noisefilter.cpp wdgnoiseoptions.ui \ kis_wdg_noise.cpp kde_module_LTLIBRARIES = chalknoisefilter.la diff --git a/chalk/plugins/filters/noisefilter/noisefilter.cc b/chalk/plugins/filters/noisefilter/noisefilter.cpp similarity index 100% rename from chalk/plugins/filters/noisefilter/noisefilter.cc rename to chalk/plugins/filters/noisefilter/noisefilter.cpp diff --git a/chalk/plugins/filters/oilpaintfilter/Makefile.am b/chalk/plugins/filters/oilpaintfilter/Makefile.am index 032fc2f3..6332d7ba 100644 --- a/chalk/plugins/filters/oilpaintfilter/Makefile.am +++ b/chalk/plugins/filters/oilpaintfilter/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkoilpaintfilter.la -chalkoilpaintfilter_la_SOURCES = kis_oilpaint_filter_plugin.cc \ - kis_oilpaint_filter.cc +chalkoilpaintfilter_la_SOURCES = kis_oilpaint_filter_plugin.cpp \ + kis_oilpaint_filter.cpp noinst_HEADERS = kis_oilpaint_filter_plugin.h \ kis_oilpaint_filter.h diff --git a/chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter.cc b/chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter.cpp similarity index 100% rename from chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter.cc rename to chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter.cpp diff --git a/chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter_plugin.cc b/chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter_plugin.cc rename to chalk/plugins/filters/oilpaintfilter/kis_oilpaint_filter_plugin.cpp diff --git a/chalk/plugins/filters/pixelizefilter/Makefile.am b/chalk/plugins/filters/pixelizefilter/Makefile.am index 750941e1..20f7bc4a 100644 --- a/chalk/plugins/filters/pixelizefilter/Makefile.am +++ b/chalk/plugins/filters/pixelizefilter/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkpixelizefilter.la -chalkpixelizefilter_la_SOURCES = kis_pixelize_filter_plugin.cc \ - kis_pixelize_filter.cc +chalkpixelizefilter_la_SOURCES = kis_pixelize_filter_plugin.cpp \ + kis_pixelize_filter.cpp noinst_HEADERS = kis_pixelize_filter_plugin.h \ kis_pixelize_filter.h diff --git a/chalk/plugins/filters/pixelizefilter/kis_pixelize_filter.cc b/chalk/plugins/filters/pixelizefilter/kis_pixelize_filter.cpp similarity index 100% rename from chalk/plugins/filters/pixelizefilter/kis_pixelize_filter.cc rename to chalk/plugins/filters/pixelizefilter/kis_pixelize_filter.cpp diff --git a/chalk/plugins/filters/pixelizefilter/kis_pixelize_filter_plugin.cc b/chalk/plugins/filters/pixelizefilter/kis_pixelize_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/pixelizefilter/kis_pixelize_filter_plugin.cc rename to chalk/plugins/filters/pixelizefilter/kis_pixelize_filter_plugin.cpp diff --git a/chalk/plugins/filters/raindropsfilter/Makefile.am b/chalk/plugins/filters/raindropsfilter/Makefile.am index 10f44c43..e6a1d468 100644 --- a/chalk/plugins/filters/raindropsfilter/Makefile.am +++ b/chalk/plugins/filters/raindropsfilter/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkraindropsfilter.la -chalkraindropsfilter_la_SOURCES = kis_raindrops_filter_plugin.cc \ - kis_raindrops_filter.cc +chalkraindropsfilter_la_SOURCES = kis_raindrops_filter_plugin.cpp \ + kis_raindrops_filter.cpp noinst_HEADERS = kis_raindrops_filter_plugin.h \ kis_raindrops_filter.h diff --git a/chalk/plugins/filters/raindropsfilter/kis_raindrops_filter.cc b/chalk/plugins/filters/raindropsfilter/kis_raindrops_filter.cpp similarity index 100% rename from chalk/plugins/filters/raindropsfilter/kis_raindrops_filter.cc rename to chalk/plugins/filters/raindropsfilter/kis_raindrops_filter.cpp diff --git a/chalk/plugins/filters/raindropsfilter/kis_raindrops_filter_plugin.cc b/chalk/plugins/filters/raindropsfilter/kis_raindrops_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/raindropsfilter/kis_raindrops_filter_plugin.cc rename to chalk/plugins/filters/raindropsfilter/kis_raindrops_filter_plugin.cpp diff --git a/chalk/plugins/filters/randompickfilter/Makefile.am b/chalk/plugins/filters/randompickfilter/Makefile.am index 65e910ff..3be553f2 100644 --- a/chalk/plugins/filters/randompickfilter/Makefile.am +++ b/chalk/plugins/filters/randompickfilter/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkrandompickfilter_la_SOURCES = randompickfilter.cc wdgrandompickoptions.ui \ +chalkrandompickfilter_la_SOURCES = randompickfilter.cpp wdgrandompickoptions.ui \ kis_wdg_random_pick.cpp kde_module_LTLIBRARIES = chalkrandompickfilter.la diff --git a/chalk/plugins/filters/randompickfilter/randompickfilter.cc b/chalk/plugins/filters/randompickfilter/randompickfilter.cpp similarity index 100% rename from chalk/plugins/filters/randompickfilter/randompickfilter.cc rename to chalk/plugins/filters/randompickfilter/randompickfilter.cpp diff --git a/chalk/plugins/filters/roundcorners/Makefile.am b/chalk/plugins/filters/roundcorners/Makefile.am index 05f2e055..59655c04 100644 --- a/chalk/plugins/filters/roundcorners/Makefile.am +++ b/chalk/plugins/filters/roundcorners/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalkroundcornersfilter.la -chalkroundcornersfilter_la_SOURCES = kis_round_corners_filter_plugin.cc \ - kis_round_corners_filter.cc +chalkroundcornersfilter_la_SOURCES = kis_round_corners_filter_plugin.cpp \ + kis_round_corners_filter.cpp noinst_HEADERS = kis_round_corners_filter_plugin.h \ kis_round_corners_filter.h diff --git a/chalk/plugins/filters/roundcorners/kis_round_corners_filter.cc b/chalk/plugins/filters/roundcorners/kis_round_corners_filter.cpp similarity index 100% rename from chalk/plugins/filters/roundcorners/kis_round_corners_filter.cc rename to chalk/plugins/filters/roundcorners/kis_round_corners_filter.cpp diff --git a/chalk/plugins/filters/roundcorners/kis_round_corners_filter_plugin.cc b/chalk/plugins/filters/roundcorners/kis_round_corners_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/roundcorners/kis_round_corners_filter_plugin.cc rename to chalk/plugins/filters/roundcorners/kis_round_corners_filter_plugin.cpp diff --git a/chalk/plugins/filters/smalltilesfilter/Makefile.am b/chalk/plugins/filters/smalltilesfilter/Makefile.am index 5705eae9..da718149 100644 --- a/chalk/plugins/filters/smalltilesfilter/Makefile.am +++ b/chalk/plugins/filters/smalltilesfilter/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalksmalltilesfilter.la -chalksmalltilesfilter_la_SOURCES = kis_small_tiles_filter_plugin.cc \ - kis_small_tiles_filter.cc +chalksmalltilesfilter_la_SOURCES = kis_small_tiles_filter_plugin.cpp \ + kis_small_tiles_filter.cpp noinst_HEADERS = kis_small_tiles_filter_plugin.h \ kis_small_tiles_filter.h diff --git a/chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter.cc b/chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter.cpp similarity index 100% rename from chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter.cc rename to chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter.cpp diff --git a/chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter_plugin.cc b/chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter_plugin.cc rename to chalk/plugins/filters/smalltilesfilter/kis_small_tiles_filter_plugin.cpp diff --git a/chalk/plugins/filters/sobelfilter/Makefile.am b/chalk/plugins/filters/sobelfilter/Makefile.am index 38893ad4..4a8e4151 100644 --- a/chalk/plugins/filters/sobelfilter/Makefile.am +++ b/chalk/plugins/filters/sobelfilter/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = \ kde_module_LTLIBRARIES = chalksobelfilter.la -chalksobelfilter_la_SOURCES = kis_sobel_filter_plugin.cc \ - kis_sobel_filter.cc +chalksobelfilter_la_SOURCES = kis_sobel_filter_plugin.cpp \ + kis_sobel_filter.cpp noinst_HEADERS = kis_sobel_filter_plugin.h \ kis_sobel_filter.h diff --git a/chalk/plugins/filters/sobelfilter/kis_sobel_filter.cc b/chalk/plugins/filters/sobelfilter/kis_sobel_filter.cpp similarity index 100% rename from chalk/plugins/filters/sobelfilter/kis_sobel_filter.cc rename to chalk/plugins/filters/sobelfilter/kis_sobel_filter.cpp diff --git a/chalk/plugins/filters/sobelfilter/kis_sobel_filter_plugin.cc b/chalk/plugins/filters/sobelfilter/kis_sobel_filter_plugin.cpp similarity index 100% rename from chalk/plugins/filters/sobelfilter/kis_sobel_filter_plugin.cc rename to chalk/plugins/filters/sobelfilter/kis_sobel_filter_plugin.cpp diff --git a/chalk/plugins/filters/threadtest/Makefile.am b/chalk/plugins/filters/threadtest/Makefile.am index 7846c3c0..e1a7c267 100644 --- a/chalk/plugins/filters/threadtest/Makefile.am +++ b/chalk/plugins/filters/threadtest/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ -I$(srcdir)/../../../../lib/kofficecore \ $(all_includes) -chalkthreadtest_la_SOURCES = threadtest.cc +chalkthreadtest_la_SOURCES = threadtest.cpp kde_module_LTLIBRARIES = chalkthreadtest.la noinst_HEADERS = threadtest.h diff --git a/chalk/plugins/filters/threadtest/threadtest.cc b/chalk/plugins/filters/threadtest/threadtest.cpp similarity index 100% rename from chalk/plugins/filters/threadtest/threadtest.cc rename to chalk/plugins/filters/threadtest/threadtest.cpp diff --git a/chalk/plugins/filters/unsharp/Makefile.am b/chalk/plugins/filters/unsharp/Makefile.am index e955e3bc..a831dbbd 100644 --- a/chalk/plugins/filters/unsharp/Makefile.am +++ b/chalk/plugins/filters/unsharp/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkunsharpfilter_la_SOURCES = wdgunsharp.ui kis_wdg_unsharp.cc unsharp.cc kis_unsharp_filter.cc +chalkunsharpfilter_la_SOURCES = wdgunsharp.ui kis_wdg_unsharp.cpp unsharp.cpp kis_unsharp_filter.cpp kde_module_LTLIBRARIES = chalkunsharpfilter.la diff --git a/chalk/plugins/filters/unsharp/kis_unsharp_filter.cc b/chalk/plugins/filters/unsharp/kis_unsharp_filter.cpp similarity index 100% rename from chalk/plugins/filters/unsharp/kis_unsharp_filter.cc rename to chalk/plugins/filters/unsharp/kis_unsharp_filter.cpp diff --git a/chalk/plugins/filters/unsharp/kis_wdg_unsharp.cc b/chalk/plugins/filters/unsharp/kis_wdg_unsharp.cpp similarity index 100% rename from chalk/plugins/filters/unsharp/kis_wdg_unsharp.cc rename to chalk/plugins/filters/unsharp/kis_wdg_unsharp.cpp diff --git a/chalk/plugins/filters/unsharp/unsharp.cc b/chalk/plugins/filters/unsharp/unsharp.cpp similarity index 100% rename from chalk/plugins/filters/unsharp/unsharp.cc rename to chalk/plugins/filters/unsharp/unsharp.cpp diff --git a/chalk/plugins/filters/wavefilter/Makefile.am b/chalk/plugins/filters/wavefilter/Makefile.am index 3425e769..a6b30051 100644 --- a/chalk/plugins/filters/wavefilter/Makefile.am +++ b/chalk/plugins/filters/wavefilter/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkwavefilter_la_SOURCES = wavefilter.cc wdgwaveoptions.ui \ +chalkwavefilter_la_SOURCES = wavefilter.cpp wdgwaveoptions.ui \ kis_wdg_wave.cpp kde_module_LTLIBRARIES = chalkwavefilter.la diff --git a/chalk/plugins/filters/wavefilter/wavefilter.cc b/chalk/plugins/filters/wavefilter/wavefilter.cpp similarity index 100% rename from chalk/plugins/filters/wavefilter/wavefilter.cc rename to chalk/plugins/filters/wavefilter/wavefilter.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/Makefile.am b/chalk/plugins/paintops/defaultpaintops/Makefile.am index 31acf6e0..84e2a408 100644 --- a/chalk/plugins/paintops/defaultpaintops/Makefile.am +++ b/chalk/plugins/paintops/defaultpaintops/Makefile.am @@ -18,14 +18,14 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalkdefaultpaintops_la_SOURCES = \ - defaultpaintops_plugin.cc \ - kis_airbrushop.cc \ - kis_brushop.cc \ - kis_duplicateop.cc \ - kis_eraseop.cc \ - kis_penop.cc \ + defaultpaintops_plugin.cpp \ + kis_airbrushop.cpp \ + kis_brushop.cpp \ + kis_duplicateop.cpp \ + kis_eraseop.cpp \ + kis_penop.cpp \ kis_dlgbrushcurvecontrol.ui \ - kis_smudgeop.cc + kis_smudgeop.cpp noinst_HEADERS = defaultpaintops_plugin.h kis_airbrushop.h kis_brushop.h \ kis_duplicateop.h kis_eraseop.h kis_penop.h kis_smudgeop.h diff --git a/chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cc b/chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cc deleted file mode 100644 index 25f12b87..00000000 --- a/chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * defaultpaintops_plugin.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "kis_airbrushop.h" -#include "kis_brushop.h" -#include "kis_duplicateop.h" -#include "kis_eraseop.h" -#include "kis_smudgeop.h" -#include "kis_penop.h" -#include "kis_global.h" -#include "kis_paintop_registry.h" - -#include "defaultpaintops_plugin.h" - -typedef KGenericFactory DefaultPaintOpsPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkdefaultpaintops, DefaultPaintOpsPluginFactory( "chalkcore" ) ) - - -DefaultPaintOpsPlugin::DefaultPaintOpsPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(DefaultPaintOpsPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisPaintOpRegistry") ) - { - KisPaintOpRegistry * r = dynamic_cast(parent); - // Add hard-coded paint ops. Plugin paintops will add - // themselves in the plugin initialization code. - r->add ( new KisAirbrushOpFactory ); - r->add ( new KisBrushOpFactory ); - r->add ( new KisDuplicateOpFactory ); - r->add ( new KisEraseOpFactory ); - r->add ( new KisPenOpFactory ); - r->add ( new KisSmudgeOpFactory ); - } - -} - -DefaultPaintOpsPlugin::~DefaultPaintOpsPlugin() -{ -} - -#include "defaultpaintops_plugin.moc" diff --git a/chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cpp b/chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cpp new file mode 100644 index 00000000..6e1d3f75 --- /dev/null +++ b/chalk/plugins/paintops/defaultpaintops/defaultpaintops_plugin.cpp @@ -0,0 +1,70 @@ +/* + * defaultpaintops_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "kis_airbrushop.h" +#include "kis_brushop.h" +#include "kis_duplicateop.h" +#include "kis_eraseop.h" +#include "kis_smudgeop.h" +#include "kis_penop.h" +#include "kis_global.h" +#include "kis_paintop_registry.h" + +#include "defaultpaintops_plugin.h" + +typedef KGenericFactory DefaultPaintOpsPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkdefaultpaintops, DefaultPaintOpsPluginFactory( "chalkcore" ) ) + + +DefaultPaintOpsPlugin::DefaultPaintOpsPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(DefaultPaintOpsPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisPaintOpRegistry") ) + { + KisPaintOpRegistry * r = dynamic_cast(parent); + // Add hard-coded paint ops. Plugin paintops will add + // themselves in the plugin initialization code. + r->add ( new KisAirbrushOpFactory ); + r->add ( new KisBrushOpFactory ); + r->add ( new KisDuplicateOpFactory ); + r->add ( new KisEraseOpFactory ); + r->add ( new KisPenOpFactory ); + r->add ( new KisSmudgeOpFactory ); + } + +} + +DefaultPaintOpsPlugin::~DefaultPaintOpsPlugin() +{ +} + +#include "defaultpaintops_plugin.moc" diff --git a/chalk/plugins/paintops/defaultpaintops/kis_airbrushop.cc b/chalk/plugins/paintops/defaultpaintops/kis_airbrushop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_airbrushop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_airbrushop.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/kis_brushop.cc b/chalk/plugins/paintops/defaultpaintops/kis_brushop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_brushop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_brushop.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/kis_convolveop.cc b/chalk/plugins/paintops/defaultpaintops/kis_convolveop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_convolveop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_convolveop.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/kis_duplicateop.cc b/chalk/plugins/paintops/defaultpaintops/kis_duplicateop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_duplicateop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_duplicateop.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/kis_eraseop.cc b/chalk/plugins/paintops/defaultpaintops/kis_eraseop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_eraseop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_eraseop.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/kis_penop.cc b/chalk/plugins/paintops/defaultpaintops/kis_penop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_penop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_penop.cpp diff --git a/chalk/plugins/paintops/defaultpaintops/kis_smudgeop.cc b/chalk/plugins/paintops/defaultpaintops/kis_smudgeop.cpp similarity index 100% rename from chalk/plugins/paintops/defaultpaintops/kis_smudgeop.cc rename to chalk/plugins/paintops/defaultpaintops/kis_smudgeop.cpp diff --git a/chalk/plugins/tools/defaulttools/Makefile.am b/chalk/plugins/tools/defaulttools/Makefile.am index c4d790cb..ad9e96a5 100644 --- a/chalk/plugins/tools/defaulttools/Makefile.am +++ b/chalk/plugins/tools/defaulttools/Makefile.am @@ -10,19 +10,19 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalkdefaulttools_la_SOURCES = \ - default_tools.cc \ - kis_tool_colorpicker.cc \ - kis_tool_move.cc \ - kis_tool_zoom.cc \ - kis_tool_brush.cc \ - kis_tool_line.cc \ - kis_tool_duplicate.cc \ - kis_tool_fill.cc \ - kis_tool_rectangle.cc \ - kis_tool_ellipse.cc \ - kis_tool_pan.cc \ - kis_tool_text.cc \ - kis_tool_gradient.cc \ + default_tools.cpp \ + kis_tool_colorpicker.cpp \ + kis_tool_move.cpp \ + kis_tool_zoom.cpp \ + kis_tool_brush.cpp \ + kis_tool_line.cpp \ + kis_tool_duplicate.cpp \ + kis_tool_fill.cpp \ + kis_tool_rectangle.cpp \ + kis_tool_ellipse.cpp \ + kis_tool_pan.cpp \ + kis_tool_text.cpp \ + kis_tool_gradient.cpp \ wdgcolorpicker.ui # Install this plugin in the KDE modules directory diff --git a/chalk/plugins/tools/defaulttools/default_tools.cc b/chalk/plugins/tools/defaulttools/default_tools.cc deleted file mode 100644 index 17e0feff..00000000 --- a/chalk/plugins/tools/defaulttools/default_tools.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * default_tools.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "default_tools.h" - -#include "kis_tool_fill.h" -#include "kis_tool_brush.h" -#include "kis_tool_freehand.h" -#include "kis_tool_gradient.h" -#include "kis_tool_rectangle.h" -#include "kis_tool_colorpicker.h" -#include "kis_tool_line.h" -#include "kis_tool_text.h" -#include "kis_tool_duplicate.h" -#include "kis_tool_move.h" -#include "kis_tool_zoom.h" -#include "kis_tool_ellipse.h" -#include "kis_tool_pan.h" - - -typedef KGenericFactory DefaultToolsFactory; -K_EXPORT_COMPONENT_FACTORY( chalkdefaulttools, DefaultToolsFactory( "chalk" ) ) - - -DefaultTools::DefaultTools(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(DefaultToolsFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast(parent); - - r->add(new KisToolFillFactory()); - r->add(new KisToolGradientFactory()); - r->add(new KisToolBrushFactory()); - r->add(new KisToolColorPickerFactory()); - r->add(new KisToolLineFactory()); - r->add(new KisToolTextFactory()); - r->add(new KisToolDuplicateFactory()); - r->add(new KisToolMoveFactory()); - r->add(new KisToolZoomFactory()); - r->add(new KisToolEllipseFactory()); - r->add(new KisToolRectangleFactory()); - r->add(new KisToolPanFactory()); - - } -} - -DefaultTools::~DefaultTools() -{ -} - -#include "default_tools.moc" diff --git a/chalk/plugins/tools/defaulttools/default_tools.cpp b/chalk/plugins/tools/defaulttools/default_tools.cpp new file mode 100644 index 00000000..6f1bedbb --- /dev/null +++ b/chalk/plugins/tools/defaulttools/default_tools.cpp @@ -0,0 +1,88 @@ +/* + * default_tools.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "default_tools.h" + +#include "kis_tool_fill.h" +#include "kis_tool_brush.h" +#include "kis_tool_freehand.h" +#include "kis_tool_gradient.h" +#include "kis_tool_rectangle.h" +#include "kis_tool_colorpicker.h" +#include "kis_tool_line.h" +#include "kis_tool_text.h" +#include "kis_tool_duplicate.h" +#include "kis_tool_move.h" +#include "kis_tool_zoom.h" +#include "kis_tool_ellipse.h" +#include "kis_tool_pan.h" + + +typedef KGenericFactory DefaultToolsFactory; +K_EXPORT_COMPONENT_FACTORY( chalkdefaulttools, DefaultToolsFactory( "chalk" ) ) + + +DefaultTools::DefaultTools(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(DefaultToolsFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(parent); + + r->add(new KisToolFillFactory()); + r->add(new KisToolGradientFactory()); + r->add(new KisToolBrushFactory()); + r->add(new KisToolColorPickerFactory()); + r->add(new KisToolLineFactory()); + r->add(new KisToolTextFactory()); + r->add(new KisToolDuplicateFactory()); + r->add(new KisToolMoveFactory()); + r->add(new KisToolZoomFactory()); + r->add(new KisToolEllipseFactory()); + r->add(new KisToolRectangleFactory()); + r->add(new KisToolPanFactory()); + + } +} + +DefaultTools::~DefaultTools() +{ +} + +#include "default_tools.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_brush.cc b/chalk/plugins/tools/defaulttools/kis_tool_brush.cc deleted file mode 100644 index 7c83a36b..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_brush.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - * kis_tool_brush.cc - part of Chalk - * - * Copyright (c) 2003-2004 Boudewijn Rempt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_config.h" -#include "kis_brush.h" -#include "kis_paintop.h" -#include "kis_paintop_registry.h" -#include "kis_cmb_composite.h" -#include "kis_cursor.h" -#include "kis_painter.h" -#include "kis_tool_brush.h" -#include "kis_canvas_subject.h" -#include "kis_boundary.h" -#include "kis_move_event.h" -#include "kis_canvas.h" -#include "kis_layer.h" - -KisToolBrush::KisToolBrush() - : super(i18n("Brush")) -{ - setName("tool_brush"); - setCursor(KisCursor::load("tool_freehand_cursor.png", 5, 5)); - m_rate = 100; // Conveniently hardcoded for now - m_timer = new TQTimer(this); - TQ_CHECK_PTR(m_timer); - - connect(m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeoutPaint())); - -} - -KisToolBrush::~KisToolBrush() -{ - delete m_timer; - m_timer = 0; -} - -void KisToolBrush::timeoutPaint() -{ - if (currentImage() && painter()) { - painter()->paintAt(m_prevPos, m_prevPressure, m_prevXTilt, m_prevYTilt); - currentImage()->activeLayer()->setDirty(painter()->dirtyRect()); - } -} - - -void KisToolBrush::update(KisCanvasSubject *subject) -{ - super::update(subject); -} - -void KisToolBrush::initPaint(KisEvent *e) -{ - super::initPaint(e); - - if (!m_painter) { - kdWarning() << "Didn't create a painter! Something is wrong!\n"; - return; - } - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), m_painter); - if (!op) return; - - m_subject->canvasController()->kiscanvas()->update(); // remove the outline - - painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. - - if (op->incremental()) { - m_timer->start( m_rate ); - } -} - - -void KisToolBrush::endPaint() -{ - m_timer->stop(); - super::endPaint(); -} - - -void KisToolBrush::setup(TDEActionCollection *collection) -{ - - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Brush"), - "tool_freehand", TQt::Key_B, this, - TQT_SLOT(activate()), collection, - name()); - m_action->setToolTip(i18n("Draw freehand")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -void KisToolBrush::move(KisMoveEvent *e) { - KisToolFreehand::move(e); - KisConfig cfg; - if (m_mode != PAINT && cfg.cursorStyle() == CURSOR_STYLE_OUTLINE) - paintOutline(e->pos()); -} - -void KisToolBrush::leave(TQEvent */*e*/) { - m_subject->canvasController()->kiscanvas()->update(); // remove the outline -} - - -void KisToolBrush::slotSetPaintingMode( int mode ) -{ - if (mode == TQButton::On) { - // Direct painting - m_paintIncremental = true; - } - else { - m_paintIncremental = false; - } -} - - -TQWidget* KisToolBrush::createOptionWidget(TQWidget* parent) -{ - TQWidget *widget = super::createOptionWidget(parent); - m_chkDirect = new TQCheckBox(i18n("Paint direct"), widget, "chkDirect"); - m_chkDirect->setChecked(true); - connect(m_chkDirect, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(slotSetPaintingMode(int))); - - m_optionLayout = new TQGridLayout(NULL, 3, 2, 0, 6); - TQ_CHECK_PTR(m_optionLayout); - - super::addOptionWidgetLayout(m_optionLayout); - m_optionLayout->addWidget(m_chkDirect, 0, 0); - - return widget; -} - -#include "kis_tool_brush.moc" - diff --git a/chalk/plugins/tools/defaulttools/kis_tool_brush.cpp b/chalk/plugins/tools/defaulttools/kis_tool_brush.cpp new file mode 100644 index 00000000..96e26202 --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_brush.cpp @@ -0,0 +1,167 @@ +/* + * kis_tool_brush.cpp - part of Chalk + * + * Copyright (c) 2003-2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_config.h" +#include "kis_brush.h" +#include "kis_paintop.h" +#include "kis_paintop_registry.h" +#include "kis_cmb_composite.h" +#include "kis_cursor.h" +#include "kis_painter.h" +#include "kis_tool_brush.h" +#include "kis_canvas_subject.h" +#include "kis_boundary.h" +#include "kis_move_event.h" +#include "kis_canvas.h" +#include "kis_layer.h" + +KisToolBrush::KisToolBrush() + : super(i18n("Brush")) +{ + setName("tool_brush"); + setCursor(KisCursor::load("tool_freehand_cursor.png", 5, 5)); + m_rate = 100; // Conveniently hardcoded for now + m_timer = new TQTimer(this); + TQ_CHECK_PTR(m_timer); + + connect(m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeoutPaint())); + +} + +KisToolBrush::~KisToolBrush() +{ + delete m_timer; + m_timer = 0; +} + +void KisToolBrush::timeoutPaint() +{ + if (currentImage() && painter()) { + painter()->paintAt(m_prevPos, m_prevPressure, m_prevXTilt, m_prevYTilt); + currentImage()->activeLayer()->setDirty(painter()->dirtyRect()); + } +} + + +void KisToolBrush::update(KisCanvasSubject *subject) +{ + super::update(subject); +} + +void KisToolBrush::initPaint(KisEvent *e) +{ + super::initPaint(e); + + if (!m_painter) { + kdWarning() << "Didn't create a painter! Something is wrong!\n"; + return; + } + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), m_painter); + if (!op) return; + + m_subject->canvasController()->kiscanvas()->update(); // remove the outline + + painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. + + if (op->incremental()) { + m_timer->start( m_rate ); + } +} + + +void KisToolBrush::endPaint() +{ + m_timer->stop(); + super::endPaint(); +} + + +void KisToolBrush::setup(TDEActionCollection *collection) +{ + + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Brush"), + "tool_freehand", TQt::Key_B, this, + TQT_SLOT(activate()), collection, + name()); + m_action->setToolTip(i18n("Draw freehand")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +void KisToolBrush::move(KisMoveEvent *e) { + KisToolFreehand::move(e); + KisConfig cfg; + if (m_mode != PAINT && cfg.cursorStyle() == CURSOR_STYLE_OUTLINE) + paintOutline(e->pos()); +} + +void KisToolBrush::leave(TQEvent */*e*/) { + m_subject->canvasController()->kiscanvas()->update(); // remove the outline +} + + +void KisToolBrush::slotSetPaintingMode( int mode ) +{ + if (mode == TQButton::On) { + // Direct painting + m_paintIncremental = true; + } + else { + m_paintIncremental = false; + } +} + + +TQWidget* KisToolBrush::createOptionWidget(TQWidget* parent) +{ + TQWidget *widget = super::createOptionWidget(parent); + m_chkDirect = new TQCheckBox(i18n("Paint direct"), widget, "chkDirect"); + m_chkDirect->setChecked(true); + connect(m_chkDirect, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(slotSetPaintingMode(int))); + + m_optionLayout = new TQGridLayout(NULL, 3, 2, 0, 6); + TQ_CHECK_PTR(m_optionLayout); + + super::addOptionWidgetLayout(m_optionLayout); + m_optionLayout->addWidget(m_chkDirect, 0, 0); + + return widget; +} + +#include "kis_tool_brush.moc" + diff --git a/chalk/plugins/tools/defaulttools/kis_tool_colorpicker.cc b/chalk/plugins/tools/defaulttools/kis_tool_colorpicker.cpp similarity index 100% rename from chalk/plugins/tools/defaulttools/kis_tool_colorpicker.cc rename to chalk/plugins/tools/defaulttools/kis_tool_colorpicker.cpp diff --git a/chalk/plugins/tools/defaulttools/kis_tool_duplicate.cc b/chalk/plugins/tools/defaulttools/kis_tool_duplicate.cc deleted file mode 100644 index 7bb4c54f..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_duplicate.cc +++ /dev/null @@ -1,255 +0,0 @@ -/* - * kis_tool_duplicate.cc - part of Chalk - * - * Copyright (c) 2004 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_brush.h" -#include "kis_cursor.h" -#include "kis_image.h" -#include "kis_tool_duplicate.h" -#include "kis_painter.h" -#include "kis_vec.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop.h" -#include "kis_paintop_registry.h" -#include "kis_canvas_subject.h" -#include "kis_perspective_grid.h" - -#include "kis_canvas_painter.h" -#include "kis_boundary_painter.h" - -KisToolDuplicate::KisToolDuplicate() - : super(i18n("Duplicate Brush")), m_isOffsetNotUptodate(true), m_position(TQPoint(-1,-1)) -{ - setName("tool_duplicate"); - m_subject = 0; - setCursor(KisCursor::load("tool_duplicate_cursor.png", 5, 5)); -} - -KisToolDuplicate::~KisToolDuplicate() -{ -} - -void KisToolDuplicate::activate() -{ - m_position = TQPoint(-1,-1); - super::activate(); - if( m_subject->currentImg()->perspectiveGrid()->countSubGrids() != 1 ) - { - m_perspectiveCorrection->setEnabled( false ); - m_perspectiveCorrection->setChecked( false ); - } else { - m_perspectiveCorrection->setEnabled( true ); - } -} - -void KisToolDuplicate::buttonPress(KisButtonPressEvent *e) -{ - if (e->state() == ShiftButton) { - m_position = e->pos(); - m_isOffsetNotUptodate = true; - } else { - if (m_position != TQPoint(-1, -1)) { - super::buttonPress(e); - } - } -} - - -void KisToolDuplicate::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Duplicate Brush"), - "tool_duplicate", TQt::Key_C, this, - TQT_SLOT(activate()), collection, - name()); - m_action->setToolTip(i18n("Duplicate parts of the image. Shift-click to select the point to duplicate from to begin.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -void KisToolDuplicate::initPaint(KisEvent *e) -{ - if( m_position != TQPoint(-1,-1)) - { - if(m_isOffsetNotUptodate) - { - m_offset = e->pos() - m_position; - m_isOffsetNotUptodate = false; - } - m_paintIncremental = false; - super::initPaint(e); - painter()->setDuplicateOffset( m_offset ); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("duplicate", 0, painter()); - if (op && m_source) { - op->setSource(m_source); - painter()->setPaintOp(op); - } - m_positionStartPainting = e->pos(); - painter()->setDuplicateStart( e->pos() ); - } -} - -void KisToolDuplicate::move(KisMoveEvent *e) -{ - - // Paint the outline where we will (or are) copying from - if( m_position == TQPoint(-1,-1) ) - return; - - TQPoint srcPos; - if (m_mode == PAINT) { - // if we are in perspective correction mode, update the offset when moving - if(m_perspectiveCorrection->isChecked()) - { - double startM[3][3]; - double endM[3][3]; - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 3; j++) - { - startM[i][j] = 0.; - endM[i][j] = 0.; - } - startM[i][i] = 1.; - endM[i][i] = 1.; - } - - // First look for the grid corresponding to the start point - KisSubPerspectiveGrid* subGridStart = *m_subject->currentImg()->perspectiveGrid()->begin();//device->image()->perspectiveGrid()->gridAt(KisPoint(srcPoint.x() +hotSpot.x(),srcPoint.y() +hotSpot.y())); - TQRect r = TQRect(0,0, m_subject->currentImg()->width(), m_subject->currentImg()->height()); - - if(subGridStart) - { - double* b = KisPerspectiveMath::computeMatrixTransfoFromPerspective( r, *subGridStart->topLeft(), *subGridStart->topRight(), *subGridStart->bottomLeft(), *subGridStart->bottomRight()); - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 3; j++) - { - startM[i][j] = b[3*i+j]; - } - } - - } - // Second look for the grid corresponding to the end point - KisSubPerspectiveGrid* subGridEnd = *m_subject->currentImg()->perspectiveGrid()->begin();// device->image()->perspectiveGrid()->gridAt(pos); - if(subGridEnd) - { - double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(*subGridEnd->topLeft(), *subGridEnd->topRight(), *subGridEnd->bottomLeft(), *subGridEnd->bottomRight(), r); - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 3; j++) - { - endM[i][j] = b[3*i+j]; - } - } - } - // Compute the translation in the perspective transformation space: - KisPoint translat; - { - KisPoint positionStartPaintingT = KisPerspectiveMath::matProd(endM, m_positionStartPainting); - KisPoint currentPositionT = KisPerspectiveMath::matProd(endM, e->pos() ); - KisPoint duplicateStartPoisitionT = KisPerspectiveMath::matProd(endM, m_positionStartPainting - m_offset); - KisPoint duplicateRealPosition = KisPerspectiveMath::matProd(startM, duplicateStartPoisitionT + (currentPositionT - positionStartPaintingT) ); - KisPoint p = e->pos() - duplicateRealPosition; - srcPos = p.floorTQPoint(); - } - - }else { - srcPos = painter()->duplicateOffset().floorTQPoint(); - } - } else { - if(m_isOffsetNotUptodate) - srcPos = e->pos().floorTQPoint() - m_position.floorTQPoint(); - else - srcPos = m_offset.floorTQPoint(); - } - - TQ_INT32 x; - TQ_INT32 y; - - // like KisPaintOp::splitCoordinate - x = (TQ_INT32)((e->x() < 0) ? e->x() - 1 : e->x()); - y = (TQ_INT32)((e->y() < 0) ? e->y() - 1 : e->y()); - srcPos = TQPoint(x - srcPos.x(), y - srcPos.y()); - - paintOutline(srcPos); - super::move(e); -} - -void KisToolDuplicate::paintAt(const KisPoint &pos, - const double pressure, - const double xtilt, - const double ytilt) -{ - if( m_position != TQPoint(-1,-1)) - { - if(m_isOffsetNotUptodate) - { - m_offset = pos - m_position; - m_isOffsetNotUptodate = false; - } - painter()->setDuplicateHealing( m_healing->isChecked() ); - painter()->setDuplicateHealingRadius( m_healingRadius->value() ); - painter()->setDuplicatePerspectiveCorrection( m_perspectiveCorrection->isChecked() ); - painter()->paintAt( pos, pressure, xtilt, ytilt); - } -} - -TQString KisToolDuplicate::quickHelp() const { - return i18n("To start, shift-click on the place you want to duplicate from. Then you can start painting. An indication of where you are copying from will be displayed while drawing and moving the mouse."); -} - -TQWidget* KisToolDuplicate::createOptionWidget(TQWidget* parent) -{ - TQWidget* widget = KisToolPaint::createOptionWidget(parent); - m_healing = new TQCheckBox(widget); - m_healing->setChecked( false); - addOptionWidgetOption(m_healing, new TQLabel(i18n("Healing"), widget )); - m_healingRadius = new KIntNumInput(widget); - - KisBrush *brush = m_subject->currentBrush(); - int healingradius = 20; - if( brush ) - { - healingradius = 2 * TQMAX(brush->width(),brush->height()); - } - - m_healingRadius->setValue( healingradius ); - addOptionWidgetOption(m_healingRadius, new TQLabel(i18n("Healing radius"), widget )); - m_perspectiveCorrection = new TQCheckBox(widget); - addOptionWidgetOption(m_perspectiveCorrection, new TQLabel(i18n("Correct the perspective"), widget )); - return widget; -} - -#include "kis_tool_duplicate.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_duplicate.cpp b/chalk/plugins/tools/defaulttools/kis_tool_duplicate.cpp new file mode 100644 index 00000000..0f917e7f --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_duplicate.cpp @@ -0,0 +1,255 @@ +/* + * kis_tool_duplicate.cpp - part of Chalk + * + * Copyright (c) 2004 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_brush.h" +#include "kis_cursor.h" +#include "kis_image.h" +#include "kis_tool_duplicate.h" +#include "kis_painter.h" +#include "kis_vec.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop.h" +#include "kis_paintop_registry.h" +#include "kis_canvas_subject.h" +#include "kis_perspective_grid.h" + +#include "kis_canvas_painter.h" +#include "kis_boundary_painter.h" + +KisToolDuplicate::KisToolDuplicate() + : super(i18n("Duplicate Brush")), m_isOffsetNotUptodate(true), m_position(TQPoint(-1,-1)) +{ + setName("tool_duplicate"); + m_subject = 0; + setCursor(KisCursor::load("tool_duplicate_cursor.png", 5, 5)); +} + +KisToolDuplicate::~KisToolDuplicate() +{ +} + +void KisToolDuplicate::activate() +{ + m_position = TQPoint(-1,-1); + super::activate(); + if( m_subject->currentImg()->perspectiveGrid()->countSubGrids() != 1 ) + { + m_perspectiveCorrection->setEnabled( false ); + m_perspectiveCorrection->setChecked( false ); + } else { + m_perspectiveCorrection->setEnabled( true ); + } +} + +void KisToolDuplicate::buttonPress(KisButtonPressEvent *e) +{ + if (e->state() == ShiftButton) { + m_position = e->pos(); + m_isOffsetNotUptodate = true; + } else { + if (m_position != TQPoint(-1, -1)) { + super::buttonPress(e); + } + } +} + + +void KisToolDuplicate::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Duplicate Brush"), + "tool_duplicate", TQt::Key_C, this, + TQT_SLOT(activate()), collection, + name()); + m_action->setToolTip(i18n("Duplicate parts of the image. Shift-click to select the point to duplicate from to begin.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +void KisToolDuplicate::initPaint(KisEvent *e) +{ + if( m_position != TQPoint(-1,-1)) + { + if(m_isOffsetNotUptodate) + { + m_offset = e->pos() - m_position; + m_isOffsetNotUptodate = false; + } + m_paintIncremental = false; + super::initPaint(e); + painter()->setDuplicateOffset( m_offset ); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("duplicate", 0, painter()); + if (op && m_source) { + op->setSource(m_source); + painter()->setPaintOp(op); + } + m_positionStartPainting = e->pos(); + painter()->setDuplicateStart( e->pos() ); + } +} + +void KisToolDuplicate::move(KisMoveEvent *e) +{ + + // Paint the outline where we will (or are) copying from + if( m_position == TQPoint(-1,-1) ) + return; + + TQPoint srcPos; + if (m_mode == PAINT) { + // if we are in perspective correction mode, update the offset when moving + if(m_perspectiveCorrection->isChecked()) + { + double startM[3][3]; + double endM[3][3]; + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 3; j++) + { + startM[i][j] = 0.; + endM[i][j] = 0.; + } + startM[i][i] = 1.; + endM[i][i] = 1.; + } + + // First look for the grid corresponding to the start point + KisSubPerspectiveGrid* subGridStart = *m_subject->currentImg()->perspectiveGrid()->begin();//device->image()->perspectiveGrid()->gridAt(KisPoint(srcPoint.x() +hotSpot.x(),srcPoint.y() +hotSpot.y())); + TQRect r = TQRect(0,0, m_subject->currentImg()->width(), m_subject->currentImg()->height()); + + if(subGridStart) + { + double* b = KisPerspectiveMath::computeMatrixTransfoFromPerspective( r, *subGridStart->topLeft(), *subGridStart->topRight(), *subGridStart->bottomLeft(), *subGridStart->bottomRight()); + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 3; j++) + { + startM[i][j] = b[3*i+j]; + } + } + + } + // Second look for the grid corresponding to the end point + KisSubPerspectiveGrid* subGridEnd = *m_subject->currentImg()->perspectiveGrid()->begin();// device->image()->perspectiveGrid()->gridAt(pos); + if(subGridEnd) + { + double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(*subGridEnd->topLeft(), *subGridEnd->topRight(), *subGridEnd->bottomLeft(), *subGridEnd->bottomRight(), r); + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 3; j++) + { + endM[i][j] = b[3*i+j]; + } + } + } + // Compute the translation in the perspective transformation space: + KisPoint translat; + { + KisPoint positionStartPaintingT = KisPerspectiveMath::matProd(endM, m_positionStartPainting); + KisPoint currentPositionT = KisPerspectiveMath::matProd(endM, e->pos() ); + KisPoint duplicateStartPoisitionT = KisPerspectiveMath::matProd(endM, m_positionStartPainting - m_offset); + KisPoint duplicateRealPosition = KisPerspectiveMath::matProd(startM, duplicateStartPoisitionT + (currentPositionT - positionStartPaintingT) ); + KisPoint p = e->pos() - duplicateRealPosition; + srcPos = p.floorTQPoint(); + } + + }else { + srcPos = painter()->duplicateOffset().floorTQPoint(); + } + } else { + if(m_isOffsetNotUptodate) + srcPos = e->pos().floorTQPoint() - m_position.floorTQPoint(); + else + srcPos = m_offset.floorTQPoint(); + } + + TQ_INT32 x; + TQ_INT32 y; + + // like KisPaintOp::splitCoordinate + x = (TQ_INT32)((e->x() < 0) ? e->x() - 1 : e->x()); + y = (TQ_INT32)((e->y() < 0) ? e->y() - 1 : e->y()); + srcPos = TQPoint(x - srcPos.x(), y - srcPos.y()); + + paintOutline(srcPos); + super::move(e); +} + +void KisToolDuplicate::paintAt(const KisPoint &pos, + const double pressure, + const double xtilt, + const double ytilt) +{ + if( m_position != TQPoint(-1,-1)) + { + if(m_isOffsetNotUptodate) + { + m_offset = pos - m_position; + m_isOffsetNotUptodate = false; + } + painter()->setDuplicateHealing( m_healing->isChecked() ); + painter()->setDuplicateHealingRadius( m_healingRadius->value() ); + painter()->setDuplicatePerspectiveCorrection( m_perspectiveCorrection->isChecked() ); + painter()->paintAt( pos, pressure, xtilt, ytilt); + } +} + +TQString KisToolDuplicate::quickHelp() const { + return i18n("To start, shift-click on the place you want to duplicate from. Then you can start painting. An indication of where you are copying from will be displayed while drawing and moving the mouse."); +} + +TQWidget* KisToolDuplicate::createOptionWidget(TQWidget* parent) +{ + TQWidget* widget = KisToolPaint::createOptionWidget(parent); + m_healing = new TQCheckBox(widget); + m_healing->setChecked( false); + addOptionWidgetOption(m_healing, new TQLabel(i18n("Healing"), widget )); + m_healingRadius = new KIntNumInput(widget); + + KisBrush *brush = m_subject->currentBrush(); + int healingradius = 20; + if( brush ) + { + healingradius = 2 * TQMAX(brush->width(),brush->height()); + } + + m_healingRadius->setValue( healingradius ); + addOptionWidgetOption(m_healingRadius, new TQLabel(i18n("Healing radius"), widget )); + m_perspectiveCorrection = new TQCheckBox(widget); + addOptionWidgetOption(m_perspectiveCorrection, new TQLabel(i18n("Correct the perspective"), widget )); + return widget; +} + +#include "kis_tool_duplicate.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_ellipse.cc b/chalk/plugins/tools/defaulttools/kis_tool_ellipse.cc deleted file mode 100644 index 919454b2..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_ellipse.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* - * kis_tool_ellipse.cc - part of Krayon - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2002 Patrick Julien - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2004 Clarence Dang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include - -#include -#include -#include - -#include "kis_painter.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_tool_ellipse.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop_registry.h" -#include "kis_undo_adapter.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" - -KisToolEllipse::KisToolEllipse() - : super(i18n ("Ellipse")), - m_dragging (false), - m_currentImage (0) -{ - setName("tool_ellipse"); - setCursor(KisCursor::load("tool_ellipse_cursor.png", 6, 6)); -} - -KisToolEllipse::~KisToolEllipse() -{ -} - -void KisToolEllipse::update (KisCanvasSubject *subject) -{ - super::update (subject); - if (m_subject) - m_currentImage = m_subject->currentImg (); -} - -void KisToolEllipse::buttonPress(KisButtonPressEvent *event) -{ - if (m_currentImage && event->button() == Qt::LeftButton) { - m_dragging = true; - m_dragStart = m_dragCenter = m_dragEnd = event->pos(); - draw(m_dragStart, m_dragEnd); - } -} - -void KisToolEllipse::move(KisMoveEvent *event) -{ - if (m_dragging) { - // erase old lines on canvas - draw(m_dragStart, m_dragEnd); - // move (alt) or resize ellipse - if (event->state() & TQt::AltButton) { - KisPoint trans = event->pos() - m_dragEnd; - m_dragStart += trans; - m_dragEnd += trans; - } else { - KisPoint diag = event->pos() - (event->state() & TQt::ControlButton - ? m_dragCenter : m_dragStart); - // circle? - if (event->state() & TQt::ShiftButton) { - double size = TQMAX(fabs(diag.x()), fabs(diag.y())); - double w = diag.x() < 0 ? -size : size; - double h = diag.y() < 0 ? -size : size; - diag = KisPoint(w, h); - } - - // resize around center point? - if (event->state() & TQt::ControlButton) { - m_dragStart = m_dragCenter - diag; - m_dragEnd = m_dragCenter + diag; - } else { - m_dragEnd = m_dragStart + diag; - } - } - // draw new lines on canvas - draw(m_dragStart, m_dragEnd); - m_dragCenter = KisPoint((m_dragStart.x() + m_dragEnd.x()) / 2, - (m_dragStart.y() + m_dragEnd.y()) / 2); - } -} - -void KisToolEllipse::buttonRelease(KisButtonReleaseEvent *event) -{ - if (!m_subject || !m_currentImage) - return; - - if (m_dragging && event->button() == Qt::LeftButton) { - // erase old lines on canvas - draw(m_dragStart, m_dragEnd); - m_dragging = false; - - if (m_dragStart == m_dragEnd) - return; - - if (!m_currentImage) - return; - - if (!m_currentImage->activeDevice()) - return; - - KisPaintDeviceSP device = m_currentImage->activeDevice (); - KisPainter painter (device); - if (m_currentImage->undo()) painter.beginTransaction (i18n ("Ellipse")); - - painter.setPaintColor(m_subject->fgColor()); - painter.setBackgroundColor(m_subject->bgColor()); - painter.setFillStyle(fillStyle()); - painter.setBrush(m_subject->currentBrush()); - painter.setPattern(m_subject->currentPattern()); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); - painter.setPaintOp(op); // Painter takes ownership - - painter.paintEllipse(m_dragStart, m_dragEnd, PRESSURE_DEFAULT/*event->pressure()*/, event->xTilt(), event->yTilt()); - device->setDirty( painter.dirtyRect() ); - notifyModified(); - - KisUndoAdapter *adapter = m_currentImage->undoAdapter(); - if (adapter) { - adapter->addCommand(painter.endTransaction()); - } - } -} - -void KisToolEllipse::draw(const KisPoint& start, const KisPoint& end ) -{ - if (!m_subject || !m_currentImage) - return; - - KisCanvasController *controller = m_subject->canvasController (); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter p (canvas); - - p.setRasterOp (TQt::NotROP); - p.drawEllipse (TQRect (controller->windowToView (start).floorTQPoint(), controller->windowToView (end).floorTQPoint())); - p.end (); -} - -void KisToolEllipse::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F7)); - m_action = new TDERadioAction(i18n("&Ellipse"), - "tool_ellipse", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - m_action->setToolTip(i18n("Draw an ellipse")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_ellipse.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_ellipse.cpp b/chalk/plugins/tools/defaulttools/kis_tool_ellipse.cpp new file mode 100644 index 00000000..0488dcb0 --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_ellipse.cpp @@ -0,0 +1,186 @@ +/* + * kis_tool_ellipse.cpp - part of Krayon + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * Copyright (c) 2004 Clarence Dang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include +#include + +#include "kis_painter.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_tool_ellipse.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop_registry.h" +#include "kis_undo_adapter.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" + +KisToolEllipse::KisToolEllipse() + : super(i18n ("Ellipse")), + m_dragging (false), + m_currentImage (0) +{ + setName("tool_ellipse"); + setCursor(KisCursor::load("tool_ellipse_cursor.png", 6, 6)); +} + +KisToolEllipse::~KisToolEllipse() +{ +} + +void KisToolEllipse::update (KisCanvasSubject *subject) +{ + super::update (subject); + if (m_subject) + m_currentImage = m_subject->currentImg (); +} + +void KisToolEllipse::buttonPress(KisButtonPressEvent *event) +{ + if (m_currentImage && event->button() == Qt::LeftButton) { + m_dragging = true; + m_dragStart = m_dragCenter = m_dragEnd = event->pos(); + draw(m_dragStart, m_dragEnd); + } +} + +void KisToolEllipse::move(KisMoveEvent *event) +{ + if (m_dragging) { + // erase old lines on canvas + draw(m_dragStart, m_dragEnd); + // move (alt) or resize ellipse + if (event->state() & TQt::AltButton) { + KisPoint trans = event->pos() - m_dragEnd; + m_dragStart += trans; + m_dragEnd += trans; + } else { + KisPoint diag = event->pos() - (event->state() & TQt::ControlButton + ? m_dragCenter : m_dragStart); + // circle? + if (event->state() & TQt::ShiftButton) { + double size = TQMAX(fabs(diag.x()), fabs(diag.y())); + double w = diag.x() < 0 ? -size : size; + double h = diag.y() < 0 ? -size : size; + diag = KisPoint(w, h); + } + + // resize around center point? + if (event->state() & TQt::ControlButton) { + m_dragStart = m_dragCenter - diag; + m_dragEnd = m_dragCenter + diag; + } else { + m_dragEnd = m_dragStart + diag; + } + } + // draw new lines on canvas + draw(m_dragStart, m_dragEnd); + m_dragCenter = KisPoint((m_dragStart.x() + m_dragEnd.x()) / 2, + (m_dragStart.y() + m_dragEnd.y()) / 2); + } +} + +void KisToolEllipse::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject || !m_currentImage) + return; + + if (m_dragging && event->button() == Qt::LeftButton) { + // erase old lines on canvas + draw(m_dragStart, m_dragEnd); + m_dragging = false; + + if (m_dragStart == m_dragEnd) + return; + + if (!m_currentImage) + return; + + if (!m_currentImage->activeDevice()) + return; + + KisPaintDeviceSP device = m_currentImage->activeDevice (); + KisPainter painter (device); + if (m_currentImage->undo()) painter.beginTransaction (i18n ("Ellipse")); + + painter.setPaintColor(m_subject->fgColor()); + painter.setBackgroundColor(m_subject->bgColor()); + painter.setFillStyle(fillStyle()); + painter.setBrush(m_subject->currentBrush()); + painter.setPattern(m_subject->currentPattern()); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); + painter.setPaintOp(op); // Painter takes ownership + + painter.paintEllipse(m_dragStart, m_dragEnd, PRESSURE_DEFAULT/*event->pressure()*/, event->xTilt(), event->yTilt()); + device->setDirty( painter.dirtyRect() ); + notifyModified(); + + KisUndoAdapter *adapter = m_currentImage->undoAdapter(); + if (adapter) { + adapter->addCommand(painter.endTransaction()); + } + } +} + +void KisToolEllipse::draw(const KisPoint& start, const KisPoint& end ) +{ + if (!m_subject || !m_currentImage) + return; + + KisCanvasController *controller = m_subject->canvasController (); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter p (canvas); + + p.setRasterOp (TQt::NotROP); + p.drawEllipse (TQRect (controller->windowToView (start).floorTQPoint(), controller->windowToView (end).floorTQPoint())); + p.end (); +} + +void KisToolEllipse::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F7)); + m_action = new TDERadioAction(i18n("&Ellipse"), + "tool_ellipse", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + m_action->setToolTip(i18n("Draw an ellipse")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_ellipse.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_fill.cc b/chalk/plugins/tools/defaulttools/kis_tool_fill.cc deleted file mode 100644 index df8e4f7c..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_fill.cc +++ /dev/null @@ -1,233 +0,0 @@ -/* - * kis_tool_fill.cc - part of Krayon - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2004 Bart Coppens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "knuminput.h" - -#include "kis_layer.h" -#include "kis_cursor.h" -#include "kis_painter.h" -#include "kis_tool_brush.h" -#include "kis_cmb_composite.h" -#include "kis_tool_fill.h" -#include "kis_colorspace.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_pattern.h" -#include "kis_fill_painter.h" -#include "kis_progress_display_interface.h" -#include "kis_undo_adapter.h" -#include "kis_canvas_subject.h" -#include "kis_selection.h" - -KisToolFill::KisToolFill() - : super(i18n("Fill")), m_wasPressed(false) -{ - setName("tool_fill"); - m_subject = 0; - m_oldColor = 0; - m_threshold = 15; - m_usePattern = false; - m_unmerged = false; - m_fillOnlySelection = false; - - setCursor(KisCursor::load("tool_fill_cursor.png", 6, 6)); -} - -void KisToolFill::update(KisCanvasSubject *subject) -{ - m_subject = subject; - m_currentImage = subject->currentImg(); - - super::update(m_subject); -} - -KisToolFill::~KisToolFill() -{ -} - -bool KisToolFill::flood(int startX, int startY) -{ - KisPaintDeviceSP device = m_currentImage->activeDevice(); - if (!device) return false; - - if (m_fillOnlySelection) { - TQRect rc = device->selection()->selectedRect(); - KisPaintDeviceSP filled = new KisPaintDevice(device->colorSpace(), "filled"); - KisFillPainter painter(filled); - if (m_usePattern) - painter.fillRect(rc.x(), rc.y(), rc.width(), rc.height(), - m_subject->currentPattern()); - else - painter.fillRect(rc.x(), rc.y(), rc.width(), rc.height(), - m_subject->fgColor(), m_opacity); - painter.end(); - KisPainter painter2(device); - if (m_currentImage->undo()) painter2.beginTransaction(i18n("Fill")); - painter2.bltSelection(rc.x(), rc.y() , m_compositeOp, filled, m_opacity, - rc.x(), rc.y(), rc.width(), rc.height()); - - device->setDirty(filled->extent()); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter2.endTransaction()); - } - return true; - } - - KisFillPainter painter(device); - if (m_currentImage->undo()) painter.beginTransaction(i18n("Flood Fill")); - painter.setPaintColor(m_subject->fgColor()); - painter.setOpacity(m_opacity); - painter.setFillThreshold(m_threshold); - painter.setCompositeOp(m_compositeOp); - painter.setPattern(m_subject->currentPattern()); - painter.setSampleMerged(!m_unmerged); - painter.setCareForSelection(true); - - KisProgressDisplayInterface *progress = m_subject->progressDisplay(); - if (progress) { - progress->setSubject(&painter, true, true); - } - - if (m_usePattern) - painter.fillPattern(startX, startY); - else - painter.fillColor(startX, startY); - - device->setDirty(painter.dirtyRect()); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); - } - - return true; -} - -void KisToolFill::buttonPress(KisButtonPressEvent *e) -{ - m_startPos = e->pos(); - m_wasPressed = true; -} - -void KisToolFill::buttonRelease(KisButtonReleaseEvent *e) -{ - if (!m_subject) return; - if (!m_currentImage || !m_currentImage->activeDevice()) return; - if (e->button() != Qt::LeftButton) return; - if(!m_wasPressed) return; - m_wasPressed = false; - int x, y; - x = m_startPos.floorX(); - y = m_startPos.floorY(); - if (!m_currentImage->bounds().contains(x, y)) { - return; - } - flood(x, y); - notifyModified(); -} - -TQWidget* KisToolFill::createOptionWidget(TQWidget* parent) -{ - TQWidget *widget = super::createOptionWidget(parent); - - m_lbThreshold = new TQLabel(i18n("Threshold: "), widget); - m_slThreshold = new KIntNumInput( widget, "int_widget"); - m_slThreshold->setRange( 1, 100); - m_slThreshold->setSteps( 3, 3); - m_slThreshold->setValue(m_threshold); - connect(m_slThreshold, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetThreshold(int))); - - m_checkUsePattern = new TQCheckBox(i18n("Use pattern"), widget); - m_checkUsePattern->setChecked(m_usePattern); - connect(m_checkUsePattern, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetUsePattern(bool))); - - m_checkSampleMerged = new TQCheckBox(i18n("Limit to current layer"), widget); - m_checkSampleMerged->setChecked(m_unmerged); - connect(m_checkSampleMerged, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetSampleMerged(bool))); - - m_checkFillSelection = new TQCheckBox(i18n("Fill entire selection"), widget); - m_checkFillSelection->setChecked(m_fillOnlySelection); - connect(m_checkFillSelection, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetFillSelection(bool))); - - addOptionWidgetOption(m_slThreshold, m_lbThreshold); - - addOptionWidgetOption(m_checkFillSelection); - addOptionWidgetOption(m_checkSampleMerged); - addOptionWidgetOption(m_checkUsePattern); - - return widget; -} - -void KisToolFill::slotSetThreshold(int threshold) -{ - m_threshold = threshold; -} - -void KisToolFill::slotSetUsePattern(bool state) -{ - m_usePattern = state; -} - -void KisToolFill::slotSetSampleMerged(bool state) -{ - m_unmerged = state; -} - -void KisToolFill::slotSetFillSelection(bool state) -{ - m_fillOnlySelection = state; - m_slThreshold->setEnabled(!state); - m_checkSampleMerged->setEnabled(!state); -} - -void KisToolFill::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Fill"), - "tool_color_fill", - TQt::Key_F, - this, - TQT_SLOT(activate()), - collection, - name()); - m_action->setToolTip(i18n("Contiguous fill")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_fill.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_fill.cpp b/chalk/plugins/tools/defaulttools/kis_tool_fill.cpp new file mode 100644 index 00000000..ceb78f06 --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_fill.cpp @@ -0,0 +1,233 @@ +/* + * kis_tool_fill.cpp - part of Krayon + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2004 Boudewijn Rempt + * Copyright (c) 2004 Bart Coppens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "knuminput.h" + +#include "kis_layer.h" +#include "kis_cursor.h" +#include "kis_painter.h" +#include "kis_tool_brush.h" +#include "kis_cmb_composite.h" +#include "kis_tool_fill.h" +#include "kis_colorspace.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_pattern.h" +#include "kis_fill_painter.h" +#include "kis_progress_display_interface.h" +#include "kis_undo_adapter.h" +#include "kis_canvas_subject.h" +#include "kis_selection.h" + +KisToolFill::KisToolFill() + : super(i18n("Fill")), m_wasPressed(false) +{ + setName("tool_fill"); + m_subject = 0; + m_oldColor = 0; + m_threshold = 15; + m_usePattern = false; + m_unmerged = false; + m_fillOnlySelection = false; + + setCursor(KisCursor::load("tool_fill_cursor.png", 6, 6)); +} + +void KisToolFill::update(KisCanvasSubject *subject) +{ + m_subject = subject; + m_currentImage = subject->currentImg(); + + super::update(m_subject); +} + +KisToolFill::~KisToolFill() +{ +} + +bool KisToolFill::flood(int startX, int startY) +{ + KisPaintDeviceSP device = m_currentImage->activeDevice(); + if (!device) return false; + + if (m_fillOnlySelection) { + TQRect rc = device->selection()->selectedRect(); + KisPaintDeviceSP filled = new KisPaintDevice(device->colorSpace(), "filled"); + KisFillPainter painter(filled); + if (m_usePattern) + painter.fillRect(rc.x(), rc.y(), rc.width(), rc.height(), + m_subject->currentPattern()); + else + painter.fillRect(rc.x(), rc.y(), rc.width(), rc.height(), + m_subject->fgColor(), m_opacity); + painter.end(); + KisPainter painter2(device); + if (m_currentImage->undo()) painter2.beginTransaction(i18n("Fill")); + painter2.bltSelection(rc.x(), rc.y() , m_compositeOp, filled, m_opacity, + rc.x(), rc.y(), rc.width(), rc.height()); + + device->setDirty(filled->extent()); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter2.endTransaction()); + } + return true; + } + + KisFillPainter painter(device); + if (m_currentImage->undo()) painter.beginTransaction(i18n("Flood Fill")); + painter.setPaintColor(m_subject->fgColor()); + painter.setOpacity(m_opacity); + painter.setFillThreshold(m_threshold); + painter.setCompositeOp(m_compositeOp); + painter.setPattern(m_subject->currentPattern()); + painter.setSampleMerged(!m_unmerged); + painter.setCareForSelection(true); + + KisProgressDisplayInterface *progress = m_subject->progressDisplay(); + if (progress) { + progress->setSubject(&painter, true, true); + } + + if (m_usePattern) + painter.fillPattern(startX, startY); + else + painter.fillColor(startX, startY); + + device->setDirty(painter.dirtyRect()); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); + } + + return true; +} + +void KisToolFill::buttonPress(KisButtonPressEvent *e) +{ + m_startPos = e->pos(); + m_wasPressed = true; +} + +void KisToolFill::buttonRelease(KisButtonReleaseEvent *e) +{ + if (!m_subject) return; + if (!m_currentImage || !m_currentImage->activeDevice()) return; + if (e->button() != Qt::LeftButton) return; + if(!m_wasPressed) return; + m_wasPressed = false; + int x, y; + x = m_startPos.floorX(); + y = m_startPos.floorY(); + if (!m_currentImage->bounds().contains(x, y)) { + return; + } + flood(x, y); + notifyModified(); +} + +TQWidget* KisToolFill::createOptionWidget(TQWidget* parent) +{ + TQWidget *widget = super::createOptionWidget(parent); + + m_lbThreshold = new TQLabel(i18n("Threshold: "), widget); + m_slThreshold = new KIntNumInput( widget, "int_widget"); + m_slThreshold->setRange( 1, 100); + m_slThreshold->setSteps( 3, 3); + m_slThreshold->setValue(m_threshold); + connect(m_slThreshold, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetThreshold(int))); + + m_checkUsePattern = new TQCheckBox(i18n("Use pattern"), widget); + m_checkUsePattern->setChecked(m_usePattern); + connect(m_checkUsePattern, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetUsePattern(bool))); + + m_checkSampleMerged = new TQCheckBox(i18n("Limit to current layer"), widget); + m_checkSampleMerged->setChecked(m_unmerged); + connect(m_checkSampleMerged, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetSampleMerged(bool))); + + m_checkFillSelection = new TQCheckBox(i18n("Fill entire selection"), widget); + m_checkFillSelection->setChecked(m_fillOnlySelection); + connect(m_checkFillSelection, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetFillSelection(bool))); + + addOptionWidgetOption(m_slThreshold, m_lbThreshold); + + addOptionWidgetOption(m_checkFillSelection); + addOptionWidgetOption(m_checkSampleMerged); + addOptionWidgetOption(m_checkUsePattern); + + return widget; +} + +void KisToolFill::slotSetThreshold(int threshold) +{ + m_threshold = threshold; +} + +void KisToolFill::slotSetUsePattern(bool state) +{ + m_usePattern = state; +} + +void KisToolFill::slotSetSampleMerged(bool state) +{ + m_unmerged = state; +} + +void KisToolFill::slotSetFillSelection(bool state) +{ + m_fillOnlySelection = state; + m_slThreshold->setEnabled(!state); + m_checkSampleMerged->setEnabled(!state); +} + +void KisToolFill::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Fill"), + "tool_color_fill", + TQt::Key_F, + this, + TQT_SLOT(activate()), + collection, + name()); + m_action->setToolTip(i18n("Contiguous fill")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_fill.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_gradient.cc b/chalk/plugins/tools/defaulttools/kis_tool_gradient.cc deleted file mode 100644 index a46fee80..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_gradient.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* - * kis_tool_gradient.cc - part of Chalk - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2002 Patrick Julien - * Copyright (c) 2003 Boudewijn Rempt - * Copyright (c) 2004 Adrian Page - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_canvas_subject.h" -#include "kis_cmb_composite.h" -#include "kis_cursor.h" -#include "kis_double_widget.h" -#include "kis_gradient_painter.h" -#include "kis_move_event.h" -#include "kis_painter.h" -#include "kis_progress_display_interface.h" -#include "kis_tool_gradient.h" -#include "kis_undo_adapter.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" - -KisToolGradient::KisToolGradient() - : super(i18n("Gradient")), - m_dragging( false ) -{ - setName("tool_gradient"); - setCursor(KisCursor::load("tool_gradient_cursor.png", 6, 6)); - - m_startPos = KisPoint(0, 0); - m_endPos = KisPoint(0, 0); - - m_reverse = false; - m_shape = KisGradientPainter::GradientShapeLinear; - m_repeat = KisGradientPainter::GradientRepeatNone; - m_antiAliasThreshold = 0.2; -} - -KisToolGradient::~KisToolGradient() -{ -} - -void KisToolGradient::update(KisCanvasSubject *subject) -{ - m_subject = subject; - super::update(m_subject); -} - -void KisToolGradient::paint(KisCanvasPainter& gc) -{ - if (m_dragging) - paintLine(gc); -} - -void KisToolGradient::paint(KisCanvasPainter& gc, const TQRect&) -{ - if (m_dragging) - paintLine(gc); -} - -void KisToolGradient::buttonPress(KisButtonPressEvent *e) -{ - if (!m_subject || !m_subject->currentImg()) { - return; - } - - if (e->button() == Qt::LeftButton) { - m_dragging = true; - m_startPos = e->pos(); - m_endPos = e->pos(); - } -} - -void KisToolGradient::move(KisMoveEvent *e) -{ - if (m_dragging) { - if (m_startPos != m_endPos) { - paintLine(); - } - - if ((e->state() & TQt::ShiftButton) == TQt::ShiftButton) { - m_endPos = straightLine(e->pos()); - } - else { - m_endPos = e->pos(); - } - - paintLine(); - } -} - -void KisToolGradient::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_dragging && e->button() == Qt::LeftButton) { - - KisCanvasController *controller = m_subject->canvasController(); - KisImageSP img = m_subject->currentImg(); - - m_dragging = false; - - if (m_startPos == m_endPos) { - controller->updateCanvas(); - m_dragging = false; - return; - } - - if ((e->state() & TQt::ShiftButton) == TQt::ShiftButton) { - m_endPos = straightLine(e->pos()); - } - else { - m_endPos = e->pos(); - } - - KisPaintDeviceSP device; - - if (img && (device = img->activeDevice())) { - - KisGradientPainter painter(device); - - if (img->undo()) painter.beginTransaction(i18n("Gradient")); - - painter.setPaintColor(m_subject->fgColor()); - painter.setGradient(*(m_subject->currentGradient())); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - - KisProgressDisplayInterface *progress = m_subject->progressDisplay(); - - if (progress) { - progress->setSubject(&painter, true, true); - } - - bool painted = painter.paintGradient(m_startPos, m_endPos, m_shape, m_repeat, m_antiAliasThreshold, m_reverse, 0, 0, m_subject->currentImg()->width(), m_subject->currentImg()->height()); - - if (painted) { - // does whole thing at moment - device->setDirty(painter.dirtyRect()); - - notifyModified(); - - if (img->undo()) { - img->undoAdapter()->addCommand(painter.endTransaction()); - } - } - - /* remove remains of the line drawn while moving */ - if (controller->kiscanvas()) { - controller->kiscanvas()->update(); - } - - } - } -} - -KisPoint KisToolGradient::straightLine(KisPoint point) -{ - KisPoint comparison = point - m_startPos; - KisPoint result; - - if ( fabs(comparison.x()) > fabs(comparison.y())) { - result.setX(point.x()); - result.setY(m_startPos.y()); - } else { - result.setX( m_startPos.x() ); - result.setY( point.y() ); - } - - return result; -} - -void KisToolGradient::paintLine() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - - paintLine(gc); - } -} - -void KisToolGradient::paintLine(KisCanvasPainter& gc) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - - KisPoint start = controller->windowToView(m_startPos); - KisPoint end = controller->windowToView(m_endPos); - - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::SolidLine); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawLine(start.floorTQPoint(), end.floorTQPoint()); - gc.setRasterOp(op); - gc.setPen(old); - } -} - -TQWidget* KisToolGradient::createOptionWidget(TQWidget* parent) -{ - TQWidget *widget = super::createOptionWidget(parent); - TQ_CHECK_PTR(widget); - - m_lbShape = new TQLabel(i18n("Shape:"), widget); - m_lbRepeat = new TQLabel(i18n("Repeat:"), widget); - - m_ckReverse = new TQCheckBox(i18n("Reverse"), widget, "reverse_check"); - connect(m_ckReverse, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetReverse(bool))); - - m_cmbShape = new TQComboBox(false, widget, "shape_combo"); - connect(m_cmbShape, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotSetShape(int))); - m_cmbShape->insertItem(i18n("Linear")); - m_cmbShape->insertItem(i18n("Bi-Linear")); - m_cmbShape->insertItem(i18n("Radial")); - m_cmbShape->insertItem(i18n("Square")); - m_cmbShape->insertItem(i18n("Conical")); - m_cmbShape->insertItem(i18n("Conical Symmetric")); - - m_cmbRepeat = new TQComboBox(false, widget, "repeat_combo"); - connect(m_cmbRepeat, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotSetRepeat(int))); - m_cmbRepeat->insertItem(i18n("None")); - m_cmbRepeat->insertItem(i18n("Forwards")); - m_cmbRepeat->insertItem(i18n("Alternating")); - - addOptionWidgetOption(m_cmbShape, m_lbShape); - - addOptionWidgetOption(m_cmbRepeat, m_lbRepeat); - - addOptionWidgetOption(m_ckReverse); - - m_lbAntiAliasThreshold = new TQLabel(i18n("Anti-alias threshold:"), widget); - - m_slAntiAliasThreshold = new KDoubleNumInput(widget, "threshold_slider"); - m_slAntiAliasThreshold->setRange( 0, 1); - m_slAntiAliasThreshold->setValue(m_antiAliasThreshold); - connect(m_slAntiAliasThreshold, TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(slotSetAntiAliasThreshold(double))); - - addOptionWidgetOption(m_slAntiAliasThreshold, m_lbAntiAliasThreshold); - - return widget; -} - -void KisToolGradient::slotSetShape(int shape) -{ - m_shape = static_cast(shape); -} - -void KisToolGradient::slotSetRepeat(int repeat) -{ - m_repeat = static_cast(repeat); -} - -void KisToolGradient::slotSetReverse(bool state) -{ - m_reverse = state; -} - -void KisToolGradient::slotSetAntiAliasThreshold(double value) -{ - m_antiAliasThreshold = value; -} - -void KisToolGradient::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Gradient"), - "tool_gradient", TQt::Key_G, this, - TQT_SLOT(activate()), collection, - name()); - m_action->setToolTip(i18n("Draw a gradient")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_gradient.moc" - diff --git a/chalk/plugins/tools/defaulttools/kis_tool_gradient.cpp b/chalk/plugins/tools/defaulttools/kis_tool_gradient.cpp new file mode 100644 index 00000000..b8f72a3b --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_gradient.cpp @@ -0,0 +1,309 @@ +/* + * kis_tool_gradient.cpp - part of Chalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2003 Boudewijn Rempt + * Copyright (c) 2004 Adrian Page + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_canvas_subject.h" +#include "kis_cmb_composite.h" +#include "kis_cursor.h" +#include "kis_double_widget.h" +#include "kis_gradient_painter.h" +#include "kis_move_event.h" +#include "kis_painter.h" +#include "kis_progress_display_interface.h" +#include "kis_tool_gradient.h" +#include "kis_undo_adapter.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolGradient::KisToolGradient() + : super(i18n("Gradient")), + m_dragging( false ) +{ + setName("tool_gradient"); + setCursor(KisCursor::load("tool_gradient_cursor.png", 6, 6)); + + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + + m_reverse = false; + m_shape = KisGradientPainter::GradientShapeLinear; + m_repeat = KisGradientPainter::GradientRepeatNone; + m_antiAliasThreshold = 0.2; +} + +KisToolGradient::~KisToolGradient() +{ +} + +void KisToolGradient::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolGradient::paint(KisCanvasPainter& gc) +{ + if (m_dragging) + paintLine(gc); +} + +void KisToolGradient::paint(KisCanvasPainter& gc, const TQRect&) +{ + if (m_dragging) + paintLine(gc); +} + +void KisToolGradient::buttonPress(KisButtonPressEvent *e) +{ + if (!m_subject || !m_subject->currentImg()) { + return; + } + + if (e->button() == Qt::LeftButton) { + m_dragging = true; + m_startPos = e->pos(); + m_endPos = e->pos(); + } +} + +void KisToolGradient::move(KisMoveEvent *e) +{ + if (m_dragging) { + if (m_startPos != m_endPos) { + paintLine(); + } + + if ((e->state() & TQt::ShiftButton) == TQt::ShiftButton) { + m_endPos = straightLine(e->pos()); + } + else { + m_endPos = e->pos(); + } + + paintLine(); + } +} + +void KisToolGradient::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_dragging && e->button() == Qt::LeftButton) { + + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + m_dragging = false; + + if (m_startPos == m_endPos) { + controller->updateCanvas(); + m_dragging = false; + return; + } + + if ((e->state() & TQt::ShiftButton) == TQt::ShiftButton) { + m_endPos = straightLine(e->pos()); + } + else { + m_endPos = e->pos(); + } + + KisPaintDeviceSP device; + + if (img && (device = img->activeDevice())) { + + KisGradientPainter painter(device); + + if (img->undo()) painter.beginTransaction(i18n("Gradient")); + + painter.setPaintColor(m_subject->fgColor()); + painter.setGradient(*(m_subject->currentGradient())); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + + KisProgressDisplayInterface *progress = m_subject->progressDisplay(); + + if (progress) { + progress->setSubject(&painter, true, true); + } + + bool painted = painter.paintGradient(m_startPos, m_endPos, m_shape, m_repeat, m_antiAliasThreshold, m_reverse, 0, 0, m_subject->currentImg()->width(), m_subject->currentImg()->height()); + + if (painted) { + // does whole thing at moment + device->setDirty(painter.dirtyRect()); + + notifyModified(); + + if (img->undo()) { + img->undoAdapter()->addCommand(painter.endTransaction()); + } + } + + /* remove remains of the line drawn while moving */ + if (controller->kiscanvas()) { + controller->kiscanvas()->update(); + } + + } + } +} + +KisPoint KisToolGradient::straightLine(KisPoint point) +{ + KisPoint comparison = point - m_startPos; + KisPoint result; + + if ( fabs(comparison.x()) > fabs(comparison.y())) { + result.setX(point.x()); + result.setY(m_startPos.y()); + } else { + result.setX( m_startPos.x() ); + result.setY( point.y() ); + } + + return result; +} + +void KisToolGradient::paintLine() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + paintLine(gc); + } +} + +void KisToolGradient::paintLine(KisCanvasPainter& gc) +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + + KisPoint start = controller->windowToView(m_startPos); + KisPoint end = controller->windowToView(m_endPos); + + RasterOp op = gc.rasterOp(); + TQPen old = gc.pen(); + TQPen pen(TQt::SolidLine); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawLine(start.floorTQPoint(), end.floorTQPoint()); + gc.setRasterOp(op); + gc.setPen(old); + } +} + +TQWidget* KisToolGradient::createOptionWidget(TQWidget* parent) +{ + TQWidget *widget = super::createOptionWidget(parent); + TQ_CHECK_PTR(widget); + + m_lbShape = new TQLabel(i18n("Shape:"), widget); + m_lbRepeat = new TQLabel(i18n("Repeat:"), widget); + + m_ckReverse = new TQCheckBox(i18n("Reverse"), widget, "reverse_check"); + connect(m_ckReverse, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetReverse(bool))); + + m_cmbShape = new TQComboBox(false, widget, "shape_combo"); + connect(m_cmbShape, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotSetShape(int))); + m_cmbShape->insertItem(i18n("Linear")); + m_cmbShape->insertItem(i18n("Bi-Linear")); + m_cmbShape->insertItem(i18n("Radial")); + m_cmbShape->insertItem(i18n("Square")); + m_cmbShape->insertItem(i18n("Conical")); + m_cmbShape->insertItem(i18n("Conical Symmetric")); + + m_cmbRepeat = new TQComboBox(false, widget, "repeat_combo"); + connect(m_cmbRepeat, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotSetRepeat(int))); + m_cmbRepeat->insertItem(i18n("None")); + m_cmbRepeat->insertItem(i18n("Forwards")); + m_cmbRepeat->insertItem(i18n("Alternating")); + + addOptionWidgetOption(m_cmbShape, m_lbShape); + + addOptionWidgetOption(m_cmbRepeat, m_lbRepeat); + + addOptionWidgetOption(m_ckReverse); + + m_lbAntiAliasThreshold = new TQLabel(i18n("Anti-alias threshold:"), widget); + + m_slAntiAliasThreshold = new KDoubleNumInput(widget, "threshold_slider"); + m_slAntiAliasThreshold->setRange( 0, 1); + m_slAntiAliasThreshold->setValue(m_antiAliasThreshold); + connect(m_slAntiAliasThreshold, TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(slotSetAntiAliasThreshold(double))); + + addOptionWidgetOption(m_slAntiAliasThreshold, m_lbAntiAliasThreshold); + + return widget; +} + +void KisToolGradient::slotSetShape(int shape) +{ + m_shape = static_cast(shape); +} + +void KisToolGradient::slotSetRepeat(int repeat) +{ + m_repeat = static_cast(repeat); +} + +void KisToolGradient::slotSetReverse(bool state) +{ + m_reverse = state; +} + +void KisToolGradient::slotSetAntiAliasThreshold(double value) +{ + m_antiAliasThreshold = value; +} + +void KisToolGradient::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Gradient"), + "tool_gradient", TQt::Key_G, this, + TQT_SLOT(activate()), collection, + name()); + m_action->setToolTip(i18n("Draw a gradient")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_gradient.moc" + diff --git a/chalk/plugins/tools/defaulttools/kis_tool_line.cc b/chalk/plugins/tools/defaulttools/kis_tool_line.cc deleted file mode 100644 index 4e118ccc..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_line.cc +++ /dev/null @@ -1,254 +0,0 @@ -/* - * kis_tool_line.cc - part of Krayon - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2002 Patrick Julien - * Copyright (c) 2003 Boudewijn Rempt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_cursor.h" -#include "kis_painter.h" -#include "kis_tool_line.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop_registry.h" -#include "kis_canvas_subject.h" -#include "kis_undo_adapter.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_layer.h" - -KisToolLine::KisToolLine() - : super(i18n("Line")), - m_dragging( false ) -{ - setName("tool_line"); - setCursor(KisCursor::load("tool_line_cursor.png", 6, 6)); - - m_painter = 0; - m_currentImage = 0; - m_startPos = KisPoint(0, 0); - m_endPos = KisPoint(0, 0); -} - -KisToolLine::~KisToolLine() -{ -} - -void KisToolLine::update(KisCanvasSubject *subject) -{ - m_subject = subject; - m_currentImage = subject->currentImg(); - - super::update(m_subject); -} - - -void KisToolLine::paint(KisCanvasPainter& gc) -{ - if (m_dragging) - paintLine(gc, TQRect()); -} - -void KisToolLine::paint(KisCanvasPainter& gc, const TQRect& rc) -{ - if (m_dragging) - paintLine(gc, rc); -} - -void KisToolLine::buttonPress(KisButtonPressEvent *e) -{ - if (!m_subject || !m_currentImage) return; - - if (!m_subject->currentBrush()) return; - - if (e->button() == Qt::LeftButton) { - m_dragging = true; - //KisCanvasController *controller = m_subject->canvasController(); - m_startPos = e->pos(); //controller->windowToView(e->pos()); - m_endPos = e->pos(); //controller->windowToView(e->pos()); - } -} - -void KisToolLine::move(KisMoveEvent *e) -{ - if (m_dragging) { - if (m_startPos != m_endPos) - paintLine(); - //KisCanvasController *controller = m_subject->canvasController(); - - if (e->state() & TQt::AltButton) { - KisPoint trans = e->pos() - m_endPos; - m_startPos += trans; - m_endPos += trans; - } else if (e->state() & TQt::ShiftButton) - m_endPos = straightLine(e->pos()); - else - m_endPos = e->pos();//controller->windowToView(e->pos()); - paintLine(); - } -} - -void KisToolLine::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_dragging && e->button() == Qt::LeftButton) { - m_dragging = false; - KisCanvasController *controller = m_subject->canvasController(); - KisImageSP img = m_subject->currentImg(); - - if (m_startPos == m_endPos) { - controller->updateCanvas(); - m_dragging = false; - return; - } - - if ((e->state() & TQt::ShiftButton) == TQt::ShiftButton) { - m_endPos = straightLine(e->pos()); - } - else { - m_endPos = e->pos(); - } - - KisPaintDeviceSP device; - if (m_currentImage && - (device = m_currentImage->activeDevice()) && - m_subject && - m_subject->currentBrush()) - { - delete m_painter; - m_painter = new KisPainter( device ); - TQ_CHECK_PTR(m_painter); - - if (m_currentImage->undo()) m_painter->beginTransaction(i18n("Line")); - - m_painter->setPaintColor(m_subject->fgColor()); - m_painter->setBrush(m_subject->currentBrush()); - m_painter->setOpacity(m_opacity); - m_painter->setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), m_painter); - m_painter->setPaintOp(op); // Painter takes ownership - m_painter->paintLine(m_startPos, PRESSURE_DEFAULT, 0, 0, m_endPos, PRESSURE_DEFAULT, 0, 0); - device->setDirty( m_painter->dirtyRect() ); - notifyModified(); - - /* remove remains of the line drawn while moving */ - if (controller->kiscanvas()) { - controller->kiscanvas()->update(); - } - - if (m_currentImage->undo() && m_painter) { - m_currentImage->undoAdapter()->addCommand(m_painter->endTransaction()); - } - delete m_painter; - m_painter = 0; - } else { - if (m_painter) - controller->updateCanvas(m_painter->dirtyRect()); // Removes the last remaining line. - } - } - -} - -KisPoint KisToolLine::straightLine(KisPoint point) -{ - KisPoint comparison = point - m_startPos; - KisPoint result; - - if ( fabs(comparison.x()) > fabs(comparison.y())) { - result.setX(point.x()); - result.setY(m_startPos.y()); - } else { - result.setX( m_startPos.x() ); - result.setY( point.y() ); - } - - return result; -} - -void KisToolLine::paintLine() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - TQRect rc; - - paintLine(gc, rc); - } -} - -void KisToolLine::paintLine(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::SolidLine); - KisPoint start; - KisPoint end; - -// Q_ASSERT(controller); - start = controller->windowToView(m_startPos); - end = controller->windowToView(m_endPos); -// start.setX(start.x() - controller->horzValue()); -// start.setY(start.y() - controller->vertValue()); -// end.setX(end.x() - controller->horzValue()); -// end.setY(end.y() - controller->vertValue()); -// end.setX((end.x() - start.x())); -// end.setY((end.y() - start.y())); -// start *= m_subject->zoomFactor(); -// end *= m_subject->zoomFactor(); - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawLine(start.floorTQPoint(), end.floorTQPoint()); - gc.setRasterOp(op); - gc.setPen(old); - } -} - -void KisToolLine::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Line"), - "tool_line", TQt::Key_L, this, - TQT_SLOT(activate()), collection, - name()); - m_action->setToolTip(i18n("Draw a line")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQString KisToolLine::quickHelp() const { - return i18n("Alt+Drag will move the origin of the currently displayed line around, Shift+Drag will force you to draw straight lines"); -} - -#include "kis_tool_line.moc" - diff --git a/chalk/plugins/tools/defaulttools/kis_tool_line.cpp b/chalk/plugins/tools/defaulttools/kis_tool_line.cpp new file mode 100644 index 00000000..87cb9390 --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_line.cpp @@ -0,0 +1,254 @@ +/* + * kis_tool_line.cpp - part of Krayon + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2003 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_cursor.h" +#include "kis_painter.h" +#include "kis_tool_line.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop_registry.h" +#include "kis_canvas_subject.h" +#include "kis_undo_adapter.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_layer.h" + +KisToolLine::KisToolLine() + : super(i18n("Line")), + m_dragging( false ) +{ + setName("tool_line"); + setCursor(KisCursor::load("tool_line_cursor.png", 6, 6)); + + m_painter = 0; + m_currentImage = 0; + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); +} + +KisToolLine::~KisToolLine() +{ +} + +void KisToolLine::update(KisCanvasSubject *subject) +{ + m_subject = subject; + m_currentImage = subject->currentImg(); + + super::update(m_subject); +} + + +void KisToolLine::paint(KisCanvasPainter& gc) +{ + if (m_dragging) + paintLine(gc, TQRect()); +} + +void KisToolLine::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + if (m_dragging) + paintLine(gc, rc); +} + +void KisToolLine::buttonPress(KisButtonPressEvent *e) +{ + if (!m_subject || !m_currentImage) return; + + if (!m_subject->currentBrush()) return; + + if (e->button() == Qt::LeftButton) { + m_dragging = true; + //KisCanvasController *controller = m_subject->canvasController(); + m_startPos = e->pos(); //controller->windowToView(e->pos()); + m_endPos = e->pos(); //controller->windowToView(e->pos()); + } +} + +void KisToolLine::move(KisMoveEvent *e) +{ + if (m_dragging) { + if (m_startPos != m_endPos) + paintLine(); + //KisCanvasController *controller = m_subject->canvasController(); + + if (e->state() & TQt::AltButton) { + KisPoint trans = e->pos() - m_endPos; + m_startPos += trans; + m_endPos += trans; + } else if (e->state() & TQt::ShiftButton) + m_endPos = straightLine(e->pos()); + else + m_endPos = e->pos();//controller->windowToView(e->pos()); + paintLine(); + } +} + +void KisToolLine::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_dragging && e->button() == Qt::LeftButton) { + m_dragging = false; + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + if (m_startPos == m_endPos) { + controller->updateCanvas(); + m_dragging = false; + return; + } + + if ((e->state() & TQt::ShiftButton) == TQt::ShiftButton) { + m_endPos = straightLine(e->pos()); + } + else { + m_endPos = e->pos(); + } + + KisPaintDeviceSP device; + if (m_currentImage && + (device = m_currentImage->activeDevice()) && + m_subject && + m_subject->currentBrush()) + { + delete m_painter; + m_painter = new KisPainter( device ); + TQ_CHECK_PTR(m_painter); + + if (m_currentImage->undo()) m_painter->beginTransaction(i18n("Line")); + + m_painter->setPaintColor(m_subject->fgColor()); + m_painter->setBrush(m_subject->currentBrush()); + m_painter->setOpacity(m_opacity); + m_painter->setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), m_painter); + m_painter->setPaintOp(op); // Painter takes ownership + m_painter->paintLine(m_startPos, PRESSURE_DEFAULT, 0, 0, m_endPos, PRESSURE_DEFAULT, 0, 0); + device->setDirty( m_painter->dirtyRect() ); + notifyModified(); + + /* remove remains of the line drawn while moving */ + if (controller->kiscanvas()) { + controller->kiscanvas()->update(); + } + + if (m_currentImage->undo() && m_painter) { + m_currentImage->undoAdapter()->addCommand(m_painter->endTransaction()); + } + delete m_painter; + m_painter = 0; + } else { + if (m_painter) + controller->updateCanvas(m_painter->dirtyRect()); // Removes the last remaining line. + } + } + +} + +KisPoint KisToolLine::straightLine(KisPoint point) +{ + KisPoint comparison = point - m_startPos; + KisPoint result; + + if ( fabs(comparison.x()) > fabs(comparison.y())) { + result.setX(point.x()); + result.setY(m_startPos.y()); + } else { + result.setX( m_startPos.x() ); + result.setY( point.y() ); + } + + return result; +} + +void KisToolLine::paintLine() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintLine(gc, rc); + } +} + +void KisToolLine::paintLine(KisCanvasPainter& gc, const TQRect&) +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + RasterOp op = gc.rasterOp(); + TQPen old = gc.pen(); + TQPen pen(TQt::SolidLine); + KisPoint start; + KisPoint end; + +// Q_ASSERT(controller); + start = controller->windowToView(m_startPos); + end = controller->windowToView(m_endPos); +// start.setX(start.x() - controller->horzValue()); +// start.setY(start.y() - controller->vertValue()); +// end.setX(end.x() - controller->horzValue()); +// end.setY(end.y() - controller->vertValue()); +// end.setX((end.x() - start.x())); +// end.setY((end.y() - start.y())); +// start *= m_subject->zoomFactor(); +// end *= m_subject->zoomFactor(); + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawLine(start.floorTQPoint(), end.floorTQPoint()); + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolLine::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Line"), + "tool_line", TQt::Key_L, this, + TQT_SLOT(activate()), collection, + name()); + m_action->setToolTip(i18n("Draw a line")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQString KisToolLine::quickHelp() const { + return i18n("Alt+Drag will move the origin of the currently displayed line around, Shift+Drag will force you to draw straight lines"); +} + +#include "kis_tool_line.moc" + diff --git a/chalk/plugins/tools/defaulttools/kis_tool_move.cc b/chalk/plugins/tools/defaulttools/kis_tool_move.cpp similarity index 100% rename from chalk/plugins/tools/defaulttools/kis_tool_move.cc rename to chalk/plugins/tools/defaulttools/kis_tool_move.cpp diff --git a/chalk/plugins/tools/defaulttools/kis_tool_pan.cc b/chalk/plugins/tools/defaulttools/kis_tool_pan.cpp similarity index 100% rename from chalk/plugins/tools/defaulttools/kis_tool_pan.cc rename to chalk/plugins/tools/defaulttools/kis_tool_pan.cpp diff --git a/chalk/plugins/tools/defaulttools/kis_tool_rectangle.cc b/chalk/plugins/tools/defaulttools/kis_tool_rectangle.cc deleted file mode 100644 index 852d2c0e..00000000 --- a/chalk/plugins/tools/defaulttools/kis_tool_rectangle.cc +++ /dev/null @@ -1,187 +0,0 @@ -/* - * kis_tool_rectangle.cc - part of Chalk - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2002 Patrick Julien - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2004 Clarence Dang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include - -#include -#include -#include - -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_canvas_controller.h" -#include "kis_canvas_subject.h" -#include "kis_move_event.h" -#include "kis_painter.h" -#include "kis_paintop_registry.h" -#include "kis_tool_rectangle.h" -#include "kis_undo_adapter.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_layer.h" - -KisToolRectangle::KisToolRectangle() - : super(i18n ("Rectangle")), - m_dragging (false), - m_currentImage (0) -{ - setName("tool_rectangle"); - setCursor(KisCursor::load("tool_rectangle_cursor.png", 6, 6)); -} - -KisToolRectangle::~KisToolRectangle() -{ -} - -void KisToolRectangle::update (KisCanvasSubject *subject) -{ - super::update (subject); - if (m_subject) - m_currentImage = m_subject->currentImg (); -} - -void KisToolRectangle::buttonPress(KisButtonPressEvent *event) -{ - if (m_currentImage && event->button() == Qt::LeftButton) { - m_dragging = true; - m_dragStart = m_dragCenter = m_dragEnd = event->pos(); - draw(m_dragStart, m_dragEnd); - } -} - -void KisToolRectangle::move(KisMoveEvent *event) -{ - if (m_dragging) { - // erase old lines on canvas - draw(m_dragStart, m_dragEnd); - // move (alt) or resize rectangle - if (event->state() & TQt::AltButton) { - KisPoint trans = event->pos() - m_dragEnd; - m_dragStart += trans; - m_dragEnd += trans; - } else { - KisPoint diag = event->pos() - (event->state() & TQt::ControlButton - ? m_dragCenter : m_dragStart); - // square? - if (event->state() & TQt::ShiftButton) { - double size = TQMAX(fabs(diag.x()), fabs(diag.y())); - double w = diag.x() < 0 ? -size : size; - double h = diag.y() < 0 ? -size : size; - diag = KisPoint(w, h); - } - - // resize around center point? - if (event->state() & TQt::ControlButton) { - m_dragStart = m_dragCenter - diag; - m_dragEnd = m_dragCenter + diag; - } else { - m_dragEnd = m_dragStart + diag; - } - } - // draw new lines on canvas - draw(m_dragStart, m_dragEnd); - m_dragCenter = KisPoint((m_dragStart.x() + m_dragEnd.x()) / 2, - (m_dragStart.y() + m_dragEnd.y()) / 2); - } -} - -void KisToolRectangle::buttonRelease(KisButtonReleaseEvent *event) -{ - if (!m_subject) - return; - - if (!m_currentImage) - return; - - KisPaintDeviceSP device = m_currentImage->activeDevice (); - if (!device) return; - - if (m_dragging && event->button() == Qt::LeftButton) { - // erase old lines on canvas - draw(m_dragStart, m_dragEnd); - m_dragging = false; - - if (m_dragStart == m_dragEnd) - return; - - if (!m_currentImage) - return; - - - KisPainter painter (device); - if (m_currentImage->undo()) painter.beginTransaction (i18n ("Rectangle")); - - painter.setPaintColor(m_subject->fgColor()); - painter.setBackgroundColor(m_subject->bgColor()); - painter.setFillStyle(fillStyle()); - painter.setBrush(m_subject->currentBrush()); - painter.setPattern(m_subject->currentPattern()); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); - painter.setPaintOp(op); - - painter.paintRect(m_dragStart, m_dragEnd, PRESSURE_DEFAULT/*event->pressure()*/, event->xTilt(), event->yTilt()); - device->setDirty( painter.dirtyRect() ); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); - } - } -} - -void KisToolRectangle::draw(const KisPoint& start, const KisPoint& end ) -{ - if (!m_subject) - return; - - KisCanvasController *controller = m_subject->canvasController (); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter p (canvas); - - p.setRasterOp (TQt::NotROP); - p.drawRect (TQRect (controller->windowToView (start).floorTQPoint(), controller->windowToView (end).floorTQPoint())); - p.end (); -} - -void KisToolRectangle::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Rectangle"), - "tool_rectangle", - TQt::Key_F6, - this, - TQT_SLOT(activate()), - collection, - name()); - m_action->setToolTip(i18n("Draw a rectangle")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_rectangle.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_rectangle.cpp b/chalk/plugins/tools/defaulttools/kis_tool_rectangle.cpp new file mode 100644 index 00000000..69e306ec --- /dev/null +++ b/chalk/plugins/tools/defaulttools/kis_tool_rectangle.cpp @@ -0,0 +1,187 @@ +/* + * kis_tool_rectangle.cpp - part of Chalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * Copyright (c) 2004 Clarence Dang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include +#include + +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_canvas_controller.h" +#include "kis_canvas_subject.h" +#include "kis_move_event.h" +#include "kis_painter.h" +#include "kis_paintop_registry.h" +#include "kis_tool_rectangle.h" +#include "kis_undo_adapter.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_layer.h" + +KisToolRectangle::KisToolRectangle() + : super(i18n ("Rectangle")), + m_dragging (false), + m_currentImage (0) +{ + setName("tool_rectangle"); + setCursor(KisCursor::load("tool_rectangle_cursor.png", 6, 6)); +} + +KisToolRectangle::~KisToolRectangle() +{ +} + +void KisToolRectangle::update (KisCanvasSubject *subject) +{ + super::update (subject); + if (m_subject) + m_currentImage = m_subject->currentImg (); +} + +void KisToolRectangle::buttonPress(KisButtonPressEvent *event) +{ + if (m_currentImage && event->button() == Qt::LeftButton) { + m_dragging = true; + m_dragStart = m_dragCenter = m_dragEnd = event->pos(); + draw(m_dragStart, m_dragEnd); + } +} + +void KisToolRectangle::move(KisMoveEvent *event) +{ + if (m_dragging) { + // erase old lines on canvas + draw(m_dragStart, m_dragEnd); + // move (alt) or resize rectangle + if (event->state() & TQt::AltButton) { + KisPoint trans = event->pos() - m_dragEnd; + m_dragStart += trans; + m_dragEnd += trans; + } else { + KisPoint diag = event->pos() - (event->state() & TQt::ControlButton + ? m_dragCenter : m_dragStart); + // square? + if (event->state() & TQt::ShiftButton) { + double size = TQMAX(fabs(diag.x()), fabs(diag.y())); + double w = diag.x() < 0 ? -size : size; + double h = diag.y() < 0 ? -size : size; + diag = KisPoint(w, h); + } + + // resize around center point? + if (event->state() & TQt::ControlButton) { + m_dragStart = m_dragCenter - diag; + m_dragEnd = m_dragCenter + diag; + } else { + m_dragEnd = m_dragStart + diag; + } + } + // draw new lines on canvas + draw(m_dragStart, m_dragEnd); + m_dragCenter = KisPoint((m_dragStart.x() + m_dragEnd.x()) / 2, + (m_dragStart.y() + m_dragEnd.y()) / 2); + } +} + +void KisToolRectangle::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject) + return; + + if (!m_currentImage) + return; + + KisPaintDeviceSP device = m_currentImage->activeDevice (); + if (!device) return; + + if (m_dragging && event->button() == Qt::LeftButton) { + // erase old lines on canvas + draw(m_dragStart, m_dragEnd); + m_dragging = false; + + if (m_dragStart == m_dragEnd) + return; + + if (!m_currentImage) + return; + + + KisPainter painter (device); + if (m_currentImage->undo()) painter.beginTransaction (i18n ("Rectangle")); + + painter.setPaintColor(m_subject->fgColor()); + painter.setBackgroundColor(m_subject->bgColor()); + painter.setFillStyle(fillStyle()); + painter.setBrush(m_subject->currentBrush()); + painter.setPattern(m_subject->currentPattern()); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); + painter.setPaintOp(op); + + painter.paintRect(m_dragStart, m_dragEnd, PRESSURE_DEFAULT/*event->pressure()*/, event->xTilt(), event->yTilt()); + device->setDirty( painter.dirtyRect() ); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); + } + } +} + +void KisToolRectangle::draw(const KisPoint& start, const KisPoint& end ) +{ + if (!m_subject) + return; + + KisCanvasController *controller = m_subject->canvasController (); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter p (canvas); + + p.setRasterOp (TQt::NotROP); + p.drawRect (TQRect (controller->windowToView (start).floorTQPoint(), controller->windowToView (end).floorTQPoint())); + p.end (); +} + +void KisToolRectangle::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Rectangle"), + "tool_rectangle", + TQt::Key_F6, + this, + TQT_SLOT(activate()), + collection, + name()); + m_action->setToolTip(i18n("Draw a rectangle")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_rectangle.moc" diff --git a/chalk/plugins/tools/defaulttools/kis_tool_text.cc b/chalk/plugins/tools/defaulttools/kis_tool_text.cpp similarity index 100% rename from chalk/plugins/tools/defaulttools/kis_tool_text.cc rename to chalk/plugins/tools/defaulttools/kis_tool_text.cpp diff --git a/chalk/plugins/tools/defaulttools/kis_tool_zoom.cc b/chalk/plugins/tools/defaulttools/kis_tool_zoom.cpp similarity index 100% rename from chalk/plugins/tools/defaulttools/kis_tool_zoom.cc rename to chalk/plugins/tools/defaulttools/kis_tool_zoom.cpp diff --git a/chalk/plugins/tools/selectiontools/Makefile.am b/chalk/plugins/tools/selectiontools/Makefile.am index febfd514..0f1b8474 100644 --- a/chalk/plugins/tools/selectiontools/Makefile.am +++ b/chalk/plugins/tools/selectiontools/Makefile.am @@ -9,10 +9,10 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkselectiontools_la_SOURCES = kis_tool_move_selection.cc \ - kis_tool_select_brush.cc kis_tool_select_contiguous.cc kis_tool_select_elliptical.cc \ - kis_tool_select_eraser.cc kis_tool_select_outline.cc kis_tool_select_polygonal.cc \ - kis_tool_select_rectangular.cc selection_tools.cc +chalkselectiontools_la_SOURCES = kis_tool_move_selection.cpp \ + kis_tool_select_brush.cpp kis_tool_select_contiguous.cpp kis_tool_select_elliptical.cpp \ + kis_tool_select_eraser.cpp kis_tool_select_outline.cpp kis_tool_select_polygonal.cpp \ + kis_tool_select_rectangular.cpp selection_tools.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalkselectiontools.la diff --git a/chalk/plugins/tools/selectiontools/kis_tool_move_selection.cc b/chalk/plugins/tools/selectiontools/kis_tool_move_selection.cpp similarity index 100% rename from chalk/plugins/tools/selectiontools/kis_tool_move_selection.cc rename to chalk/plugins/tools/selectiontools/kis_tool_move_selection.cpp diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc deleted file mode 100644 index acc90362..00000000 --- a/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* - * kis_tool_select_brush.cc - part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_brush.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_cmb_composite.h" -#include "kis_cursor.h" -#include "kis_doc.h" -#include "kis_paintop.h" -#include "kis_paintop_registry.h" -#include "kis_move_event.h" -#include "kis_painter.h" -#include "kis_selection.h" -#include "kis_tool_select_brush.h" -#include "kis_types.h" -#include "kis_layer.h" -#include "kis_view.h" -#include "kis_selection_options.h" -#include "kis_selected_transaction.h" - -KisToolSelectBrush::KisToolSelectBrush() - : super(i18n("SelectBrush")) -{ - setName("tool_select_brush"); - m_optWidget = 0; - setCursor(KisCursor::load("tool_brush_selection_cursor.png", 5, 5)); - m_paintOnSelection = true; -} - -KisToolSelectBrush::~KisToolSelectBrush() -{ -} - -void KisToolSelectBrush::activate() -{ - super::activate(); - - if (!m_optWidget) - return; - - m_optWidget->slotActivated(); -} - -void KisToolSelectBrush::initPaint(KisEvent* /*e*/) -{ - if (!m_currentImage || !m_currentImage->activeDevice()) return; - - m_mode = PAINT; - m_dragDist = 0; - - // Create painter - KisPaintDeviceSP dev = m_currentImage->activeDevice(); - if (m_painter) - delete m_painter; - bool hasSelection = dev->hasSelection(); - if (m_currentImage->undo()) m_transaction = new KisSelectedTransaction(i18n("Selection Brush"), dev); - if(! hasSelection) - { - dev->selection()->clear(); - dev->emitSelectionChanged(); - } - KisSelectionSP selection = dev->selection(); - - m_target = selection; - m_painter = new KisPainter(selection.data()); - TQ_CHECK_PTR(m_painter); - m_painter->setPaintColor(KisColor(TQt::black, selection->colorSpace())); - m_painter->setBrush(m_subject->currentBrush()); - m_painter->setOpacity(OPACITY_OPAQUE);//m_subject->fgColor().colorSpace()->intensity8(m_subject->fgColor().data())); - m_painter->setCompositeOp(COMPOSITE_OVER); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, painter()); - painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. - - // Set the cursor -- ideally. this should be a mask created from the brush, - // now that X11 can handle colored cursors. -#if 0 - // Setting cursors has no effect until the tool is selected again; this - // should be fixed. - setCursor(KisCursor::brushCursor()); -#endif -} - -void KisToolSelectBrush::endPaint() -{ - m_mode = HOVER; - if (m_currentImage && m_currentImage->activeLayer()) { - if (m_currentImage->undo() && m_painter) { - // If painting in mouse release, make sure painter - // is destructed or end()ed - m_currentImage->undoAdapter()->addCommand(m_transaction); - } - delete m_painter; - m_painter = 0; - if (m_currentImage->activeDevice()) - m_currentImage->activeDevice()->emitSelectionChanged(); - notifyModified(); - } -} - - -void KisToolSelectBrush::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Selection Brush"), - "tool_brush_selection", "Ctrl+Shift+B", this, - TQT_SLOT(activate()), collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setToolTip(i18n("Paint a selection")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQWidget* KisToolSelectBrush::createOptionWidget(TQWidget* parent) -{ - Q_UNUSED(parent); - // Commented out due to the fact that this doesn't actually work if you change the action -#if 0 - m_optWidget = new KisSelectionOptions(parent, m_subject); - TQ_CHECK_PTR(m_optWidget); - m_optWidget->setCaption(i18n("Selection Brush")); - - TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); - l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); - - return m_optWidget; -#endif - return 0; -} - -TQWidget* KisToolSelectBrush::optionWidget() -{ - return m_optWidget; -} - -#include "kis_tool_select_brush.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cpp b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cpp new file mode 100644 index 00000000..ba80434f --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cpp @@ -0,0 +1,168 @@ +/* + * kis_tool_select_brush.cpp - part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_brush.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_cmb_composite.h" +#include "kis_cursor.h" +#include "kis_doc.h" +#include "kis_paintop.h" +#include "kis_paintop_registry.h" +#include "kis_move_event.h" +#include "kis_painter.h" +#include "kis_selection.h" +#include "kis_tool_select_brush.h" +#include "kis_types.h" +#include "kis_layer.h" +#include "kis_view.h" +#include "kis_selection_options.h" +#include "kis_selected_transaction.h" + +KisToolSelectBrush::KisToolSelectBrush() + : super(i18n("SelectBrush")) +{ + setName("tool_select_brush"); + m_optWidget = 0; + setCursor(KisCursor::load("tool_brush_selection_cursor.png", 5, 5)); + m_paintOnSelection = true; +} + +KisToolSelectBrush::~KisToolSelectBrush() +{ +} + +void KisToolSelectBrush::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectBrush::initPaint(KisEvent* /*e*/) +{ + if (!m_currentImage || !m_currentImage->activeDevice()) return; + + m_mode = PAINT; + m_dragDist = 0; + + // Create painter + KisPaintDeviceSP dev = m_currentImage->activeDevice(); + if (m_painter) + delete m_painter; + bool hasSelection = dev->hasSelection(); + if (m_currentImage->undo()) m_transaction = new KisSelectedTransaction(i18n("Selection Brush"), dev); + if(! hasSelection) + { + dev->selection()->clear(); + dev->emitSelectionChanged(); + } + KisSelectionSP selection = dev->selection(); + + m_target = selection; + m_painter = new KisPainter(selection.data()); + TQ_CHECK_PTR(m_painter); + m_painter->setPaintColor(KisColor(TQt::black, selection->colorSpace())); + m_painter->setBrush(m_subject->currentBrush()); + m_painter->setOpacity(OPACITY_OPAQUE);//m_subject->fgColor().colorSpace()->intensity8(m_subject->fgColor().data())); + m_painter->setCompositeOp(COMPOSITE_OVER); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, painter()); + painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. + + // Set the cursor -- ideally. this should be a mask created from the brush, + // now that X11 can handle colored cursors. +#if 0 + // Setting cursors has no effect until the tool is selected again; this + // should be fixed. + setCursor(KisCursor::brushCursor()); +#endif +} + +void KisToolSelectBrush::endPaint() +{ + m_mode = HOVER; + if (m_currentImage && m_currentImage->activeLayer()) { + if (m_currentImage->undo() && m_painter) { + // If painting in mouse release, make sure painter + // is destructed or end()ed + m_currentImage->undoAdapter()->addCommand(m_transaction); + } + delete m_painter; + m_painter = 0; + if (m_currentImage->activeDevice()) + m_currentImage->activeDevice()->emitSelectionChanged(); + notifyModified(); + } +} + + +void KisToolSelectBrush::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Selection Brush"), + "tool_brush_selection", "Ctrl+Shift+B", this, + TQT_SLOT(activate()), collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Paint a selection")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectBrush::createOptionWidget(TQWidget* parent) +{ + Q_UNUSED(parent); + // Commented out due to the fact that this doesn't actually work if you change the action +#if 0 + m_optWidget = new KisSelectionOptions(parent, m_subject); + TQ_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Selection Brush")); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +#endif + return 0; +} + +TQWidget* KisToolSelectBrush::optionWidget() +{ + return m_optWidget; +} + +#include "kis_tool_select_brush.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cpp similarity index 100% rename from chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cc rename to chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cpp diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc deleted file mode 100644 index def162ef..00000000 --- a/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc +++ /dev/null @@ -1,321 +0,0 @@ -/* - * kis_tool_select_elliptical.cc -- part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_autobrush_resource.h" -#include "kis_canvas_controller.h" -#include "kis_canvas_subject.h" -#include "kis_cursor.h" -#include "kis_image.h" -#include "kis_painter.h" -#include "kis_tool_select_elliptical.h" -#include "kis_layer.h" -#include "kis_undo_adapter.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_selection.h" -#include "kis_selection_options.h" -#include "kis_selected_transaction.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" - -KisToolSelectElliptical::KisToolSelectElliptical() - : super(i18n("Elliptical Select")) -{ - setName("tool_select_elliptical"); - setCursor(KisCursor::load("tool_elliptical_selection_cursor.png", 6, 6)); - - m_subject = 0; - m_selecting = false; - m_centerPos = KisPoint(0, 0); - m_startPos = KisPoint(0, 0); - m_endPos = KisPoint(0, 0); - m_optWidget = 0; - m_selectAction = SELECTION_ADD; -} - -KisToolSelectElliptical::~KisToolSelectElliptical() -{ -} - -void KisToolSelectElliptical::activate() -{ - super::activate(); - - if (!m_optWidget) - return; - - m_optWidget->slotActivated(); -} - -void KisToolSelectElliptical::update(KisCanvasSubject *subject) -{ - m_subject = subject; - super::update(m_subject); -} - -void KisToolSelectElliptical::paint(KisCanvasPainter& gc) -{ - if (m_selecting) - paintOutline(gc, TQRect()); -} - -void KisToolSelectElliptical::paint(KisCanvasPainter& gc, const TQRect& rc) -{ - if (m_selecting) - paintOutline(gc, rc); -} - -void KisToolSelectElliptical::clearSelection() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisImageSP img = m_subject->currentImg(); - - Q_ASSERT(controller); - -// if (img && img->floatingSelection().data() != 0) { -// img->unsetFloatingSelection(); -// controller->canvas()->update(); -// } - - m_startPos = KisPoint(0, 0); - m_endPos = KisPoint(0, 0); - m_selecting = false; - } -} - -void KisToolSelectElliptical::buttonPress(KisButtonPressEvent *e) -{ - if (m_subject) { - KisImageSP img = m_subject->currentImg(); - - if (img && img->activeDevice() && e->button() == Qt::LeftButton) { - clearSelection(); - m_startPos = m_endPos = m_centerPos = e->pos(); - m_selecting = true; - paintOutline(); - } - } -} - -void KisToolSelectElliptical::move(KisMoveEvent *e) -{ - if (m_subject && m_selecting) { - paintOutline(); - // move (alt) or resize ellipse - if (e->state() & TQt::AltButton) { - KisPoint trans = e->pos() - m_endPos; - m_startPos += trans; - m_endPos += trans; - } else { - KisPoint diag = e->pos() - (e->state() & TQt::ControlButton - ? m_centerPos : m_startPos); - // circle? - if (e->state() & TQt::ShiftButton) { - double size = TQMAX(fabs(diag.x()), fabs(diag.y())); - double w = diag.x() < 0 ? -size : size; - double h = diag.y() < 0 ? -size : size; - diag = KisPoint(w, h); - } - - // resize around center point? - if (e->state() & TQt::ControlButton) { - m_startPos = m_centerPos - diag; - m_endPos = m_centerPos + diag; - } else { - m_endPos = m_startPos + diag; - } - } - paintOutline(); - m_centerPos = KisPoint((m_startPos.x() + m_endPos.x()) / 2, - (m_startPos.y() + m_endPos.y()) / 2); - } -} - -void KisToolSelectElliptical::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_subject && m_selecting && e->button() == Qt::LeftButton) { - - paintOutline(); - - if (m_startPos == m_endPos) { - clearSelection(); - } else { - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - KisImageSP img = m_subject->currentImg(); - - if (!img) - return; - - if (m_endPos.y() < 0) - m_endPos.setY(0); - - if (m_endPos.y() > img->height()) - m_endPos.setY(img->height()); - - if (m_endPos.x() < 0) - m_endPos.setX(0); - - if (m_endPos.x() > img->width()) - m_endPos.setX(img->width()); - - if (img && img->activeDevice()) { - KisPaintDeviceSP dev = img->activeDevice(); - KisSelectedTransaction *t = 0; - if (img->undo()) t = new KisSelectedTransaction(i18n("Elliptical Selection"), dev); - - bool hasSelection = dev->hasSelection(); - if(! hasSelection) - { - dev->selection()->clear(); - if(m_selectAction==SELECTION_SUBTRACT) - dev->selection()->invert(); - } - TQRect rc( m_startPos.floorTQPoint(), m_endPos.floorTQPoint()); - rc = rc.normalize(); - - KisSelectionSP tmpSel = new KisSelection(dev); - KisAutobrushCircleShape shape(rc.width(),rc.height(), 1, 1); - TQ_UINT8 value; - for (int y = 0; y <= rc.height(); y++) - for (int x = 0; x <= rc.width(); x++) - { - value = MAX_SELECTED - shape.valueAt(x,y); - tmpSel->setSelected( x+rc.x(), y+rc.y(), value); - } - switch(m_selectAction) - { - case SELECTION_ADD: - dev->addSelection(tmpSel); - break; - case SELECTION_SUBTRACT: - dev->subtractSelection(tmpSel); - break; - } - - if(hasSelection) { - dev->setDirty(rc); - dev->emitSelectionChanged(rc); - } else { - dev->setDirty(); - dev->emitSelectionChanged(); - } - - if (img->undo()) - img->undoAdapter()->addCommand(t); - - TQApplication::restoreOverrideCursor(); - } - } - m_selecting = false; - } -} - -void KisToolSelectElliptical::paintOutline() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - TQRect rc; - - paintOutline(gc, rc); - } -} - -void KisToolSelectElliptical::paintOutline(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::DotLine); - TQPoint start; - TQPoint end; - - Q_ASSERT(controller); - start = controller->windowToView(m_startPos).floorTQPoint(); - end = controller->windowToView(m_endPos).floorTQPoint(); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawEllipse(TQRect(start, end)); - gc.setRasterOp(op); - gc.setPen(old); - } -} - -void KisToolSelectElliptical::slotSetAction(int action) { - if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) - m_selectAction =(enumSelectionMode)action; -} - -void KisToolSelectElliptical::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Elliptical Selection"), - "tool_elliptical_selection" , - TQt::Key_J, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setToolTip(i18n("Select an elliptical area")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQWidget* KisToolSelectElliptical::createOptionWidget(TQWidget* parent) -{ - m_optWidget = new KisSelectionOptions(parent, m_subject); - TQ_CHECK_PTR(m_optWidget); - m_optWidget->setCaption(i18n("Elliptical Selection")); - - connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); - - TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); - l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); - - return m_optWidget; -} - -TQWidget* KisToolSelectElliptical::optionWidget() -{ - return m_optWidget; -} - - - -#include "kis_tool_select_elliptical.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cpp b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cpp new file mode 100644 index 00000000..f85da332 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cpp @@ -0,0 +1,321 @@ +/* + * kis_tool_select_elliptical.cpp -- part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_autobrush_resource.h" +#include "kis_canvas_controller.h" +#include "kis_canvas_subject.h" +#include "kis_cursor.h" +#include "kis_image.h" +#include "kis_painter.h" +#include "kis_tool_select_elliptical.h" +#include "kis_layer.h" +#include "kis_undo_adapter.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_selection.h" +#include "kis_selection_options.h" +#include "kis_selected_transaction.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolSelectElliptical::KisToolSelectElliptical() + : super(i18n("Elliptical Select")) +{ + setName("tool_select_elliptical"); + setCursor(KisCursor::load("tool_elliptical_selection_cursor.png", 6, 6)); + + m_subject = 0; + m_selecting = false; + m_centerPos = KisPoint(0, 0); + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_optWidget = 0; + m_selectAction = SELECTION_ADD; +} + +KisToolSelectElliptical::~KisToolSelectElliptical() +{ +} + +void KisToolSelectElliptical::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectElliptical::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolSelectElliptical::paint(KisCanvasPainter& gc) +{ + if (m_selecting) + paintOutline(gc, TQRect()); +} + +void KisToolSelectElliptical::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + if (m_selecting) + paintOutline(gc, rc); +} + +void KisToolSelectElliptical::clearSelection() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + Q_ASSERT(controller); + +// if (img && img->floatingSelection().data() != 0) { +// img->unsetFloatingSelection(); +// controller->canvas()->update(); +// } + + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_selecting = false; + } +} + +void KisToolSelectElliptical::buttonPress(KisButtonPressEvent *e) +{ + if (m_subject) { + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice() && e->button() == Qt::LeftButton) { + clearSelection(); + m_startPos = m_endPos = m_centerPos = e->pos(); + m_selecting = true; + paintOutline(); + } + } +} + +void KisToolSelectElliptical::move(KisMoveEvent *e) +{ + if (m_subject && m_selecting) { + paintOutline(); + // move (alt) or resize ellipse + if (e->state() & TQt::AltButton) { + KisPoint trans = e->pos() - m_endPos; + m_startPos += trans; + m_endPos += trans; + } else { + KisPoint diag = e->pos() - (e->state() & TQt::ControlButton + ? m_centerPos : m_startPos); + // circle? + if (e->state() & TQt::ShiftButton) { + double size = TQMAX(fabs(diag.x()), fabs(diag.y())); + double w = diag.x() < 0 ? -size : size; + double h = diag.y() < 0 ? -size : size; + diag = KisPoint(w, h); + } + + // resize around center point? + if (e->state() & TQt::ControlButton) { + m_startPos = m_centerPos - diag; + m_endPos = m_centerPos + diag; + } else { + m_endPos = m_startPos + diag; + } + } + paintOutline(); + m_centerPos = KisPoint((m_startPos.x() + m_endPos.x()) / 2, + (m_startPos.y() + m_endPos.y()) / 2); + } +} + +void KisToolSelectElliptical::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_subject && m_selecting && e->button() == Qt::LeftButton) { + + paintOutline(); + + if (m_startPos == m_endPos) { + clearSelection(); + } else { + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisImageSP img = m_subject->currentImg(); + + if (!img) + return; + + if (m_endPos.y() < 0) + m_endPos.setY(0); + + if (m_endPos.y() > img->height()) + m_endPos.setY(img->height()); + + if (m_endPos.x() < 0) + m_endPos.setX(0); + + if (m_endPos.x() > img->width()) + m_endPos.setX(img->width()); + + if (img && img->activeDevice()) { + KisPaintDeviceSP dev = img->activeDevice(); + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Elliptical Selection"), dev); + + bool hasSelection = dev->hasSelection(); + if(! hasSelection) + { + dev->selection()->clear(); + if(m_selectAction==SELECTION_SUBTRACT) + dev->selection()->invert(); + } + TQRect rc( m_startPos.floorTQPoint(), m_endPos.floorTQPoint()); + rc = rc.normalize(); + + KisSelectionSP tmpSel = new KisSelection(dev); + KisAutobrushCircleShape shape(rc.width(),rc.height(), 1, 1); + TQ_UINT8 value; + for (int y = 0; y <= rc.height(); y++) + for (int x = 0; x <= rc.width(); x++) + { + value = MAX_SELECTED - shape.valueAt(x,y); + tmpSel->setSelected( x+rc.x(), y+rc.y(), value); + } + switch(m_selectAction) + { + case SELECTION_ADD: + dev->addSelection(tmpSel); + break; + case SELECTION_SUBTRACT: + dev->subtractSelection(tmpSel); + break; + } + + if(hasSelection) { + dev->setDirty(rc); + dev->emitSelectionChanged(rc); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (img->undo()) + img->undoAdapter()->addCommand(t); + + TQApplication::restoreOverrideCursor(); + } + } + m_selecting = false; + } +} + +void KisToolSelectElliptical::paintOutline() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintOutline(gc, rc); + } +} + +void KisToolSelectElliptical::paintOutline(KisCanvasPainter& gc, const TQRect&) +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + RasterOp op = gc.rasterOp(); + TQPen old = gc.pen(); + TQPen pen(TQt::DotLine); + TQPoint start; + TQPoint end; + + Q_ASSERT(controller); + start = controller->windowToView(m_startPos).floorTQPoint(); + end = controller->windowToView(m_endPos).floorTQPoint(); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawEllipse(TQRect(start, end)); + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolSelectElliptical::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + +void KisToolSelectElliptical::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Elliptical Selection"), + "tool_elliptical_selection" , + TQt::Key_J, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Select an elliptical area")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectElliptical::createOptionWidget(TQWidget* parent) +{ + m_optWidget = new KisSelectionOptions(parent, m_subject); + TQ_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Elliptical Selection")); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectElliptical::optionWidget() +{ + return m_optWidget; +} + + + +#include "kis_tool_select_elliptical.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc deleted file mode 100644 index af7f8d84..00000000 --- a/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* - * kis_tool_select_brush.cc - part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_brush.h" -#include "kis_layer.h" -#include "kis_paintop.h" -#include "kis_paintop_registry.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_cmb_composite.h" -#include "kis_cursor.h" -#include "kis_doc.h" -#include "kis_move_event.h" -#include "kis_painter.h" -#include "kis_selection.h" -#include "kis_tool_select_eraser.h" -#include "kis_types.h" -#include "kis_view.h" -#include "kis_selection_options.h" - -KisToolSelectEraser::KisToolSelectEraser() - : super(i18n("SelectEraser")) -{ - setName("tool_select_eraser"); - setCursor(KisCursor::load("tool_eraser_selection_cursor.png", 5, 5)); - m_optWidget = 0; - m_paintOnSelection = true; -} - -KisToolSelectEraser::~KisToolSelectEraser() -{ -} - -void KisToolSelectEraser::activate() -{ - super::activate(); - - if (!m_optWidget) - return; - - m_optWidget->slotActivated(); -} - -void KisToolSelectEraser::initPaint(KisEvent */*e*/) -{ - if (!m_currentImage || !m_currentImage->activeDevice()) return; - - m_mode = PAINT; - m_dragDist = 0; - - // Create painter - KisPaintDeviceSP dev = m_currentImage->activeDevice(); - - if (dev == 0) return; - - if (m_painter) - delete m_painter; - if(! dev->hasSelection()) - { - dev->selection()->clear(); - dev->emitSelectionChanged(); - } - KisSelectionSP selection = dev->selection(); - - m_target = selection; - m_painter = new KisPainter(selection.data()); - TQ_CHECK_PTR(m_painter); - m_painter->beginTransaction(i18n("Selection Eraser")); - m_painter->setPaintColor(KisColor(TQt::white, selection->colorSpace())); - m_painter->setBrush(m_subject->currentBrush()); - m_painter->setOpacity(OPACITY_OPAQUE); - m_painter->setCompositeOp(COMPOSITE_ERASE); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("eraser", 0, painter()); - painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. - - // Set the cursor -- ideally. this should be a mask created from the brush, - // now that X11 can handle colored cursors. -#if 0 - // Setting cursors has no effect until the tool is selected again; this - // should be fixed. - setCursor(KisCursor::eraserCursor()); -#endif -} - -void KisToolSelectEraser::endPaint() { - super::endPaint(); - if (m_currentImage && m_currentImage->activeDevice()) - m_currentImage->activeDevice()->emitSelectionChanged(); -} -void KisToolSelectEraser::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("Selection &Eraser"), - "tool_eraser_selection", "Ctrl+Shift+E", this, - TQT_SLOT(activate()), collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setToolTip(i18n("Erase parts of a selection")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQWidget* KisToolSelectEraser::createOptionWidget(TQWidget* parent) -{ - Q_UNUSED(parent); - // Commented out due to the fact that this doesn't actually work if you change the action -#if 0 - m_optWidget = new KisSelectionOptions(parent, m_subject); - TQ_CHECK_PTR(m_optWidget); - m_optWidget->setCaption(i18n("Selection Eraser")); - - TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); - l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); - - return m_optWidget; -#endif - return 0; -} - -TQWidget* KisToolSelectEraser::optionWidget() -{ - return m_optWidget; -} - -#include "kis_tool_select_eraser.moc" - diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cpp b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cpp new file mode 100644 index 00000000..9cfef0a8 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cpp @@ -0,0 +1,156 @@ +/* + * kis_tool_select_brush.cpp - part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_brush.h" +#include "kis_layer.h" +#include "kis_paintop.h" +#include "kis_paintop_registry.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_cmb_composite.h" +#include "kis_cursor.h" +#include "kis_doc.h" +#include "kis_move_event.h" +#include "kis_painter.h" +#include "kis_selection.h" +#include "kis_tool_select_eraser.h" +#include "kis_types.h" +#include "kis_view.h" +#include "kis_selection_options.h" + +KisToolSelectEraser::KisToolSelectEraser() + : super(i18n("SelectEraser")) +{ + setName("tool_select_eraser"); + setCursor(KisCursor::load("tool_eraser_selection_cursor.png", 5, 5)); + m_optWidget = 0; + m_paintOnSelection = true; +} + +KisToolSelectEraser::~KisToolSelectEraser() +{ +} + +void KisToolSelectEraser::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectEraser::initPaint(KisEvent */*e*/) +{ + if (!m_currentImage || !m_currentImage->activeDevice()) return; + + m_mode = PAINT; + m_dragDist = 0; + + // Create painter + KisPaintDeviceSP dev = m_currentImage->activeDevice(); + + if (dev == 0) return; + + if (m_painter) + delete m_painter; + if(! dev->hasSelection()) + { + dev->selection()->clear(); + dev->emitSelectionChanged(); + } + KisSelectionSP selection = dev->selection(); + + m_target = selection; + m_painter = new KisPainter(selection.data()); + TQ_CHECK_PTR(m_painter); + m_painter->beginTransaction(i18n("Selection Eraser")); + m_painter->setPaintColor(KisColor(TQt::white, selection->colorSpace())); + m_painter->setBrush(m_subject->currentBrush()); + m_painter->setOpacity(OPACITY_OPAQUE); + m_painter->setCompositeOp(COMPOSITE_ERASE); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("eraser", 0, painter()); + painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. + + // Set the cursor -- ideally. this should be a mask created from the brush, + // now that X11 can handle colored cursors. +#if 0 + // Setting cursors has no effect until the tool is selected again; this + // should be fixed. + setCursor(KisCursor::eraserCursor()); +#endif +} + +void KisToolSelectEraser::endPaint() { + super::endPaint(); + if (m_currentImage && m_currentImage->activeDevice()) + m_currentImage->activeDevice()->emitSelectionChanged(); +} +void KisToolSelectEraser::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("Selection &Eraser"), + "tool_eraser_selection", "Ctrl+Shift+E", this, + TQT_SLOT(activate()), collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Erase parts of a selection")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectEraser::createOptionWidget(TQWidget* parent) +{ + Q_UNUSED(parent); + // Commented out due to the fact that this doesn't actually work if you change the action +#if 0 + m_optWidget = new KisSelectionOptions(parent, m_subject); + TQ_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Selection Eraser")); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +#endif + return 0; +} + +TQWidget* KisToolSelectEraser::optionWidget() +{ + return m_optWidget; +} + +#include "kis_tool_select_eraser.moc" + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_outline.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_outline.cpp similarity index 100% rename from chalk/plugins/tools/selectiontools/kis_tool_select_outline.cc rename to chalk/plugins/tools/selectiontools/kis_tool_select_outline.cpp diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cpp similarity index 100% rename from chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cc rename to chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cpp diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc deleted file mode 100644 index 09d33866..00000000 --- a/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc +++ /dev/null @@ -1,323 +0,0 @@ - -/* - * kis_tool_select_rectangular.cc -- part of Chalk - * - * Copyright (c) 1999 Michael Koch - * 2001 John Califf - * 2002 Patrick Julien - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_canvas_controller.h" -#include "kis_canvas_subject.h" -#include "kis_cursor.h" -#include "kis_image.h" -#include "kis_painter.h" -#include "kis_layer.h" -#include "kis_tool_select_rectangular.h" -#include "kis_undo_adapter.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_selection.h" -#include "kis_selection_options.h" -#include -#include "kis_canvas.h" -#include "kis_canvas_painter.h" - -KisToolSelectRectangular::KisToolSelectRectangular() - : super(i18n("Rectangular Select Tool")) -{ - setName("tool_select_rectangular"); - setCursor(KisCursor::load("tool_rectangular_selection_cursor.png", 6, 6)); - m_subject = 0; - m_selecting = false; - m_centerPos = KisPoint(0, 0); - m_startPos = KisPoint(0, 0); - m_endPos = KisPoint(0, 0); - m_optWidget = 0; - m_selectAction = SELECTION_ADD; -} - -KisToolSelectRectangular::~KisToolSelectRectangular() -{ -} - -void KisToolSelectRectangular::activate() -{ - super::activate(); - - if (!m_optWidget) - return; - - m_optWidget->slotActivated(); -} - -void KisToolSelectRectangular::update(KisCanvasSubject *subject) -{ - m_subject = subject; - super::update(m_subject); -} - -void KisToolSelectRectangular::paint(KisCanvasPainter& gc) -{ - if (m_selecting) - paintOutline(gc, TQRect()); -} - -void KisToolSelectRectangular::paint(KisCanvasPainter& gc, const TQRect& rc) -{ - if (m_selecting) - paintOutline(gc, rc); -} - -void KisToolSelectRectangular::clearSelection() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisImageSP img = m_subject->currentImg(); - - Q_ASSERT(controller); - - m_centerPos = KisPoint(0, 0); - m_startPos = KisPoint(0, 0); - m_endPos = KisPoint(0, 0); - m_selecting = false; - } -} - -void KisToolSelectRectangular::buttonPress(KisButtonPressEvent *e) -{ - if (m_subject) { - KisImageSP img = m_subject->currentImg(); - - if (img && img->activeDevice() && e->button() == Qt::LeftButton) { - clearSelection(); - m_startPos = m_endPos = m_centerPos = e->pos(); - m_selecting = true; - } - } -} - -void KisToolSelectRectangular::move(KisMoveEvent *e) -{ - if (m_subject && m_selecting) { - paintOutline(); - // move (alt) or resize rectangle - if (e->state() & TQt::AltButton) { - KisPoint trans = e->pos() - m_endPos; - m_startPos += trans; - m_endPos += trans; - } else { - KisPoint diag = e->pos() - (e->state() & TQt::ControlButton - ? m_centerPos : m_startPos); - // square? - if (e->state() & TQt::ShiftButton) { - double size = TQMAX(fabs(diag.x()), fabs(diag.y())); - double w = diag.x() < 0 ? -size : size; - double h = diag.y() < 0 ? -size : size; - diag = KisPoint(w, h); - } - - // resize around center point? - if (e->state() & TQt::ControlButton) { - m_startPos = m_centerPos - diag; - m_endPos = m_centerPos + diag; - } else { - m_endPos = m_startPos + diag; - } - } - paintOutline(); - m_centerPos = KisPoint((m_startPos.x() + m_endPos.x()) / 2, - (m_startPos.y() + m_endPos.y()) / 2); - } -} - -void KisToolSelectRectangular::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_subject && m_selecting && e->button() == Qt::LeftButton) { - - paintOutline(); - - if (m_startPos == m_endPos) { - clearSelection(); - } else { - KisImageSP img = m_subject->currentImg(); - - if (!img) - return; - - if (m_endPos.y() < 0) - m_endPos.setY(0); - - if (m_endPos.y() > img->height()) - m_endPos.setY(img->height()); - - if (m_endPos.x() < 0) - m_endPos.setX(0); - - if (m_endPos.x() > img->width()) - m_endPos.setX(img->width()); - if (img && img->activeDevice()) { - - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - KisPaintDeviceSP dev = img->activeDevice(); - bool hasSelection = dev->hasSelection(); - - KisSelectedTransaction *t = 0; - if (img->undo()) t = new KisSelectedTransaction(i18n("Rectangular Selection"), dev); - KisSelectionSP selection = dev->selection(); - TQRect rc(m_startPos.floorTQPoint(), m_endPos.floorTQPoint()); - rc = rc.normalize(); - - // We don't want the border of the 'rectangle' to be included in our selection - rc.setSize(rc.size() - TQSize(1,1)); - - if(! hasSelection) - { - selection->clear(); - if(m_selectAction==SELECTION_SUBTRACT) - selection->invert(); - } - - KisSelectionSP tmpSel = new KisSelection(dev); - tmpSel->select(rc); - switch(m_selectAction) - { - case SELECTION_ADD: - dev->addSelection(tmpSel); - break; - case SELECTION_SUBTRACT: - dev->subtractSelection(tmpSel); - break; - default: - break; - } - - - if(hasSelection) { - dev->setDirty(rc); - dev->emitSelectionChanged(rc); - } else { - dev->setDirty(); - dev->emitSelectionChanged(); - } - - if (img->undo()) - img->undoAdapter()->addCommand(t); - - KisCanvasController *controller = m_subject -> canvasController(); - controller -> kiscanvas() -> update(); - - TQApplication::restoreOverrideCursor(); - } - } - - m_selecting = false; - } -} - -void KisToolSelectRectangular::paintOutline() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - TQRect rc; - - paintOutline(gc, rc); - } -} - -void KisToolSelectRectangular::paintOutline(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::DotLine); - TQPoint start; - TQPoint end; - - Q_ASSERT(controller); - start = controller->windowToView(m_startPos.floorTQPoint()); - end = controller->windowToView(m_endPos.floorTQPoint()); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawRect(TQRect(start, end)); - gc.setRasterOp(op); - gc.setPen(old); - } -} - -void KisToolSelectRectangular::slotSetAction(int action) { - if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) - m_selectAction =(enumSelectionMode)action; -} - -void KisToolSelectRectangular::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Rectangular Selection"), - "tool_rect_selection", - TQt::Key_R, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setExclusiveGroup("tools"); - m_action->setToolTip(i18n("Select a rectangular area")); - m_ownAction = true; - } -} - -TQWidget* KisToolSelectRectangular::createOptionWidget(TQWidget* parent) -{ - m_optWidget = new KisSelectionOptions(parent, m_subject); - TQ_CHECK_PTR(m_optWidget); - m_optWidget->setCaption(i18n("Rectangular Selection")); - - connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); - - TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); - l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); - - return m_optWidget; -} - -TQWidget* KisToolSelectRectangular::optionWidget() -{ - return m_optWidget; -} - - - - -#include "kis_tool_select_rectangular.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cpp b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cpp new file mode 100644 index 00000000..5a6772ba --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cpp @@ -0,0 +1,323 @@ + +/* + * kis_tool_select_rectangular.cpp -- part of Chalk + * + * Copyright (c) 1999 Michael Koch + * 2001 John Califf + * 2002 Patrick Julien + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_canvas_controller.h" +#include "kis_canvas_subject.h" +#include "kis_cursor.h" +#include "kis_image.h" +#include "kis_painter.h" +#include "kis_layer.h" +#include "kis_tool_select_rectangular.h" +#include "kis_undo_adapter.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_selection.h" +#include "kis_selection_options.h" +#include +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolSelectRectangular::KisToolSelectRectangular() + : super(i18n("Rectangular Select Tool")) +{ + setName("tool_select_rectangular"); + setCursor(KisCursor::load("tool_rectangular_selection_cursor.png", 6, 6)); + m_subject = 0; + m_selecting = false; + m_centerPos = KisPoint(0, 0); + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_optWidget = 0; + m_selectAction = SELECTION_ADD; +} + +KisToolSelectRectangular::~KisToolSelectRectangular() +{ +} + +void KisToolSelectRectangular::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectRectangular::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolSelectRectangular::paint(KisCanvasPainter& gc) +{ + if (m_selecting) + paintOutline(gc, TQRect()); +} + +void KisToolSelectRectangular::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + if (m_selecting) + paintOutline(gc, rc); +} + +void KisToolSelectRectangular::clearSelection() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + Q_ASSERT(controller); + + m_centerPos = KisPoint(0, 0); + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_selecting = false; + } +} + +void KisToolSelectRectangular::buttonPress(KisButtonPressEvent *e) +{ + if (m_subject) { + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice() && e->button() == Qt::LeftButton) { + clearSelection(); + m_startPos = m_endPos = m_centerPos = e->pos(); + m_selecting = true; + } + } +} + +void KisToolSelectRectangular::move(KisMoveEvent *e) +{ + if (m_subject && m_selecting) { + paintOutline(); + // move (alt) or resize rectangle + if (e->state() & TQt::AltButton) { + KisPoint trans = e->pos() - m_endPos; + m_startPos += trans; + m_endPos += trans; + } else { + KisPoint diag = e->pos() - (e->state() & TQt::ControlButton + ? m_centerPos : m_startPos); + // square? + if (e->state() & TQt::ShiftButton) { + double size = TQMAX(fabs(diag.x()), fabs(diag.y())); + double w = diag.x() < 0 ? -size : size; + double h = diag.y() < 0 ? -size : size; + diag = KisPoint(w, h); + } + + // resize around center point? + if (e->state() & TQt::ControlButton) { + m_startPos = m_centerPos - diag; + m_endPos = m_centerPos + diag; + } else { + m_endPos = m_startPos + diag; + } + } + paintOutline(); + m_centerPos = KisPoint((m_startPos.x() + m_endPos.x()) / 2, + (m_startPos.y() + m_endPos.y()) / 2); + } +} + +void KisToolSelectRectangular::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_subject && m_selecting && e->button() == Qt::LeftButton) { + + paintOutline(); + + if (m_startPos == m_endPos) { + clearSelection(); + } else { + KisImageSP img = m_subject->currentImg(); + + if (!img) + return; + + if (m_endPos.y() < 0) + m_endPos.setY(0); + + if (m_endPos.y() > img->height()) + m_endPos.setY(img->height()); + + if (m_endPos.x() < 0) + m_endPos.setX(0); + + if (m_endPos.x() > img->width()) + m_endPos.setX(img->width()); + if (img && img->activeDevice()) { + + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisPaintDeviceSP dev = img->activeDevice(); + bool hasSelection = dev->hasSelection(); + + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Rectangular Selection"), dev); + KisSelectionSP selection = dev->selection(); + TQRect rc(m_startPos.floorTQPoint(), m_endPos.floorTQPoint()); + rc = rc.normalize(); + + // We don't want the border of the 'rectangle' to be included in our selection + rc.setSize(rc.size() - TQSize(1,1)); + + if(! hasSelection) + { + selection->clear(); + if(m_selectAction==SELECTION_SUBTRACT) + selection->invert(); + } + + KisSelectionSP tmpSel = new KisSelection(dev); + tmpSel->select(rc); + switch(m_selectAction) + { + case SELECTION_ADD: + dev->addSelection(tmpSel); + break; + case SELECTION_SUBTRACT: + dev->subtractSelection(tmpSel); + break; + default: + break; + } + + + if(hasSelection) { + dev->setDirty(rc); + dev->emitSelectionChanged(rc); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (img->undo()) + img->undoAdapter()->addCommand(t); + + KisCanvasController *controller = m_subject -> canvasController(); + controller -> kiscanvas() -> update(); + + TQApplication::restoreOverrideCursor(); + } + } + + m_selecting = false; + } +} + +void KisToolSelectRectangular::paintOutline() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintOutline(gc, rc); + } +} + +void KisToolSelectRectangular::paintOutline(KisCanvasPainter& gc, const TQRect&) +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + RasterOp op = gc.rasterOp(); + TQPen old = gc.pen(); + TQPen pen(TQt::DotLine); + TQPoint start; + TQPoint end; + + Q_ASSERT(controller); + start = controller->windowToView(m_startPos.floorTQPoint()); + end = controller->windowToView(m_endPos.floorTQPoint()); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawRect(TQRect(start, end)); + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolSelectRectangular::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + +void KisToolSelectRectangular::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Rectangular Selection"), + "tool_rect_selection", + TQt::Key_R, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setExclusiveGroup("tools"); + m_action->setToolTip(i18n("Select a rectangular area")); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectRectangular::createOptionWidget(TQWidget* parent) +{ + m_optWidget = new KisSelectionOptions(parent, m_subject); + TQ_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Rectangular Selection")); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectRectangular::optionWidget() +{ + return m_optWidget; +} + + + + +#include "kis_tool_select_rectangular.moc" diff --git a/chalk/plugins/tools/selectiontools/selection_tools.cc b/chalk/plugins/tools/selectiontools/selection_tools.cc deleted file mode 100644 index 8407a076..00000000 --- a/chalk/plugins/tools/selectiontools/selection_tools.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * selection_tools.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "selection_tools.h" - -#include "kis_tool_select_outline.h" -#include "kis_tool_select_polygonal.h" -#include "kis_tool_select_rectangular.h" -#include "kis_tool_select_contiguous.h" -#include "kis_tool_select_elliptical.h" -#include "kis_tool_select_eraser.h" -#include "kis_tool_select_brush.h" -#include "kis_tool_move_selection.h" - -typedef KGenericFactory SelectionToolsFactory; -K_EXPORT_COMPONENT_FACTORY( chalkselectiontools, SelectionToolsFactory( "chalk" ) ) - - -SelectionTools::SelectionTools(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(SelectionToolsFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast(parent); - r->add(new KisToolSelectOutlineFactory()); - r->add(new KisToolSelectPolygonalFactory()); - r->add(new KisToolSelectRectangularFactory()); - r->add(new KisToolSelectBrushFactory()); - r->add(new KisToolSelectContiguousFactory()); - r->add(new KisToolSelectEllipticalFactory()); - r->add(new KisToolSelectEraserFactory()); - r->add(new KisToolMoveSelectionFactory()); - } -} - -SelectionTools::~SelectionTools() -{ -} - -#include "selection_tools.moc" diff --git a/chalk/plugins/tools/selectiontools/selection_tools.cpp b/chalk/plugins/tools/selectiontools/selection_tools.cpp new file mode 100644 index 00000000..f34a3b34 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/selection_tools.cpp @@ -0,0 +1,77 @@ +/* + * selection_tools.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "selection_tools.h" + +#include "kis_tool_select_outline.h" +#include "kis_tool_select_polygonal.h" +#include "kis_tool_select_rectangular.h" +#include "kis_tool_select_contiguous.h" +#include "kis_tool_select_elliptical.h" +#include "kis_tool_select_eraser.h" +#include "kis_tool_select_brush.h" +#include "kis_tool_move_selection.h" + +typedef KGenericFactory SelectionToolsFactory; +K_EXPORT_COMPONENT_FACTORY( chalkselectiontools, SelectionToolsFactory( "chalk" ) ) + + +SelectionTools::SelectionTools(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(SelectionToolsFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(parent); + r->add(new KisToolSelectOutlineFactory()); + r->add(new KisToolSelectPolygonalFactory()); + r->add(new KisToolSelectRectangularFactory()); + r->add(new KisToolSelectBrushFactory()); + r->add(new KisToolSelectContiguousFactory()); + r->add(new KisToolSelectEllipticalFactory()); + r->add(new KisToolSelectEraserFactory()); + r->add(new KisToolMoveSelectionFactory()); + } +} + +SelectionTools::~SelectionTools() +{ +} + +#include "selection_tools.moc" diff --git a/chalk/plugins/tools/tool_crop/Makefile.am b/chalk/plugins/tools/tool_crop/Makefile.am index fe320b84..5bf3c1f6 100644 --- a/chalk/plugins/tools/tool_crop/Makefile.am +++ b/chalk/plugins/tools/tool_crop/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalktoolcrop_la_SOURCES = \ wdg_tool_crop.ui \ - tool_crop.cc \ - kis_tool_crop.cc + tool_crop.cpp \ + kis_tool_crop.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolcrop.la diff --git a/chalk/plugins/tools/tool_crop/kis_tool_crop.cc b/chalk/plugins/tools/tool_crop/kis_tool_crop.cc deleted file mode 100644 index 11a47590..00000000 --- a/chalk/plugins/tools/tool_crop/kis_tool_crop.cc +++ /dev/null @@ -1,925 +0,0 @@ -/* - * kis_tool_crop.cc -- part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2005 Michael Thaler - * Copyright (c) 2006 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kis_tool_crop.h" -#include "wdg_tool_crop.h" - -#include "kis_canvas.h" -#include "kis_canvas_painter.h" - - - -KisToolCrop::KisToolCrop() - : super(i18n("Crop")) -{ - setName("tool_crop"); - m_cropCursor = KisCursor::load("tool_crop_cursor.png", 6, 6); - setCursor(m_cropCursor); - m_subject = 0; - m_selecting = false; - m_rectCrop = TQRect(0, 0, 0, 0); - m_handleSize = 13; - m_haveCropSelection = false; - m_optWidget = 0; -} - -KisToolCrop::~KisToolCrop() -{ -} - -void KisToolCrop::update(KisCanvasSubject *subject) -{ - m_subject = subject; - super::update(m_subject); -} - -void KisToolCrop::activate() -{ - super::activate(); - - // No current crop rectangle, try to use the selection of the device to make a rectangle - if (m_subject && m_subject->currentImg() && m_subject->currentImg()->activeDevice()) { - KisPaintDeviceSP device = m_subject->currentImg()->activeDevice(); - if (!device->hasSelection()) { - //m_rectCrop = m_subject->currentImg()->bounds(); - //validateSelection(); - m_haveCropSelection = false; - m_selecting = false; - } - else { - - m_rectCrop = device->selection()->selectedRect(); - validateSelection(); - crop(); - } - } -} - -void KisToolCrop::deactivate() -{ - clearRect(); -} - - -void KisToolCrop::paint(KisCanvasPainter& gc) -{ - paintOutlineWithHandles(gc, TQRect()); -} - -void KisToolCrop::paint(KisCanvasPainter& gc, const TQRect& rc) -{ - paintOutlineWithHandles(gc, rc); -} - -void KisToolCrop::clearRect() -{ - kdDebug() << "Clearing\n"; - if (m_subject) { - - KisCanvasController *controller = m_subject->canvasController(); - KisImageSP img = m_subject->currentImg(); - - Q_ASSERT(controller); - - controller->kiscanvas()->update(); - - m_rectCrop = TQRect(0,0,0,0); - - updateWidgetValues(); - m_selecting = false; - } -} - -void KisToolCrop::buttonPress(KisButtonPressEvent *e) -{ - if (m_subject) { - KisImageSP img = m_subject->currentImg(); - - if (img && img->activeDevice() && e->button() == Qt::LeftButton) { - - TQPoint pos = e->pos().floorTQPoint(); - TQRect b = img->bounds(); - - if (pos.x() < b.x()) - pos.setX(b.x()); - else if (pos.x() > b.x() + b.width()) - pos.setX(b.x() + b.width()); - - if (pos.y() < b.y()) - pos.setY(b.y()); - else if (pos.y() > b.y() + b.height()) - pos.setY(b.y() + b.height()); - - m_selecting = true; - - if( !m_haveCropSelection ) //if the selection is not set - { - m_rectCrop = TQRect( pos.x(), pos.y(), 0, 0); - paintOutlineWithHandles(); - } - else - { - KisCanvasController *controller = m_subject->canvasController(); - m_mouseOnHandleType = mouseOnHandle(controller ->windowToView(pos)); - m_dragStart = pos; - } - - updateWidgetValues(); - } - } -} - -void KisToolCrop::move(KisMoveEvent *e) -{ - if ( m_subject && m_subject->currentImg()) - { - if( m_selecting ) //if the user selects - { - if( !m_haveCropSelection ) //if the cropSelection is not yet set - { - paintOutlineWithHandles(); - - m_rectCrop.setBottomRight( e->pos().floorTQPoint()); - - KisImageSP image = m_subject->currentImg(); - - m_rectCrop.setRight( TQMIN(m_rectCrop.right(), image->width())); - m_rectCrop.setBottom( TQMIN(m_rectCrop.bottom(), image->width())); - m_rectCrop = m_rectCrop.normalize(); - - paintOutlineWithHandles(); - } - else //if the crop selection is set - { - m_dragStop = e->pos().floorTQPoint(); - if (m_mouseOnHandleType != None && m_dragStart != m_dragStop ) { - - - TQ_INT32 imageWidth = m_subject->currentImg()->width(); - TQ_INT32 imageHeight = m_subject->currentImg()->height(); - - paintOutlineWithHandles(); - - TQPoint pos = e->pos().floorTQPoint(); - if( m_mouseOnHandleType == Inside ) - { - m_rectCrop.moveBy( ( m_dragStop.x() - m_dragStart.x() ), ( m_dragStop.y() - m_dragStart.y() ) ); - if( m_rectCrop.left() < 0 ) - { - m_rectCrop.moveLeft( 0 ); - } - if( m_rectCrop.right() > imageWidth ) - { - m_rectCrop.moveRight( imageWidth ); - } - if( m_rectCrop.top() < 0 ) - { - m_rectCrop.moveTop( 0 ); - } - if( m_rectCrop.bottom() > imageHeight ) - { - m_rectCrop.moveBottom( imageHeight ); - } - } else if(m_optWidget->boolRatio->isChecked()) - { - TQPoint drag = m_dragStop - m_dragStart; - if( ! m_optWidget->boolWidth->isChecked() && !m_optWidget->boolHeight->isChecked() ) - { - switch (m_mouseOnHandleType) - { - case (UpperLeft): - { - TQ_INT32 dep = (drag.x() + drag.y()) / 2; - m_rectCrop.setTop( m_rectCrop.top() + dep ); - m_rectCrop.setLeft( (int) ( m_rectCrop.right() - m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); - } - break; - case (LowerRight): - { - TQ_INT32 dep = (drag.x() + drag.y()) / 2; - m_rectCrop.setBottom( m_rectCrop.bottom() + dep ); - m_rectCrop.setWidth( (int) ( m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); - break; - } - case (UpperRight): - { - TQ_INT32 dep = (drag.x() - drag.y()) / 2; - m_rectCrop.setTop( m_rectCrop.top() - dep ); - m_rectCrop.setWidth( (int) ( m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); - break; - } - case (LowerLeft): - { - TQ_INT32 dep = (drag.x() - drag.y()) / 2; - m_rectCrop.setBottom( m_rectCrop.bottom() - dep ); - m_rectCrop.setLeft( (int) ( m_rectCrop.right() - m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); - break; - } - case (Upper): - m_rectCrop.setTop( pos.y() + m_dy ); - m_rectCrop.setWidth( (int) (m_rectCrop.height() * m_optWidget->doubleRatio->value()) ); - break; - case (Lower): - m_rectCrop.setBottom( pos.y() + m_dy ); - m_rectCrop.setWidth( (int) (m_rectCrop.height() * m_optWidget->doubleRatio->value()) ); - break; - case (Left): - m_rectCrop.setLeft( pos.x() + m_dx ); - m_rectCrop.setHeight( (int) (m_rectCrop.width() / m_optWidget->doubleRatio->value()) ); - break; - case (Right): - m_rectCrop.setRight( pos.x() + m_dx ); - m_rectCrop.setHeight( (int) (m_rectCrop.width() / m_optWidget->doubleRatio->value()) ); - break; - case (Inside): // never happen - break; - } - } - } else { - if( m_optWidget->boolWidth->isChecked() ) - { - m_rectCrop.setWidth( m_optWidget->intWidth->value() + 1 ); - } else { - switch (m_mouseOnHandleType) - { - case (LowerLeft): - case (Left): - case (UpperLeft): - m_rectCrop.setLeft( pos.x() + m_dx ); - break; - case (Right): - case (UpperRight): - case (LowerRight): - m_rectCrop.setRight( pos.x() + m_dx ); - break; - default: - break; - } - } - if( m_optWidget->boolHeight->isChecked() ) - { - m_rectCrop.setHeight( m_optWidget->intHeight->value() + 1 ); - } else { - switch (m_mouseOnHandleType) - { - case (UpperLeft): - case (Upper): - case (UpperRight): - m_rectCrop.setTop( pos.y() + m_dy ); - break; - case (LowerRight): - case (LowerLeft): - case (Lower): - m_rectCrop.setBottom( pos.y() + m_dy ); - break; - default: - break; - } - } - } - if( m_rectCrop.height() < 0) - { - if( m_mouseOnHandleType == Lower) - m_mouseOnHandleType = Upper; - else if( m_mouseOnHandleType == LowerLeft) - m_mouseOnHandleType = UpperLeft; - else if( m_mouseOnHandleType == LowerRight) - m_mouseOnHandleType = UpperRight; - else if( m_mouseOnHandleType == Upper) - m_mouseOnHandleType = Lower; - else if( m_mouseOnHandleType == UpperLeft) - m_mouseOnHandleType = LowerLeft; - else if( m_mouseOnHandleType == UpperRight) - m_mouseOnHandleType = LowerRight; - } - if( m_rectCrop.width() < 0) - { - if( m_mouseOnHandleType == Right) - m_mouseOnHandleType = Left; - else if( m_mouseOnHandleType == UpperRight) - m_mouseOnHandleType = UpperLeft; - else if( m_mouseOnHandleType == LowerRight) - m_mouseOnHandleType = LowerLeft; - else if( m_mouseOnHandleType == Left) - m_mouseOnHandleType = Right; - else if( m_mouseOnHandleType == UpperLeft) - m_mouseOnHandleType = UpperRight; - else if( m_mouseOnHandleType == LowerLeft) - m_mouseOnHandleType = LowerRight; - } - - m_rectCrop = m_rectCrop.normalize(); - m_rectCrop = m_rectCrop.intersect( TQRect(0,0, imageWidth + 1, imageHeight + 1 ) ); - m_dragStart = e->pos().floorTQPoint(); - paintOutlineWithHandles(); - } - } - updateWidgetValues(); - } - else //if we are not selecting - { - if ( m_haveCropSelection ) //if the crop selection is set - { - KisCanvasController *controller = m_subject->canvasController(); - TQ_INT32 type = mouseOnHandle(controller->windowToView(e->pos().floorTQPoint())); - //set resize cursor if we are on one of the handles - setMoveResizeCursor(type); - } - } - } -} - -void KisToolCrop::updateWidgetValues(bool updateratio) -{ - TQRect r = realRectCrop(); - setOptionWidgetX(r.x()); - setOptionWidgetY(r.y()); - setOptionWidgetWidth(r.width() ); - setOptionWidgetHeight(r.height() ); - if(updateratio && !m_optWidget->boolRatio->isChecked() ) - setOptionWidgetRatio((double)r.width() / (double)r.height() ); -} - -void KisToolCrop::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_subject && m_subject->currentImg() && m_selecting && e->button() == Qt::LeftButton) { - - m_selecting = false; - m_haveCropSelection = true; - - paintOutlineWithHandles(); - validateSelection(); - paintOutlineWithHandles(); - } -} - -void KisToolCrop::doubleClick(KisDoubleClickEvent *) -{ - if (m_haveCropSelection) crop(); -} - -void KisToolCrop::validateSelection(bool updateratio) -{ - if (m_subject) { - KisImageSP image = m_subject->currentImg(); - - if (image) { - TQ_INT32 imageWidth = image->width(); - TQ_INT32 imageHeight = image->height(); - m_rectCrop.setLeft(TQMAX(0, m_rectCrop.left())); - m_rectCrop.setTop(TQMAX(0, m_rectCrop.top())); - m_rectCrop.setRight(TQMIN(imageWidth, m_rectCrop.right())); - m_rectCrop.setBottom(TQMIN(imageHeight, m_rectCrop.bottom())); - - updateWidgetValues(updateratio); - } - } -} - -void KisToolCrop::paintOutlineWithHandles() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - TQRect rc; - - paintOutlineWithHandles(gc, rc); - } -} - -void KisToolCrop::paintOutlineWithHandles(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject && (m_selecting || m_haveCropSelection)) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::SolidLine); - pen.setWidth(1); - TQPoint start; - TQPoint end; - - Q_ASSERT(controller); - start = controller->windowToView(m_rectCrop.topLeft()); - end = controller->windowToView(m_rectCrop.bottomRight()); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - //draw handles - m_handlesRegion = handles(TQRect(start, end)); - - TQ_INT32 startx; - TQ_INT32 starty; - TQ_INT32 endx; - TQ_INT32 endy; - if(start.x()<=end.x()) - { - startx=start.x(); - endx=end.x(); - } - else - { - startx=end.x(); - endx=start.x(); - } - if(start.y()<=end.y()) - { - starty=start.y(); - endy=end.y(); - } - else - { - starty=end.y(); - endy=start.y(); - } - //draw upper line of selection - gc.drawLine(startx + m_handleSize / 2 + 1, starty, startx + (endx - startx - m_handleSize) / 2 + 1, starty); - gc.drawLine(startx + (endx - startx + m_handleSize) / 2 + 1, starty, endx - m_handleSize / 2, starty); - //draw lower line of selection - gc.drawLine(startx + m_handleSize / 2 + 1, endy, startx + (endx - startx - m_handleSize) / 2 + 1, endy); - gc.drawLine(startx + (endx - startx + m_handleSize) / 2 + 1, endy, endx - m_handleSize / 2 , endy); - //draw right line of selection - gc.drawLine(startx, starty + m_handleSize / 2 + 1, startx, starty + (endy - starty - m_handleSize) / 2 + 1); - gc.drawLine(startx, starty + (endy - starty + m_handleSize) / 2 + 1, startx, endy - m_handleSize / 2); - //draw left line of selection - gc.drawLine(endx, starty + m_handleSize / 2 + 1, endx, starty + (endy - starty - m_handleSize) / 2 + 1); - gc.drawLine(endx, starty + (endy - starty + m_handleSize) / 2 + 1, endx, endy - m_handleSize / 2); - - //draw guides - gc.drawLine(0,endy,startx - m_handleSize / 2,endy); - gc.drawLine(startx,endy + m_handleSize / 2 + 1, startx, controller->kiscanvas()->height()); - gc.drawLine(endx,0,endx,starty - m_handleSize / 2); - gc.drawLine(endx + m_handleSize / 2 + 1,starty, controller->kiscanvas()->width(), starty); - TQMemArray rects = m_handlesRegion.rects (); - for (TQMemArray ::ConstIterator it = rects.begin (); it != rects.end (); ++it) - { - gc.fillRect (*it, TQt::black); - } - - - gc.setRasterOp(op); - gc.setPen(old); - } -} - -void KisToolCrop::crop() { - // XXX: Should cropping be part of KisImage/KisPaintDevice's API? - - m_haveCropSelection = false; - setCursor(m_cropCursor); - - KisImageSP img = m_subject->currentImg(); - - if (!img) - return; - - TQRect rc = realRectCrop().normalize(); - - // The visitor adds the undo steps to the macro - if (m_optWidget->cmbType->currentItem() == 0) { - - TQRect dirty = img->bounds(); - - // The layer(s) under the current layer will take care of adding - // undo information to the Crop macro. - if (img->undo()) - img->undoAdapter()->beginMacro(i18n("Crop")); - - KisCropVisitor v(rc, false); - KisLayerSP layer = img->activeLayer(); - layer->accept(v); - layer->setDirty( dirty ); - if (img->undo()) - img->undoAdapter()->endMacro(); - - } - else { - // Resize creates the undo macro itself - img->resize(rc, true); - } - - m_rectCrop = TQRect(0,0,0,0); - - updateWidgetValues(); -} - -void KisToolCrop::setCropX(int x) -{ - if (!m_haveCropSelection) { - m_haveCropSelection = true; - } - else { - paintOutlineWithHandles(); // remove outlines - } - - m_rectCrop.setX(x); - - validateSelection(); - paintOutlineWithHandles(); -} - -void KisToolCrop::setCropY(int y) -{ - if (!m_haveCropSelection) { - m_haveCropSelection = true; - } - else { - paintOutlineWithHandles(); // remove outlines - } - - m_rectCrop.setY(y); - - validateSelection(); - paintOutlineWithHandles(); - -} - -void KisToolCrop::setCropWidth(int w) -{ - if (!m_haveCropSelection) { - m_haveCropSelection = true; - } - else { - paintOutlineWithHandles(); // remove outlines - } - - m_rectCrop.setWidth(w + 1); - - if( m_optWidget->boolRatio->isChecked() ) - { - m_rectCrop.setHeight( (int) ( w / m_optWidget->doubleRatio->value() ) ); - } else { - setOptionWidgetRatio((double)m_rectCrop.width() / (double)m_rectCrop.height() ); - } - - validateSelection(); - paintOutlineWithHandles(); - -} - -void KisToolCrop::setCropHeight(int h) -{ - if (!m_haveCropSelection) { - m_haveCropSelection = true; - } - else { - paintOutlineWithHandles(); // remove outlines - } - - m_rectCrop.setHeight(h + 1); - - if( m_optWidget->boolRatio->isChecked() ) - { - m_rectCrop.setWidth( (int) ( h * m_optWidget->doubleRatio->value() ) ); - } else { - setOptionWidgetRatio((double)m_rectCrop.width() / (double)m_rectCrop.height() ); - } - - validateSelection(); - paintOutlineWithHandles(); - -} - -void KisToolCrop::setRatio(double ) -{ - if( ! (m_optWidget->boolWidth->isChecked() && m_optWidget->boolHeight->isChecked() )) - { - if (!m_haveCropSelection) { - m_haveCropSelection = true; - } - else { - paintOutlineWithHandles(); // remove outlines - } - if( m_optWidget->boolWidth->isChecked() ) - { - m_rectCrop.setHeight( (int) ( m_rectCrop.width() / m_optWidget->doubleRatio->value()) ); - setOptionWidgetHeight( m_rectCrop.height() ); - } else if(m_optWidget->boolHeight->isChecked()) { - m_rectCrop.setWidth( (int) (m_rectCrop.height() * m_optWidget->doubleRatio->value()) ); - setOptionWidgetWidth( m_rectCrop.width() ); - } else { - int newwidth = (int) (m_optWidget->doubleRatio->value() * m_rectCrop.height()); - newwidth = (newwidth + m_rectCrop.width()) / 2; - m_rectCrop.setWidth( newwidth + 1); - setOptionWidgetWidth( newwidth ); - m_rectCrop.setHeight( (int) (newwidth / m_optWidget->doubleRatio->value()) + 1 ); - setOptionWidgetHeight( m_rectCrop.height() - 1 ); - } - validateSelection(false); - paintOutlineWithHandles(); - } -} - -void KisToolCrop::setOptionWidgetX(TQ_INT32 x) -{ - // Disable signals otherwise we get the valueChanged signal, which we don't want - // to go through the logic for setting values that way. - m_optWidget->intX->blockSignals(true); - m_optWidget->intX->setValue(x); - m_optWidget->intX->blockSignals(false); -} - -void KisToolCrop::setOptionWidgetY(TQ_INT32 y) -{ - m_optWidget->intY->blockSignals(true); - m_optWidget->intY->setValue(y); - m_optWidget->intY->blockSignals(false); -} - -void KisToolCrop::setOptionWidgetWidth(TQ_INT32 x) -{ - m_optWidget->intWidth->blockSignals(true); - m_optWidget->intWidth->setValue(x); - m_optWidget->intWidth->blockSignals(false); -} - -void KisToolCrop::setOptionWidgetHeight(TQ_INT32 y) -{ - m_optWidget->intHeight->blockSignals(true); - m_optWidget->intHeight->setValue(y); - m_optWidget->intHeight->blockSignals(false); -} - -void KisToolCrop::setOptionWidgetRatio(double ratio) -{ - m_optWidget->doubleRatio->blockSignals(true); - m_optWidget->doubleRatio->setValue(ratio); - m_optWidget->doubleRatio->blockSignals(false); -} - - -TQWidget* KisToolCrop::createOptionWidget(TQWidget* parent) -{ - m_optWidget = new WdgToolCrop(parent); - TQ_CHECK_PTR(m_optWidget); - - connect(m_optWidget->bnCrop, TQT_SIGNAL(clicked()), this, TQT_SLOT(crop())); - - connect(m_optWidget->intX, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropX(int))); - connect(m_optWidget->intY, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropY(int))); - connect(m_optWidget->intWidth, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropWidth(int))); - connect(m_optWidget->intHeight, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropHeight(int))); - connect(m_optWidget->doubleRatio, TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(setRatio( double ))); - - return m_optWidget; -} - -TQWidget* KisToolCrop::optionWidget() -{ - return m_optWidget; -} - -void KisToolCrop::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Crop"), - "tool_crop", - 0, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Crop an area")); - m_action->setExclusiveGroup("tools"); - - m_ownAction = true; - } -} - -TQRect toTQRect(double x, double y, int w, int h) -{ - return TQRect(int(x), int(y), w, h); -} - -TQRegion KisToolCrop::handles(TQRect rect) -{ - TQRegion handlesRegion; - - //add handle at the lower right corner - handlesRegion += toTQRect( TQABS( rect.width() ) - m_handleSize / 2.0, TQABS( rect.height() ) - m_handleSize / 2.0, m_handleSize, m_handleSize ); - //add handle at the upper right corner - handlesRegion += toTQRect( TQABS( rect.width() ) - m_handleSize / 2.0 , 0 - m_handleSize / 2.0, m_handleSize, m_handleSize ); - //add rectangle at the lower left corner - handlesRegion += toTQRect( 0 - m_handleSize / 2.0 , TQABS( rect.height() ) - m_handleSize / 2.0, m_handleSize, m_handleSize ); - //add rectangle at the upper left corner - handlesRegion += toTQRect( 0 - m_handleSize / 2.0, 0 - m_handleSize / 2.0, m_handleSize, m_handleSize ); - //add handle at the lower edge of the rectangle - handlesRegion += toTQRect( ( TQABS( rect.width() ) - m_handleSize ) / 2.0 , TQABS( rect.height() ) - m_handleSize / 2.0, m_handleSize, m_handleSize ); - //add handle at the right edge of the rectangle - handlesRegion += toTQRect( TQABS( rect.width() ) - m_handleSize / 2.0 , ( TQABS( rect.height() ) - m_handleSize ) / 2.0, m_handleSize, m_handleSize ); - //add handle at the upper edge of the rectangle - handlesRegion += toTQRect( ( TQABS( rect.width() ) - m_handleSize ) / 2.0 , 0 - m_handleSize / 2.0, m_handleSize, m_handleSize ); - //add handle at the left edge of the rectangle - handlesRegion += toTQRect( 0 - m_handleSize / 2.0, ( TQABS( rect.height() ) - m_handleSize ) / 2.0, m_handleSize, m_handleSize ); - - //move the handles to the correct position - if( rect.width() >= 0 && rect.height() >= 0) - { - handlesRegion.translate ( rect.x(), rect.y() ); - } - else if( rect.width() < 0 && rect.height() >= 0) - { - handlesRegion.translate ( rect.x() - TQABS( rect.width() ), rect.y() ); - } - else if( rect.width() >= 0 && rect.height() < 0) - { - handlesRegion.translate ( rect.x(), rect.y() - TQABS( rect.height() ) ); - } - else if( rect.width() < 0 && rect.height() < 0) - { - handlesRegion.translate ( rect.x() - TQABS( rect.width() ), rect.y() - TQABS( rect.height() ) ); - } - return handlesRegion; -} - -TQ_INT32 KisToolCrop::mouseOnHandle(TQPoint currentViewPoint) -{ - KisCanvasController *controller = m_subject->canvasController(); - Q_ASSERT(controller); - TQPoint start = controller->windowToView(m_rectCrop.topLeft()); - TQPoint end = controller->windowToView(m_rectCrop.bottomRight()); - - TQ_INT32 startx; - TQ_INT32 starty; - TQ_INT32 endx; - TQ_INT32 endy; - if(start.x()<=end.x()) - { - startx=start.x(); - endx=end.x(); - } - else - { - startx=end.x(); - endx=start.x(); - } - if(start.y()<=end.y()) - { - starty=start.y(); - endy=end.y(); - } - else - { - starty=end.y(); - endy=start.y(); - } - - if ( toTQRect ( startx - m_handleSize / 2.0, starty - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dx= startx-currentViewPoint.x(); - m_dy = starty - currentViewPoint.y(); - } - return UpperLeft; - } - else if ( toTQRect ( startx - m_handleSize / 2.0, endy - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dx = startx-currentViewPoint.x(); - m_dy = endy-currentViewPoint.y(); - } - return LowerLeft; - } - else if ( toTQRect ( endx - m_handleSize / 2.0, starty - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dx = endx - currentViewPoint.x(); - m_dy = starty - currentViewPoint.y() ; - } - return UpperRight; - } - else if ( toTQRect ( endx - m_handleSize / 2.0, endy - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dx = endx - currentViewPoint.x(); - m_dy= endy - currentViewPoint.y(); - } - return LowerRight; - } - else if ( toTQRect ( startx + ( endx - startx - m_handleSize ) / 2.0, starty - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dy = starty - currentViewPoint.y() ; - } - return Upper; - } - else if ( toTQRect ( startx + ( endx - startx - m_handleSize ) / 2.0, endy - m_handleSize / 2, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dy = endy - currentViewPoint.y(); - } - return Lower; - } - else if ( toTQRect ( startx - m_handleSize / 2.0, starty + ( endy - starty - m_handleSize ) / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dx = startx - currentViewPoint.x() ; - } - return Left; - } - else if ( toTQRect ( endx - m_handleSize / 2.0 , starty + ( endy - starty - m_handleSize ) / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) - { - if( !m_selecting ) - { - m_dx = endx-currentViewPoint.x(); - } - return Right; - } - else if ( toTQRect ( startx , starty, endx - startx , endy - starty ).contains( currentViewPoint ) ) - { - return Inside; - } - else return None; -} - -void KisToolCrop::setMoveResizeCursor (TQ_INT32 handle) -{ - switch (handle) - { - case (UpperLeft): - case (LowerRight): - m_subject->canvasController()->setCanvasCursor(KisCursor::sizeFDiagCursor()); - return; - case (LowerLeft): - case (UpperRight): - m_subject->canvasController()->setCanvasCursor(KisCursor::sizeBDiagCursor()); - return; - case (Upper): - case (Lower): - m_subject->canvasController()->setCanvasCursor(KisCursor::sizeVerCursor()); - return; - case (Left): - case (Right): - m_subject->canvasController()->setCanvasCursor(KisCursor::sizeHorCursor()); - return; - case (Inside): - m_subject->canvasController()->setCanvasCursor(KisCursor::sizeAllCursor()); - return; - } - m_subject->canvasController()->setCanvasCursor(KisCursor::arrowCursor()); - return; -} - - -#include "kis_tool_crop.moc" diff --git a/chalk/plugins/tools/tool_crop/kis_tool_crop.cpp b/chalk/plugins/tools/tool_crop/kis_tool_crop.cpp new file mode 100644 index 00000000..58454b4f --- /dev/null +++ b/chalk/plugins/tools/tool_crop/kis_tool_crop.cpp @@ -0,0 +1,925 @@ +/* + * kis_tool_crop.cpp -- part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * Copyright (c) 2005 Michael Thaler + * Copyright (c) 2006 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kis_tool_crop.h" +#include "wdg_tool_crop.h" + +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + + + +KisToolCrop::KisToolCrop() + : super(i18n("Crop")) +{ + setName("tool_crop"); + m_cropCursor = KisCursor::load("tool_crop_cursor.png", 6, 6); + setCursor(m_cropCursor); + m_subject = 0; + m_selecting = false; + m_rectCrop = TQRect(0, 0, 0, 0); + m_handleSize = 13; + m_haveCropSelection = false; + m_optWidget = 0; +} + +KisToolCrop::~KisToolCrop() +{ +} + +void KisToolCrop::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolCrop::activate() +{ + super::activate(); + + // No current crop rectangle, try to use the selection of the device to make a rectangle + if (m_subject && m_subject->currentImg() && m_subject->currentImg()->activeDevice()) { + KisPaintDeviceSP device = m_subject->currentImg()->activeDevice(); + if (!device->hasSelection()) { + //m_rectCrop = m_subject->currentImg()->bounds(); + //validateSelection(); + m_haveCropSelection = false; + m_selecting = false; + } + else { + + m_rectCrop = device->selection()->selectedRect(); + validateSelection(); + crop(); + } + } +} + +void KisToolCrop::deactivate() +{ + clearRect(); +} + + +void KisToolCrop::paint(KisCanvasPainter& gc) +{ + paintOutlineWithHandles(gc, TQRect()); +} + +void KisToolCrop::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + paintOutlineWithHandles(gc, rc); +} + +void KisToolCrop::clearRect() +{ + kdDebug() << "Clearing\n"; + if (m_subject) { + + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + Q_ASSERT(controller); + + controller->kiscanvas()->update(); + + m_rectCrop = TQRect(0,0,0,0); + + updateWidgetValues(); + m_selecting = false; + } +} + +void KisToolCrop::buttonPress(KisButtonPressEvent *e) +{ + if (m_subject) { + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice() && e->button() == Qt::LeftButton) { + + TQPoint pos = e->pos().floorTQPoint(); + TQRect b = img->bounds(); + + if (pos.x() < b.x()) + pos.setX(b.x()); + else if (pos.x() > b.x() + b.width()) + pos.setX(b.x() + b.width()); + + if (pos.y() < b.y()) + pos.setY(b.y()); + else if (pos.y() > b.y() + b.height()) + pos.setY(b.y() + b.height()); + + m_selecting = true; + + if( !m_haveCropSelection ) //if the selection is not set + { + m_rectCrop = TQRect( pos.x(), pos.y(), 0, 0); + paintOutlineWithHandles(); + } + else + { + KisCanvasController *controller = m_subject->canvasController(); + m_mouseOnHandleType = mouseOnHandle(controller ->windowToView(pos)); + m_dragStart = pos; + } + + updateWidgetValues(); + } + } +} + +void KisToolCrop::move(KisMoveEvent *e) +{ + if ( m_subject && m_subject->currentImg()) + { + if( m_selecting ) //if the user selects + { + if( !m_haveCropSelection ) //if the cropSelection is not yet set + { + paintOutlineWithHandles(); + + m_rectCrop.setBottomRight( e->pos().floorTQPoint()); + + KisImageSP image = m_subject->currentImg(); + + m_rectCrop.setRight( TQMIN(m_rectCrop.right(), image->width())); + m_rectCrop.setBottom( TQMIN(m_rectCrop.bottom(), image->width())); + m_rectCrop = m_rectCrop.normalize(); + + paintOutlineWithHandles(); + } + else //if the crop selection is set + { + m_dragStop = e->pos().floorTQPoint(); + if (m_mouseOnHandleType != None && m_dragStart != m_dragStop ) { + + + TQ_INT32 imageWidth = m_subject->currentImg()->width(); + TQ_INT32 imageHeight = m_subject->currentImg()->height(); + + paintOutlineWithHandles(); + + TQPoint pos = e->pos().floorTQPoint(); + if( m_mouseOnHandleType == Inside ) + { + m_rectCrop.moveBy( ( m_dragStop.x() - m_dragStart.x() ), ( m_dragStop.y() - m_dragStart.y() ) ); + if( m_rectCrop.left() < 0 ) + { + m_rectCrop.moveLeft( 0 ); + } + if( m_rectCrop.right() > imageWidth ) + { + m_rectCrop.moveRight( imageWidth ); + } + if( m_rectCrop.top() < 0 ) + { + m_rectCrop.moveTop( 0 ); + } + if( m_rectCrop.bottom() > imageHeight ) + { + m_rectCrop.moveBottom( imageHeight ); + } + } else if(m_optWidget->boolRatio->isChecked()) + { + TQPoint drag = m_dragStop - m_dragStart; + if( ! m_optWidget->boolWidth->isChecked() && !m_optWidget->boolHeight->isChecked() ) + { + switch (m_mouseOnHandleType) + { + case (UpperLeft): + { + TQ_INT32 dep = (drag.x() + drag.y()) / 2; + m_rectCrop.setTop( m_rectCrop.top() + dep ); + m_rectCrop.setLeft( (int) ( m_rectCrop.right() - m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); + } + break; + case (LowerRight): + { + TQ_INT32 dep = (drag.x() + drag.y()) / 2; + m_rectCrop.setBottom( m_rectCrop.bottom() + dep ); + m_rectCrop.setWidth( (int) ( m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); + break; + } + case (UpperRight): + { + TQ_INT32 dep = (drag.x() - drag.y()) / 2; + m_rectCrop.setTop( m_rectCrop.top() - dep ); + m_rectCrop.setWidth( (int) ( m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); + break; + } + case (LowerLeft): + { + TQ_INT32 dep = (drag.x() - drag.y()) / 2; + m_rectCrop.setBottom( m_rectCrop.bottom() - dep ); + m_rectCrop.setLeft( (int) ( m_rectCrop.right() - m_optWidget->doubleRatio->value() * m_rectCrop.height() ) ); + break; + } + case (Upper): + m_rectCrop.setTop( pos.y() + m_dy ); + m_rectCrop.setWidth( (int) (m_rectCrop.height() * m_optWidget->doubleRatio->value()) ); + break; + case (Lower): + m_rectCrop.setBottom( pos.y() + m_dy ); + m_rectCrop.setWidth( (int) (m_rectCrop.height() * m_optWidget->doubleRatio->value()) ); + break; + case (Left): + m_rectCrop.setLeft( pos.x() + m_dx ); + m_rectCrop.setHeight( (int) (m_rectCrop.width() / m_optWidget->doubleRatio->value()) ); + break; + case (Right): + m_rectCrop.setRight( pos.x() + m_dx ); + m_rectCrop.setHeight( (int) (m_rectCrop.width() / m_optWidget->doubleRatio->value()) ); + break; + case (Inside): // never happen + break; + } + } + } else { + if( m_optWidget->boolWidth->isChecked() ) + { + m_rectCrop.setWidth( m_optWidget->intWidth->value() + 1 ); + } else { + switch (m_mouseOnHandleType) + { + case (LowerLeft): + case (Left): + case (UpperLeft): + m_rectCrop.setLeft( pos.x() + m_dx ); + break; + case (Right): + case (UpperRight): + case (LowerRight): + m_rectCrop.setRight( pos.x() + m_dx ); + break; + default: + break; + } + } + if( m_optWidget->boolHeight->isChecked() ) + { + m_rectCrop.setHeight( m_optWidget->intHeight->value() + 1 ); + } else { + switch (m_mouseOnHandleType) + { + case (UpperLeft): + case (Upper): + case (UpperRight): + m_rectCrop.setTop( pos.y() + m_dy ); + break; + case (LowerRight): + case (LowerLeft): + case (Lower): + m_rectCrop.setBottom( pos.y() + m_dy ); + break; + default: + break; + } + } + } + if( m_rectCrop.height() < 0) + { + if( m_mouseOnHandleType == Lower) + m_mouseOnHandleType = Upper; + else if( m_mouseOnHandleType == LowerLeft) + m_mouseOnHandleType = UpperLeft; + else if( m_mouseOnHandleType == LowerRight) + m_mouseOnHandleType = UpperRight; + else if( m_mouseOnHandleType == Upper) + m_mouseOnHandleType = Lower; + else if( m_mouseOnHandleType == UpperLeft) + m_mouseOnHandleType = LowerLeft; + else if( m_mouseOnHandleType == UpperRight) + m_mouseOnHandleType = LowerRight; + } + if( m_rectCrop.width() < 0) + { + if( m_mouseOnHandleType == Right) + m_mouseOnHandleType = Left; + else if( m_mouseOnHandleType == UpperRight) + m_mouseOnHandleType = UpperLeft; + else if( m_mouseOnHandleType == LowerRight) + m_mouseOnHandleType = LowerLeft; + else if( m_mouseOnHandleType == Left) + m_mouseOnHandleType = Right; + else if( m_mouseOnHandleType == UpperLeft) + m_mouseOnHandleType = UpperRight; + else if( m_mouseOnHandleType == LowerLeft) + m_mouseOnHandleType = LowerRight; + } + + m_rectCrop = m_rectCrop.normalize(); + m_rectCrop = m_rectCrop.intersect( TQRect(0,0, imageWidth + 1, imageHeight + 1 ) ); + m_dragStart = e->pos().floorTQPoint(); + paintOutlineWithHandles(); + } + } + updateWidgetValues(); + } + else //if we are not selecting + { + if ( m_haveCropSelection ) //if the crop selection is set + { + KisCanvasController *controller = m_subject->canvasController(); + TQ_INT32 type = mouseOnHandle(controller->windowToView(e->pos().floorTQPoint())); + //set resize cursor if we are on one of the handles + setMoveResizeCursor(type); + } + } + } +} + +void KisToolCrop::updateWidgetValues(bool updateratio) +{ + TQRect r = realRectCrop(); + setOptionWidgetX(r.x()); + setOptionWidgetY(r.y()); + setOptionWidgetWidth(r.width() ); + setOptionWidgetHeight(r.height() ); + if(updateratio && !m_optWidget->boolRatio->isChecked() ) + setOptionWidgetRatio((double)r.width() / (double)r.height() ); +} + +void KisToolCrop::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_subject && m_subject->currentImg() && m_selecting && e->button() == Qt::LeftButton) { + + m_selecting = false; + m_haveCropSelection = true; + + paintOutlineWithHandles(); + validateSelection(); + paintOutlineWithHandles(); + } +} + +void KisToolCrop::doubleClick(KisDoubleClickEvent *) +{ + if (m_haveCropSelection) crop(); +} + +void KisToolCrop::validateSelection(bool updateratio) +{ + if (m_subject) { + KisImageSP image = m_subject->currentImg(); + + if (image) { + TQ_INT32 imageWidth = image->width(); + TQ_INT32 imageHeight = image->height(); + m_rectCrop.setLeft(TQMAX(0, m_rectCrop.left())); + m_rectCrop.setTop(TQMAX(0, m_rectCrop.top())); + m_rectCrop.setRight(TQMIN(imageWidth, m_rectCrop.right())); + m_rectCrop.setBottom(TQMIN(imageHeight, m_rectCrop.bottom())); + + updateWidgetValues(updateratio); + } + } +} + +void KisToolCrop::paintOutlineWithHandles() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintOutlineWithHandles(gc, rc); + } +} + +void KisToolCrop::paintOutlineWithHandles(KisCanvasPainter& gc, const TQRect&) +{ + if (m_subject && (m_selecting || m_haveCropSelection)) { + KisCanvasController *controller = m_subject->canvasController(); + RasterOp op = gc.rasterOp(); + TQPen old = gc.pen(); + TQPen pen(TQt::SolidLine); + pen.setWidth(1); + TQPoint start; + TQPoint end; + + Q_ASSERT(controller); + start = controller->windowToView(m_rectCrop.topLeft()); + end = controller->windowToView(m_rectCrop.bottomRight()); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + //draw handles + m_handlesRegion = handles(TQRect(start, end)); + + TQ_INT32 startx; + TQ_INT32 starty; + TQ_INT32 endx; + TQ_INT32 endy; + if(start.x()<=end.x()) + { + startx=start.x(); + endx=end.x(); + } + else + { + startx=end.x(); + endx=start.x(); + } + if(start.y()<=end.y()) + { + starty=start.y(); + endy=end.y(); + } + else + { + starty=end.y(); + endy=start.y(); + } + //draw upper line of selection + gc.drawLine(startx + m_handleSize / 2 + 1, starty, startx + (endx - startx - m_handleSize) / 2 + 1, starty); + gc.drawLine(startx + (endx - startx + m_handleSize) / 2 + 1, starty, endx - m_handleSize / 2, starty); + //draw lower line of selection + gc.drawLine(startx + m_handleSize / 2 + 1, endy, startx + (endx - startx - m_handleSize) / 2 + 1, endy); + gc.drawLine(startx + (endx - startx + m_handleSize) / 2 + 1, endy, endx - m_handleSize / 2 , endy); + //draw right line of selection + gc.drawLine(startx, starty + m_handleSize / 2 + 1, startx, starty + (endy - starty - m_handleSize) / 2 + 1); + gc.drawLine(startx, starty + (endy - starty + m_handleSize) / 2 + 1, startx, endy - m_handleSize / 2); + //draw left line of selection + gc.drawLine(endx, starty + m_handleSize / 2 + 1, endx, starty + (endy - starty - m_handleSize) / 2 + 1); + gc.drawLine(endx, starty + (endy - starty + m_handleSize) / 2 + 1, endx, endy - m_handleSize / 2); + + //draw guides + gc.drawLine(0,endy,startx - m_handleSize / 2,endy); + gc.drawLine(startx,endy + m_handleSize / 2 + 1, startx, controller->kiscanvas()->height()); + gc.drawLine(endx,0,endx,starty - m_handleSize / 2); + gc.drawLine(endx + m_handleSize / 2 + 1,starty, controller->kiscanvas()->width(), starty); + TQMemArray rects = m_handlesRegion.rects (); + for (TQMemArray ::ConstIterator it = rects.begin (); it != rects.end (); ++it) + { + gc.fillRect (*it, TQt::black); + } + + + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolCrop::crop() { + // XXX: Should cropping be part of KisImage/KisPaintDevice's API? + + m_haveCropSelection = false; + setCursor(m_cropCursor); + + KisImageSP img = m_subject->currentImg(); + + if (!img) + return; + + TQRect rc = realRectCrop().normalize(); + + // The visitor adds the undo steps to the macro + if (m_optWidget->cmbType->currentItem() == 0) { + + TQRect dirty = img->bounds(); + + // The layer(s) under the current layer will take care of adding + // undo information to the Crop macro. + if (img->undo()) + img->undoAdapter()->beginMacro(i18n("Crop")); + + KisCropVisitor v(rc, false); + KisLayerSP layer = img->activeLayer(); + layer->accept(v); + layer->setDirty( dirty ); + if (img->undo()) + img->undoAdapter()->endMacro(); + + } + else { + // Resize creates the undo macro itself + img->resize(rc, true); + } + + m_rectCrop = TQRect(0,0,0,0); + + updateWidgetValues(); +} + +void KisToolCrop::setCropX(int x) +{ + if (!m_haveCropSelection) { + m_haveCropSelection = true; + } + else { + paintOutlineWithHandles(); // remove outlines + } + + m_rectCrop.setX(x); + + validateSelection(); + paintOutlineWithHandles(); +} + +void KisToolCrop::setCropY(int y) +{ + if (!m_haveCropSelection) { + m_haveCropSelection = true; + } + else { + paintOutlineWithHandles(); // remove outlines + } + + m_rectCrop.setY(y); + + validateSelection(); + paintOutlineWithHandles(); + +} + +void KisToolCrop::setCropWidth(int w) +{ + if (!m_haveCropSelection) { + m_haveCropSelection = true; + } + else { + paintOutlineWithHandles(); // remove outlines + } + + m_rectCrop.setWidth(w + 1); + + if( m_optWidget->boolRatio->isChecked() ) + { + m_rectCrop.setHeight( (int) ( w / m_optWidget->doubleRatio->value() ) ); + } else { + setOptionWidgetRatio((double)m_rectCrop.width() / (double)m_rectCrop.height() ); + } + + validateSelection(); + paintOutlineWithHandles(); + +} + +void KisToolCrop::setCropHeight(int h) +{ + if (!m_haveCropSelection) { + m_haveCropSelection = true; + } + else { + paintOutlineWithHandles(); // remove outlines + } + + m_rectCrop.setHeight(h + 1); + + if( m_optWidget->boolRatio->isChecked() ) + { + m_rectCrop.setWidth( (int) ( h * m_optWidget->doubleRatio->value() ) ); + } else { + setOptionWidgetRatio((double)m_rectCrop.width() / (double)m_rectCrop.height() ); + } + + validateSelection(); + paintOutlineWithHandles(); + +} + +void KisToolCrop::setRatio(double ) +{ + if( ! (m_optWidget->boolWidth->isChecked() && m_optWidget->boolHeight->isChecked() )) + { + if (!m_haveCropSelection) { + m_haveCropSelection = true; + } + else { + paintOutlineWithHandles(); // remove outlines + } + if( m_optWidget->boolWidth->isChecked() ) + { + m_rectCrop.setHeight( (int) ( m_rectCrop.width() / m_optWidget->doubleRatio->value()) ); + setOptionWidgetHeight( m_rectCrop.height() ); + } else if(m_optWidget->boolHeight->isChecked()) { + m_rectCrop.setWidth( (int) (m_rectCrop.height() * m_optWidget->doubleRatio->value()) ); + setOptionWidgetWidth( m_rectCrop.width() ); + } else { + int newwidth = (int) (m_optWidget->doubleRatio->value() * m_rectCrop.height()); + newwidth = (newwidth + m_rectCrop.width()) / 2; + m_rectCrop.setWidth( newwidth + 1); + setOptionWidgetWidth( newwidth ); + m_rectCrop.setHeight( (int) (newwidth / m_optWidget->doubleRatio->value()) + 1 ); + setOptionWidgetHeight( m_rectCrop.height() - 1 ); + } + validateSelection(false); + paintOutlineWithHandles(); + } +} + +void KisToolCrop::setOptionWidgetX(TQ_INT32 x) +{ + // Disable signals otherwise we get the valueChanged signal, which we don't want + // to go through the logic for setting values that way. + m_optWidget->intX->blockSignals(true); + m_optWidget->intX->setValue(x); + m_optWidget->intX->blockSignals(false); +} + +void KisToolCrop::setOptionWidgetY(TQ_INT32 y) +{ + m_optWidget->intY->blockSignals(true); + m_optWidget->intY->setValue(y); + m_optWidget->intY->blockSignals(false); +} + +void KisToolCrop::setOptionWidgetWidth(TQ_INT32 x) +{ + m_optWidget->intWidth->blockSignals(true); + m_optWidget->intWidth->setValue(x); + m_optWidget->intWidth->blockSignals(false); +} + +void KisToolCrop::setOptionWidgetHeight(TQ_INT32 y) +{ + m_optWidget->intHeight->blockSignals(true); + m_optWidget->intHeight->setValue(y); + m_optWidget->intHeight->blockSignals(false); +} + +void KisToolCrop::setOptionWidgetRatio(double ratio) +{ + m_optWidget->doubleRatio->blockSignals(true); + m_optWidget->doubleRatio->setValue(ratio); + m_optWidget->doubleRatio->blockSignals(false); +} + + +TQWidget* KisToolCrop::createOptionWidget(TQWidget* parent) +{ + m_optWidget = new WdgToolCrop(parent); + TQ_CHECK_PTR(m_optWidget); + + connect(m_optWidget->bnCrop, TQT_SIGNAL(clicked()), this, TQT_SLOT(crop())); + + connect(m_optWidget->intX, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropX(int))); + connect(m_optWidget->intY, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropY(int))); + connect(m_optWidget->intWidth, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropWidth(int))); + connect(m_optWidget->intHeight, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setCropHeight(int))); + connect(m_optWidget->doubleRatio, TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(setRatio( double ))); + + return m_optWidget; +} + +TQWidget* KisToolCrop::optionWidget() +{ + return m_optWidget; +} + +void KisToolCrop::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Crop"), + "tool_crop", + 0, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Crop an area")); + m_action->setExclusiveGroup("tools"); + + m_ownAction = true; + } +} + +TQRect toTQRect(double x, double y, int w, int h) +{ + return TQRect(int(x), int(y), w, h); +} + +TQRegion KisToolCrop::handles(TQRect rect) +{ + TQRegion handlesRegion; + + //add handle at the lower right corner + handlesRegion += toTQRect( TQABS( rect.width() ) - m_handleSize / 2.0, TQABS( rect.height() ) - m_handleSize / 2.0, m_handleSize, m_handleSize ); + //add handle at the upper right corner + handlesRegion += toTQRect( TQABS( rect.width() ) - m_handleSize / 2.0 , 0 - m_handleSize / 2.0, m_handleSize, m_handleSize ); + //add rectangle at the lower left corner + handlesRegion += toTQRect( 0 - m_handleSize / 2.0 , TQABS( rect.height() ) - m_handleSize / 2.0, m_handleSize, m_handleSize ); + //add rectangle at the upper left corner + handlesRegion += toTQRect( 0 - m_handleSize / 2.0, 0 - m_handleSize / 2.0, m_handleSize, m_handleSize ); + //add handle at the lower edge of the rectangle + handlesRegion += toTQRect( ( TQABS( rect.width() ) - m_handleSize ) / 2.0 , TQABS( rect.height() ) - m_handleSize / 2.0, m_handleSize, m_handleSize ); + //add handle at the right edge of the rectangle + handlesRegion += toTQRect( TQABS( rect.width() ) - m_handleSize / 2.0 , ( TQABS( rect.height() ) - m_handleSize ) / 2.0, m_handleSize, m_handleSize ); + //add handle at the upper edge of the rectangle + handlesRegion += toTQRect( ( TQABS( rect.width() ) - m_handleSize ) / 2.0 , 0 - m_handleSize / 2.0, m_handleSize, m_handleSize ); + //add handle at the left edge of the rectangle + handlesRegion += toTQRect( 0 - m_handleSize / 2.0, ( TQABS( rect.height() ) - m_handleSize ) / 2.0, m_handleSize, m_handleSize ); + + //move the handles to the correct position + if( rect.width() >= 0 && rect.height() >= 0) + { + handlesRegion.translate ( rect.x(), rect.y() ); + } + else if( rect.width() < 0 && rect.height() >= 0) + { + handlesRegion.translate ( rect.x() - TQABS( rect.width() ), rect.y() ); + } + else if( rect.width() >= 0 && rect.height() < 0) + { + handlesRegion.translate ( rect.x(), rect.y() - TQABS( rect.height() ) ); + } + else if( rect.width() < 0 && rect.height() < 0) + { + handlesRegion.translate ( rect.x() - TQABS( rect.width() ), rect.y() - TQABS( rect.height() ) ); + } + return handlesRegion; +} + +TQ_INT32 KisToolCrop::mouseOnHandle(TQPoint currentViewPoint) +{ + KisCanvasController *controller = m_subject->canvasController(); + Q_ASSERT(controller); + TQPoint start = controller->windowToView(m_rectCrop.topLeft()); + TQPoint end = controller->windowToView(m_rectCrop.bottomRight()); + + TQ_INT32 startx; + TQ_INT32 starty; + TQ_INT32 endx; + TQ_INT32 endy; + if(start.x()<=end.x()) + { + startx=start.x(); + endx=end.x(); + } + else + { + startx=end.x(); + endx=start.x(); + } + if(start.y()<=end.y()) + { + starty=start.y(); + endy=end.y(); + } + else + { + starty=end.y(); + endy=start.y(); + } + + if ( toTQRect ( startx - m_handleSize / 2.0, starty - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dx= startx-currentViewPoint.x(); + m_dy = starty - currentViewPoint.y(); + } + return UpperLeft; + } + else if ( toTQRect ( startx - m_handleSize / 2.0, endy - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dx = startx-currentViewPoint.x(); + m_dy = endy-currentViewPoint.y(); + } + return LowerLeft; + } + else if ( toTQRect ( endx - m_handleSize / 2.0, starty - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dx = endx - currentViewPoint.x(); + m_dy = starty - currentViewPoint.y() ; + } + return UpperRight; + } + else if ( toTQRect ( endx - m_handleSize / 2.0, endy - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dx = endx - currentViewPoint.x(); + m_dy= endy - currentViewPoint.y(); + } + return LowerRight; + } + else if ( toTQRect ( startx + ( endx - startx - m_handleSize ) / 2.0, starty - m_handleSize / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dy = starty - currentViewPoint.y() ; + } + return Upper; + } + else if ( toTQRect ( startx + ( endx - startx - m_handleSize ) / 2.0, endy - m_handleSize / 2, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dy = endy - currentViewPoint.y(); + } + return Lower; + } + else if ( toTQRect ( startx - m_handleSize / 2.0, starty + ( endy - starty - m_handleSize ) / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dx = startx - currentViewPoint.x() ; + } + return Left; + } + else if ( toTQRect ( endx - m_handleSize / 2.0 , starty + ( endy - starty - m_handleSize ) / 2.0, m_handleSize, m_handleSize ).contains( currentViewPoint ) ) + { + if( !m_selecting ) + { + m_dx = endx-currentViewPoint.x(); + } + return Right; + } + else if ( toTQRect ( startx , starty, endx - startx , endy - starty ).contains( currentViewPoint ) ) + { + return Inside; + } + else return None; +} + +void KisToolCrop::setMoveResizeCursor (TQ_INT32 handle) +{ + switch (handle) + { + case (UpperLeft): + case (LowerRight): + m_subject->canvasController()->setCanvasCursor(KisCursor::sizeFDiagCursor()); + return; + case (LowerLeft): + case (UpperRight): + m_subject->canvasController()->setCanvasCursor(KisCursor::sizeBDiagCursor()); + return; + case (Upper): + case (Lower): + m_subject->canvasController()->setCanvasCursor(KisCursor::sizeVerCursor()); + return; + case (Left): + case (Right): + m_subject->canvasController()->setCanvasCursor(KisCursor::sizeHorCursor()); + return; + case (Inside): + m_subject->canvasController()->setCanvasCursor(KisCursor::sizeAllCursor()); + return; + } + m_subject->canvasController()->setCanvasCursor(KisCursor::arrowCursor()); + return; +} + + +#include "kis_tool_crop.moc" diff --git a/chalk/plugins/tools/tool_crop/tool_crop.cc b/chalk/plugins/tools/tool_crop/tool_crop.cc deleted file mode 100644 index 97f6e0e8..00000000 --- a/chalk/plugins/tools/tool_crop/tool_crop.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * tool_crop.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "tool_crop.h" -#include "kis_tool_crop.h" - - -typedef KGenericFactory ToolCropFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolcrop, ToolCropFactory( "chalk" ) ) - - -ToolCrop::ToolCrop(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolCropFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast(parent); - r->add(new KisToolCropFactory()); - } - -} - -ToolCrop::~ToolCrop() -{ -} - -#include "tool_crop.moc" diff --git a/chalk/plugins/tools/tool_crop/tool_crop.cpp b/chalk/plugins/tools/tool_crop/tool_crop.cpp new file mode 100644 index 00000000..30df11ec --- /dev/null +++ b/chalk/plugins/tools/tool_crop/tool_crop.cpp @@ -0,0 +1,62 @@ +/* + * tool_crop.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "tool_crop.h" +#include "kis_tool_crop.h" + + +typedef KGenericFactory ToolCropFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolcrop, ToolCropFactory( "chalk" ) ) + + +ToolCrop::ToolCrop(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolCropFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(parent); + r->add(new KisToolCropFactory()); + } + +} + +ToolCrop::~ToolCrop() +{ +} + +#include "tool_crop.moc" diff --git a/chalk/plugins/tools/tool_curves/Makefile.am b/chalk/plugins/tools/tool_curves/Makefile.am index 92366e55..75a515f2 100644 --- a/chalk/plugins/tools/tool_curves/Makefile.am +++ b/chalk/plugins/tools/tool_curves/Makefile.am @@ -10,15 +10,15 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalktoolcurves_la_SOURCES = \ - kis_curve_framework.cc \ - kis_tool_curve.cc \ - tool_curves.cc \ + kis_curve_framework.cpp \ + kis_tool_curve.cpp \ + tool_curves.cpp \ wdg_tool_example.ui \ - kis_tool_example.cc \ - kis_tool_bezier.cc \ - kis_tool_bezier_paint.cc \ - kis_tool_bezier_select.cc \ - kis_tool_moutline.cc + kis_tool_example.cpp \ + kis_tool_bezier.cpp \ + kis_tool_bezier_paint.cpp \ + kis_tool_bezier_select.cpp \ + kis_tool_moutline.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolcurves.la diff --git a/chalk/plugins/tools/tool_curves/kis_curve_framework.cc b/chalk/plugins/tools/tool_curves/kis_curve_framework.cpp similarity index 100% rename from chalk/plugins/tools/tool_curves/kis_curve_framework.cc rename to chalk/plugins/tools/tool_curves/kis_curve_framework.cpp diff --git a/chalk/plugins/tools/tool_curves/kis_tool_bezier.cc b/chalk/plugins/tools/tool_curves/kis_tool_bezier.cc deleted file mode 100644 index e4c1d05d..00000000 --- a/chalk/plugins/tools/tool_curves/kis_tool_bezier.cc +++ /dev/null @@ -1,366 +0,0 @@ -/* - * kis_tool_bezier.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_global.h" -#include "kis_doc.h" -#include "kis_painter.h" -#include "kis_point.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_vec.h" - -#include "kis_curve_framework.h" -#include "kis_tool_bezier.h" - -KisCurve::iterator KisCurveBezier::groupEndpoint (KisCurve::iterator it) const -{ - iterator temp = it; - if ((*it).hint() == BEZIERNEXTCONTROLHINT) - temp -= 1; - if ((*it).hint() == BEZIERPREVCONTROLHINT) - temp += 1; - return temp; -} - -KisCurve::iterator KisCurveBezier::groupPrevControl (KisCurve::iterator it) const -{ - iterator temp = it; - if ((*it).hint() == BEZIERENDHINT) - temp -= 1; - if ((*it).hint() == BEZIERNEXTCONTROLHINT) - temp -= 2; - return temp; -} - -KisCurve::iterator KisCurveBezier::groupNextControl (KisCurve::iterator it) const -{ - iterator temp = it; - if ((*it).hint() == BEZIERENDHINT) - temp += 1; - if ((*it).hint() == BEZIERPREVCONTROLHINT) - temp += 2; - return temp; -} - -bool KisCurveBezier::groupSelected (KisCurve::iterator it) const -{ - if ((*groupPrevControl(it)).isSelected() || (*groupEndpoint(it)).isSelected() || (*groupNextControl(it)).isSelected()) - return true; - return false; -} - -KisCurve::iterator KisCurveBezier::nextGroupEndpoint (KisCurve::iterator it) const -{ - iterator temp = it; - if ((*it).hint() == BEZIERPREVCONTROLHINT) { - temp += 2; - temp = temp.nextPivot(); - } - if ((*it).hint() == BEZIERENDHINT) { - temp += 1; - temp = temp.nextPivot(); - } - if ((*it).hint() == BEZIERNEXTCONTROLHINT) { - temp = temp.nextPivot(); - } - temp = temp.nextPivot(); - return temp; -} - -KisCurve::iterator KisCurveBezier::prevGroupEndpoint (KisCurve::iterator it) const -{ - iterator temp = it; - if ((*it).hint() == BEZIERNEXTCONTROLHINT) { - temp -= 1; - temp = temp.previousPivot().previousPivot(); - } - if ((*it).hint() == BEZIERENDHINT) { - temp = temp.previousPivot().previousPivot(); - } - if ((*it).hint() == BEZIERPREVCONTROLHINT) { - temp = temp.previousPivot(); - } - temp = temp.previousPivot(); - return temp; -} - -KisPoint KisCurveBezier::midpoint (const KisPoint& P1, const KisPoint& P2) -{ - KisPoint temp; - temp.setX((P1.x()+P2.x())/2); - temp.setY((P1.y()+P2.y())/2); - return temp; -} - -void KisCurveBezier::recursiveCurve (const KisPoint& P1, const KisPoint& P2, const KisPoint& P3, - const KisPoint& P4, int level, KisCurve::iterator it) -{ - if (level > m_maxLevel) { - addPoint(it,midpoint(P1,P4),false,false,LINEHINT); - return; - } - - KisPoint L1, L2, L3, L4; - KisPoint H, R1, R2, R3, R4; - - L1 = P1; - L2 = midpoint(P1, P2); - H = midpoint(P2, P3); - R3 = midpoint(P3, P4); - R4 = P4; - L3 = midpoint(L2, H); - R2 = midpoint(R3, H); - L4 = midpoint(L3, R2); - R1 = L4; - recursiveCurve(L1, L2, L3, L4, level + 1, it); - recursiveCurve(R1, R2, R3, R4, level + 1, it); -} - -void KisCurveBezier::calculateCurve(KisCurve::iterator tstart, KisCurve::iterator tend, KisCurve::iterator) -{ - if (pivots().count() < 4) - return; - - iterator origin, dest, control1, control2; - - if ((*tstart).hint() == BEZIERENDHINT) { - origin = tstart; - control1 = tstart.nextPivot(); - } else if ((*tstart).hint() == BEZIERNEXTCONTROLHINT) { - origin = tstart.previousPivot(); - control1 = tstart; - } else if ((*tstart).hint() == BEZIERPREVCONTROLHINT) { - origin = tstart.nextPivot(); - control1 = origin.nextPivot(); - } else - return; - - if ((*tend).hint() == BEZIERENDHINT) { - dest = tend; - control2 = tend.previousPivot(); - } else if ((*tend).hint() == BEZIERPREVCONTROLHINT) { - dest = tend.nextPivot(); - control2 = tend; - } else if ((*tend).hint() == BEZIERNEXTCONTROLHINT) { - dest = tend.previousPivot(); - control2 = dest.previousPivot(); - } else - return; - - deleteCurve(control1,control2); - recursiveCurve((*origin).point(),(*control1).point(),(*control2).point(),(*dest).point(),1,control2); - -} - -KisCurve::iterator KisCurveBezier::pushPivot (const KisPoint& point) -{ - iterator it; - - it = pushPoint(point,true,false,BEZIERENDHINT); - if (count() > 1) - addPoint(it,point,true,false,BEZIERPREVCONTROLHINT); - - it = pushPoint(point,true,false,BEZIERNEXTCONTROLHINT); - - return selectPivot(it); -} - -KisCurve::iterator KisCurveBezier::movePivot(KisCurve::iterator it, const KisPoint& newPt) -{ - if (!(*it).isPivot()) - return end(); - - int hint = (*it).hint(); - iterator thisEnd, prevEnd, nextEnd; - - thisEnd = groupEndpoint(it); - prevEnd = prevGroupEndpoint(it); - nextEnd = nextGroupEndpoint(it); - - if (hint == BEZIERENDHINT) { - KisPoint trans = newPt - (*it).point(); - (*thisEnd).setPoint((*thisEnd).point()+trans); - (*thisEnd.previous()).setPoint((*thisEnd.previous()).point()+trans); - (*thisEnd.next()).setPoint((*thisEnd.next()).point()+trans); - } else if (!(m_actionOptions & KEEPSELECTEDOPTION)) - (*it).setPoint(newPt); - if (!(m_actionOptions & KEEPSELECTEDOPTION) && hint != BEZIERENDHINT) { - if (nextEnd == end() || (m_actionOptions & SYMMETRICALCONTROLSOPTION)) { - KisPoint trans = (*it).point() - (*thisEnd).point(); - trans = KisPoint(-trans.x()*2,-trans.y()*2); - if (hint == BEZIERNEXTCONTROLHINT) - (*groupPrevControl(it)).setPoint(newPt+trans); - else - (*groupNextControl(it)).setPoint(newPt+trans); - } - } - - if (nextEnd != end() && count() > 4) - calculateCurve (thisEnd,nextEnd,iterator()); - if (prevEnd != thisEnd && count() > 4) - calculateCurve (prevEnd,thisEnd,iterator()); - - return it; -} - -void KisCurveBezier::deletePivot (KisCurve::iterator it) -{ - if (!(*it).isPivot()) - return; - - iterator prevControl,thisEnd,nextControl; - - prevControl = prevGroupEndpoint(it).nextPivot(); - thisEnd = groupEndpoint(it); - nextControl = nextGroupEndpoint(it).previousPivot(); - - if ((*thisEnd) == first()) { - deleteFirstPivot(); - deleteFirstPivot(); - deleteFirstPivot(); - } else if ((*thisEnd.next()) == last()) { - deleteLastPivot(); - deleteLastPivot(); - deleteLastPivot(); - } else { - deleteCurve(prevControl,nextControl); - calculateCurve(prevControl,nextControl,iterator()); - } -} - -KisToolBezier::KisToolBezier(const TQString& UIName) - : super(UIName) -{ - m_derivated = new KisCurveBezier; - m_curve = m_derivated; - - m_supportMinimalDraw = false; - - m_transactionMessage = i18n("Bezier Curve"); -} - -KisToolBezier::~KisToolBezier() -{ - -} - -KisCurve::iterator KisToolBezier::handleUnderMouse(const TQPoint& pos) -{ - TQPoint qpos; - KisCurve pivs = m_curve->pivots(), inHandle; - KisCurve::iterator it; - int hint; - for (it = pivs.begin(); it != pivs.end(); it++) { - qpos = m_subject->canvasController()->windowToView((*it).point().toTQPoint()); - hint = (*it).hint(); - if (hint != BEZIERENDHINT && !m_derivated->groupSelected(it)) - continue; - if (hint == BEZIERENDHINT && (m_actionOptions & SHIFTOPTION)) - continue; - if (pivotRect(qpos).contains(pos)) { - inHandle.pushPoint((*it)); - if (hint == BEZIERENDHINT && !(m_actionOptions & SHIFTOPTION)) - break; - if (hint != BEZIERENDHINT && (m_actionOptions & SHIFTOPTION)) - break; - } - } - if (inHandle.isEmpty()) - return m_curve->end(); - - return m_curve->find(inHandle.last()); -} - -KisCurve::iterator KisToolBezier::drawPoint (KisCanvasPainter& gc, KisCurve::iterator point) -{ - if ((*point).hint() != BEZIERENDHINT) - return ++point; - - KisCanvasController *controller = m_subject->canvasController(); - - // Now draw the bezier - - KisCurve::iterator origin,control1,control2,destination; - - origin = point; - control1 = origin.next(); - control2 = control1.nextPivot(); - destination = control2.next(); - - if (control2 != m_curve->end()) { - point = control2; - TQPointArray vec(4); - vec[0] = controller->windowToView((*origin).point().toTQPoint()); - vec[1] = controller->windowToView((*control1).point().toTQPoint()); - vec[2] = controller->windowToView((*control2).point().toTQPoint()); - vec[3] = controller->windowToView((*destination).point().toTQPoint()); - gc.drawCubicBezier(vec); - } - - point += 1; - - return point; -} - -void KisToolBezier::drawPivotHandle (KisCanvasPainter& gc, KisCurve::iterator point) -{ - if ((*point).hint() != BEZIERENDHINT) - return; - - KisCanvasController *controller = m_subject->canvasController(); - - TQPoint endpPos = controller->windowToView((*point).point().toTQPoint()); - - if (!m_derivated->groupSelected(point)) { - gc.setPen(m_pivotPen); - gc.drawRoundRect(pivotRect(endpPos),m_pivotRounding,m_pivotRounding); - } else { - TQPoint nextControlPos = controller->windowToView((*point.next()).point().toTQPoint()); - TQPoint prevControlPos = controller->windowToView((*point.previousPivot()).point().toTQPoint()); - - gc.setPen(m_selectedPivotPen); - gc.drawRoundRect(selectedPivotRect(endpPos),m_selectedPivotRounding,m_selectedPivotRounding); - if ((prevControlPos != endpPos || nextControlPos != endpPos) && !(m_actionOptions & CONTROLOPTION)) { - gc.drawRoundRect(pivotRect(nextControlPos),m_pivotRounding,m_pivotRounding); - gc.drawLine(endpPos,nextControlPos); - gc.drawRoundRect(pivotRect(prevControlPos),m_pivotRounding,m_pivotRounding); - gc.drawLine(prevControlPos,endpPos); - } - } - - gc.setPen(m_drawingPen); -} - -#include "kis_tool_bezier.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_bezier.cpp b/chalk/plugins/tools/tool_curves/kis_tool_bezier.cpp new file mode 100644 index 00000000..9195dfbd --- /dev/null +++ b/chalk/plugins/tools/tool_curves/kis_tool_bezier.cpp @@ -0,0 +1,366 @@ +/* + * kis_tool_bezier.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_global.h" +#include "kis_doc.h" +#include "kis_painter.h" +#include "kis_point.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_vec.h" + +#include "kis_curve_framework.h" +#include "kis_tool_bezier.h" + +KisCurve::iterator KisCurveBezier::groupEndpoint (KisCurve::iterator it) const +{ + iterator temp = it; + if ((*it).hint() == BEZIERNEXTCONTROLHINT) + temp -= 1; + if ((*it).hint() == BEZIERPREVCONTROLHINT) + temp += 1; + return temp; +} + +KisCurve::iterator KisCurveBezier::groupPrevControl (KisCurve::iterator it) const +{ + iterator temp = it; + if ((*it).hint() == BEZIERENDHINT) + temp -= 1; + if ((*it).hint() == BEZIERNEXTCONTROLHINT) + temp -= 2; + return temp; +} + +KisCurve::iterator KisCurveBezier::groupNextControl (KisCurve::iterator it) const +{ + iterator temp = it; + if ((*it).hint() == BEZIERENDHINT) + temp += 1; + if ((*it).hint() == BEZIERPREVCONTROLHINT) + temp += 2; + return temp; +} + +bool KisCurveBezier::groupSelected (KisCurve::iterator it) const +{ + if ((*groupPrevControl(it)).isSelected() || (*groupEndpoint(it)).isSelected() || (*groupNextControl(it)).isSelected()) + return true; + return false; +} + +KisCurve::iterator KisCurveBezier::nextGroupEndpoint (KisCurve::iterator it) const +{ + iterator temp = it; + if ((*it).hint() == BEZIERPREVCONTROLHINT) { + temp += 2; + temp = temp.nextPivot(); + } + if ((*it).hint() == BEZIERENDHINT) { + temp += 1; + temp = temp.nextPivot(); + } + if ((*it).hint() == BEZIERNEXTCONTROLHINT) { + temp = temp.nextPivot(); + } + temp = temp.nextPivot(); + return temp; +} + +KisCurve::iterator KisCurveBezier::prevGroupEndpoint (KisCurve::iterator it) const +{ + iterator temp = it; + if ((*it).hint() == BEZIERNEXTCONTROLHINT) { + temp -= 1; + temp = temp.previousPivot().previousPivot(); + } + if ((*it).hint() == BEZIERENDHINT) { + temp = temp.previousPivot().previousPivot(); + } + if ((*it).hint() == BEZIERPREVCONTROLHINT) { + temp = temp.previousPivot(); + } + temp = temp.previousPivot(); + return temp; +} + +KisPoint KisCurveBezier::midpoint (const KisPoint& P1, const KisPoint& P2) +{ + KisPoint temp; + temp.setX((P1.x()+P2.x())/2); + temp.setY((P1.y()+P2.y())/2); + return temp; +} + +void KisCurveBezier::recursiveCurve (const KisPoint& P1, const KisPoint& P2, const KisPoint& P3, + const KisPoint& P4, int level, KisCurve::iterator it) +{ + if (level > m_maxLevel) { + addPoint(it,midpoint(P1,P4),false,false,LINEHINT); + return; + } + + KisPoint L1, L2, L3, L4; + KisPoint H, R1, R2, R3, R4; + + L1 = P1; + L2 = midpoint(P1, P2); + H = midpoint(P2, P3); + R3 = midpoint(P3, P4); + R4 = P4; + L3 = midpoint(L2, H); + R2 = midpoint(R3, H); + L4 = midpoint(L3, R2); + R1 = L4; + recursiveCurve(L1, L2, L3, L4, level + 1, it); + recursiveCurve(R1, R2, R3, R4, level + 1, it); +} + +void KisCurveBezier::calculateCurve(KisCurve::iterator tstart, KisCurve::iterator tend, KisCurve::iterator) +{ + if (pivots().count() < 4) + return; + + iterator origin, dest, control1, control2; + + if ((*tstart).hint() == BEZIERENDHINT) { + origin = tstart; + control1 = tstart.nextPivot(); + } else if ((*tstart).hint() == BEZIERNEXTCONTROLHINT) { + origin = tstart.previousPivot(); + control1 = tstart; + } else if ((*tstart).hint() == BEZIERPREVCONTROLHINT) { + origin = tstart.nextPivot(); + control1 = origin.nextPivot(); + } else + return; + + if ((*tend).hint() == BEZIERENDHINT) { + dest = tend; + control2 = tend.previousPivot(); + } else if ((*tend).hint() == BEZIERPREVCONTROLHINT) { + dest = tend.nextPivot(); + control2 = tend; + } else if ((*tend).hint() == BEZIERNEXTCONTROLHINT) { + dest = tend.previousPivot(); + control2 = dest.previousPivot(); + } else + return; + + deleteCurve(control1,control2); + recursiveCurve((*origin).point(),(*control1).point(),(*control2).point(),(*dest).point(),1,control2); + +} + +KisCurve::iterator KisCurveBezier::pushPivot (const KisPoint& point) +{ + iterator it; + + it = pushPoint(point,true,false,BEZIERENDHINT); + if (count() > 1) + addPoint(it,point,true,false,BEZIERPREVCONTROLHINT); + + it = pushPoint(point,true,false,BEZIERNEXTCONTROLHINT); + + return selectPivot(it); +} + +KisCurve::iterator KisCurveBezier::movePivot(KisCurve::iterator it, const KisPoint& newPt) +{ + if (!(*it).isPivot()) + return end(); + + int hint = (*it).hint(); + iterator thisEnd, prevEnd, nextEnd; + + thisEnd = groupEndpoint(it); + prevEnd = prevGroupEndpoint(it); + nextEnd = nextGroupEndpoint(it); + + if (hint == BEZIERENDHINT) { + KisPoint trans = newPt - (*it).point(); + (*thisEnd).setPoint((*thisEnd).point()+trans); + (*thisEnd.previous()).setPoint((*thisEnd.previous()).point()+trans); + (*thisEnd.next()).setPoint((*thisEnd.next()).point()+trans); + } else if (!(m_actionOptions & KEEPSELECTEDOPTION)) + (*it).setPoint(newPt); + if (!(m_actionOptions & KEEPSELECTEDOPTION) && hint != BEZIERENDHINT) { + if (nextEnd == end() || (m_actionOptions & SYMMETRICALCONTROLSOPTION)) { + KisPoint trans = (*it).point() - (*thisEnd).point(); + trans = KisPoint(-trans.x()*2,-trans.y()*2); + if (hint == BEZIERNEXTCONTROLHINT) + (*groupPrevControl(it)).setPoint(newPt+trans); + else + (*groupNextControl(it)).setPoint(newPt+trans); + } + } + + if (nextEnd != end() && count() > 4) + calculateCurve (thisEnd,nextEnd,iterator()); + if (prevEnd != thisEnd && count() > 4) + calculateCurve (prevEnd,thisEnd,iterator()); + + return it; +} + +void KisCurveBezier::deletePivot (KisCurve::iterator it) +{ + if (!(*it).isPivot()) + return; + + iterator prevControl,thisEnd,nextControl; + + prevControl = prevGroupEndpoint(it).nextPivot(); + thisEnd = groupEndpoint(it); + nextControl = nextGroupEndpoint(it).previousPivot(); + + if ((*thisEnd) == first()) { + deleteFirstPivot(); + deleteFirstPivot(); + deleteFirstPivot(); + } else if ((*thisEnd.next()) == last()) { + deleteLastPivot(); + deleteLastPivot(); + deleteLastPivot(); + } else { + deleteCurve(prevControl,nextControl); + calculateCurve(prevControl,nextControl,iterator()); + } +} + +KisToolBezier::KisToolBezier(const TQString& UIName) + : super(UIName) +{ + m_derivated = new KisCurveBezier; + m_curve = m_derivated; + + m_supportMinimalDraw = false; + + m_transactionMessage = i18n("Bezier Curve"); +} + +KisToolBezier::~KisToolBezier() +{ + +} + +KisCurve::iterator KisToolBezier::handleUnderMouse(const TQPoint& pos) +{ + TQPoint qpos; + KisCurve pivs = m_curve->pivots(), inHandle; + KisCurve::iterator it; + int hint; + for (it = pivs.begin(); it != pivs.end(); it++) { + qpos = m_subject->canvasController()->windowToView((*it).point().toTQPoint()); + hint = (*it).hint(); + if (hint != BEZIERENDHINT && !m_derivated->groupSelected(it)) + continue; + if (hint == BEZIERENDHINT && (m_actionOptions & SHIFTOPTION)) + continue; + if (pivotRect(qpos).contains(pos)) { + inHandle.pushPoint((*it)); + if (hint == BEZIERENDHINT && !(m_actionOptions & SHIFTOPTION)) + break; + if (hint != BEZIERENDHINT && (m_actionOptions & SHIFTOPTION)) + break; + } + } + if (inHandle.isEmpty()) + return m_curve->end(); + + return m_curve->find(inHandle.last()); +} + +KisCurve::iterator KisToolBezier::drawPoint (KisCanvasPainter& gc, KisCurve::iterator point) +{ + if ((*point).hint() != BEZIERENDHINT) + return ++point; + + KisCanvasController *controller = m_subject->canvasController(); + + // Now draw the bezier + + KisCurve::iterator origin,control1,control2,destination; + + origin = point; + control1 = origin.next(); + control2 = control1.nextPivot(); + destination = control2.next(); + + if (control2 != m_curve->end()) { + point = control2; + TQPointArray vec(4); + vec[0] = controller->windowToView((*origin).point().toTQPoint()); + vec[1] = controller->windowToView((*control1).point().toTQPoint()); + vec[2] = controller->windowToView((*control2).point().toTQPoint()); + vec[3] = controller->windowToView((*destination).point().toTQPoint()); + gc.drawCubicBezier(vec); + } + + point += 1; + + return point; +} + +void KisToolBezier::drawPivotHandle (KisCanvasPainter& gc, KisCurve::iterator point) +{ + if ((*point).hint() != BEZIERENDHINT) + return; + + KisCanvasController *controller = m_subject->canvasController(); + + TQPoint endpPos = controller->windowToView((*point).point().toTQPoint()); + + if (!m_derivated->groupSelected(point)) { + gc.setPen(m_pivotPen); + gc.drawRoundRect(pivotRect(endpPos),m_pivotRounding,m_pivotRounding); + } else { + TQPoint nextControlPos = controller->windowToView((*point.next()).point().toTQPoint()); + TQPoint prevControlPos = controller->windowToView((*point.previousPivot()).point().toTQPoint()); + + gc.setPen(m_selectedPivotPen); + gc.drawRoundRect(selectedPivotRect(endpPos),m_selectedPivotRounding,m_selectedPivotRounding); + if ((prevControlPos != endpPos || nextControlPos != endpPos) && !(m_actionOptions & CONTROLOPTION)) { + gc.drawRoundRect(pivotRect(nextControlPos),m_pivotRounding,m_pivotRounding); + gc.drawLine(endpPos,nextControlPos); + gc.drawRoundRect(pivotRect(prevControlPos),m_pivotRounding,m_pivotRounding); + gc.drawLine(prevControlPos,endpPos); + } + } + + gc.setPen(m_drawingPen); +} + +#include "kis_tool_bezier.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cc b/chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cc deleted file mode 100644 index 06f34f8c..00000000 --- a/chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * kis_tool_curve.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_cmb_composite.h" -#include "kis_colorspace.h" -#include "kis_config.h" -#include "kis_cursor.h" -#include "kis_doc.h" -#include "kis_global.h" -#include "kis_image.h" -#include "kis_int_spinbox.h" -#include "kis_paint_device.h" -#include "kis_painter.h" -#include "kis_paintop_registry.h" -#include "kis_point.h" -#include "kis_tool_controller.h" -#include "kis_tool_paint.h" - -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_canvas_subject.h" - -#include "kis_curve_framework.h" -#include "kis_tool_bezier_paint.h" - -KisToolBezierPaint::KisToolBezierPaint() - : super(i18n("Bezier Painting Tool")) -{ - setName("tool_bezier_paint"); - m_cursor = "tool_bezier_cursor.png"; - setCursor(KisCursor::load(m_cursor, 6, 6)); -} - -KisToolBezierPaint::~KisToolBezierPaint() -{ - -} - -KisCurve::iterator KisToolBezierPaint::paintPoint (KisPainter& painter, KisCurve::iterator point) -{ - KisCurve::iterator origin,destination,control1,control2; - switch ((*point).hint()) { - case BEZIERENDHINT: - origin = point++; - control1 = point; - control2 = control1.nextPivot(); - destination = control2.next(); - if (m_curve->count() > 4 && (*point) != m_curve->last()) { - point = point.nextPivot().next(); - painter.paintAt((*origin).point(),PRESSURE_DEFAULT,0,0); - painter.paintBezierCurve((*origin).point(),PRESSURE_DEFAULT,0,0,(*control1).point(), - (*control2).point(),(*destination).point(),PRESSURE_DEFAULT,0,0,0); - } - break; - default: - point = super::paintPoint(painter,point); - } - - return point; -} - -void KisToolBezierPaint::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("&Bezier"), - "tool_bezier_paint", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Draw cubic beziers. Keep Alt, Control or Shift pressed for options. Return or double-click to finish.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_bezier_paint.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cpp b/chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cpp new file mode 100644 index 00000000..a8d1514b --- /dev/null +++ b/chalk/plugins/tools/tool_curves/kis_tool_bezier_paint.cpp @@ -0,0 +1,115 @@ +/* + * kis_tool_curve.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_cmb_composite.h" +#include "kis_colorspace.h" +#include "kis_config.h" +#include "kis_cursor.h" +#include "kis_doc.h" +#include "kis_global.h" +#include "kis_image.h" +#include "kis_int_spinbox.h" +#include "kis_paint_device.h" +#include "kis_painter.h" +#include "kis_paintop_registry.h" +#include "kis_point.h" +#include "kis_tool_controller.h" +#include "kis_tool_paint.h" + +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_canvas_subject.h" + +#include "kis_curve_framework.h" +#include "kis_tool_bezier_paint.h" + +KisToolBezierPaint::KisToolBezierPaint() + : super(i18n("Bezier Painting Tool")) +{ + setName("tool_bezier_paint"); + m_cursor = "tool_bezier_cursor.png"; + setCursor(KisCursor::load(m_cursor, 6, 6)); +} + +KisToolBezierPaint::~KisToolBezierPaint() +{ + +} + +KisCurve::iterator KisToolBezierPaint::paintPoint (KisPainter& painter, KisCurve::iterator point) +{ + KisCurve::iterator origin,destination,control1,control2; + switch ((*point).hint()) { + case BEZIERENDHINT: + origin = point++; + control1 = point; + control2 = control1.nextPivot(); + destination = control2.next(); + if (m_curve->count() > 4 && (*point) != m_curve->last()) { + point = point.nextPivot().next(); + painter.paintAt((*origin).point(),PRESSURE_DEFAULT,0,0); + painter.paintBezierCurve((*origin).point(),PRESSURE_DEFAULT,0,0,(*control1).point(), + (*control2).point(),(*destination).point(),PRESSURE_DEFAULT,0,0,0); + } + break; + default: + point = super::paintPoint(painter,point); + } + + return point; +} + +void KisToolBezierPaint::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("&Bezier"), + "tool_bezier_paint", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Draw cubic beziers. Keep Alt, Control or Shift pressed for options. Return or double-click to finish.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_bezier_paint.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cc b/chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cc deleted file mode 100644 index 72418920..00000000 --- a/chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - * kis_tool_curve.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_cmb_composite.h" -#include "kis_colorspace.h" -#include "kis_config.h" -#include "kis_cursor.h" -#include "kis_doc.h" -#include "kis_global.h" -#include "kis_image.h" -#include "kis_int_spinbox.h" -#include "kis_paint_device.h" -#include "kis_painter.h" -#include "kis_paintop_registry.h" -#include "kis_point.h" -#include "kis_tool_controller.h" -#include "kis_tool_paint.h" - -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_canvas_subject.h" - -#include "kis_curve_framework.h" -#include "kis_tool_bezier_select.h" - -KisToolBezierSelect::KisToolBezierSelect() - : super(i18n("Bezier Selection Tool")) -{ - setName("tool_bezier_select"); - m_cursor = "tool_bezier_cursor.png"; - setCursor(KisCursor::load(m_cursor, 6, 6)); -} - -KisToolBezierSelect::~KisToolBezierSelect() -{ - -} - -TQValueVector KisToolBezierSelect::convertCurve() -{ - TQValueVector points; - - for (KisCurve::iterator i = m_curve->begin(); i != m_curve->end(); i++) { - if (((*i).hint() != BEZIERPREVCONTROLHINT) && ((*i).hint() != BEZIERNEXTCONTROLHINT)) - points.append((*i).point()); - } - - return points; -} - -void KisToolBezierSelect::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("&Bezier"), - "tool_bezier_select", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Select areas of the image with bezier paths.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_bezier_select.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cpp b/chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cpp new file mode 100644 index 00000000..65735860 --- /dev/null +++ b/chalk/plugins/tools/tool_curves/kis_tool_bezier_select.cpp @@ -0,0 +1,104 @@ +/* + * kis_tool_curve.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_cmb_composite.h" +#include "kis_colorspace.h" +#include "kis_config.h" +#include "kis_cursor.h" +#include "kis_doc.h" +#include "kis_global.h" +#include "kis_image.h" +#include "kis_int_spinbox.h" +#include "kis_paint_device.h" +#include "kis_painter.h" +#include "kis_paintop_registry.h" +#include "kis_point.h" +#include "kis_tool_controller.h" +#include "kis_tool_paint.h" + +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_canvas_subject.h" + +#include "kis_curve_framework.h" +#include "kis_tool_bezier_select.h" + +KisToolBezierSelect::KisToolBezierSelect() + : super(i18n("Bezier Selection Tool")) +{ + setName("tool_bezier_select"); + m_cursor = "tool_bezier_cursor.png"; + setCursor(KisCursor::load(m_cursor, 6, 6)); +} + +KisToolBezierSelect::~KisToolBezierSelect() +{ + +} + +TQValueVector KisToolBezierSelect::convertCurve() +{ + TQValueVector points; + + for (KisCurve::iterator i = m_curve->begin(); i != m_curve->end(); i++) { + if (((*i).hint() != BEZIERPREVCONTROLHINT) && ((*i).hint() != BEZIERNEXTCONTROLHINT)) + points.append((*i).point()); + } + + return points; +} + +void KisToolBezierSelect::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("&Bezier"), + "tool_bezier_select", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Select areas of the image with bezier paths.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_bezier_select.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_curve.cc b/chalk/plugins/tools/tool_curves/kis_tool_curve.cc deleted file mode 100644 index 7449e581..00000000 --- a/chalk/plugins/tools/tool_curves/kis_tool_curve.cc +++ /dev/null @@ -1,593 +0,0 @@ -/* - * kis_tool_curve.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "kis_global.h" -#include "kis_doc.h" -#include "kis_painter.h" -#include "kis_point.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_tool_controller.h" -#include "kis_vec.h" -#include "kis_selection.h" -#include "kis_selection_options.h" -#include "kis_selected_transaction.h" -#include "kis_paintop_registry.h" - -#include "kis_curve_framework.h" -#include "kis_tool_curve.h" - -TQRect KisToolCurve::pivotRect (const TQPoint& pos) -{ - return TQRect (pos-TQPoint(4,4),pos+TQPoint(4,4)); -} - -TQRect KisToolCurve::selectedPivotRect (const TQPoint& pos) -{ - return TQRect (pos-TQPoint(5,5),pos+TQPoint(5,5)); -} - -KisToolCurve::KisToolCurve(const TQString& UIName) - : super(UIName) -{ - m_UIName = UIName; - m_currentImage = 0; - m_optWidget = 0; - - m_curve = 0; - - m_dragging = false; - m_draggingCursor = false; - m_drawPivots = true; - m_drawingPen = TQPen(TQt::white, 0, TQt::SolidLine); - m_pivotPen = TQPen(TQt::gray, 0, TQt::SolidLine); - m_selectedPivotPen = TQPen(TQt::yellow, 0, TQt::SolidLine); - m_pivotRounding = m_selectedPivotRounding = 55; - - m_actionOptions = NOOPTIONS; - m_supportMinimalDraw = true; - m_selectAction = SELECTION_ADD; -} - -KisToolCurve::~KisToolCurve() -{ - -} - -void KisToolCurve::update (KisCanvasSubject *subject) -{ - super::update(subject); - if (m_subject) - m_currentImage = m_subject->currentImg(); -} - -void KisToolCurve::deactivate() -{ - draw(false); - if (m_curve) { - m_curve->clear(); - m_curve->endActionOptions(); - } - - m_actionOptions = NOOPTIONS; - m_dragging = false; - m_drawPivots = true; -} - -void KisToolCurve::buttonPress(KisButtonPressEvent *event) -{ - updateOptions(event->state()); - if (!m_currentImage) - return; - if (event->button() == Qt::LeftButton) { - m_dragging = true; - m_currentPoint = event->pos(); - PointPair temp = pointUnderMouse (m_subject->canvasController()->windowToView(event->pos().toTQPoint())); - if (temp.first == m_curve->end() && !(m_actionOptions)) { - draw(true, true); - m_curve->selectAll(false); - draw(true, true); - draw(m_curve->end()); - m_previous = m_curve->find(m_curve->last()); - m_current = m_curve->pushPivot(event->pos()); - if (m_curve->pivots().count() > 1) - m_curve->calculateCurve(m_previous,m_current,m_current); - draw(m_current); - } else { - draw(true, true); - if (temp.second) - m_current = m_curve->selectPivot(temp.first); - else - m_current = selectByMouse(temp.first); - - if (!(*m_current).isSelected()) - m_dragging = false; - draw(true, true); - } - } -} - -void KisToolCurve::keyPress(TQKeyEvent *event) -{ - if (event->key() == TQt::Key_Return) { - m_dragging = false; - commitCurve(); - } else - if (event->key() == TQt::Key_Escape) { - m_dragging = false; - draw(false); - m_curve->clear(); - } else - if (event->key() == TQt::Key_Delete) { - draw(false); - m_dragging = false; - m_curve->deleteSelected(); - m_current = m_curve->find(m_curve->last()); - m_previous = m_curve->selectPivot(m_current); - draw(false); - } -} - -void KisToolCurve::keyRelease(TQKeyEvent *) -{ - -} - -void KisToolCurve::buttonRelease(KisButtonReleaseEvent *event) -{ - updateOptions(event->state()); - m_dragging = false; -} - -void KisToolCurve::doubleClick(KisDoubleClickEvent *) -{ - commitCurve(); -} - -void KisToolCurve::move(KisMoveEvent *event) -{ - updateOptions(event->state()); - PointPair temp = pointUnderMouse(m_subject->canvasController()->windowToView(event->pos().toTQPoint())); - if (temp.first == m_curve->end() && !m_dragging) { - if (m_draggingCursor) { - setCursor(KisCursor::load(m_cursor, 6, 6)); - m_draggingCursor = false; - } - } else { - setCursor(KisCursor::load("tool_curve_dragging.png", 6, 6)); - m_draggingCursor = true; - } - if (m_dragging) { - draw(); - KisPoint trans = event->pos() - m_currentPoint; - m_curve->moveSelected(trans); - m_currentPoint = event->pos(); - draw(); - } -} - -double pointToSegmentDistance(const KisPoint& p, const KisPoint& l0, const KisPoint& l1) -{ - double lineLength = sqrt((l1.x() - l0.x()) * (l1.x() - l0.x()) + (l1.y() - l0.y()) * (l1.y() - l0.y())); - double distance = 0; - KisVector2D v0(l0), v1(l1), v(p), seg(v0-v1), dist0(v0-p), dist1(v1-p); - - if (seg.length() < dist0.length() || - seg.length() < dist1.length()) // the point doesn't perpendicolarly intersecate the segment (or it's too far from the segment) - return (double)INT_MAX; - - if (lineLength > DBL_EPSILON) { - distance = ((l0.y() - l1.y()) * p.x() + (l1.x() - l0.x()) * p.y() + l0.x() * l1.y() - l1.x() * l0.y()) / lineLength; - distance = fabs(distance); - } - - return distance; -} - -PointPair KisToolCurve::pointUnderMouse(const TQPoint& pos) -{ - KisCurve::iterator it, next; - TQPoint pos1, pos2; - it = handleUnderMouse(pos); - if (it != m_curve->end()) - return PointPair(it,true); - - for (it = m_curve->begin(); it != m_curve->end(); it++) { - next = it.next(); - if (next == m_curve->end() || it == m_curve->end()) - return PointPair(m_curve->end(),false); - if ((*it).hint() > LINEHINT || (*next).hint() > LINEHINT) - continue; - pos1 = m_subject->canvasController()->windowToView((*it).point().toTQPoint()); - pos2 = m_subject->canvasController()->windowToView((*next).point().toTQPoint()); - if (pos1 == pos2) - continue; - if (pointToSegmentDistance(pos,pos1,pos2) <= MAXDISTANCE) - break; - } - - return PointPair(it,false); -} - -KisCurve::iterator KisToolCurve::handleUnderMouse(const TQPoint& pos) -{ - KisCurve pivs = m_curve->pivots(), inHandle; - KisCurve::iterator it; - for (it = pivs.begin(); it != pivs.end(); it++) { - if (pivotRect(m_subject->canvasController()->windowToView((*it).point().toTQPoint())).contains(pos)) - inHandle.pushPoint((*it)); - } - if (inHandle.isEmpty()) - return m_curve->end(); - return m_curve->find(inHandle.last()); -} - -KisCurve::iterator KisToolCurve::selectByMouse(KisCurve::iterator it) -{ - KisCurve::iterator prevPivot, nextPivot; - - if ((*it).isPivot()) - prevPivot = it; - else - prevPivot = it.previousPivot(); - nextPivot = it.nextPivot(); - - m_curve->selectPivot(prevPivot); - (*nextPivot).setSelected(true); - - return prevPivot; -} - -int KisToolCurve::updateOptions(int key) -{ - int options = 0x0000; - - if (key & TQt::ControlButton) - options |= CONTROLOPTION; - - if (key & TQt::ShiftButton) - options |= SHIFTOPTION; - - if (key & TQt::AltButton) - options |= ALTOPTION; - - if (options != m_actionOptions) { - draw(false); - m_actionOptions = options; - m_curve->setActionOptions(m_actionOptions); - draw(false); - } - - return m_actionOptions; -} - -void KisToolCurve::draw(bool m, bool o) -{ - draw(KisCurve::iterator(), o, m); -} - -void KisToolCurve::draw(KisCurve::iterator inf, bool pivotonly, bool minimal) -{ - if (m_curve->isEmpty()) - return; - KisCanvasPainter *gc; - KisCanvasController *controller; - KisCanvas *canvas; - if (m_subject && m_currentImage) { - controller = m_subject->canvasController(); - canvas = controller->kiscanvas(); - gc = new KisCanvasPainter(canvas); - } else - return; - - gc->setPen(m_drawingPen); - gc->setRasterOp(TQt::XorROP); - - KisCurve::iterator it, finish; - - if (minimal && m_supportMinimalDraw) { - if (pivotonly) { - KisCurve p = m_curve->pivots(); - for (KisCurve::iterator i = p.begin(); i != p.end(); i++) - drawPivotHandle (*gc, i); - delete gc; - return; - } - if (inf.target() != 0) { - if (inf != m_curve->end()) { - it = inf.previousPivot(); - finish = inf.nextPivot(); - } else { - it = --m_curve->end(); - finish = m_curve->end(); - } - } else { - KisCurve sel = m_curve->selectedPivots(); - if (sel.isEmpty()) { - delete gc; - return; - } - for (KisCurve::iterator i = sel.begin(); i != sel.end(); i++) { - it = m_curve->find(*i).previousPivot(); - finish = m_curve->find(*i).nextPivot(); - if ((*finish).isSelected()) - finish = finish.previousPivot(); - while (it != finish) { - if ((*it).isPivot()) - drawPivotHandle (*gc, it); - it = drawPoint (*gc, it); - } - } - delete gc; - return; - } - } else { - it = m_curve->begin(); - finish = m_curve->end(); - } - while (it != finish) { - if ((*it).isPivot()) - drawPivotHandle (*gc, it); - it = drawPoint (*gc, it); - } - - delete gc; -} - -KisCurve::iterator KisToolCurve::drawPoint(KisCanvasPainter& gc, KisCurve::iterator point) -{ - KisCanvasController *controller = m_subject->canvasController(); - - TQPoint pos1, pos2; - pos1 = controller->windowToView((*point).point().toTQPoint()); - - switch ((*point).hint()) { - case POINTHINT: - gc.drawPoint(pos1); - point += 1; - break; - case LINEHINT: - gc.drawPoint(pos1); - if (++point != m_curve->end() && (*point).hint() <= LINEHINT) { - pos2 = controller->windowToView((*point).point().toTQPoint()); - gc.drawLine(pos1,pos2); - } - break; - default: - point += 1; - } - - return point; -} - -void KisToolCurve::drawPivotHandle(KisCanvasPainter& gc, KisCurve::iterator point) -{ - KisCanvasController *controller = m_subject->canvasController(); - - if (m_drawPivots) { - TQPoint pos = controller->windowToView((*point).point().toTQPoint()); - if ((*point).isSelected()) { - gc.setPen(m_selectedPivotPen); - gc.drawRoundRect(selectedPivotRect(pos),m_selectedPivotRounding,m_selectedPivotRounding); - } else { - gc.setPen(m_pivotPen); - gc.drawRoundRect(pivotRect(pos),m_pivotRounding,m_pivotRounding); - } - gc.setPen(m_drawingPen); - } -} - -void KisToolCurve::paint(KisCanvasPainter&) -{ - draw(false); -} - -void KisToolCurve::paint(KisCanvasPainter&, const TQRect&) -{ - draw(false); -} - -void KisToolCurve::commitCurve() -{ - if (toolType() == TOOL_SHAPE || toolType() == TOOL_FREEHAND) - paintCurve(); - else if (toolType() == TOOL_SELECT) - selectCurve(); - else - kdDebug(0) << "NO SUPPORT FOR THIS TYPE OF TOOL" << endl; - - m_curve->clear(); - m_curve->endActionOptions(); -} - -void KisToolCurve::paintCurve() -{ - KisPaintDeviceSP device = m_currentImage->activeDevice (); - if (!device) return; - - KisPainter painter (device); - if (m_currentImage->undo()) painter.beginTransaction (m_transactionMessage); - - painter.setPaintColor(m_subject->fgColor()); - painter.setBrush(m_subject->currentBrush()); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); - painter.setPaintOp(op); // Painter takes ownership - -// Call paintPoint - KisCurve::iterator it = m_curve->begin(); - while (it != m_curve->end()) - it = paintPoint(painter,it); -// Finish - - device->setDirty( painter.dirtyRect() ); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); - } - - draw(false); -} - -KisCurve::iterator KisToolCurve::paintPoint (KisPainter& painter, KisCurve::iterator point) -{ - KisCurve::iterator next = point; next+=1; - switch ((*point).hint()) { - case POINTHINT: - painter.paintAt((*point++).point(), PRESSURE_DEFAULT, 0, 0); - break; - case LINEHINT: - if (next != m_curve->end() && (*next).hint() <= LINEHINT) - painter.paintLine((*point++).point(), PRESSURE_DEFAULT, 0, 0, (*next).point(), PRESSURE_DEFAULT, 0, 0); - else - painter.paintAt((*point++).point(), PRESSURE_DEFAULT, 0, 0); - break; - default: - point += 1; - } - - return point; -} - -TQValueVector KisToolCurve::convertCurve() -{ - TQValueVector points; - - for (KisCurve::iterator i = m_curve->begin(); i != m_curve->end(); i++) - if ((*i).hint() != NOHINTS) - points.append((*i).point()); - - return points; -} - -void KisToolCurve::selectCurve() -{ - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - KisPaintDeviceSP dev = m_currentImage->activeDevice(); - bool hasSelection = dev->hasSelection(); - KisSelectedTransaction *t = 0; - if (m_currentImage->undo()) t = new KisSelectedTransaction(m_transactionMessage, dev); - KisSelectionSP selection = dev->selection(); - - if (!hasSelection) { - selection->clear(); - } - - KisPainter painter(selection.data()); - - painter.setPaintColor(KisColor(TQt::black, selection->colorSpace())); - painter.setFillStyle(KisPainter::FillStyleForegroundColor); - painter.setStrokeStyle(KisPainter::StrokeStyleNone); - painter.setBrush(m_subject->currentBrush()); - painter.setOpacity(OPACITY_OPAQUE); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, &painter); - painter.setPaintOp(op); // And now the painter owns the op and will destroy it. - - switch (m_selectAction) { - case SELECTION_ADD: - painter.setCompositeOp(COMPOSITE_OVER); - break; - case SELECTION_SUBTRACT: - painter.setCompositeOp(COMPOSITE_SUBTRACT); - break; - default: - break; - } - - painter.paintPolygon(convertCurve()); - - - if(hasSelection) { - TQRect dirty(painter.dirtyRect()); - dev->setDirty(dirty); - dev->emitSelectionChanged(dirty); - } else { - dev->setDirty(); - dev->emitSelectionChanged(); - } - - if (m_currentImage->undo()) - m_currentImage->undoAdapter()->addCommand(t); - - TQApplication::restoreOverrideCursor(); - - draw(false); -} - -TQWidget* KisToolCurve::createOptionWidget(TQWidget* parent) -{ - if (toolType() == TOOL_SHAPE || toolType() == TOOL_FREEHAND) - return super::createOptionWidget(parent); - else if (toolType() == TOOL_SELECT) - return createSelectionOptionWidget(parent); - else - kdDebug(0) << "NO SUPPORT FOR THIS TOOL TYPE" << endl; - return 0; -} - -void KisToolCurve::slotSetAction(int action) { - if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) - m_selectAction =(enumSelectionMode)action; -} - -TQWidget* KisToolCurve::createSelectionOptionWidget(TQWidget* parent) -{ - m_optWidget = new KisSelectionOptions(parent, m_subject); - TQ_CHECK_PTR(m_optWidget); - m_optWidget->setCaption(m_UIName); - - connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); - - TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); - l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); - - return m_optWidget; -} - -TQWidget* KisToolCurve::optionWidget() -{ - if (toolType() == TOOL_SELECT) - return m_optWidget; - else - return super::optionWidget(); -} - -#include "kis_tool_curve.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_curve.cpp b/chalk/plugins/tools/tool_curves/kis_tool_curve.cpp new file mode 100644 index 00000000..ea1f9a77 --- /dev/null +++ b/chalk/plugins/tools/tool_curves/kis_tool_curve.cpp @@ -0,0 +1,593 @@ +/* + * kis_tool_curve.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_global.h" +#include "kis_doc.h" +#include "kis_painter.h" +#include "kis_point.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_tool_controller.h" +#include "kis_vec.h" +#include "kis_selection.h" +#include "kis_selection_options.h" +#include "kis_selected_transaction.h" +#include "kis_paintop_registry.h" + +#include "kis_curve_framework.h" +#include "kis_tool_curve.h" + +TQRect KisToolCurve::pivotRect (const TQPoint& pos) +{ + return TQRect (pos-TQPoint(4,4),pos+TQPoint(4,4)); +} + +TQRect KisToolCurve::selectedPivotRect (const TQPoint& pos) +{ + return TQRect (pos-TQPoint(5,5),pos+TQPoint(5,5)); +} + +KisToolCurve::KisToolCurve(const TQString& UIName) + : super(UIName) +{ + m_UIName = UIName; + m_currentImage = 0; + m_optWidget = 0; + + m_curve = 0; + + m_dragging = false; + m_draggingCursor = false; + m_drawPivots = true; + m_drawingPen = TQPen(TQt::white, 0, TQt::SolidLine); + m_pivotPen = TQPen(TQt::gray, 0, TQt::SolidLine); + m_selectedPivotPen = TQPen(TQt::yellow, 0, TQt::SolidLine); + m_pivotRounding = m_selectedPivotRounding = 55; + + m_actionOptions = NOOPTIONS; + m_supportMinimalDraw = true; + m_selectAction = SELECTION_ADD; +} + +KisToolCurve::~KisToolCurve() +{ + +} + +void KisToolCurve::update (KisCanvasSubject *subject) +{ + super::update(subject); + if (m_subject) + m_currentImage = m_subject->currentImg(); +} + +void KisToolCurve::deactivate() +{ + draw(false); + if (m_curve) { + m_curve->clear(); + m_curve->endActionOptions(); + } + + m_actionOptions = NOOPTIONS; + m_dragging = false; + m_drawPivots = true; +} + +void KisToolCurve::buttonPress(KisButtonPressEvent *event) +{ + updateOptions(event->state()); + if (!m_currentImage) + return; + if (event->button() == Qt::LeftButton) { + m_dragging = true; + m_currentPoint = event->pos(); + PointPair temp = pointUnderMouse (m_subject->canvasController()->windowToView(event->pos().toTQPoint())); + if (temp.first == m_curve->end() && !(m_actionOptions)) { + draw(true, true); + m_curve->selectAll(false); + draw(true, true); + draw(m_curve->end()); + m_previous = m_curve->find(m_curve->last()); + m_current = m_curve->pushPivot(event->pos()); + if (m_curve->pivots().count() > 1) + m_curve->calculateCurve(m_previous,m_current,m_current); + draw(m_current); + } else { + draw(true, true); + if (temp.second) + m_current = m_curve->selectPivot(temp.first); + else + m_current = selectByMouse(temp.first); + + if (!(*m_current).isSelected()) + m_dragging = false; + draw(true, true); + } + } +} + +void KisToolCurve::keyPress(TQKeyEvent *event) +{ + if (event->key() == TQt::Key_Return) { + m_dragging = false; + commitCurve(); + } else + if (event->key() == TQt::Key_Escape) { + m_dragging = false; + draw(false); + m_curve->clear(); + } else + if (event->key() == TQt::Key_Delete) { + draw(false); + m_dragging = false; + m_curve->deleteSelected(); + m_current = m_curve->find(m_curve->last()); + m_previous = m_curve->selectPivot(m_current); + draw(false); + } +} + +void KisToolCurve::keyRelease(TQKeyEvent *) +{ + +} + +void KisToolCurve::buttonRelease(KisButtonReleaseEvent *event) +{ + updateOptions(event->state()); + m_dragging = false; +} + +void KisToolCurve::doubleClick(KisDoubleClickEvent *) +{ + commitCurve(); +} + +void KisToolCurve::move(KisMoveEvent *event) +{ + updateOptions(event->state()); + PointPair temp = pointUnderMouse(m_subject->canvasController()->windowToView(event->pos().toTQPoint())); + if (temp.first == m_curve->end() && !m_dragging) { + if (m_draggingCursor) { + setCursor(KisCursor::load(m_cursor, 6, 6)); + m_draggingCursor = false; + } + } else { + setCursor(KisCursor::load("tool_curve_dragging.png", 6, 6)); + m_draggingCursor = true; + } + if (m_dragging) { + draw(); + KisPoint trans = event->pos() - m_currentPoint; + m_curve->moveSelected(trans); + m_currentPoint = event->pos(); + draw(); + } +} + +double pointToSegmentDistance(const KisPoint& p, const KisPoint& l0, const KisPoint& l1) +{ + double lineLength = sqrt((l1.x() - l0.x()) * (l1.x() - l0.x()) + (l1.y() - l0.y()) * (l1.y() - l0.y())); + double distance = 0; + KisVector2D v0(l0), v1(l1), v(p), seg(v0-v1), dist0(v0-p), dist1(v1-p); + + if (seg.length() < dist0.length() || + seg.length() < dist1.length()) // the point doesn't perpendicolarly intersecate the segment (or it's too far from the segment) + return (double)INT_MAX; + + if (lineLength > DBL_EPSILON) { + distance = ((l0.y() - l1.y()) * p.x() + (l1.x() - l0.x()) * p.y() + l0.x() * l1.y() - l1.x() * l0.y()) / lineLength; + distance = fabs(distance); + } + + return distance; +} + +PointPair KisToolCurve::pointUnderMouse(const TQPoint& pos) +{ + KisCurve::iterator it, next; + TQPoint pos1, pos2; + it = handleUnderMouse(pos); + if (it != m_curve->end()) + return PointPair(it,true); + + for (it = m_curve->begin(); it != m_curve->end(); it++) { + next = it.next(); + if (next == m_curve->end() || it == m_curve->end()) + return PointPair(m_curve->end(),false); + if ((*it).hint() > LINEHINT || (*next).hint() > LINEHINT) + continue; + pos1 = m_subject->canvasController()->windowToView((*it).point().toTQPoint()); + pos2 = m_subject->canvasController()->windowToView((*next).point().toTQPoint()); + if (pos1 == pos2) + continue; + if (pointToSegmentDistance(pos,pos1,pos2) <= MAXDISTANCE) + break; + } + + return PointPair(it,false); +} + +KisCurve::iterator KisToolCurve::handleUnderMouse(const TQPoint& pos) +{ + KisCurve pivs = m_curve->pivots(), inHandle; + KisCurve::iterator it; + for (it = pivs.begin(); it != pivs.end(); it++) { + if (pivotRect(m_subject->canvasController()->windowToView((*it).point().toTQPoint())).contains(pos)) + inHandle.pushPoint((*it)); + } + if (inHandle.isEmpty()) + return m_curve->end(); + return m_curve->find(inHandle.last()); +} + +KisCurve::iterator KisToolCurve::selectByMouse(KisCurve::iterator it) +{ + KisCurve::iterator prevPivot, nextPivot; + + if ((*it).isPivot()) + prevPivot = it; + else + prevPivot = it.previousPivot(); + nextPivot = it.nextPivot(); + + m_curve->selectPivot(prevPivot); + (*nextPivot).setSelected(true); + + return prevPivot; +} + +int KisToolCurve::updateOptions(int key) +{ + int options = 0x0000; + + if (key & TQt::ControlButton) + options |= CONTROLOPTION; + + if (key & TQt::ShiftButton) + options |= SHIFTOPTION; + + if (key & TQt::AltButton) + options |= ALTOPTION; + + if (options != m_actionOptions) { + draw(false); + m_actionOptions = options; + m_curve->setActionOptions(m_actionOptions); + draw(false); + } + + return m_actionOptions; +} + +void KisToolCurve::draw(bool m, bool o) +{ + draw(KisCurve::iterator(), o, m); +} + +void KisToolCurve::draw(KisCurve::iterator inf, bool pivotonly, bool minimal) +{ + if (m_curve->isEmpty()) + return; + KisCanvasPainter *gc; + KisCanvasController *controller; + KisCanvas *canvas; + if (m_subject && m_currentImage) { + controller = m_subject->canvasController(); + canvas = controller->kiscanvas(); + gc = new KisCanvasPainter(canvas); + } else + return; + + gc->setPen(m_drawingPen); + gc->setRasterOp(TQt::XorROP); + + KisCurve::iterator it, finish; + + if (minimal && m_supportMinimalDraw) { + if (pivotonly) { + KisCurve p = m_curve->pivots(); + for (KisCurve::iterator i = p.begin(); i != p.end(); i++) + drawPivotHandle (*gc, i); + delete gc; + return; + } + if (inf.target() != 0) { + if (inf != m_curve->end()) { + it = inf.previousPivot(); + finish = inf.nextPivot(); + } else { + it = --m_curve->end(); + finish = m_curve->end(); + } + } else { + KisCurve sel = m_curve->selectedPivots(); + if (sel.isEmpty()) { + delete gc; + return; + } + for (KisCurve::iterator i = sel.begin(); i != sel.end(); i++) { + it = m_curve->find(*i).previousPivot(); + finish = m_curve->find(*i).nextPivot(); + if ((*finish).isSelected()) + finish = finish.previousPivot(); + while (it != finish) { + if ((*it).isPivot()) + drawPivotHandle (*gc, it); + it = drawPoint (*gc, it); + } + } + delete gc; + return; + } + } else { + it = m_curve->begin(); + finish = m_curve->end(); + } + while (it != finish) { + if ((*it).isPivot()) + drawPivotHandle (*gc, it); + it = drawPoint (*gc, it); + } + + delete gc; +} + +KisCurve::iterator KisToolCurve::drawPoint(KisCanvasPainter& gc, KisCurve::iterator point) +{ + KisCanvasController *controller = m_subject->canvasController(); + + TQPoint pos1, pos2; + pos1 = controller->windowToView((*point).point().toTQPoint()); + + switch ((*point).hint()) { + case POINTHINT: + gc.drawPoint(pos1); + point += 1; + break; + case LINEHINT: + gc.drawPoint(pos1); + if (++point != m_curve->end() && (*point).hint() <= LINEHINT) { + pos2 = controller->windowToView((*point).point().toTQPoint()); + gc.drawLine(pos1,pos2); + } + break; + default: + point += 1; + } + + return point; +} + +void KisToolCurve::drawPivotHandle(KisCanvasPainter& gc, KisCurve::iterator point) +{ + KisCanvasController *controller = m_subject->canvasController(); + + if (m_drawPivots) { + TQPoint pos = controller->windowToView((*point).point().toTQPoint()); + if ((*point).isSelected()) { + gc.setPen(m_selectedPivotPen); + gc.drawRoundRect(selectedPivotRect(pos),m_selectedPivotRounding,m_selectedPivotRounding); + } else { + gc.setPen(m_pivotPen); + gc.drawRoundRect(pivotRect(pos),m_pivotRounding,m_pivotRounding); + } + gc.setPen(m_drawingPen); + } +} + +void KisToolCurve::paint(KisCanvasPainter&) +{ + draw(false); +} + +void KisToolCurve::paint(KisCanvasPainter&, const TQRect&) +{ + draw(false); +} + +void KisToolCurve::commitCurve() +{ + if (toolType() == TOOL_SHAPE || toolType() == TOOL_FREEHAND) + paintCurve(); + else if (toolType() == TOOL_SELECT) + selectCurve(); + else + kdDebug(0) << "NO SUPPORT FOR THIS TYPE OF TOOL" << endl; + + m_curve->clear(); + m_curve->endActionOptions(); +} + +void KisToolCurve::paintCurve() +{ + KisPaintDeviceSP device = m_currentImage->activeDevice (); + if (!device) return; + + KisPainter painter (device); + if (m_currentImage->undo()) painter.beginTransaction (m_transactionMessage); + + painter.setPaintColor(m_subject->fgColor()); + painter.setBrush(m_subject->currentBrush()); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); + painter.setPaintOp(op); // Painter takes ownership + +// Call paintPoint + KisCurve::iterator it = m_curve->begin(); + while (it != m_curve->end()) + it = paintPoint(painter,it); +// Finish + + device->setDirty( painter.dirtyRect() ); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); + } + + draw(false); +} + +KisCurve::iterator KisToolCurve::paintPoint (KisPainter& painter, KisCurve::iterator point) +{ + KisCurve::iterator next = point; next+=1; + switch ((*point).hint()) { + case POINTHINT: + painter.paintAt((*point++).point(), PRESSURE_DEFAULT, 0, 0); + break; + case LINEHINT: + if (next != m_curve->end() && (*next).hint() <= LINEHINT) + painter.paintLine((*point++).point(), PRESSURE_DEFAULT, 0, 0, (*next).point(), PRESSURE_DEFAULT, 0, 0); + else + painter.paintAt((*point++).point(), PRESSURE_DEFAULT, 0, 0); + break; + default: + point += 1; + } + + return point; +} + +TQValueVector KisToolCurve::convertCurve() +{ + TQValueVector points; + + for (KisCurve::iterator i = m_curve->begin(); i != m_curve->end(); i++) + if ((*i).hint() != NOHINTS) + points.append((*i).point()); + + return points; +} + +void KisToolCurve::selectCurve() +{ + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisPaintDeviceSP dev = m_currentImage->activeDevice(); + bool hasSelection = dev->hasSelection(); + KisSelectedTransaction *t = 0; + if (m_currentImage->undo()) t = new KisSelectedTransaction(m_transactionMessage, dev); + KisSelectionSP selection = dev->selection(); + + if (!hasSelection) { + selection->clear(); + } + + KisPainter painter(selection.data()); + + painter.setPaintColor(KisColor(TQt::black, selection->colorSpace())); + painter.setFillStyle(KisPainter::FillStyleForegroundColor); + painter.setStrokeStyle(KisPainter::StrokeStyleNone); + painter.setBrush(m_subject->currentBrush()); + painter.setOpacity(OPACITY_OPAQUE); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, &painter); + painter.setPaintOp(op); // And now the painter owns the op and will destroy it. + + switch (m_selectAction) { + case SELECTION_ADD: + painter.setCompositeOp(COMPOSITE_OVER); + break; + case SELECTION_SUBTRACT: + painter.setCompositeOp(COMPOSITE_SUBTRACT); + break; + default: + break; + } + + painter.paintPolygon(convertCurve()); + + + if(hasSelection) { + TQRect dirty(painter.dirtyRect()); + dev->setDirty(dirty); + dev->emitSelectionChanged(dirty); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (m_currentImage->undo()) + m_currentImage->undoAdapter()->addCommand(t); + + TQApplication::restoreOverrideCursor(); + + draw(false); +} + +TQWidget* KisToolCurve::createOptionWidget(TQWidget* parent) +{ + if (toolType() == TOOL_SHAPE || toolType() == TOOL_FREEHAND) + return super::createOptionWidget(parent); + else if (toolType() == TOOL_SELECT) + return createSelectionOptionWidget(parent); + else + kdDebug(0) << "NO SUPPORT FOR THIS TOOL TYPE" << endl; + return 0; +} + +void KisToolCurve::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + +TQWidget* KisToolCurve::createSelectionOptionWidget(TQWidget* parent) +{ + m_optWidget = new KisSelectionOptions(parent, m_subject); + TQ_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(m_UIName); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolCurve::optionWidget() +{ + if (toolType() == TOOL_SELECT) + return m_optWidget; + else + return super::optionWidget(); +} + +#include "kis_tool_curve.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_example.cc b/chalk/plugins/tools/tool_curves/kis_tool_example.cc deleted file mode 100644 index 75e3da2b..00000000 --- a/chalk/plugins/tools/tool_curves/kis_tool_example.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * kis_tool_example.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_global.h" -#include "kis_doc.h" -#include "kis_painter.h" -#include "kis_point.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop_registry.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_vec.h" - -#include "kis_curve_framework.h" - -#include "kis_tool_example.h" - - -class KisCurveExample : public KisCurve { - - typedef KisCurve super; - -public: - - KisCurveExample() : super() {} - - ~KisCurveExample() {} - - virtual iterator pushPivot (const KisPoint&); - -}; - -KisCurve::iterator KisCurveExample::pushPivot (const KisPoint& point) -{ - return selectPivot(iterator(*this,m_curve.append(CurvePoint(point,true,false,LINEHINT))), true); -} - -KisToolExample::KisToolExample() - : super(i18n("Tool for Curves - Example")) -{ - setName("tool_example"); - m_cursor = "tool_example_cursor.png"; - setCursor(KisCursor::load(m_cursor, 6, 6)); - - m_curve = new KisCurveExample; -} - -KisToolExample::~KisToolExample() -{ - -} - -void KisToolExample::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("&Example"), - "tool_example", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("This is a test tool for the Curve Framework.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_example.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_example.cpp b/chalk/plugins/tools/tool_curves/kis_tool_example.cpp new file mode 100644 index 00000000..a21bb808 --- /dev/null +++ b/chalk/plugins/tools/tool_curves/kis_tool_example.cpp @@ -0,0 +1,108 @@ +/* + * kis_tool_example.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_global.h" +#include "kis_doc.h" +#include "kis_painter.h" +#include "kis_point.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop_registry.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_vec.h" + +#include "kis_curve_framework.h" + +#include "kis_tool_example.h" + + +class KisCurveExample : public KisCurve { + + typedef KisCurve super; + +public: + + KisCurveExample() : super() {} + + ~KisCurveExample() {} + + virtual iterator pushPivot (const KisPoint&); + +}; + +KisCurve::iterator KisCurveExample::pushPivot (const KisPoint& point) +{ + return selectPivot(iterator(*this,m_curve.append(CurvePoint(point,true,false,LINEHINT))), true); +} + +KisToolExample::KisToolExample() + : super(i18n("Tool for Curves - Example")) +{ + setName("tool_example"); + m_cursor = "tool_example_cursor.png"; + setCursor(KisCursor::load(m_cursor, 6, 6)); + + m_curve = new KisCurveExample; +} + +KisToolExample::~KisToolExample() +{ + +} + +void KisToolExample::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("&Example"), + "tool_example", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("This is a test tool for the Curve Framework.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_example.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_moutline.cc b/chalk/plugins/tools/tool_curves/kis_tool_moutline.cc deleted file mode 100644 index 178ff278..00000000 --- a/chalk/plugins/tools/tool_curves/kis_tool_moutline.cc +++ /dev/null @@ -1,809 +0,0 @@ -/* - * kis_tool_moutline.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_global.h" -#include "kis_iterators_pixel.h" -#include "kis_colorspace.h" -#include "kis_channelinfo.h" -#include "kis_doc.h" -#include "kis_painter.h" -#include "kis_point.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_tool_controller.h" -#include "kis_vec.h" -#include "kis_selection.h" -#include "kis_selection_options.h" -#include "kis_selected_transaction.h" -#include "kis_paintop_registry.h" -#include "kis_convolution_painter.h" - -#include "kis_tool_moutline.h" - -using namespace std; - -#define RMS(a, b) (sqrt ((a) * (a) + (b) * (b))) -#define ROUND(x) ((int) ((x) + 0.5)) - -const int NOEDGE = 0x0000; - -const int ORTHOGONAL_COST = 10; // 1*10 -const int DIAGONAL_COST = 14; // sqrt(2)*10 -const int MALUS = 20; // This applies to NOEDGE nodes - -const int DEFAULTDIST = 40; // Default distance between two automatic pivots -const int MAXDIST = 55; // Max distance -const int MINDIST = 15; -const int PAGESTEP = 5; - -class Node { - - TQPoint m_pos; - int m_gCost; - int m_hCost; - int m_tCost; - bool m_malus; - TQPoint m_parent; - -public: - - Node() - { - m_pos = m_parent = TQPoint(-1,-1); - m_gCost = m_hCost = m_tCost = 0; - m_malus = false; - } - - Node(const Node& node) - { - m_pos = node.pos(); - m_gCost = node.gCost(); - m_hCost = node.hCost(); - m_tCost = node.tCost(); - m_malus = node.malus(); - m_parent = node.parent(); - } - - Node(const TQPoint& parent, const TQPoint& pos, int g, int h, bool malus) - : m_pos(pos), m_hCost(h), m_malus(malus) - { - setGCost(g); - m_parent = parent; - } - ~Node () - { - } - - int gCost () const {return m_gCost;} - int hCost () const {return m_hCost;} - int tCost () const {return m_tCost;} - bool malus () const {return m_malus;} - TQPoint pos () const {return m_pos;} - int col () const {return m_pos.x();} - int row () const {return m_pos.y();} - TQPoint parent () const {return m_parent;} - - void setGCost (int g) - { - m_gCost = g+(m_malus?MALUS:0); - m_tCost = m_gCost+m_hCost; - } - void setHCost (int h) - { - m_hCost = h; - m_tCost = m_gCost+m_hCost; - } - void setPos (const TQPoint& pos) - { - m_pos = pos; - } - void setMalus (bool malus) - { - m_malus = malus; - } - void clear () - { - m_pos = TQPoint(-1,-1); - } - - bool operator== (const Node& n2) const - { - return m_pos == n2.pos(); - } - bool operator!= (const Node& n2) const - { - return m_pos != n2.pos(); - } - bool operator== (const TQPoint& n2) const - { - return m_pos == n2; - } - bool operator!= (const TQPoint& n2) const - { - return m_pos != n2; - } - bool operator< (const Node& n2) const - { - return m_tCost < n2.tCost(); - } - bool operator> (const Node& n2) const - { - return m_tCost > n2.tCost(); - } - - TQValueList getNeighbor(const GrayMatrix& src, const Node& end) - { - TQPoint tmpdist; - TQValueList temp; - int dcol, drow; - int g, h; - bool malus; - int x[8] = { 1, 1, 0,-1,-1,-1, 0, 1}, - y[8] = { 0,-1,-1,-1, 0, 1, 1, 1}; - - for (int i = 0; i < 8; i++) { - dcol = m_pos.x() + x[i]; - drow = m_pos.y() + y[i]; - tmpdist = TQPoint(dcol,drow) - end.pos(); - // I use src[0] here because all cols have same number of rows - if (dcol == (int)src.count() || dcol < 0 || - drow == (int)src[0].count() || drow < 0) - continue; - if (src[dcol][drow]) - malus = false; - else - malus = true; - if (i%2) - g = m_gCost + DIAGONAL_COST; - else - g = m_gCost + ORTHOGONAL_COST; - h = ORTHOGONAL_COST * (abs(tmpdist.x()) + abs(tmpdist.y())); - temp.append(Node(m_pos,TQPoint(dcol,drow),g,h,malus)); - } - return temp; - } - -}; - -KisKernelSP createKernel( TQ_INT32 i0, TQ_INT32 i1, TQ_INT32 i2, - TQ_INT32 i3, TQ_INT32 i4, TQ_INT32 i5, - TQ_INT32 i6, TQ_INT32 i7, TQ_INT32 i8, - TQ_INT32 factor, TQ_INT32 offset ) -{ - KisKernelSP kernel = new KisKernel(); - kernel->width = 3; - kernel->height = 3; - - kernel->factor = factor; - kernel->offset = offset; - - kernel->data = new TQ_INT32[9]; - kernel->data[0] = i0; - kernel->data[1] = i1; - kernel->data[2] = i2; - kernel->data[3] = i3; - kernel->data[4] = i4; - kernel->data[5] = i5; - kernel->data[6] = i6; - kernel->data[7] = i7; - kernel->data[8] = i8; - - return kernel; -} - -KisCurveMagnetic::KisCurveMagnetic (KisToolMagnetic *parent) - : m_parent(parent) -{ - m_standardkeepselected = false; -} - -KisCurveMagnetic::~KisCurveMagnetic () -{ - -} - -KisCurve::iterator KisCurveMagnetic::addPivot (KisCurve::iterator it, const KisPoint& point) -{ - return iterator(*this,m_curve.insert(it.position(), CurvePoint(point,true,false,LINEHINT))); -} - -KisCurve::iterator KisCurveMagnetic::pushPivot (const KisPoint& point) -{ - iterator it; - - it = pushPoint(point,true,false,LINEHINT); -// if (count() == 1 && !m_parent->editingMode()) -// addPoint(it,point,true,false,LINEHINT); - - return selectPivot(it); -} - -void KisCurveMagnetic::calculateCurve (KisCurve::iterator p1, KisCurve::iterator p2, KisCurve::iterator it) -{ - if (p1 == m_curve.end() || p2 == m_curve.end()) // It happens sometimes, for example on the first click - return; - if (m_parent->editingMode()) - return; - TQPoint start = (*p1).point().roundTQPoint(); - TQPoint end = (*p2).point().roundTQPoint(); - TQRect rc = TQRect(start,end).normalize(); - rc.setTopLeft(rc.topLeft()+TQPoint(-8,-8)); // Enlarge the view, so problems with gaussian blur can be removed - rc.setBottomRight(rc.bottomRight()+TQPoint(8,8)); // and we are able to find paths that go beyond the rect. - - KisPaintDeviceSP src = m_parent->m_currentImage->activeDevice(); - GrayMatrix dst = GrayMatrix(rc.width(),GrayCol(rc.height())); - - detectEdges (rc, src, dst); - reduceMatrix (rc, dst, 3, 3, 3, 3); - - Node startNode, endNode; - multiset openSet; - NodeMatrix openMatrix = NodeMatrix(rc.width(),NodeCol(rc.height())); - NodeMatrix closedMatrix = NodeMatrix(rc.width(),NodeCol(rc.height())); - - TQPoint tl(rc.topLeft().x(),rc.topLeft().y()); - start -= tl; // Relative to the matrix - end -= tl; // Relative to the matrix - - findEdge (start.x(), start.y(), dst, startNode); - openMatrix[startNode.col()][startNode.row()] = *openSet.insert(startNode); - endNode.setPos(end); - - while (!openSet.empty()) { - Node current = *openSet.begin(); - - openSet.erase(openSet.begin()); - openMatrix[current.col()][current.row()].clear(); - - TQValueList successors = current.getNeighbor(dst,endNode); - for (TQValueList::iterator i = successors.begin(); i != successors.end(); i++) { - int col = (*i).col(); - int row = (*i).row(); - if ((*i) == endNode) { - while (current.parent() != TQPoint(-1,-1)) { - it = addPoint(it,KisPoint(tl+current.pos()),false,false,LINEHINT); - current = closedMatrix[current.parent().x()][current.parent().y()]; - } - return; - } - Node *openNode = &openMatrix[col][row]; - if (*openNode != TQPoint(-1,-1)) { - if (*i > *openNode) - continue; - else { - openSet.erase(tqFind(openSet.begin(),openSet.end(),*openNode)); - openNode->clear(); // Clear the Node - } - } - Node *closedNode = &closedMatrix[col][row]; - if (*closedNode != TQPoint(-1,-1)) { - if ((*i) > (*closedNode)) - continue; - else { - openMatrix[col][row] = *openSet.insert(*closedNode); - closedNode->clear(); // Clear the Node - continue; - } - } - openMatrix[col][row] = *openSet.insert(*i); - } - closedMatrix[current.col()][current.row()] = current; - } -} - -void KisCurveMagnetic::findEdge (int col, int row, const GrayMatrix& src, Node& node) -{ - int x = -1; - int y = -1; - - // tmpdist out of range - KisVector2D mindist(5.0,5.0), tmpdist(1000.0,1000.0); - for (int i = -5; i < 6; i++) { - for (int j = -5; j < 6; j++) { - if (src[col+i][row+j] != NOEDGE) { - tmpdist = KisVector2D(i,j); - if (tmpdist.length() < mindist.length()) - mindist = tmpdist; - } - } - } - if (tmpdist.x() == 1000.0) - mindist = KisVector2D(0.0,0.0); - - x = (int)(col + mindist.x()); - y = (int)(row + mindist.y()); - - node.setPos(TQPoint(x,y)); -} - -void KisCurveMagnetic::reduceMatrix (TQRect& rc, GrayMatrix& m, int top, int right, int bottom, int left) -{ - TQPoint topleft(top, left); - TQPoint bottomright(bottom, right); - - rc.setTopLeft(rc.topLeft()+topleft); - rc.setBottomRight(rc.bottomRight()-bottomright); - - if (left) - m.erase(m.begin(),m.begin()+left); - if (right) - m.erase(m.end()-right,m.end()); - if (top) { - for (uint i = 0; i < m.count(); i++) - m[i].erase(m[i].begin(),m[i].begin()+top); - } - if (bottom) { - for (uint i = 0; i < m.count(); i++) - m[i].erase(m[i].end()-bottom,m[i].end()); - } -} - -void KisCurveMagnetic::detectEdges (const TQRect & rect, KisPaintDeviceSP src, GrayMatrix& dst) -{ - GrayMatrix graysrc(rect.width(),GrayCol(rect.height())); - GrayMatrix xdeltas(rect.width(),GrayCol(rect.height())); - GrayMatrix ydeltas(rect.width(),GrayCol(rect.height())); - GrayMatrix magnitude(rect.width(),GrayCol(rect.height())); - KisPaintDeviceSP smooth = new KisPaintDevice(src->colorSpace()); - - gaussianBlur(rect, src, smooth); - toGrayScale(rect, smooth, graysrc); - getDeltas(graysrc, xdeltas, ydeltas); - getMagnitude(xdeltas, ydeltas, magnitude); - nonMaxSupp(magnitude, xdeltas, ydeltas, dst); -} - -void KisCurveMagnetic::gaussianBlur (const TQRect& rect, KisPaintDeviceSP src, KisPaintDeviceSP dst) -{ - int grectx = rect.x(); - int grecty = rect.y(); - int grectw = rect.width(); - int grecth = rect.height(); - if (dst != src) { - KisPainter gc(dst); - gc.bitBlt(grectx, grecty, COMPOSITE_COPY, src, grectx, grecty, grectw, grecth); - gc.end(); - } - - KisConvolutionPainter painter( dst ); - // FIXME createKernel could create dynamic gaussian kernels having sigma as argument - KisKernelSP kernel = createKernel( 1, 1, 1, 1, 24, 1, 1, 1, 1, 32, 0); - painter.applyMatrix(kernel, grectx, grecty, grectw, grecth, BORDER_AVOID); -} - -void KisCurveMagnetic::toGrayScale (const TQRect& rect, KisPaintDeviceSP src, GrayMatrix& dst) -{ - int grectx = rect.x(); - int grecty = rect.y(); - int grectw = rect.width(); - int grecth = rect.height(); - TQColor c; - KisColorSpace *cs = src->colorSpace(); - - for (int row = 0; row < grecth; row++) { - KisHLineIteratorPixel srcIt = src->createHLineIterator(grectx, grecty+row, grectw, false); - for (int col = 0; col < grectw; col++) { - cs->toTQColor(srcIt.rawData(),&c); - dst[col][row] = tqGray(c.rgb()); - ++srcIt; - } - } -} - -void KisCurveMagnetic::getDeltas (const GrayMatrix& src, GrayMatrix& xdelta, GrayMatrix& ydelta) -{ - uint start = 1, xend = src[0].count()-1, yend = src.count()-1; - TQ_INT16 deri; - for (uint col = 0; col < src.count(); col++) { - for (uint row = 0; row < src[col].count(); row++) { - if (row >= start && row < xend) { - deri = src[col][row+1] - src[col][row-1]; - xdelta[col][row] = deri; - } else - xdelta[col][row] = 0; - if (col >= start && col < yend) { - deri = src[col+1][row] - src[col-1][row]; - ydelta[col][row] = deri; - } else - ydelta[col][row] = 0; - } - } -} - -void KisCurveMagnetic::getMagnitude (const GrayMatrix& xdelta, const GrayMatrix& ydelta, GrayMatrix& gradient) -{ - for (uint col = 0; col < xdelta.count(); col++) { - for (uint row = 0; row < xdelta[col].count(); row++) - gradient[col][row] = (TQ_INT16)(ROUND(RMS(xdelta[col][row],ydelta[col][row]))); - } -} - -void KisCurveMagnetic::nonMaxSupp (const GrayMatrix& magnitude, const GrayMatrix& xdelta, const GrayMatrix& ydelta, GrayMatrix& nms) -{ - // Directions: - // 1: 0 - 22.5 degrees - // 2: 22.5 - 67.5 degrees - // 3: 67.5 - 90 degrees - // Second direction is relative to a quadrant. The quadrant is known by looking at x and y derivatives - // First quadrant: Gx < 0 & Gy >= 0 - // Second quadrant: Gx < 0 & Gy < 0 - // Third quadrant: Gx >= 0 & Gy < 0 - // Fourth quadrant: Gx >= 0 & Gy >= 0 - // For this reason: first direction is relative to Gy only and third direction to Gx only - - double theta; // theta = invtan (|Gy| / |Gx|) This give the direction relative to a quadrant - TQ_INT16 mag; // Current magnitude - TQ_INT16 lmag; // Magnitude at the left (So this pixel is "more internal" than the current - TQ_INT16 rmag; // Magnitude at the right (So this pixel is "more external") - double xdel; // Current xdelta - double ydel; // Current ydelta - TQ_INT16 result; - - for (uint col = 0; col < magnitude.count(); col++) { - for (uint row = 0; row < magnitude[col].count(); row++) { - mag = magnitude[col][row]; - if (!mag || row == 0 || row == (magnitude[col].count()-1) || - col == 0 || col == (magnitude.count()-1)) - { - result = NOEDGE; - } else { - xdel = (double)xdelta[col][row]; - ydel = (double)ydelta[col][row]; - theta = atan(fabs(ydel)/fabs(xdel)); - if (theta < 0) - theta = fabs(theta)+M_PI_2; - theta = (theta * 360.0) / (2.0*M_PI); // Radians -> degrees - if (theta >= 0 && theta < 22.5) { // .0 - .3926990816 - if (ydel >= 0) { - lmag = magnitude[col][row-1]; - rmag = magnitude[col][row+1]; - } else { - lmag = magnitude[col][row+1]; - rmag = magnitude[col][row-1]; - } - } - if (theta >= 22.5 && theta < 67.5) { // .3926990816 - 1.1780972449 - if (xdel >= 0) { - if (ydel >= 0) { - lmag = magnitude[col-1][row-1]; - rmag = magnitude[col+1][row+1]; - } else { - lmag = magnitude[col+1][row-1]; - rmag = magnitude[col-1][row+1]; - } - } else { - if (ydel >= 0) { - lmag = magnitude[col-1][row+1]; - rmag = magnitude[col+1][row-1]; - } else { - lmag = magnitude[col+1][row+1]; - rmag = magnitude[col-1][row-1]; - } - } - } - if (theta >= 67.5 && theta <= 90.0) { // 1.1780972449 - 1.5707963266 - if (xdel >= 0) { - lmag = magnitude[col+1][row]; - rmag = magnitude[col-1][row]; - } else { - lmag = magnitude[col-1][row]; - rmag = magnitude[col+1][row]; - } - } - - if ((mag < lmag) || (mag < rmag)) { - result = NOEDGE; - } else { - if (rmag == mag) // If the external magnitude is equal to the current, suppress current. - result = NOEDGE; - else - result = (mag > 255) ? 255 : mag; - } - } - nms[col][row] = result; - } - } -} - -KisToolMagnetic::KisToolMagnetic () - : super("Magnetic Outline Tool") -{ - setName("tool_moutline"); - setCursor(KisCursor::load("tool_moutline_cursor.png", 6, 6)); - - m_editingMode = false; - m_editingCursor = m_draggingCursor = false; - - m_mode = 0; - m_curve = m_derived = 0; - m_current = m_previous = 0; - - m_distance = DEFAULTDIST; - - m_transactionMessage = i18n("Magnetic Outline Selection"); -} - -KisToolMagnetic::~KisToolMagnetic () -{ - m_curve = 0; - delete m_derived; -} - -void KisToolMagnetic::update (KisCanvasSubject *subject) -{ - super::update(subject); -} - -void KisToolMagnetic::activate () -{ - super::activate(); - if (!m_derived) { - m_derived = new KisCurveMagnetic(this); - m_curve = m_derived; - } -} - -void KisToolMagnetic::deactivate () -{ - m_curve->endActionOptions(); - m_actionOptions = NOOPTIONS; - m_dragging = false; - m_drawPivots = true; -} - -void KisToolMagnetic::keyPress(TQKeyEvent *event) -{ - if (event->key() == TQt::Key_Control) { - draw(false); - if (m_editingMode) { - m_editingMode = false; - if (m_current != 0) - m_curve->selectPivot(m_current,false); - m_mode->setText(i18n("Automatic Mode")); - } else { - m_editingMode = true; - m_mode->setText(i18n("Manual Mode")); - } - draw(false); - } else if (event->key() == TQt::Key_Delete && m_curve->count()) { - draw(false); - m_dragging = false; - if (m_curve->pivots().count() == 2) - m_curve->clear(); - else { - if ((*m_current) == m_curve->last() && !(m_editingMode)) { - m_curve->deletePivot(m_current.previousPivot()); - m_previous = m_current.previousPivot(); - } else { - m_editingMode = false; - m_curve->deletePivot(m_current); - m_previous = m_current = m_curve->selectPivot(m_curve->lastIterator()); - m_editingMode = true; - } - } - draw(false); - } else - super::keyPress(event); -} - -void KisToolMagnetic::buttonRelease(KisButtonReleaseEvent *event) -{ - if (m_editingMode) { - draw(m_current); - m_editingMode = false; - if (!m_curve->isEmpty()) - m_curve->movePivot(m_current, m_currentPoint); - m_editingMode = true; - draw(m_current); - } - super::buttonRelease(event); -} - -void KisToolMagnetic::buttonPress(KisButtonPressEvent *event) -{ - updateOptions(event->state()); - if (!m_currentImage) - return; - if (event->button() == Qt::LeftButton) { - m_dragging = true; - m_currentPoint = event->pos(); - PointPair temp(m_curve->end(),false); - if (m_editingMode) - temp = pointUnderMouse (m_subject->canvasController()->windowToView(event->pos().toTQPoint())); - if (temp.first == m_curve->end() && !(m_actionOptions)) { - if (m_editingMode) { - draw(true, true); - m_curve->selectAll(false); - draw(true, true); - } - draw(m_curve->end()); - if (!m_curve->isEmpty()) { - m_previous = m_current; - m_current = m_curve->pushPivot(event->pos()); - } else { - m_previous = m_current = m_curve->pushPivot(event->pos()); - } - if (m_curve->pivots().count() > 1) - m_curve->calculateCurve(m_previous,m_current,m_current); - if (m_editingMode) - draw(); - else { - if ((*m_previous).point() == (*m_current).point()) - draw(m_curve->end()); - else - draw(); - } - } else if (temp.first != m_curve->end() && m_editingMode) { - if (temp.second) { - draw(true, true); - m_current = m_curve->selectPivot(temp.first); - draw(true, true); - } else { - draw(false); - m_current = selectByMouse(temp.first); - draw(false); - } - if (!(*m_current).isSelected()) - m_dragging = false; - } - } -} - -void KisToolMagnetic::move(KisMoveEvent *event) -{ - updateOptions(event->state()); - if (m_currentPoint == event->pos().floorTQPoint()) - return; - if (m_editingMode) { - PointPair temp = pointUnderMouse(m_subject->canvasController()->windowToView(event->pos().toTQPoint())); - if (temp.first == m_curve->end() && !m_dragging) { - if (m_editingCursor || m_draggingCursor) { - setCursor(KisCursor::load("tool_moutline_cursor.png", 6, 6)); - m_editingCursor = m_draggingCursor = false; - } - } else { - if (!m_draggingCursor && temp.second) { - setCursor(KisCursor::load("tool_moutline_dragging.png", 6, 6)); - m_editingCursor = false; - m_draggingCursor = true; - } - if (!m_editingCursor && !temp.second) { - setCursor(KisCursor::load("tool_moutline_editing.png", 6, 6)); - m_editingCursor = true; - m_draggingCursor = false; - } - } - if (!m_dragging) - return; - } else { - if (m_editingCursor || m_draggingCursor) { - setCursor(KisCursor::load("tool_moutline_cursor.png", 6, 6)); - m_editingCursor = m_draggingCursor = false; - } - } - if (m_curve->selectedPivots().isEmpty()) - return; - - KisPoint trans = event->pos() - m_currentPoint; - KisPoint dist; - dist = (*m_current).point() - (*m_current.previousPivot()).point(); - if ((m_distance >= MINDIST && (fabs(dist.x()) + fabs(dist.y())) > m_distance && !(m_editingMode)) - || m_curve->pivots().count() == 1) { - draw(m_curve->end()); - m_previous = m_current; - m_current = m_curve->pushPivot(event->pos()); - } else if ((*m_previous).point() == (*m_current).point() && (*m_previous).point() == m_curve->last().point()) - draw(m_curve->end()); - else - draw(m_current); - m_curve->movePivot(m_current,event->pos()); - m_currentPoint = event->pos().floorTQPoint(); - draw(m_current); -} - -KisCurve::iterator KisToolMagnetic::selectByMouse(KisCurve::iterator it) -{ - KisCurve::iterator currPivot = m_curve->selectPivot(m_curve->addPivot(it, KisPoint(0,0))); - m_curve->movePivot(currPivot,(*it).point()); - - return currPivot; -} - -void KisToolMagnetic::slotCommitCurve () -{ - if (!m_curve->isEmpty()) - commitCurve(); -} - -void KisToolMagnetic::slotSetDistance (int dist) -{ - m_distance = dist; -} - -TQWidget* KisToolMagnetic::createOptionWidget(TQWidget* parent) -{ - m_optWidget = super::createOptionWidget(parent); - TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); - TQGridLayout *box = new TQGridLayout(l, 2, 2, 3); - box->setColStretch(0, 1); - box->setColStretch(1, 1); - TQ_CHECK_PTR(box); - - m_mode = new TQLabel(i18n("Automatic mode"), m_optWidget); - m_lbDistance = new TQLabel(i18n("Distance: "), m_optWidget); - TQPushButton *finish = new TQPushButton(i18n("To Selection"), m_optWidget); - m_slDistance = new TQSlider(MINDIST, MAXDIST, PAGESTEP, m_distance, Qt::Horizontal, m_optWidget); - - connect(m_slDistance, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetDistance(int))); - connect(finish, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotCommitCurve())); - - box->addWidget(m_lbDistance, 0, 0); - box->addWidget(m_slDistance, 0, 1); - box->addWidget(m_mode, 1, 0); - box->addWidget(finish, 1, 1); - - return m_optWidget; -} - -void KisToolMagnetic::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("Magnetic Outline"), - "tool_moutline", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Magnetic Selection: move around an edge to select it. Hit Ctrl to enter/quit manual mode, and double click to finish.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_moutline.moc" diff --git a/chalk/plugins/tools/tool_curves/kis_tool_moutline.cpp b/chalk/plugins/tools/tool_curves/kis_tool_moutline.cpp new file mode 100644 index 00000000..ebf82634 --- /dev/null +++ b/chalk/plugins/tools/tool_curves/kis_tool_moutline.cpp @@ -0,0 +1,809 @@ +/* + * kis_tool_moutline.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_global.h" +#include "kis_iterators_pixel.h" +#include "kis_colorspace.h" +#include "kis_channelinfo.h" +#include "kis_doc.h" +#include "kis_painter.h" +#include "kis_point.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_tool_controller.h" +#include "kis_vec.h" +#include "kis_selection.h" +#include "kis_selection_options.h" +#include "kis_selected_transaction.h" +#include "kis_paintop_registry.h" +#include "kis_convolution_painter.h" + +#include "kis_tool_moutline.h" + +using namespace std; + +#define RMS(a, b) (sqrt ((a) * (a) + (b) * (b))) +#define ROUND(x) ((int) ((x) + 0.5)) + +const int NOEDGE = 0x0000; + +const int ORTHOGONAL_COST = 10; // 1*10 +const int DIAGONAL_COST = 14; // sqrt(2)*10 +const int MALUS = 20; // This applies to NOEDGE nodes + +const int DEFAULTDIST = 40; // Default distance between two automatic pivots +const int MAXDIST = 55; // Max distance +const int MINDIST = 15; +const int PAGESTEP = 5; + +class Node { + + TQPoint m_pos; + int m_gCost; + int m_hCost; + int m_tCost; + bool m_malus; + TQPoint m_parent; + +public: + + Node() + { + m_pos = m_parent = TQPoint(-1,-1); + m_gCost = m_hCost = m_tCost = 0; + m_malus = false; + } + + Node(const Node& node) + { + m_pos = node.pos(); + m_gCost = node.gCost(); + m_hCost = node.hCost(); + m_tCost = node.tCost(); + m_malus = node.malus(); + m_parent = node.parent(); + } + + Node(const TQPoint& parent, const TQPoint& pos, int g, int h, bool malus) + : m_pos(pos), m_hCost(h), m_malus(malus) + { + setGCost(g); + m_parent = parent; + } + ~Node () + { + } + + int gCost () const {return m_gCost;} + int hCost () const {return m_hCost;} + int tCost () const {return m_tCost;} + bool malus () const {return m_malus;} + TQPoint pos () const {return m_pos;} + int col () const {return m_pos.x();} + int row () const {return m_pos.y();} + TQPoint parent () const {return m_parent;} + + void setGCost (int g) + { + m_gCost = g+(m_malus?MALUS:0); + m_tCost = m_gCost+m_hCost; + } + void setHCost (int h) + { + m_hCost = h; + m_tCost = m_gCost+m_hCost; + } + void setPos (const TQPoint& pos) + { + m_pos = pos; + } + void setMalus (bool malus) + { + m_malus = malus; + } + void clear () + { + m_pos = TQPoint(-1,-1); + } + + bool operator== (const Node& n2) const + { + return m_pos == n2.pos(); + } + bool operator!= (const Node& n2) const + { + return m_pos != n2.pos(); + } + bool operator== (const TQPoint& n2) const + { + return m_pos == n2; + } + bool operator!= (const TQPoint& n2) const + { + return m_pos != n2; + } + bool operator< (const Node& n2) const + { + return m_tCost < n2.tCost(); + } + bool operator> (const Node& n2) const + { + return m_tCost > n2.tCost(); + } + + TQValueList getNeighbor(const GrayMatrix& src, const Node& end) + { + TQPoint tmpdist; + TQValueList temp; + int dcol, drow; + int g, h; + bool malus; + int x[8] = { 1, 1, 0,-1,-1,-1, 0, 1}, + y[8] = { 0,-1,-1,-1, 0, 1, 1, 1}; + + for (int i = 0; i < 8; i++) { + dcol = m_pos.x() + x[i]; + drow = m_pos.y() + y[i]; + tmpdist = TQPoint(dcol,drow) - end.pos(); + // I use src[0] here because all cols have same number of rows + if (dcol == (int)src.count() || dcol < 0 || + drow == (int)src[0].count() || drow < 0) + continue; + if (src[dcol][drow]) + malus = false; + else + malus = true; + if (i%2) + g = m_gCost + DIAGONAL_COST; + else + g = m_gCost + ORTHOGONAL_COST; + h = ORTHOGONAL_COST * (abs(tmpdist.x()) + abs(tmpdist.y())); + temp.append(Node(m_pos,TQPoint(dcol,drow),g,h,malus)); + } + return temp; + } + +}; + +KisKernelSP createKernel( TQ_INT32 i0, TQ_INT32 i1, TQ_INT32 i2, + TQ_INT32 i3, TQ_INT32 i4, TQ_INT32 i5, + TQ_INT32 i6, TQ_INT32 i7, TQ_INT32 i8, + TQ_INT32 factor, TQ_INT32 offset ) +{ + KisKernelSP kernel = new KisKernel(); + kernel->width = 3; + kernel->height = 3; + + kernel->factor = factor; + kernel->offset = offset; + + kernel->data = new TQ_INT32[9]; + kernel->data[0] = i0; + kernel->data[1] = i1; + kernel->data[2] = i2; + kernel->data[3] = i3; + kernel->data[4] = i4; + kernel->data[5] = i5; + kernel->data[6] = i6; + kernel->data[7] = i7; + kernel->data[8] = i8; + + return kernel; +} + +KisCurveMagnetic::KisCurveMagnetic (KisToolMagnetic *parent) + : m_parent(parent) +{ + m_standardkeepselected = false; +} + +KisCurveMagnetic::~KisCurveMagnetic () +{ + +} + +KisCurve::iterator KisCurveMagnetic::addPivot (KisCurve::iterator it, const KisPoint& point) +{ + return iterator(*this,m_curve.insert(it.position(), CurvePoint(point,true,false,LINEHINT))); +} + +KisCurve::iterator KisCurveMagnetic::pushPivot (const KisPoint& point) +{ + iterator it; + + it = pushPoint(point,true,false,LINEHINT); +// if (count() == 1 && !m_parent->editingMode()) +// addPoint(it,point,true,false,LINEHINT); + + return selectPivot(it); +} + +void KisCurveMagnetic::calculateCurve (KisCurve::iterator p1, KisCurve::iterator p2, KisCurve::iterator it) +{ + if (p1 == m_curve.end() || p2 == m_curve.end()) // It happens sometimes, for example on the first click + return; + if (m_parent->editingMode()) + return; + TQPoint start = (*p1).point().roundTQPoint(); + TQPoint end = (*p2).point().roundTQPoint(); + TQRect rc = TQRect(start,end).normalize(); + rc.setTopLeft(rc.topLeft()+TQPoint(-8,-8)); // Enlarge the view, so problems with gaussian blur can be removed + rc.setBottomRight(rc.bottomRight()+TQPoint(8,8)); // and we are able to find paths that go beyond the rect. + + KisPaintDeviceSP src = m_parent->m_currentImage->activeDevice(); + GrayMatrix dst = GrayMatrix(rc.width(),GrayCol(rc.height())); + + detectEdges (rc, src, dst); + reduceMatrix (rc, dst, 3, 3, 3, 3); + + Node startNode, endNode; + multiset openSet; + NodeMatrix openMatrix = NodeMatrix(rc.width(),NodeCol(rc.height())); + NodeMatrix closedMatrix = NodeMatrix(rc.width(),NodeCol(rc.height())); + + TQPoint tl(rc.topLeft().x(),rc.topLeft().y()); + start -= tl; // Relative to the matrix + end -= tl; // Relative to the matrix + + findEdge (start.x(), start.y(), dst, startNode); + openMatrix[startNode.col()][startNode.row()] = *openSet.insert(startNode); + endNode.setPos(end); + + while (!openSet.empty()) { + Node current = *openSet.begin(); + + openSet.erase(openSet.begin()); + openMatrix[current.col()][current.row()].clear(); + + TQValueList successors = current.getNeighbor(dst,endNode); + for (TQValueList::iterator i = successors.begin(); i != successors.end(); i++) { + int col = (*i).col(); + int row = (*i).row(); + if ((*i) == endNode) { + while (current.parent() != TQPoint(-1,-1)) { + it = addPoint(it,KisPoint(tl+current.pos()),false,false,LINEHINT); + current = closedMatrix[current.parent().x()][current.parent().y()]; + } + return; + } + Node *openNode = &openMatrix[col][row]; + if (*openNode != TQPoint(-1,-1)) { + if (*i > *openNode) + continue; + else { + openSet.erase(tqFind(openSet.begin(),openSet.end(),*openNode)); + openNode->clear(); // Clear the Node + } + } + Node *closedNode = &closedMatrix[col][row]; + if (*closedNode != TQPoint(-1,-1)) { + if ((*i) > (*closedNode)) + continue; + else { + openMatrix[col][row] = *openSet.insert(*closedNode); + closedNode->clear(); // Clear the Node + continue; + } + } + openMatrix[col][row] = *openSet.insert(*i); + } + closedMatrix[current.col()][current.row()] = current; + } +} + +void KisCurveMagnetic::findEdge (int col, int row, const GrayMatrix& src, Node& node) +{ + int x = -1; + int y = -1; + + // tmpdist out of range + KisVector2D mindist(5.0,5.0), tmpdist(1000.0,1000.0); + for (int i = -5; i < 6; i++) { + for (int j = -5; j < 6; j++) { + if (src[col+i][row+j] != NOEDGE) { + tmpdist = KisVector2D(i,j); + if (tmpdist.length() < mindist.length()) + mindist = tmpdist; + } + } + } + if (tmpdist.x() == 1000.0) + mindist = KisVector2D(0.0,0.0); + + x = (int)(col + mindist.x()); + y = (int)(row + mindist.y()); + + node.setPos(TQPoint(x,y)); +} + +void KisCurveMagnetic::reduceMatrix (TQRect& rc, GrayMatrix& m, int top, int right, int bottom, int left) +{ + TQPoint topleft(top, left); + TQPoint bottomright(bottom, right); + + rc.setTopLeft(rc.topLeft()+topleft); + rc.setBottomRight(rc.bottomRight()-bottomright); + + if (left) + m.erase(m.begin(),m.begin()+left); + if (right) + m.erase(m.end()-right,m.end()); + if (top) { + for (uint i = 0; i < m.count(); i++) + m[i].erase(m[i].begin(),m[i].begin()+top); + } + if (bottom) { + for (uint i = 0; i < m.count(); i++) + m[i].erase(m[i].end()-bottom,m[i].end()); + } +} + +void KisCurveMagnetic::detectEdges (const TQRect & rect, KisPaintDeviceSP src, GrayMatrix& dst) +{ + GrayMatrix graysrc(rect.width(),GrayCol(rect.height())); + GrayMatrix xdeltas(rect.width(),GrayCol(rect.height())); + GrayMatrix ydeltas(rect.width(),GrayCol(rect.height())); + GrayMatrix magnitude(rect.width(),GrayCol(rect.height())); + KisPaintDeviceSP smooth = new KisPaintDevice(src->colorSpace()); + + gaussianBlur(rect, src, smooth); + toGrayScale(rect, smooth, graysrc); + getDeltas(graysrc, xdeltas, ydeltas); + getMagnitude(xdeltas, ydeltas, magnitude); + nonMaxSupp(magnitude, xdeltas, ydeltas, dst); +} + +void KisCurveMagnetic::gaussianBlur (const TQRect& rect, KisPaintDeviceSP src, KisPaintDeviceSP dst) +{ + int grectx = rect.x(); + int grecty = rect.y(); + int grectw = rect.width(); + int grecth = rect.height(); + if (dst != src) { + KisPainter gc(dst); + gc.bitBlt(grectx, grecty, COMPOSITE_COPY, src, grectx, grecty, grectw, grecth); + gc.end(); + } + + KisConvolutionPainter painter( dst ); + // FIXME createKernel could create dynamic gaussian kernels having sigma as argument + KisKernelSP kernel = createKernel( 1, 1, 1, 1, 24, 1, 1, 1, 1, 32, 0); + painter.applyMatrix(kernel, grectx, grecty, grectw, grecth, BORDER_AVOID); +} + +void KisCurveMagnetic::toGrayScale (const TQRect& rect, KisPaintDeviceSP src, GrayMatrix& dst) +{ + int grectx = rect.x(); + int grecty = rect.y(); + int grectw = rect.width(); + int grecth = rect.height(); + TQColor c; + KisColorSpace *cs = src->colorSpace(); + + for (int row = 0; row < grecth; row++) { + KisHLineIteratorPixel srcIt = src->createHLineIterator(grectx, grecty+row, grectw, false); + for (int col = 0; col < grectw; col++) { + cs->toTQColor(srcIt.rawData(),&c); + dst[col][row] = tqGray(c.rgb()); + ++srcIt; + } + } +} + +void KisCurveMagnetic::getDeltas (const GrayMatrix& src, GrayMatrix& xdelta, GrayMatrix& ydelta) +{ + uint start = 1, xend = src[0].count()-1, yend = src.count()-1; + TQ_INT16 deri; + for (uint col = 0; col < src.count(); col++) { + for (uint row = 0; row < src[col].count(); row++) { + if (row >= start && row < xend) { + deri = src[col][row+1] - src[col][row-1]; + xdelta[col][row] = deri; + } else + xdelta[col][row] = 0; + if (col >= start && col < yend) { + deri = src[col+1][row] - src[col-1][row]; + ydelta[col][row] = deri; + } else + ydelta[col][row] = 0; + } + } +} + +void KisCurveMagnetic::getMagnitude (const GrayMatrix& xdelta, const GrayMatrix& ydelta, GrayMatrix& gradient) +{ + for (uint col = 0; col < xdelta.count(); col++) { + for (uint row = 0; row < xdelta[col].count(); row++) + gradient[col][row] = (TQ_INT16)(ROUND(RMS(xdelta[col][row],ydelta[col][row]))); + } +} + +void KisCurveMagnetic::nonMaxSupp (const GrayMatrix& magnitude, const GrayMatrix& xdelta, const GrayMatrix& ydelta, GrayMatrix& nms) +{ + // Directions: + // 1: 0 - 22.5 degrees + // 2: 22.5 - 67.5 degrees + // 3: 67.5 - 90 degrees + // Second direction is relative to a quadrant. The quadrant is known by looking at x and y derivatives + // First quadrant: Gx < 0 & Gy >= 0 + // Second quadrant: Gx < 0 & Gy < 0 + // Third quadrant: Gx >= 0 & Gy < 0 + // Fourth quadrant: Gx >= 0 & Gy >= 0 + // For this reason: first direction is relative to Gy only and third direction to Gx only + + double theta; // theta = invtan (|Gy| / |Gx|) This give the direction relative to a quadrant + TQ_INT16 mag; // Current magnitude + TQ_INT16 lmag; // Magnitude at the left (So this pixel is "more internal" than the current + TQ_INT16 rmag; // Magnitude at the right (So this pixel is "more external") + double xdel; // Current xdelta + double ydel; // Current ydelta + TQ_INT16 result; + + for (uint col = 0; col < magnitude.count(); col++) { + for (uint row = 0; row < magnitude[col].count(); row++) { + mag = magnitude[col][row]; + if (!mag || row == 0 || row == (magnitude[col].count()-1) || + col == 0 || col == (magnitude.count()-1)) + { + result = NOEDGE; + } else { + xdel = (double)xdelta[col][row]; + ydel = (double)ydelta[col][row]; + theta = atan(fabs(ydel)/fabs(xdel)); + if (theta < 0) + theta = fabs(theta)+M_PI_2; + theta = (theta * 360.0) / (2.0*M_PI); // Radians -> degrees + if (theta >= 0 && theta < 22.5) { // .0 - .3926990816 + if (ydel >= 0) { + lmag = magnitude[col][row-1]; + rmag = magnitude[col][row+1]; + } else { + lmag = magnitude[col][row+1]; + rmag = magnitude[col][row-1]; + } + } + if (theta >= 22.5 && theta < 67.5) { // .3926990816 - 1.1780972449 + if (xdel >= 0) { + if (ydel >= 0) { + lmag = magnitude[col-1][row-1]; + rmag = magnitude[col+1][row+1]; + } else { + lmag = magnitude[col+1][row-1]; + rmag = magnitude[col-1][row+1]; + } + } else { + if (ydel >= 0) { + lmag = magnitude[col-1][row+1]; + rmag = magnitude[col+1][row-1]; + } else { + lmag = magnitude[col+1][row+1]; + rmag = magnitude[col-1][row-1]; + } + } + } + if (theta >= 67.5 && theta <= 90.0) { // 1.1780972449 - 1.5707963266 + if (xdel >= 0) { + lmag = magnitude[col+1][row]; + rmag = magnitude[col-1][row]; + } else { + lmag = magnitude[col-1][row]; + rmag = magnitude[col+1][row]; + } + } + + if ((mag < lmag) || (mag < rmag)) { + result = NOEDGE; + } else { + if (rmag == mag) // If the external magnitude is equal to the current, suppress current. + result = NOEDGE; + else + result = (mag > 255) ? 255 : mag; + } + } + nms[col][row] = result; + } + } +} + +KisToolMagnetic::KisToolMagnetic () + : super("Magnetic Outline Tool") +{ + setName("tool_moutline"); + setCursor(KisCursor::load("tool_moutline_cursor.png", 6, 6)); + + m_editingMode = false; + m_editingCursor = m_draggingCursor = false; + + m_mode = 0; + m_curve = m_derived = 0; + m_current = m_previous = 0; + + m_distance = DEFAULTDIST; + + m_transactionMessage = i18n("Magnetic Outline Selection"); +} + +KisToolMagnetic::~KisToolMagnetic () +{ + m_curve = 0; + delete m_derived; +} + +void KisToolMagnetic::update (KisCanvasSubject *subject) +{ + super::update(subject); +} + +void KisToolMagnetic::activate () +{ + super::activate(); + if (!m_derived) { + m_derived = new KisCurveMagnetic(this); + m_curve = m_derived; + } +} + +void KisToolMagnetic::deactivate () +{ + m_curve->endActionOptions(); + m_actionOptions = NOOPTIONS; + m_dragging = false; + m_drawPivots = true; +} + +void KisToolMagnetic::keyPress(TQKeyEvent *event) +{ + if (event->key() == TQt::Key_Control) { + draw(false); + if (m_editingMode) { + m_editingMode = false; + if (m_current != 0) + m_curve->selectPivot(m_current,false); + m_mode->setText(i18n("Automatic Mode")); + } else { + m_editingMode = true; + m_mode->setText(i18n("Manual Mode")); + } + draw(false); + } else if (event->key() == TQt::Key_Delete && m_curve->count()) { + draw(false); + m_dragging = false; + if (m_curve->pivots().count() == 2) + m_curve->clear(); + else { + if ((*m_current) == m_curve->last() && !(m_editingMode)) { + m_curve->deletePivot(m_current.previousPivot()); + m_previous = m_current.previousPivot(); + } else { + m_editingMode = false; + m_curve->deletePivot(m_current); + m_previous = m_current = m_curve->selectPivot(m_curve->lastIterator()); + m_editingMode = true; + } + } + draw(false); + } else + super::keyPress(event); +} + +void KisToolMagnetic::buttonRelease(KisButtonReleaseEvent *event) +{ + if (m_editingMode) { + draw(m_current); + m_editingMode = false; + if (!m_curve->isEmpty()) + m_curve->movePivot(m_current, m_currentPoint); + m_editingMode = true; + draw(m_current); + } + super::buttonRelease(event); +} + +void KisToolMagnetic::buttonPress(KisButtonPressEvent *event) +{ + updateOptions(event->state()); + if (!m_currentImage) + return; + if (event->button() == Qt::LeftButton) { + m_dragging = true; + m_currentPoint = event->pos(); + PointPair temp(m_curve->end(),false); + if (m_editingMode) + temp = pointUnderMouse (m_subject->canvasController()->windowToView(event->pos().toTQPoint())); + if (temp.first == m_curve->end() && !(m_actionOptions)) { + if (m_editingMode) { + draw(true, true); + m_curve->selectAll(false); + draw(true, true); + } + draw(m_curve->end()); + if (!m_curve->isEmpty()) { + m_previous = m_current; + m_current = m_curve->pushPivot(event->pos()); + } else { + m_previous = m_current = m_curve->pushPivot(event->pos()); + } + if (m_curve->pivots().count() > 1) + m_curve->calculateCurve(m_previous,m_current,m_current); + if (m_editingMode) + draw(); + else { + if ((*m_previous).point() == (*m_current).point()) + draw(m_curve->end()); + else + draw(); + } + } else if (temp.first != m_curve->end() && m_editingMode) { + if (temp.second) { + draw(true, true); + m_current = m_curve->selectPivot(temp.first); + draw(true, true); + } else { + draw(false); + m_current = selectByMouse(temp.first); + draw(false); + } + if (!(*m_current).isSelected()) + m_dragging = false; + } + } +} + +void KisToolMagnetic::move(KisMoveEvent *event) +{ + updateOptions(event->state()); + if (m_currentPoint == event->pos().floorTQPoint()) + return; + if (m_editingMode) { + PointPair temp = pointUnderMouse(m_subject->canvasController()->windowToView(event->pos().toTQPoint())); + if (temp.first == m_curve->end() && !m_dragging) { + if (m_editingCursor || m_draggingCursor) { + setCursor(KisCursor::load("tool_moutline_cursor.png", 6, 6)); + m_editingCursor = m_draggingCursor = false; + } + } else { + if (!m_draggingCursor && temp.second) { + setCursor(KisCursor::load("tool_moutline_dragging.png", 6, 6)); + m_editingCursor = false; + m_draggingCursor = true; + } + if (!m_editingCursor && !temp.second) { + setCursor(KisCursor::load("tool_moutline_editing.png", 6, 6)); + m_editingCursor = true; + m_draggingCursor = false; + } + } + if (!m_dragging) + return; + } else { + if (m_editingCursor || m_draggingCursor) { + setCursor(KisCursor::load("tool_moutline_cursor.png", 6, 6)); + m_editingCursor = m_draggingCursor = false; + } + } + if (m_curve->selectedPivots().isEmpty()) + return; + + KisPoint trans = event->pos() - m_currentPoint; + KisPoint dist; + dist = (*m_current).point() - (*m_current.previousPivot()).point(); + if ((m_distance >= MINDIST && (fabs(dist.x()) + fabs(dist.y())) > m_distance && !(m_editingMode)) + || m_curve->pivots().count() == 1) { + draw(m_curve->end()); + m_previous = m_current; + m_current = m_curve->pushPivot(event->pos()); + } else if ((*m_previous).point() == (*m_current).point() && (*m_previous).point() == m_curve->last().point()) + draw(m_curve->end()); + else + draw(m_current); + m_curve->movePivot(m_current,event->pos()); + m_currentPoint = event->pos().floorTQPoint(); + draw(m_current); +} + +KisCurve::iterator KisToolMagnetic::selectByMouse(KisCurve::iterator it) +{ + KisCurve::iterator currPivot = m_curve->selectPivot(m_curve->addPivot(it, KisPoint(0,0))); + m_curve->movePivot(currPivot,(*it).point()); + + return currPivot; +} + +void KisToolMagnetic::slotCommitCurve () +{ + if (!m_curve->isEmpty()) + commitCurve(); +} + +void KisToolMagnetic::slotSetDistance (int dist) +{ + m_distance = dist; +} + +TQWidget* KisToolMagnetic::createOptionWidget(TQWidget* parent) +{ + m_optWidget = super::createOptionWidget(parent); + TQVBoxLayout * l = dynamic_cast(m_optWidget->layout()); + TQGridLayout *box = new TQGridLayout(l, 2, 2, 3); + box->setColStretch(0, 1); + box->setColStretch(1, 1); + TQ_CHECK_PTR(box); + + m_mode = new TQLabel(i18n("Automatic mode"), m_optWidget); + m_lbDistance = new TQLabel(i18n("Distance: "), m_optWidget); + TQPushButton *finish = new TQPushButton(i18n("To Selection"), m_optWidget); + m_slDistance = new TQSlider(MINDIST, MAXDIST, PAGESTEP, m_distance, Qt::Horizontal, m_optWidget); + + connect(m_slDistance, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetDistance(int))); + connect(finish, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotCommitCurve())); + + box->addWidget(m_lbDistance, 0, 0); + box->addWidget(m_slDistance, 0, 1); + box->addWidget(m_mode, 1, 0); + box->addWidget(finish, 1, 1); + + return m_optWidget; +} + +void KisToolMagnetic::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("Magnetic Outline"), + "tool_moutline", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Magnetic Selection: move around an edge to select it. Hit Ctrl to enter/quit manual mode, and double click to finish.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_moutline.moc" diff --git a/chalk/plugins/tools/tool_curves/tool_curves.cc b/chalk/plugins/tools/tool_curves/tool_curves.cc deleted file mode 100644 index b21f5aae..00000000 --- a/chalk/plugins/tools/tool_curves/tool_curves.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * tool_bezier.cc -- part of Chalk - * - * Copyright (c) 2006 Emanuele Tamponi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "tool_curves.h" -#include "kis_tool_bezier_paint.h" -#include "kis_tool_bezier_select.h" -#include "kis_tool_moutline.h" - - -typedef KGenericFactory ToolCurvesFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolcurves, ToolCurvesFactory( "chalk" ) ) - - -ToolCurves::ToolCurves(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolCurvesFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast( parent ); - r->add(new KisToolBezierPaintFactory()); - r->add(new KisToolBezierSelectFactory()); - r->add(new KisToolMagneticFactory()); - } - -} - -ToolCurves::~ToolCurves() -{ -} - -#include "tool_curves.moc" diff --git a/chalk/plugins/tools/tool_curves/tool_curves.cpp b/chalk/plugins/tools/tool_curves/tool_curves.cpp new file mode 100644 index 00000000..28f65604 --- /dev/null +++ b/chalk/plugins/tools/tool_curves/tool_curves.cpp @@ -0,0 +1,67 @@ +/* + * tool_bezier.cpp -- part of Chalk + * + * Copyright (c) 2006 Emanuele Tamponi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "tool_curves.h" +#include "kis_tool_bezier_paint.h" +#include "kis_tool_bezier_select.h" +#include "kis_tool_moutline.h" + + +typedef KGenericFactory ToolCurvesFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolcurves, ToolCurvesFactory( "chalk" ) ) + + +ToolCurves::ToolCurves(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolCurvesFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast( parent ); + r->add(new KisToolBezierPaintFactory()); + r->add(new KisToolBezierSelectFactory()); + r->add(new KisToolMagneticFactory()); + } + +} + +ToolCurves::~ToolCurves() +{ +} + +#include "tool_curves.moc" diff --git a/chalk/plugins/tools/tool_filter/Makefile.am b/chalk/plugins/tools/tool_filter/Makefile.am index d99a3924..b12ab69b 100644 --- a/chalk/plugins/tools/tool_filter/Makefile.am +++ b/chalk/plugins/tools/tool_filter/Makefile.am @@ -10,9 +10,9 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalktoolfilter_la_SOURCES = \ - kis_filterop.cc \ - kis_tool_filter.cc \ - tool_filter.cc + kis_filterop.cpp \ + kis_tool_filter.cpp \ + tool_filter.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolfilter.la diff --git a/chalk/plugins/tools/tool_filter/kis_filterop.cc b/chalk/plugins/tools/tool_filter/kis_filterop.cpp similarity index 100% rename from chalk/plugins/tools/tool_filter/kis_filterop.cc rename to chalk/plugins/tools/tool_filter/kis_filterop.cpp diff --git a/chalk/plugins/tools/tool_filter/kis_tool_filter.cc b/chalk/plugins/tools/tool_filter/kis_tool_filter.cc deleted file mode 100644 index 07133d3b..00000000 --- a/chalk/plugins/tools/tool_filter/kis_tool_filter.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* - * kis_tool_filter.cc - part of Chalk - * - * Copyright (c) 2004 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "kis_filter_config_widget.h" -#include "kis_tool_filter.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -KisToolFilter::KisToolFilter() - : super(i18n("Filter Brush")), m_filterConfigurationWidget(0) -{ - setName("tool_filter"); - m_subject = 0; - setCursor(KisCursor::load("tool_filter_cursor.png", 5, 5)); -} - -KisToolFilter::~KisToolFilter() -{ -} - -void KisToolFilter::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Filter Brush"), - "tool_filter", 0, this, - TQT_SLOT(activate()), collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setToolTip(i18n("Paint with filters")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -void KisToolFilter::initPaint(KisEvent *e) -{ - // Some filters want to paint directly on the current state of - // the canvas, others cannot handle that and need a temporary layer - // so they can work on the old data before painting started. - m_paintIncremental = m_filter->supportsIncrementalPainting(); - - super::initPaint(e); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("filter", 0, painter()); - op->setSource ( m_source ); - painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. - painter()->setFilter( m_filter ); - - // XXX: Isn't there a better way to set the config? The filter config widget needs to - // to go into the tool options widget, and just the data carried over to the filter. - // I've got a bit of a problem with core classes having too much GUI about them. - // BSAR. - dynamic_cast(op)->setFilterConfiguration( m_filter->configuration( m_filterConfigurationWidget) ); -} - -TQWidget* KisToolFilter::createOptionWidget(TQWidget* parent) -{ - TQWidget *widget = super::createOptionWidget(parent); - - m_cbFilter = new KisCmbIDList(widget); - TQ_CHECK_PTR(m_cbFilter); - - TQLabel* lbFilter = new TQLabel(i18n("Filter:"), widget); - TQ_CHECK_PTR(lbFilter); - - // Check which filters support painting - KisIDList l = KisFilterRegistry::instance()->listKeys(); - KisIDList l2; - KisIDList::iterator it; - for (it = l.begin(); it != l.end(); ++it) { - KisFilterSP f = KisFilterRegistry::instance()->get(*it); - if (f->supportsPainting()) { - l2.push_back(*it); - } - } - m_cbFilter ->setIDList( l2 ); - - addOptionWidgetOption(m_cbFilter, lbFilter); - - m_optionLayout = new TQGridLayout(widget, 1, 1, 0, 6); - TQ_CHECK_PTR(m_optionLayout); - super::addOptionWidgetLayout(m_optionLayout); - - connect(m_cbFilter, TQT_SIGNAL(activated ( const KisID& )), this, TQT_SLOT( changeFilter( const KisID& ) ) ); - changeFilter( m_cbFilter->currentItem () ); - - return widget; -} - -void KisToolFilter::changeFilter( const KisID & id) -{ - m_filter = KisFilterRegistry::instance()->get( id ); - Q_ASSERT(m_filter != 0); - if( m_filterConfigurationWidget != 0 ) - { - m_optionLayout->remove ( m_filterConfigurationWidget ); - delete m_filterConfigurationWidget; - } - - m_source = m_currentImage->activeDevice(); - if (!m_source) return; - - m_filterConfigurationWidget = m_filter->createConfigurationWidget( optionWidget(), m_source ); - if( m_filterConfigurationWidget != 0 ) - { - m_optionLayout->addMultiCellWidget ( m_filterConfigurationWidget, 2, 2, 0, 1 ); - m_filterConfigurationWidget->show(); - } -} - -#include "kis_tool_filter.moc" diff --git a/chalk/plugins/tools/tool_filter/kis_tool_filter.cpp b/chalk/plugins/tools/tool_filter/kis_tool_filter.cpp new file mode 100644 index 00000000..14e2d616 --- /dev/null +++ b/chalk/plugins/tools/tool_filter/kis_tool_filter.cpp @@ -0,0 +1,154 @@ +/* + * kis_tool_filter.cpp - part of Chalk + * + * Copyright (c) 2004 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "kis_filter_config_widget.h" +#include "kis_tool_filter.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +KisToolFilter::KisToolFilter() + : super(i18n("Filter Brush")), m_filterConfigurationWidget(0) +{ + setName("tool_filter"); + m_subject = 0; + setCursor(KisCursor::load("tool_filter_cursor.png", 5, 5)); +} + +KisToolFilter::~KisToolFilter() +{ +} + +void KisToolFilter::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Filter Brush"), + "tool_filter", 0, this, + TQT_SLOT(activate()), collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Paint with filters")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +void KisToolFilter::initPaint(KisEvent *e) +{ + // Some filters want to paint directly on the current state of + // the canvas, others cannot handle that and need a temporary layer + // so they can work on the old data before painting started. + m_paintIncremental = m_filter->supportsIncrementalPainting(); + + super::initPaint(e); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("filter", 0, painter()); + op->setSource ( m_source ); + painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. + painter()->setFilter( m_filter ); + + // XXX: Isn't there a better way to set the config? The filter config widget needs to + // to go into the tool options widget, and just the data carried over to the filter. + // I've got a bit of a problem with core classes having too much GUI about them. + // BSAR. + dynamic_cast(op)->setFilterConfiguration( m_filter->configuration( m_filterConfigurationWidget) ); +} + +TQWidget* KisToolFilter::createOptionWidget(TQWidget* parent) +{ + TQWidget *widget = super::createOptionWidget(parent); + + m_cbFilter = new KisCmbIDList(widget); + TQ_CHECK_PTR(m_cbFilter); + + TQLabel* lbFilter = new TQLabel(i18n("Filter:"), widget); + TQ_CHECK_PTR(lbFilter); + + // Check which filters support painting + KisIDList l = KisFilterRegistry::instance()->listKeys(); + KisIDList l2; + KisIDList::iterator it; + for (it = l.begin(); it != l.end(); ++it) { + KisFilterSP f = KisFilterRegistry::instance()->get(*it); + if (f->supportsPainting()) { + l2.push_back(*it); + } + } + m_cbFilter ->setIDList( l2 ); + + addOptionWidgetOption(m_cbFilter, lbFilter); + + m_optionLayout = new TQGridLayout(widget, 1, 1, 0, 6); + TQ_CHECK_PTR(m_optionLayout); + super::addOptionWidgetLayout(m_optionLayout); + + connect(m_cbFilter, TQT_SIGNAL(activated ( const KisID& )), this, TQT_SLOT( changeFilter( const KisID& ) ) ); + changeFilter( m_cbFilter->currentItem () ); + + return widget; +} + +void KisToolFilter::changeFilter( const KisID & id) +{ + m_filter = KisFilterRegistry::instance()->get( id ); + Q_ASSERT(m_filter != 0); + if( m_filterConfigurationWidget != 0 ) + { + m_optionLayout->remove ( m_filterConfigurationWidget ); + delete m_filterConfigurationWidget; + } + + m_source = m_currentImage->activeDevice(); + if (!m_source) return; + + m_filterConfigurationWidget = m_filter->createConfigurationWidget( optionWidget(), m_source ); + if( m_filterConfigurationWidget != 0 ) + { + m_optionLayout->addMultiCellWidget ( m_filterConfigurationWidget, 2, 2, 0, 1 ); + m_filterConfigurationWidget->show(); + } +} + +#include "kis_tool_filter.moc" diff --git a/chalk/plugins/tools/tool_filter/tool_filter.cc b/chalk/plugins/tools/tool_filter/tool_filter.cc deleted file mode 100644 index bda2357e..00000000 --- a/chalk/plugins/tools/tool_filter/tool_filter.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * tool_filter.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "tool_filter.h" -#include "kis_filterop.h" -#include "kis_tool_filter.h" - - -typedef KGenericFactory ToolFilterFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolfilter, ToolFilterFactory( "chalk" ) ) - - -ToolFilter::ToolFilter(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolFilterFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast(parent); - r->add( new KisToolFilterFactory()); - - // XXX: Put this in a separate plugin? - KisPaintOpRegistry * pr = KisPaintOpRegistry::instance(); - pr->add( new KisFilterOpFactory ); - - } -} - -ToolFilter::~ToolFilter() -{ -} - -#include "tool_filter.moc" diff --git a/chalk/plugins/tools/tool_filter/tool_filter.cpp b/chalk/plugins/tools/tool_filter/tool_filter.cpp new file mode 100644 index 00000000..484a7d9f --- /dev/null +++ b/chalk/plugins/tools/tool_filter/tool_filter.cpp @@ -0,0 +1,68 @@ +/* + * tool_filter.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "tool_filter.h" +#include "kis_filterop.h" +#include "kis_tool_filter.h" + + +typedef KGenericFactory ToolFilterFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolfilter, ToolFilterFactory( "chalk" ) ) + + +ToolFilter::ToolFilter(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolFilterFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(parent); + r->add( new KisToolFilterFactory()); + + // XXX: Put this in a separate plugin? + KisPaintOpRegistry * pr = KisPaintOpRegistry::instance(); + pr->add( new KisFilterOpFactory ); + + } +} + +ToolFilter::~ToolFilter() +{ +} + +#include "tool_filter.moc" diff --git a/chalk/plugins/tools/tool_perspectivegrid/Makefile.am b/chalk/plugins/tools/tool_perspectivegrid/Makefile.am index 8544c078..c15df268 100644 --- a/chalk/plugins/tools/tool_perspectivegrid/Makefile.am +++ b/chalk/plugins/tools/tool_perspectivegrid/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalktoolperspectivegrid_la_SOURCES = \ - tool_perspectivegrid.cc \ - kis_tool_perspectivegrid.cc + tool_perspectivegrid.cpp \ + kis_tool_perspectivegrid.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolperspectivegrid.la diff --git a/chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc b/chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc deleted file mode 100644 index 2dbe56d3..00000000 --- a/chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cc +++ /dev/null @@ -1,499 +0,0 @@ -/* - * kis_tool_perspectivegrid.cc - part of Chalk - * - * Copyright (c) 2006 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -KisToolPerspectiveGrid::KisToolPerspectiveGrid() - : super(i18n("Perspective Grid")), m_handleSize(13), m_handleHalfSize(6) - -{ - setName("tool_perspectivegrid"); - - m_subject = 0; - m_dragging = false; -} - -KisToolPerspectiveGrid::~KisToolPerspectiveGrid() -{ -} - -void KisToolPerspectiveGrid::activate() -{ - m_subject->perspectiveGridManager()->startEdition(); - if( ! m_subject->currentImg()->perspectiveGrid()->hasSubGrids() ) - { - m_mode = MODE_CREATION; - m_points.clear(); - } else { - m_mode = MODE_EDITING; - drawGrid(); - } - super::activate(); -} - -void KisToolPerspectiveGrid::deactivate() -{ - m_subject->perspectiveGridManager()->stopEdition(); - m_subject->perspectiveGridManager()->setGridVisible( true); - if( m_mode == MODE_CREATION ) - { - drawGridCreation(); - m_points.clear(); - m_dragging = false; - } else { - drawGrid(); - } -} - - -void KisToolPerspectiveGrid::update (KisCanvasSubject *subject) -{ - m_subject = subject; - super::update(m_subject); -} - -bool KisToolPerspectiveGrid::mouseNear(const TQPoint& mousep, const TQPoint point) -{ - return (TQRect( (point.x() - m_handleHalfSize), (point.y() - m_handleHalfSize), m_handleSize, m_handleSize).contains(mousep) ); -} - -void KisToolPerspectiveGrid::buttonPress(KisButtonPressEvent *event) -{ - KisPerspectiveGrid* pGrid = m_subject->currentImg()->perspectiveGrid(); - if(!pGrid->hasSubGrids() && m_mode != MODE_CREATION) - { // it's possible that the perspectiv grid was cleared - m_mode = MODE_CREATION; - m_points.clear(); - } - if( m_mode == MODE_CREATION && event->button() == Qt::LeftButton) - { - m_dragging = true; - - if (m_points.isEmpty()) - { - m_dragStart = event->pos(); - m_dragEnd = event->pos(); - m_points.append(m_dragStart); - } else { - m_dragStart = m_dragEnd; - m_dragEnd = event->pos(); - drawGridCreation(); - } - } else if(m_mode == MODE_EDITING && event->button() == Qt::LeftButton){ - // Look for the handle which was pressed - if (!m_subject) - return; - KisCanvasController *controller = m_subject->canvasController(); - Q_ASSERT(controller); - TQPoint mousep = controller->windowToView( event->pos().roundTQPoint() ); - - for( TQValueList::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) - { - KisSubPerspectiveGrid* grid = *it; - if( mouseNear( mousep, controller->windowToView(grid->topLeft()->roundTQPoint() ) ) ) - { - kdDebug() << " PRESS TOPLEFT HANDLE " << endl; - m_mode = MODE_DRAGING_NODE; - m_selectedNode1 = grid->topLeft(); - break; - } - else if( mouseNear( mousep, controller->windowToView(grid->topRight()->roundTQPoint() ) ) ) - { - kdDebug() << " PRESS TOPRIGHT HANDLE " << endl; - m_mode = MODE_DRAGING_NODE; - m_selectedNode1 = grid->topRight(); - break; - } - else if( mouseNear( mousep, controller->windowToView(grid->bottomLeft()->roundTQPoint() ) ) ) - { - kdDebug() << " PRESS BOTTOMLEFT HANDLE " << endl; - m_mode = MODE_DRAGING_NODE; - m_selectedNode1 = grid->bottomLeft(); - break; - } - else if( mouseNear( mousep, controller->windowToView(grid->bottomRight()->roundTQPoint() ) ) ) - { - kdDebug() << " PRESS BOTTOMRIGHT HANDLE " << endl; - m_mode = MODE_DRAGING_NODE; - m_selectedNode1 = grid->bottomRight(); - break; - } - else if( !grid->leftGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topLeft() + *grid->bottomLeft() )*0.5) ).roundTQPoint() ) ) - { - kdDebug() << " PRESS LEFT HANDLE " << endl; - m_mode = MODE_DRAGING_TRANSLATING_TWONODES; - drawGrid(); - m_selectedNode1 = new KisPerspectiveGridNode( *grid->topLeft() ); - m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomLeft() ); - KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( m_selectedNode1, grid->topLeft() , grid->bottomLeft(), m_selectedNode2); - m_dragEnd = event->pos(); - newsubgrid->setRightGrid( grid); - grid->setLeftGrid( newsubgrid); - pGrid->addNewSubGrid( newsubgrid); - drawGrid(); - break; - } - else if( !grid->rightGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topRight() + *grid->bottomRight() )*0.5) ).roundTQPoint() ) ) - { - kdDebug() << " PRESS RIGHT HANDLE " << endl; - m_mode = MODE_DRAGING_TRANSLATING_TWONODES; - drawGrid(); - m_selectedNode1 = new KisPerspectiveGridNode( *grid->topRight() ); - m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomRight() ); - KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( grid->topRight(), m_selectedNode1, m_selectedNode2, grid->bottomRight()); - m_dragEnd = event->pos(); - newsubgrid->setLeftGrid( grid); - grid->setRightGrid( newsubgrid); - pGrid->addNewSubGrid( newsubgrid); - drawGrid(); - break; - } - else if( !grid->topGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topLeft() + *grid->topRight() )*0.5) ).roundTQPoint() ) ) - { - kdDebug() << " PRESS TOP HANDLE " << endl; - m_mode = MODE_DRAGING_TRANSLATING_TWONODES; - drawGrid(); - m_selectedNode1 = new KisPerspectiveGridNode( *grid->topLeft() ); - m_selectedNode2 = new KisPerspectiveGridNode( *grid->topRight() ); - KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( m_selectedNode1, m_selectedNode2, grid->topRight(), grid->topLeft() ); - m_dragEnd = event->pos(); - newsubgrid->setBottomGrid( grid); - grid->setTopGrid( newsubgrid); - pGrid->addNewSubGrid( newsubgrid); - drawGrid(); - break; - } - else if( !grid->bottomGrid() && mouseNear( mousep, controller->windowToView( ((*grid->bottomLeft() + *grid->bottomRight() )*0.5) ).roundTQPoint() ) ) - { - kdDebug() << " PRESS BOTTOM HANDLE " << endl; - m_mode = MODE_DRAGING_TRANSLATING_TWONODES; - drawGrid(); - m_selectedNode1 = new KisPerspectiveGridNode( *grid->bottomLeft() ); - m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomRight() ); - KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( grid->bottomLeft(), grid->bottomRight(), m_selectedNode2, m_selectedNode1); - m_dragEnd = event->pos(); - newsubgrid->setTopGrid( grid); - grid->setBottomGrid( newsubgrid); - pGrid->addNewSubGrid( newsubgrid); - drawGrid(); - break; - } - } - } -} - - -void KisToolPerspectiveGrid::move(KisMoveEvent *event) -{ - if( m_mode == MODE_CREATION ) - { - if (m_dragging) { - // erase old lines on canvas - drawGridCreation(); - // get current mouse position - m_dragEnd = event->pos(); - // draw new lines on canvas - drawGridCreation(); - } - } else { - if( m_mode == MODE_DRAGING_NODE) - { - drawGrid(); - m_selectedNode1->setX( event->pos().x() ); - m_selectedNode1->setY( event->pos().y() ); - drawGrid(); - } - if( m_mode == MODE_DRAGING_TRANSLATING_TWONODES) - { - drawGrid(); - KisPoint translate = event->pos() - m_dragEnd; - m_dragEnd = event->pos(); - *m_selectedNode1 += translate;; - *m_selectedNode2 += translate;; - drawGrid(); - } - } -} - -void KisToolPerspectiveGrid::buttonRelease(KisButtonReleaseEvent *event) -{ - if (!m_subject) - return; - - if( m_mode == MODE_CREATION ) - { - if (m_dragging && event->button() == Qt::LeftButton) { - m_dragging = false; - m_points.append (m_dragEnd); - if( m_points.size() == 4) - { // wow we have a grid, isn't that cool ? - drawGridCreation(); // Clean - m_subject->currentImg()->perspectiveGrid()->addNewSubGrid( new KisSubPerspectiveGrid( new KisPerspectiveGridNode(m_points[0]), new KisPerspectiveGridNode(m_points[1]), new KisPerspectiveGridNode(m_points[2]), new KisPerspectiveGridNode(m_points[3]) ) ); - drawGrid(); - m_mode = MODE_EDITING; - } - } - } else { - m_mode = MODE_EDITING; - m_selectedNode1 = 0; - m_selectedNode2 = 0; - } - -/* if (m_dragging && event->button() == RightButton) { - - }*/ -} - -void KisToolPerspectiveGrid::paint(KisCanvasPainter& gc) -{ - if( m_mode == MODE_CREATION ) - { - drawGridCreation(gc); - } else { - drawGrid(gc); - } -} - -void KisToolPerspectiveGrid::paint(KisCanvasPainter& gc, const TQRect&) -{ - if( m_mode == MODE_CREATION ) - { - drawGridCreation(gc); - } else { - drawGrid(gc); - } -} - -void KisToolPerspectiveGrid::drawGridCreation() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - - drawGridCreation(gc); - } -} - - -void KisToolPerspectiveGrid::drawGridCreation(KisCanvasPainter& gc) -{ - if (!m_subject) - return; - - TQPen pen(TQt::white); - - gc.setPen(pen); - gc.setRasterOp(TQt::XorROP); - - KisCanvasController *controller = m_subject->canvasController(); - KisPoint start, end; - TQPoint startPos; - TQPoint endPos; - - if (m_dragging) { - startPos = controller->windowToView(m_dragStart.floorTQPoint()); - endPos = controller->windowToView(m_dragEnd.floorTQPoint()); - gc.drawLine(startPos, endPos); - } else { - for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { - - if (it == m_points.begin()) - { - start = (*it); - } else { - end = (*it); - - startPos = controller->windowToView(start.floorTQPoint()); - endPos = controller->windowToView(end.floorTQPoint()); - - gc.drawLine(startPos, endPos); - - start = end; - } - } - } -} - -void KisToolPerspectiveGrid::drawSmallRectangle(KisCanvasPainter& gc, TQPoint p) -{ - gc.drawRect( p.x() - m_handleHalfSize - 1, p.y() - m_handleHalfSize - 1, m_handleSize, m_handleSize); -} - -void KisToolPerspectiveGrid::drawGrid(KisCanvasPainter& gc) -{ - - if (!m_subject) - return; - - KisCanvasController *controller = m_subject->canvasController(); - - TQPen pen(TQt::white); - TQPoint startPos; - TQPoint endPos; - - gc.setPen(pen); - gc.setRasterOp(TQt::XorROP); - KisPerspectiveGrid* pGrid = m_subject->currentImg()->perspectiveGrid(); - - for( TQValueList::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) - { - KisSubPerspectiveGrid* grid = *it; - int index = grid->index(); - bool drawLeft = !(grid->leftGrid() && (index > grid->leftGrid()->index() ) ); - bool drawRight = !(grid->rightGrid() && (index > grid->rightGrid()->index() ) ); - bool drawTop = !(grid->topGrid() && (index > grid->topGrid()->index() ) ); - bool drawBottom = !(grid->bottomGrid() && (index > grid->bottomGrid()->index() ) ); - if(drawTop) { - startPos = controller->windowToView(grid->topLeft()->roundTQPoint()); - endPos = controller->windowToView(grid->topRight()->roundTQPoint()); - gc.drawLine( startPos, endPos ); - if( !grid->topGrid() ) - { - drawSmallRectangle(gc, (endPos + startPos) / 2); - } - if(drawLeft) { - drawSmallRectangle(gc, startPos); - } - if(drawRight) { - drawSmallRectangle(gc, endPos); - } - } - if(drawRight) { - startPos = controller->windowToView(grid->topRight()->roundTQPoint()); - endPos = controller->windowToView(grid->bottomRight()->roundTQPoint()); - gc.drawLine( startPos, endPos ); - if( !grid->rightGrid() ) - { - drawSmallRectangle(gc, (endPos + startPos) / 2); - } - } - if(drawBottom) { - startPos = controller->windowToView(grid->bottomRight()->roundTQPoint()); - endPos = controller->windowToView(grid->bottomLeft()->roundTQPoint()); - gc.drawLine( startPos, endPos ); - if( !grid->bottomGrid() ) - { - drawSmallRectangle(gc, (endPos + startPos) / 2); - } - if(drawLeft) { - drawSmallRectangle(gc, endPos); - } - if(drawRight) { - drawSmallRectangle(gc, startPos); - } - } - if(drawLeft) { - startPos = controller->windowToView(grid->bottomLeft()->roundTQPoint()); - endPos = controller->windowToView(grid->topLeft()->roundTQPoint()); - gc.drawLine( startPos, endPos ); - if( !grid->leftGrid() ) - { - drawSmallRectangle(gc, (endPos + startPos) / 2); - } - } - KisPoint tbVpf = grid->topBottomVanishingPoint(); - if( fabs(tbVpf.x()) < 30000000. && fabs(tbVpf.y()) < 30000000.) - { - TQPoint tbVp = controller->windowToView(tbVpf.roundTQPoint()); - gc.drawLine( tbVp.x() - m_handleHalfSize, tbVp.y() - m_handleHalfSize, tbVp.x() + m_handleHalfSize, tbVp.y() + m_handleHalfSize); - gc.drawLine( tbVp.x() - m_handleHalfSize, tbVp.y() + m_handleHalfSize, tbVp.x() + m_handleHalfSize, tbVp.y() - m_handleHalfSize); - } - KisPoint lrVpf = grid->leftRightVanishingPoint(); - if( fabs(lrVpf.x()) < 30000000. && fabs(lrVpf.y()) < 30000000.) - { // Don't display it, if it is too far, or you get funny results - TQPoint lrVp = controller->windowToView(lrVpf.roundTQPoint()); - gc.drawLine( lrVp.x() - m_handleHalfSize, lrVp.y() - m_handleHalfSize, lrVp.x() + m_handleHalfSize, lrVp.y() + m_handleHalfSize); - gc.drawLine( lrVp.x() - m_handleHalfSize, lrVp.y() + m_handleHalfSize, lrVp.x() + m_handleHalfSize, lrVp.y() - m_handleHalfSize); - } - } -} - -void KisToolPerspectiveGrid::drawGrid() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - - drawGrid(gc); - } - -} - - -void KisToolPerspectiveGrid::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Perspective Grid"), - "tool_perspectivegrid" , - 0, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setExclusiveGroup("tools"); - m_action->setToolTip(i18n("Edit the perspective grid")); - m_ownAction = true; - } -} - - -// TQWidget* KisToolPerspectiveGrid::createOptionWidget(TQWidget* parent) -// { -// return 0; -// } -// -// TQWidget* KisToolPerspectiveGrid::optionWidget() -// { -// return 0; -// } - - -#include "kis_tool_perspectivegrid.moc" diff --git a/chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cpp b/chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cpp new file mode 100644 index 00000000..7d5df0f2 --- /dev/null +++ b/chalk/plugins/tools/tool_perspectivegrid/kis_tool_perspectivegrid.cpp @@ -0,0 +1,499 @@ +/* + * kis_tool_perspectivegrid.cpp - part of Chalk + * + * Copyright (c) 2006 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +KisToolPerspectiveGrid::KisToolPerspectiveGrid() + : super(i18n("Perspective Grid")), m_handleSize(13), m_handleHalfSize(6) + +{ + setName("tool_perspectivegrid"); + + m_subject = 0; + m_dragging = false; +} + +KisToolPerspectiveGrid::~KisToolPerspectiveGrid() +{ +} + +void KisToolPerspectiveGrid::activate() +{ + m_subject->perspectiveGridManager()->startEdition(); + if( ! m_subject->currentImg()->perspectiveGrid()->hasSubGrids() ) + { + m_mode = MODE_CREATION; + m_points.clear(); + } else { + m_mode = MODE_EDITING; + drawGrid(); + } + super::activate(); +} + +void KisToolPerspectiveGrid::deactivate() +{ + m_subject->perspectiveGridManager()->stopEdition(); + m_subject->perspectiveGridManager()->setGridVisible( true); + if( m_mode == MODE_CREATION ) + { + drawGridCreation(); + m_points.clear(); + m_dragging = false; + } else { + drawGrid(); + } +} + + +void KisToolPerspectiveGrid::update (KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +bool KisToolPerspectiveGrid::mouseNear(const TQPoint& mousep, const TQPoint point) +{ + return (TQRect( (point.x() - m_handleHalfSize), (point.y() - m_handleHalfSize), m_handleSize, m_handleSize).contains(mousep) ); +} + +void KisToolPerspectiveGrid::buttonPress(KisButtonPressEvent *event) +{ + KisPerspectiveGrid* pGrid = m_subject->currentImg()->perspectiveGrid(); + if(!pGrid->hasSubGrids() && m_mode != MODE_CREATION) + { // it's possible that the perspectiv grid was cleared + m_mode = MODE_CREATION; + m_points.clear(); + } + if( m_mode == MODE_CREATION && event->button() == Qt::LeftButton) + { + m_dragging = true; + + if (m_points.isEmpty()) + { + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.append(m_dragStart); + } else { + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + drawGridCreation(); + } + } else if(m_mode == MODE_EDITING && event->button() == Qt::LeftButton){ + // Look for the handle which was pressed + if (!m_subject) + return; + KisCanvasController *controller = m_subject->canvasController(); + Q_ASSERT(controller); + TQPoint mousep = controller->windowToView( event->pos().roundTQPoint() ); + + for( TQValueList::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) + { + KisSubPerspectiveGrid* grid = *it; + if( mouseNear( mousep, controller->windowToView(grid->topLeft()->roundTQPoint() ) ) ) + { + kdDebug() << " PRESS TOPLEFT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->topLeft(); + break; + } + else if( mouseNear( mousep, controller->windowToView(grid->topRight()->roundTQPoint() ) ) ) + { + kdDebug() << " PRESS TOPRIGHT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->topRight(); + break; + } + else if( mouseNear( mousep, controller->windowToView(grid->bottomLeft()->roundTQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOMLEFT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->bottomLeft(); + break; + } + else if( mouseNear( mousep, controller->windowToView(grid->bottomRight()->roundTQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOMRIGHT HANDLE " << endl; + m_mode = MODE_DRAGING_NODE; + m_selectedNode1 = grid->bottomRight(); + break; + } + else if( !grid->leftGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topLeft() + *grid->bottomLeft() )*0.5) ).roundTQPoint() ) ) + { + kdDebug() << " PRESS LEFT HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->topLeft() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomLeft() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( m_selectedNode1, grid->topLeft() , grid->bottomLeft(), m_selectedNode2); + m_dragEnd = event->pos(); + newsubgrid->setRightGrid( grid); + grid->setLeftGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + else if( !grid->rightGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topRight() + *grid->bottomRight() )*0.5) ).roundTQPoint() ) ) + { + kdDebug() << " PRESS RIGHT HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->topRight() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomRight() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( grid->topRight(), m_selectedNode1, m_selectedNode2, grid->bottomRight()); + m_dragEnd = event->pos(); + newsubgrid->setLeftGrid( grid); + grid->setRightGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + else if( !grid->topGrid() && mouseNear( mousep, controller->windowToView( ((*grid->topLeft() + *grid->topRight() )*0.5) ).roundTQPoint() ) ) + { + kdDebug() << " PRESS TOP HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->topLeft() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->topRight() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( m_selectedNode1, m_selectedNode2, grid->topRight(), grid->topLeft() ); + m_dragEnd = event->pos(); + newsubgrid->setBottomGrid( grid); + grid->setTopGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + else if( !grid->bottomGrid() && mouseNear( mousep, controller->windowToView( ((*grid->bottomLeft() + *grid->bottomRight() )*0.5) ).roundTQPoint() ) ) + { + kdDebug() << " PRESS BOTTOM HANDLE " << endl; + m_mode = MODE_DRAGING_TRANSLATING_TWONODES; + drawGrid(); + m_selectedNode1 = new KisPerspectiveGridNode( *grid->bottomLeft() ); + m_selectedNode2 = new KisPerspectiveGridNode( *grid->bottomRight() ); + KisSubPerspectiveGrid* newsubgrid = new KisSubPerspectiveGrid( grid->bottomLeft(), grid->bottomRight(), m_selectedNode2, m_selectedNode1); + m_dragEnd = event->pos(); + newsubgrid->setTopGrid( grid); + grid->setBottomGrid( newsubgrid); + pGrid->addNewSubGrid( newsubgrid); + drawGrid(); + break; + } + } + } +} + + +void KisToolPerspectiveGrid::move(KisMoveEvent *event) +{ + if( m_mode == MODE_CREATION ) + { + if (m_dragging) { + // erase old lines on canvas + drawGridCreation(); + // get current mouse position + m_dragEnd = event->pos(); + // draw new lines on canvas + drawGridCreation(); + } + } else { + if( m_mode == MODE_DRAGING_NODE) + { + drawGrid(); + m_selectedNode1->setX( event->pos().x() ); + m_selectedNode1->setY( event->pos().y() ); + drawGrid(); + } + if( m_mode == MODE_DRAGING_TRANSLATING_TWONODES) + { + drawGrid(); + KisPoint translate = event->pos() - m_dragEnd; + m_dragEnd = event->pos(); + *m_selectedNode1 += translate;; + *m_selectedNode2 += translate;; + drawGrid(); + } + } +} + +void KisToolPerspectiveGrid::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject) + return; + + if( m_mode == MODE_CREATION ) + { + if (m_dragging && event->button() == Qt::LeftButton) { + m_dragging = false; + m_points.append (m_dragEnd); + if( m_points.size() == 4) + { // wow we have a grid, isn't that cool ? + drawGridCreation(); // Clean + m_subject->currentImg()->perspectiveGrid()->addNewSubGrid( new KisSubPerspectiveGrid( new KisPerspectiveGridNode(m_points[0]), new KisPerspectiveGridNode(m_points[1]), new KisPerspectiveGridNode(m_points[2]), new KisPerspectiveGridNode(m_points[3]) ) ); + drawGrid(); + m_mode = MODE_EDITING; + } + } + } else { + m_mode = MODE_EDITING; + m_selectedNode1 = 0; + m_selectedNode2 = 0; + } + +/* if (m_dragging && event->button() == RightButton) { + + }*/ +} + +void KisToolPerspectiveGrid::paint(KisCanvasPainter& gc) +{ + if( m_mode == MODE_CREATION ) + { + drawGridCreation(gc); + } else { + drawGrid(gc); + } +} + +void KisToolPerspectiveGrid::paint(KisCanvasPainter& gc, const TQRect&) +{ + if( m_mode == MODE_CREATION ) + { + drawGridCreation(gc); + } else { + drawGrid(gc); + } +} + +void KisToolPerspectiveGrid::drawGridCreation() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + drawGridCreation(gc); + } +} + + +void KisToolPerspectiveGrid::drawGridCreation(KisCanvasPainter& gc) +{ + if (!m_subject) + return; + + TQPen pen(TQt::white); + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + + KisCanvasController *controller = m_subject->canvasController(); + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + + if (m_dragging) { + startPos = controller->windowToView(m_dragStart.floorTQPoint()); + endPos = controller->windowToView(m_dragEnd.floorTQPoint()); + gc.drawLine(startPos, endPos); + } else { + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorTQPoint()); + endPos = controller->windowToView(end.floorTQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } +} + +void KisToolPerspectiveGrid::drawSmallRectangle(KisCanvasPainter& gc, TQPoint p) +{ + gc.drawRect( p.x() - m_handleHalfSize - 1, p.y() - m_handleHalfSize - 1, m_handleSize, m_handleSize); +} + +void KisToolPerspectiveGrid::drawGrid(KisCanvasPainter& gc) +{ + + if (!m_subject) + return; + + KisCanvasController *controller = m_subject->canvasController(); + + TQPen pen(TQt::white); + TQPoint startPos; + TQPoint endPos; + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + KisPerspectiveGrid* pGrid = m_subject->currentImg()->perspectiveGrid(); + + for( TQValueList::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) + { + KisSubPerspectiveGrid* grid = *it; + int index = grid->index(); + bool drawLeft = !(grid->leftGrid() && (index > grid->leftGrid()->index() ) ); + bool drawRight = !(grid->rightGrid() && (index > grid->rightGrid()->index() ) ); + bool drawTop = !(grid->topGrid() && (index > grid->topGrid()->index() ) ); + bool drawBottom = !(grid->bottomGrid() && (index > grid->bottomGrid()->index() ) ); + if(drawTop) { + startPos = controller->windowToView(grid->topLeft()->roundTQPoint()); + endPos = controller->windowToView(grid->topRight()->roundTQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->topGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + if(drawLeft) { + drawSmallRectangle(gc, startPos); + } + if(drawRight) { + drawSmallRectangle(gc, endPos); + } + } + if(drawRight) { + startPos = controller->windowToView(grid->topRight()->roundTQPoint()); + endPos = controller->windowToView(grid->bottomRight()->roundTQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->rightGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + } + if(drawBottom) { + startPos = controller->windowToView(grid->bottomRight()->roundTQPoint()); + endPos = controller->windowToView(grid->bottomLeft()->roundTQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->bottomGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + if(drawLeft) { + drawSmallRectangle(gc, endPos); + } + if(drawRight) { + drawSmallRectangle(gc, startPos); + } + } + if(drawLeft) { + startPos = controller->windowToView(grid->bottomLeft()->roundTQPoint()); + endPos = controller->windowToView(grid->topLeft()->roundTQPoint()); + gc.drawLine( startPos, endPos ); + if( !grid->leftGrid() ) + { + drawSmallRectangle(gc, (endPos + startPos) / 2); + } + } + KisPoint tbVpf = grid->topBottomVanishingPoint(); + if( fabs(tbVpf.x()) < 30000000. && fabs(tbVpf.y()) < 30000000.) + { + TQPoint tbVp = controller->windowToView(tbVpf.roundTQPoint()); + gc.drawLine( tbVp.x() - m_handleHalfSize, tbVp.y() - m_handleHalfSize, tbVp.x() + m_handleHalfSize, tbVp.y() + m_handleHalfSize); + gc.drawLine( tbVp.x() - m_handleHalfSize, tbVp.y() + m_handleHalfSize, tbVp.x() + m_handleHalfSize, tbVp.y() - m_handleHalfSize); + } + KisPoint lrVpf = grid->leftRightVanishingPoint(); + if( fabs(lrVpf.x()) < 30000000. && fabs(lrVpf.y()) < 30000000.) + { // Don't display it, if it is too far, or you get funny results + TQPoint lrVp = controller->windowToView(lrVpf.roundTQPoint()); + gc.drawLine( lrVp.x() - m_handleHalfSize, lrVp.y() - m_handleHalfSize, lrVp.x() + m_handleHalfSize, lrVp.y() + m_handleHalfSize); + gc.drawLine( lrVp.x() - m_handleHalfSize, lrVp.y() + m_handleHalfSize, lrVp.x() + m_handleHalfSize, lrVp.y() - m_handleHalfSize); + } + } +} + +void KisToolPerspectiveGrid::drawGrid() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + drawGrid(gc); + } + +} + + +void KisToolPerspectiveGrid::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Perspective Grid"), + "tool_perspectivegrid" , + 0, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setExclusiveGroup("tools"); + m_action->setToolTip(i18n("Edit the perspective grid")); + m_ownAction = true; + } +} + + +// TQWidget* KisToolPerspectiveGrid::createOptionWidget(TQWidget* parent) +// { +// return 0; +// } +// +// TQWidget* KisToolPerspectiveGrid::optionWidget() +// { +// return 0; +// } + + +#include "kis_tool_perspectivegrid.moc" diff --git a/chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc b/chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc deleted file mode 100644 index f2800a59..00000000 --- a/chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * tool_perspectivegrid.cc -- Part of Chalk - * - * Copyright (c) 2006 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "tool_perspectivegrid.h" -#include "kis_tool_perspectivegrid.h" - - -typedef KGenericFactory ToolPerspectiveGridFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolperspectivegrid, ToolPerspectiveGridFactory( "chalk" ) ) - - -ToolPerspectiveGrid::ToolPerspectiveGrid(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolPerspectiveGridFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast(parent); - r->add(new KisToolPerspectiveGridFactory()); - } - -} - -ToolPerspectiveGrid::~ToolPerspectiveGrid() -{ -} - -#include "tool_perspectivegrid.moc" diff --git a/chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cpp b/chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cpp new file mode 100644 index 00000000..2f326965 --- /dev/null +++ b/chalk/plugins/tools/tool_perspectivegrid/tool_perspectivegrid.cpp @@ -0,0 +1,62 @@ +/* + * tool_perspectivegrid.cpp -- Part of Chalk + * + * Copyright (c) 2006 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "tool_perspectivegrid.h" +#include "kis_tool_perspectivegrid.h" + + +typedef KGenericFactory ToolPerspectiveGridFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolperspectivegrid, ToolPerspectiveGridFactory( "chalk" ) ) + + +ToolPerspectiveGrid::ToolPerspectiveGrid(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolPerspectiveGridFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(parent); + r->add(new KisToolPerspectiveGridFactory()); + } + +} + +ToolPerspectiveGrid::~ToolPerspectiveGrid() +{ +} + +#include "tool_perspectivegrid.moc" diff --git a/chalk/plugins/tools/tool_perspectivetransform/Makefile.am b/chalk/plugins/tools/tool_perspectivetransform/Makefile.am index 08c8d707..275f6413 100644 --- a/chalk/plugins/tools/tool_perspectivetransform/Makefile.am +++ b/chalk/plugins/tools/tool_perspectivetransform/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalktoolperspectivetransform_la_SOURCES = \ - tool_perspectivetransform.cc \ - kis_tool_perspectivetransform.cc + tool_perspectivetransform.cpp \ + kis_tool_perspectivetransform.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolperspectivetransform.la diff --git a/chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cc b/chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cc deleted file mode 100644 index ae334e62..00000000 --- a/chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cc +++ /dev/null @@ -1,742 +0,0 @@ -/* - * kis_tool_transform.cc -- part of Chalk - * - * Copyright (c) 2006 Cyrille Berger - * - * Based on the transform tool from : - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2005 Casper Boemann - * - * 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; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kis_tool_perspectivetransform.h" - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include "wdg_tool_transform.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" - -namespace { - class PerspectiveTransformCmd : public KisSelectedTransaction { - typedef KisSelectedTransaction super; - - public: - PerspectiveTransformCmd(KisToolPerspectiveTransform *tool, KisPaintDeviceSP device, KisPaintDeviceSP origDevice, KisPoint topleft, KisPoint topright, KisPoint bottomleft, KisPoint bottomright, KisSelectionSP origSel, TQRect initialRect); - virtual ~PerspectiveTransformCmd(); - - public: - virtual void execute(); - virtual void unexecute(); - void transformArgs(KisPoint &topleft, KisPoint &topright, KisPoint &bottomleft, KisPoint& bottomright) const; - KisSelectionSP origSelection(TQRect& initialRect) const; - KisPaintDeviceSP theDevice(); - KisPaintDeviceSP origDevice(); - - private: - TQRect m_initialRect; - KisPoint m_topleft, m_topright, m_bottomleft, m_bottomright; - KisToolPerspectiveTransform *m_tool; - KisSelectionSP m_origSelection; - KisPaintDeviceSP m_device; - KisPaintDeviceSP m_origDevice; - }; - - PerspectiveTransformCmd::PerspectiveTransformCmd(KisToolPerspectiveTransform *tool, KisPaintDeviceSP device, KisPaintDeviceSP origDevice, KisPoint topleft, KisPoint topright, KisPoint bottomleft, KisPoint bottomright, KisSelectionSP origSel, TQRect initialRect) : - super(i18n("Perspective Transform"), device), m_initialRect(initialRect) - , m_topleft(topleft), m_topright(topright), m_bottomleft(bottomleft), m_bottomright(bottomright) - , m_tool(tool), m_origSelection(origSel), m_device(device), m_origDevice(origDevice) - { - } - - PerspectiveTransformCmd::~PerspectiveTransformCmd() - { - } - - void PerspectiveTransformCmd::transformArgs(KisPoint &topleft, KisPoint &topright, KisPoint &bottomleft, KisPoint& bottomright) const - { - topleft = m_topleft; - topright = m_topright; - bottomleft = m_bottomleft; - bottomright = m_bottomright; - } - - KisSelectionSP PerspectiveTransformCmd::origSelection(TQRect& initialRect) const - { - initialRect = m_initialRect; - return m_origSelection; - } - - void PerspectiveTransformCmd::execute() - { - super::execute(); - } - - void PerspectiveTransformCmd::unexecute() - { - super::unexecute(); - } - - KisPaintDeviceSP PerspectiveTransformCmd::theDevice() - { - return m_device; - } - - KisPaintDeviceSP PerspectiveTransformCmd::origDevice() - { - return m_origDevice; - } -} - -KisToolPerspectiveTransform::KisToolPerspectiveTransform() - : super(i18n("Perspective Transform")) -{ - setName("tool_perspectivetransform"); - setCursor(KisCursor::selectCursor()); - m_subject = 0; - m_origDevice = 0; - m_origSelection = 0; - m_handleHalfSize = 8; - m_handleSize = 2 * m_handleHalfSize; - m_handleSelected = NOHANDLE; -} - -KisToolPerspectiveTransform::~KisToolPerspectiveTransform() -{ -} - -void KisToolPerspectiveTransform::deactivate() -{ - if (m_subject && m_subject->undoAdapter()) m_subject->undoAdapter()->removeCommandHistoryListener( this ); - - KisImageSP img = m_subject->currentImg(); - if (!img) return; - - paintOutline(); - - disconnect(m_subject->currentImg().data(), TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayerActivated(KisLayerSP))); -} - -void KisToolPerspectiveTransform::activate() -{ - super::activate(); - m_currentSelectedPoint = 0; - if(m_subject && m_subject->currentImg() && m_subject->currentImg()->activeDevice()) - { - //connect(m_subject, commandExecuted(KCommand *c), this, notifyCommandAdded( KCommand * c)); - m_subject->undoAdapter()->setCommandHistoryListener( this ); - -// KisToolControllerInterface *controller = m_subject->toolController(); -// if (controller) -// controller->setCurrentTool(this); - - PerspectiveTransformCmd * cmd=0; - - if(m_subject->currentImg()->undoAdapter()->presentCommand()) - cmd = dynamic_cast(m_subject->currentImg()->undoAdapter()->presentCommand()); - - // One of our commands is on top - if(cmd &&cmd->theDevice() == m_subject->currentImg()->activeDevice()) - { - m_interractionMode = EDITRECTINTERRACTION; - // and it even has the same device - // We should ask for tool args and orig selection - m_origDevice = cmd->origDevice(); - cmd->transformArgs(m_topleft, m_topright, m_bottomleft, m_bottomright); - m_origSelection = cmd->origSelection(m_initialRect); - paintOutline(); - } - else - { - m_interractionMode = DRAWRECTINTERRACTION; - m_points.clear(); - initHandles(); - } - } - connect(m_subject->currentImg(), TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayerActivated(KisLayerSP))); -} - -void KisToolPerspectiveTransform::initHandles() -{ -// TQ_INT32 x,y,w,h; - KisImageSP img = m_subject->currentImg(); - - KisPaintDeviceSP dev = img->activeDevice(); - if (!dev ) return; - - // Create a lazy copy of the current state - m_origDevice = new KisPaintDevice(*dev.data()); - Q_ASSERT(m_origDevice); - - if(dev->hasSelection()) - { - KisSelectionSP sel = dev->selection(); - m_origSelection = new KisSelection(*sel.data()); - m_initialRect = sel->selectedExactRect(); - } - else { - m_initialRect = dev->exactBounds(); - } - m_topleft = KisPoint(m_initialRect.topLeft()); - m_topright = KisPoint(m_initialRect.topRight()); - m_bottomleft = KisPoint(m_initialRect.bottomLeft()); - m_bottomright = KisPoint(m_initialRect.bottomRight()); - - m_subject->canvasController() ->updateCanvas(); -} - -void KisToolPerspectiveTransform::paint(KisCanvasPainter& gc) -{ - paintOutline(gc, TQRect()); -} - -void KisToolPerspectiveTransform::paint(KisCanvasPainter& gc, const TQRect& rc) -{ - paintOutline(gc, rc); -} - -bool KisToolPerspectiveTransform::mouseNear(const TQPoint& mousep, const TQPoint point) -{ - return (TQRect( (point.x() - m_handleHalfSize), (point.y() - m_handleHalfSize), m_handleSize, m_handleSize).contains(mousep) ); -} - -void KisToolPerspectiveTransform::buttonPress(KisButtonPressEvent *event) -{ - if (m_subject) { - switch(m_interractionMode) - { - case DRAWRECTINTERRACTION: - { - if (m_points.isEmpty()) - { - m_dragging = false; - m_dragStart = event->pos(); - m_dragEnd = event->pos(); - m_points.append(m_dragStart); - paintOutline(); - } else { - m_dragging = true; - m_dragStart = m_dragEnd; - m_dragEnd = event->pos(); - paintOutline(); - } - } - case EDITRECTINTERRACTION: - { - KisImageSP img = m_subject->currentImg(); - - if (img && img->activeDevice() && event->button() == Qt::LeftButton) { - m_actualyMoveWhileSelected = false; - m_dragEnd = event->pos(); - KisCanvasController *controller = m_subject->canvasController(); - TQPoint mousep = controller->windowToView( event->pos().roundTQPoint() ); - if( mouseNear( mousep, controller->windowToView(m_topleft.roundTQPoint() ) ) ) - { - kdDebug() << " PRESS TOPLEFT HANDLE " << endl; - m_currentSelectedPoint = &m_topleft; - } - else if( mouseNear( mousep, controller->windowToView(m_topright.roundTQPoint() ) ) ) - { - kdDebug() << " PRESS TOPRIGHT HANDLE " << endl; - m_currentSelectedPoint = &m_topright; - } - else if( mouseNear( mousep, controller->windowToView(m_bottomleft.roundTQPoint() ) ) ) - { - kdDebug() << " PRESS BOTTOMLEFT HANDLE " << endl; - m_currentSelectedPoint = &m_bottomleft; - } - else if( mouseNear( mousep, controller->windowToView(m_bottomright.roundTQPoint() ) ) ) - { - kdDebug() << " PRESS BOTTOMRIGHT HANDLE " << endl; - m_currentSelectedPoint = &m_bottomright; - } else if( mouseNear( mousep, controller->windowToView(KisPoint((m_topleft+m_topright)*0.5).roundTQPoint() ) ) ) - { - kdDebug() << " PRESS TOP HANDLE " << endl; - m_handleSelected = TOPHANDLE; - }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_topleft+m_bottomleft)*0.5).roundTQPoint() ) ) ) - { - kdDebug() << " PRESS LEFT HANDLE " << endl; - m_handleSelected = LEFTHANDLE; - }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_bottomleft+m_bottomright)*0.5).roundTQPoint() ) ) ) - { - kdDebug() << " PRESS BOTTOM HANDLE " << endl; - m_handleSelected = BOTTOMHANDLE; - }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_bottomright+m_topright)*0.5).roundTQPoint() ) ) ) - { - kdDebug() << " PRESS RIGHT HANDLE " << endl; - m_handleSelected = RIGHTHANDLE; - }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_topleft+m_bottomleft + m_bottomright+m_topright)*0.25).roundTQPoint() ) ) ) - { - kdDebug() << " PRESS MIDDLE HANDLE " << endl; - m_handleSelected = MIDDLEHANDLE; - } - } - } - } - } -} - -void KisToolPerspectiveTransform::move(KisMoveEvent *event) -{ - switch(m_interractionMode) - { - case DRAWRECTINTERRACTION: - { - if (m_dragging) { - // erase old lines on canvas - paintOutline(); - // get current mouse position - m_dragEnd = event->pos(); - // draw new lines on canvas - paintOutline(); - } - } - - case EDITRECTINTERRACTION: - { - if(m_currentSelectedPoint) - { - paintOutline(); - KisPoint translate = event->pos() - m_dragEnd; - m_dragEnd = event->pos(); - *m_currentSelectedPoint += translate;; - paintOutline(); - m_actualyMoveWhileSelected = true; - } - else if(m_handleSelected == TOPHANDLE || m_handleSelected == LEFTHANDLE || m_handleSelected == BOTTOMHANDLE || m_handleSelected == RIGHTHANDLE) - { - paintOutline(); - - KisPoint translate = event->pos() - m_dragEnd; - m_dragEnd = event->pos(); - - double matrixFrom[3][3]; - double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(m_topleft, m_topright, m_bottomleft, m_bottomright, m_initialRect); - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 3; j++) - { - matrixFrom[i][j] = b[3*i+j]; - } - } - delete b; - - KisPoint topLeft = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.topLeft()) ); - KisPoint topRight = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.topRight()) ); - KisPoint bottomLeft = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.bottomLeft()) ); - KisPoint bottomRight = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.bottomRight()) ); - TQRect dstRect = m_initialRect; - switch(m_handleSelected) - { - case TOPHANDLE: - dstRect.setTop( static_cast( dstRect.top() + translate.y() ) ) ; - break; - case LEFTHANDLE: - dstRect.setLeft( static_cast( dstRect.left() + translate.x() ) ); - break; - case BOTTOMHANDLE: - dstRect.setBottom( static_cast( dstRect.bottom() + translate.y() ) ); - break; - case RIGHTHANDLE: - dstRect.setRight( static_cast( dstRect.right() + translate.x() ) ); - break; - case MIDDLEHANDLE: - case NOHANDLE: - kdDebug() << "Should NOT happen" << endl; - } - double matrixTo[3][3]; - b = KisPerspectiveMath::computeMatrixTransfoToPerspective(topLeft, topRight, bottomLeft, bottomRight, dstRect ); - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 3; j++) - { - matrixTo[i][j] = b[3*i+j]; - } - } - delete b; - m_topleft = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.topLeft())); - m_topright = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.topRight())); - m_bottomleft = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.bottomLeft())); - m_bottomright = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.bottomRight())); - - paintOutline(); - m_actualyMoveWhileSelected = true; - } else if (m_handleSelected == MIDDLEHANDLE) { - paintOutline(); - KisPoint translate = event->pos() - m_dragEnd; - m_dragEnd = event->pos(); - m_topleft += translate; - m_topright += translate; - m_bottomleft += translate; - m_bottomright += translate; - paintOutline(); - m_actualyMoveWhileSelected = true; - } - } - }; -} - -void KisToolPerspectiveTransform::buttonRelease(KisButtonReleaseEvent * event) -{ - KisImageSP img = m_subject->currentImg(); - - if (!img) - return; - if( event->button() == Qt::LeftButton) - { - switch(m_interractionMode) - { - case DRAWRECTINTERRACTION: - { - if (m_dragging && event->button() == Qt::LeftButton) { - paintOutline(); - m_dragging = false; - m_points.append (m_dragEnd); - if( m_points.size() == 4) - { - // from the points, select which is topleft ? topright ? bottomright ? and bottomleft ? - m_topleft = m_points[0]; - m_topright = m_points[1]; - m_bottomleft = m_points[3]; - m_bottomright = m_points[2]; - double matrix[3][3]; - double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(m_topleft, m_topright, m_bottomleft, m_bottomright, m_initialRect ); - for(int i = 0; i < 3; i++) - { - for(int j = 0; j < 3; j++) - { - kdDebug() << "sol[" << 3*i+j << "]=" << b[3*i+j] << endl; - matrix[i][j] = b[3*i+j]; - } - } - m_topleft = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.topLeft())); - m_topright = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.topRight())); - m_bottomleft = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.bottomLeft())); - m_bottomright = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.bottomRight())); - m_interractionMode = EDITRECTINTERRACTION; - paintOutline(); - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - transform(); - TQApplication::restoreOverrideCursor(); - } else { - paintOutline(); - } - } - } - break; - case EDITRECTINTERRACTION: - { - if(m_currentSelectedPoint ) - { - m_currentSelectedPoint = 0; - if(m_actualyMoveWhileSelected) - { - paintOutline(); - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - transform(); - TQApplication::restoreOverrideCursor(); - } - } - if(m_handleSelected != NOHANDLE) - { - m_handleSelected = NOHANDLE; - if(m_actualyMoveWhileSelected) - { -// paintOutline(); - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - transform(); - TQApplication::restoreOverrideCursor(); - } - } - } - break; - } - } -} - -void KisToolPerspectiveTransform::paintOutline() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - TQRect rc; - - paintOutline(gc, rc); - } -} - -void KisToolPerspectiveTransform::paintOutline(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::SolidLine); - pen.setWidth(1); - Q_ASSERT(controller); - - switch(m_interractionMode) - { - case DRAWRECTINTERRACTION: - { - kdDebug() << "DRAWRECTINTERRACTION paintOutline " << m_points.size() << endl; - KisPoint start, end; - TQPoint startPos; - TQPoint endPos; - for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { - - if (it == m_points.begin()) - { - start = (*it); - } else { - end = (*it); - - startPos = controller->windowToView(start.floorTQPoint()); - endPos = controller->windowToView(end.floorTQPoint()); - - gc.drawLine(startPos, endPos); - - start = end; - } - } - } - break; - case EDITRECTINTERRACTION: - { - TQPoint topleft = controller->windowToView(m_topleft ).roundTQPoint(); - TQPoint topright = controller->windowToView(m_topright).roundTQPoint(); - TQPoint bottomleft = controller->windowToView(m_bottomleft).roundTQPoint(); - TQPoint bottomright = controller->windowToView(m_bottomright).roundTQPoint(); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawRect(topleft.x()-4, topleft.y()-4, 8, 8); - gc.drawLine(topleft.x(), topleft.y(), (topleft.x()+topright.x())/2, (topleft.y()+topright.y())/2); - gc.drawRect((topleft.x()+topright.x())/2-4, (topleft.y()+topright.y())/2-4, 8, 8); - gc.drawLine((topleft.x()+topright.x())/2, (topleft.y()+topright.y())/2, topright.x(), topright.y()); - gc.drawRect(topright.x()-4, topright.y()-4, 8, 8); - gc.drawLine(topright.x(), topright.y(), (topright.x()+bottomright.x())/2, (topright.y()+bottomright.y())/2); - gc.drawRect((topright.x()+bottomright.x())/2-4, (topright.y()+bottomright.y())/2-4, 8, 8); - gc.drawLine((topright.x()+bottomright.x())/2, (topright.y()+bottomright.y())/2,bottomright.x(), bottomright.y()); - gc.drawRect(bottomright.x()-4, bottomright.y()-4, 8, 8); - gc.drawLine(bottomright.x(), bottomright.y(), (bottomleft.x()+bottomright.x())/2, (bottomleft.y()+bottomright.y())/2); - gc.drawRect((bottomleft.x()+bottomright.x())/2-4, (bottomleft.y()+bottomright.y())/2-4, 8, 8); - gc.drawLine((bottomleft.x()+bottomright.x())/2, (bottomleft.y()+bottomright.y())/2, bottomleft.x(), bottomleft.y()); - gc.drawRect(bottomleft.x()-4, bottomleft.y()-4, 8, 8); - gc.drawLine(bottomleft.x(), bottomleft.y(), (topleft.x()+bottomleft.x())/2, (topleft.y()+bottomleft.y())/2); - gc.drawRect((topleft.x()+bottomleft.x())/2-4, (topleft.y()+bottomleft.y())/2-4, 8, 8); - gc.drawLine((topleft.x()+bottomleft.x())/2, (topleft.y()+bottomleft.y())/2, topleft.x(), topleft.y()); - gc.drawRect((bottomleft.x()+bottomright.x()+topleft.x()+topright.x())/4-4, (bottomleft.y()+bottomright.y()+topleft.y()+topright.y())/4-4, 8, 8); - } - break; - } - gc.setRasterOp(op); - gc.setPen(old); - } -} - -void KisToolPerspectiveTransform::transform() -{ - KisImageSP img = m_subject->currentImg(); - - if (!img || !img->activeDevice()) - return; - - KisProgressDisplayInterface *progress = m_subject->progressDisplay(); - - // This mementoes the current state of the active device. - PerspectiveTransformCmd * transaction = new PerspectiveTransformCmd(this, img->activeDevice(), m_origDevice, - m_topleft, m_topright, m_bottomleft, m_bottomright, m_origSelection, m_initialRect); - - // Copy the original state back. - TQRect rc = m_origDevice->extent(); - rc = rc.normalize(); - img->activeDevice()->clear(); - KisPainter gc(img->activeDevice()); - gc.bitBlt(rc.x(), rc.y(), COMPOSITE_COPY, m_origDevice, rc.x(), rc.y(), rc.width(), rc.height()); - gc.end(); - - // Also restore the original selection. - if(m_origSelection) - { - TQRect rc = m_origSelection->selectedRect(); - rc = rc.normalize(); - img->activeDevice()->selection()->clear(); - KisPainter sgc(img->activeDevice()->selection().data()); - sgc.bitBlt(rc.x(), rc.y(), COMPOSITE_COPY, m_origSelection.data(), rc.x(), rc.y(), rc.width(), rc.height()); - sgc.end(); - } - else - if(img->activeDevice()->hasSelection()) - img->activeDevice()->selection()->clear(); - - // Perform the transform. Since we copied the original state back, this doesn't degrade - // after many tweaks. Since we started the transaction before the copy back, the memento - // has the previous state. - KisPerspectiveTransformWorker t(img->activeDevice(),m_topleft, m_topright, m_bottomleft, m_bottomright, progress); - t.run(); - - // If canceled, go back to the memento - if(t.isCanceled()) - { - transaction->unexecute(); - delete transaction; - return; - } - - img->activeDevice()->setDirty(rc); // XXX: This is not enough - should union with new extent - - // Else add the command -- this will have the memento from the previous state, - // and the transformed state from the original device we cached in our activated() - // method. - if (transaction) { - if (img->undo()) - img->undoAdapter()->addCommand(transaction); - else - delete transaction; - } -} - -void KisToolPerspectiveTransform::notifyCommandAdded( KCommand * command) -{ - PerspectiveTransformCmd * cmd = dynamic_cast(command); - if (cmd == 0) { - // The last added command wasn't one of ours; - // we should reset to the new state of the canvas. - // In effect we should treat this as if the tool has been just activated - initHandles(); - } -} - -void KisToolPerspectiveTransform::notifyCommandExecuted( KCommand * command) -{ - Q_UNUSED(command); - PerspectiveTransformCmd * cmd=0; - if(m_subject->currentImg()->undoAdapter()->presentCommand()) - cmd = dynamic_cast(m_subject->currentImg()->undoAdapter()->presentCommand()); - - if (cmd == 0) { - // The command now on the top of the stack isn't one of ours - // We should treat this as if the tool has been just activated - initHandles(); - } - else - { - // One of our commands is now on top - // We should ask for tool args and orig selection - m_origDevice = cmd->origDevice(); - cmd->transformArgs(m_topleft, m_topright, m_bottomleft, m_bottomright); - m_origSelection = cmd->origSelection(m_initialRect); - m_subject->canvasController() ->updateCanvas(); - } -} - -void KisToolPerspectiveTransform::slotLayerActivated(KisLayerSP) -{ - activate(); -} - - -TQWidget* KisToolPerspectiveTransform::createOptionWidget(TQWidget* /*parent*/) -{ -#if 0 - m_optWidget = new WdgToolPerspectiveTransform(parent); - TQ_CHECK_PTR(m_optWidget); - - m_optWidget->cmbFilter->clear(); - m_optWidget->cmbFilter->setIDList(KisFilterStrategyRegistry::instance()->listKeys()); - - m_optWidget->cmbFilter->setCurrentText("Mitchell"); - connect(m_optWidget->cmbFilter, TQT_SIGNAL(activated(const KisID &)), - this, TQT_SLOT(slotSetFilter(const KisID &))); - - KisID filterID = m_optWidget->cmbFilter->currentItem(); - m_filter = KisFilterStrategyRegistry::instance()->get(filterID); - -/* - connect(m_optWidget->intStartX, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setStartX(int))); - connect(m_optWidget->intStartY, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setStartY(int))); - connect(m_optWidget->intEndX, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setEndX(int))); - connect(m_optWidget->intEndY, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setEndY(int))); -*/ - m_optWidget->intStartX->hide(); - m_optWidget->intStartY->hide(); - m_optWidget->intEndX->hide(); - m_optWidget->intEndY->hide(); - m_optWidget->textLabel1->hide(); - m_optWidget->textLabel2->hide(); - m_optWidget->textLabel3->hide(); - m_optWidget->textLabel4->hide(); -#endif - return 0; -} - -TQWidget* KisToolPerspectiveTransform::optionWidget() -{ - return 0; -} - -void KisToolPerspectiveTransform::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - m_action = new TDERadioAction(i18n("&Perspective Transform"), - "tool_perspectivetransform", - 0, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - m_action->setToolTip(i18n("Perspective transform a layer or a selection")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -#include "kis_tool_perspectivetransform.moc" diff --git a/chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cpp b/chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cpp new file mode 100644 index 00000000..e73f5da3 --- /dev/null +++ b/chalk/plugins/tools/tool_perspectivetransform/kis_tool_perspectivetransform.cpp @@ -0,0 +1,742 @@ +/* + * kis_tool_transform.cpp -- part of Chalk + * + * Copyright (c) 2006 Cyrille Berger + * + * Based on the transform tool from : + * Copyright (c) 2004 Boudewijn Rempt + * Copyright (c) 2005 Casper Boemann + * + * 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; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_tool_perspectivetransform.h" + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "wdg_tool_transform.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +namespace { + class PerspectiveTransformCmd : public KisSelectedTransaction { + typedef KisSelectedTransaction super; + + public: + PerspectiveTransformCmd(KisToolPerspectiveTransform *tool, KisPaintDeviceSP device, KisPaintDeviceSP origDevice, KisPoint topleft, KisPoint topright, KisPoint bottomleft, KisPoint bottomright, KisSelectionSP origSel, TQRect initialRect); + virtual ~PerspectiveTransformCmd(); + + public: + virtual void execute(); + virtual void unexecute(); + void transformArgs(KisPoint &topleft, KisPoint &topright, KisPoint &bottomleft, KisPoint& bottomright) const; + KisSelectionSP origSelection(TQRect& initialRect) const; + KisPaintDeviceSP theDevice(); + KisPaintDeviceSP origDevice(); + + private: + TQRect m_initialRect; + KisPoint m_topleft, m_topright, m_bottomleft, m_bottomright; + KisToolPerspectiveTransform *m_tool; + KisSelectionSP m_origSelection; + KisPaintDeviceSP m_device; + KisPaintDeviceSP m_origDevice; + }; + + PerspectiveTransformCmd::PerspectiveTransformCmd(KisToolPerspectiveTransform *tool, KisPaintDeviceSP device, KisPaintDeviceSP origDevice, KisPoint topleft, KisPoint topright, KisPoint bottomleft, KisPoint bottomright, KisSelectionSP origSel, TQRect initialRect) : + super(i18n("Perspective Transform"), device), m_initialRect(initialRect) + , m_topleft(topleft), m_topright(topright), m_bottomleft(bottomleft), m_bottomright(bottomright) + , m_tool(tool), m_origSelection(origSel), m_device(device), m_origDevice(origDevice) + { + } + + PerspectiveTransformCmd::~PerspectiveTransformCmd() + { + } + + void PerspectiveTransformCmd::transformArgs(KisPoint &topleft, KisPoint &topright, KisPoint &bottomleft, KisPoint& bottomright) const + { + topleft = m_topleft; + topright = m_topright; + bottomleft = m_bottomleft; + bottomright = m_bottomright; + } + + KisSelectionSP PerspectiveTransformCmd::origSelection(TQRect& initialRect) const + { + initialRect = m_initialRect; + return m_origSelection; + } + + void PerspectiveTransformCmd::execute() + { + super::execute(); + } + + void PerspectiveTransformCmd::unexecute() + { + super::unexecute(); + } + + KisPaintDeviceSP PerspectiveTransformCmd::theDevice() + { + return m_device; + } + + KisPaintDeviceSP PerspectiveTransformCmd::origDevice() + { + return m_origDevice; + } +} + +KisToolPerspectiveTransform::KisToolPerspectiveTransform() + : super(i18n("Perspective Transform")) +{ + setName("tool_perspectivetransform"); + setCursor(KisCursor::selectCursor()); + m_subject = 0; + m_origDevice = 0; + m_origSelection = 0; + m_handleHalfSize = 8; + m_handleSize = 2 * m_handleHalfSize; + m_handleSelected = NOHANDLE; +} + +KisToolPerspectiveTransform::~KisToolPerspectiveTransform() +{ +} + +void KisToolPerspectiveTransform::deactivate() +{ + if (m_subject && m_subject->undoAdapter()) m_subject->undoAdapter()->removeCommandHistoryListener( this ); + + KisImageSP img = m_subject->currentImg(); + if (!img) return; + + paintOutline(); + + disconnect(m_subject->currentImg().data(), TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayerActivated(KisLayerSP))); +} + +void KisToolPerspectiveTransform::activate() +{ + super::activate(); + m_currentSelectedPoint = 0; + if(m_subject && m_subject->currentImg() && m_subject->currentImg()->activeDevice()) + { + //connect(m_subject, commandExecuted(KCommand *c), this, notifyCommandAdded( KCommand * c)); + m_subject->undoAdapter()->setCommandHistoryListener( this ); + +// KisToolControllerInterface *controller = m_subject->toolController(); +// if (controller) +// controller->setCurrentTool(this); + + PerspectiveTransformCmd * cmd=0; + + if(m_subject->currentImg()->undoAdapter()->presentCommand()) + cmd = dynamic_cast(m_subject->currentImg()->undoAdapter()->presentCommand()); + + // One of our commands is on top + if(cmd &&cmd->theDevice() == m_subject->currentImg()->activeDevice()) + { + m_interractionMode = EDITRECTINTERRACTION; + // and it even has the same device + // We should ask for tool args and orig selection + m_origDevice = cmd->origDevice(); + cmd->transformArgs(m_topleft, m_topright, m_bottomleft, m_bottomright); + m_origSelection = cmd->origSelection(m_initialRect); + paintOutline(); + } + else + { + m_interractionMode = DRAWRECTINTERRACTION; + m_points.clear(); + initHandles(); + } + } + connect(m_subject->currentImg(), TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayerActivated(KisLayerSP))); +} + +void KisToolPerspectiveTransform::initHandles() +{ +// TQ_INT32 x,y,w,h; + KisImageSP img = m_subject->currentImg(); + + KisPaintDeviceSP dev = img->activeDevice(); + if (!dev ) return; + + // Create a lazy copy of the current state + m_origDevice = new KisPaintDevice(*dev.data()); + Q_ASSERT(m_origDevice); + + if(dev->hasSelection()) + { + KisSelectionSP sel = dev->selection(); + m_origSelection = new KisSelection(*sel.data()); + m_initialRect = sel->selectedExactRect(); + } + else { + m_initialRect = dev->exactBounds(); + } + m_topleft = KisPoint(m_initialRect.topLeft()); + m_topright = KisPoint(m_initialRect.topRight()); + m_bottomleft = KisPoint(m_initialRect.bottomLeft()); + m_bottomright = KisPoint(m_initialRect.bottomRight()); + + m_subject->canvasController() ->updateCanvas(); +} + +void KisToolPerspectiveTransform::paint(KisCanvasPainter& gc) +{ + paintOutline(gc, TQRect()); +} + +void KisToolPerspectiveTransform::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + paintOutline(gc, rc); +} + +bool KisToolPerspectiveTransform::mouseNear(const TQPoint& mousep, const TQPoint point) +{ + return (TQRect( (point.x() - m_handleHalfSize), (point.y() - m_handleHalfSize), m_handleSize, m_handleSize).contains(mousep) ); +} + +void KisToolPerspectiveTransform::buttonPress(KisButtonPressEvent *event) +{ + if (m_subject) { + switch(m_interractionMode) + { + case DRAWRECTINTERRACTION: + { + if (m_points.isEmpty()) + { + m_dragging = false; + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.append(m_dragStart); + paintOutline(); + } else { + m_dragging = true; + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + paintOutline(); + } + } + case EDITRECTINTERRACTION: + { + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice() && event->button() == Qt::LeftButton) { + m_actualyMoveWhileSelected = false; + m_dragEnd = event->pos(); + KisCanvasController *controller = m_subject->canvasController(); + TQPoint mousep = controller->windowToView( event->pos().roundTQPoint() ); + if( mouseNear( mousep, controller->windowToView(m_topleft.roundTQPoint() ) ) ) + { + kdDebug() << " PRESS TOPLEFT HANDLE " << endl; + m_currentSelectedPoint = &m_topleft; + } + else if( mouseNear( mousep, controller->windowToView(m_topright.roundTQPoint() ) ) ) + { + kdDebug() << " PRESS TOPRIGHT HANDLE " << endl; + m_currentSelectedPoint = &m_topright; + } + else if( mouseNear( mousep, controller->windowToView(m_bottomleft.roundTQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOMLEFT HANDLE " << endl; + m_currentSelectedPoint = &m_bottomleft; + } + else if( mouseNear( mousep, controller->windowToView(m_bottomright.roundTQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOMRIGHT HANDLE " << endl; + m_currentSelectedPoint = &m_bottomright; + } else if( mouseNear( mousep, controller->windowToView(KisPoint((m_topleft+m_topright)*0.5).roundTQPoint() ) ) ) + { + kdDebug() << " PRESS TOP HANDLE " << endl; + m_handleSelected = TOPHANDLE; + }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_topleft+m_bottomleft)*0.5).roundTQPoint() ) ) ) + { + kdDebug() << " PRESS LEFT HANDLE " << endl; + m_handleSelected = LEFTHANDLE; + }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_bottomleft+m_bottomright)*0.5).roundTQPoint() ) ) ) + { + kdDebug() << " PRESS BOTTOM HANDLE " << endl; + m_handleSelected = BOTTOMHANDLE; + }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_bottomright+m_topright)*0.5).roundTQPoint() ) ) ) + { + kdDebug() << " PRESS RIGHT HANDLE " << endl; + m_handleSelected = RIGHTHANDLE; + }else if( mouseNear( mousep, controller->windowToView(KisPoint((m_topleft+m_bottomleft + m_bottomright+m_topright)*0.25).roundTQPoint() ) ) ) + { + kdDebug() << " PRESS MIDDLE HANDLE " << endl; + m_handleSelected = MIDDLEHANDLE; + } + } + } + } + } +} + +void KisToolPerspectiveTransform::move(KisMoveEvent *event) +{ + switch(m_interractionMode) + { + case DRAWRECTINTERRACTION: + { + if (m_dragging) { + // erase old lines on canvas + paintOutline(); + // get current mouse position + m_dragEnd = event->pos(); + // draw new lines on canvas + paintOutline(); + } + } + + case EDITRECTINTERRACTION: + { + if(m_currentSelectedPoint) + { + paintOutline(); + KisPoint translate = event->pos() - m_dragEnd; + m_dragEnd = event->pos(); + *m_currentSelectedPoint += translate;; + paintOutline(); + m_actualyMoveWhileSelected = true; + } + else if(m_handleSelected == TOPHANDLE || m_handleSelected == LEFTHANDLE || m_handleSelected == BOTTOMHANDLE || m_handleSelected == RIGHTHANDLE) + { + paintOutline(); + + KisPoint translate = event->pos() - m_dragEnd; + m_dragEnd = event->pos(); + + double matrixFrom[3][3]; + double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(m_topleft, m_topright, m_bottomleft, m_bottomright, m_initialRect); + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 3; j++) + { + matrixFrom[i][j] = b[3*i+j]; + } + } + delete b; + + KisPoint topLeft = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.topLeft()) ); + KisPoint topRight = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.topRight()) ); + KisPoint bottomLeft = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.bottomLeft()) ); + KisPoint bottomRight = KisPerspectiveMath::matProd(matrixFrom, KisPoint(m_initialRect.bottomRight()) ); + TQRect dstRect = m_initialRect; + switch(m_handleSelected) + { + case TOPHANDLE: + dstRect.setTop( static_cast( dstRect.top() + translate.y() ) ) ; + break; + case LEFTHANDLE: + dstRect.setLeft( static_cast( dstRect.left() + translate.x() ) ); + break; + case BOTTOMHANDLE: + dstRect.setBottom( static_cast( dstRect.bottom() + translate.y() ) ); + break; + case RIGHTHANDLE: + dstRect.setRight( static_cast( dstRect.right() + translate.x() ) ); + break; + case MIDDLEHANDLE: + case NOHANDLE: + kdDebug() << "Should NOT happen" << endl; + } + double matrixTo[3][3]; + b = KisPerspectiveMath::computeMatrixTransfoToPerspective(topLeft, topRight, bottomLeft, bottomRight, dstRect ); + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 3; j++) + { + matrixTo[i][j] = b[3*i+j]; + } + } + delete b; + m_topleft = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.topLeft())); + m_topright = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.topRight())); + m_bottomleft = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.bottomLeft())); + m_bottomright = KisPerspectiveMath::matProd(matrixTo, KisPoint(m_initialRect.bottomRight())); + + paintOutline(); + m_actualyMoveWhileSelected = true; + } else if (m_handleSelected == MIDDLEHANDLE) { + paintOutline(); + KisPoint translate = event->pos() - m_dragEnd; + m_dragEnd = event->pos(); + m_topleft += translate; + m_topright += translate; + m_bottomleft += translate; + m_bottomright += translate; + paintOutline(); + m_actualyMoveWhileSelected = true; + } + } + }; +} + +void KisToolPerspectiveTransform::buttonRelease(KisButtonReleaseEvent * event) +{ + KisImageSP img = m_subject->currentImg(); + + if (!img) + return; + if( event->button() == Qt::LeftButton) + { + switch(m_interractionMode) + { + case DRAWRECTINTERRACTION: + { + if (m_dragging && event->button() == Qt::LeftButton) { + paintOutline(); + m_dragging = false; + m_points.append (m_dragEnd); + if( m_points.size() == 4) + { + // from the points, select which is topleft ? topright ? bottomright ? and bottomleft ? + m_topleft = m_points[0]; + m_topright = m_points[1]; + m_bottomleft = m_points[3]; + m_bottomright = m_points[2]; + double matrix[3][3]; + double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(m_topleft, m_topright, m_bottomleft, m_bottomright, m_initialRect ); + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 3; j++) + { + kdDebug() << "sol[" << 3*i+j << "]=" << b[3*i+j] << endl; + matrix[i][j] = b[3*i+j]; + } + } + m_topleft = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.topLeft())); + m_topright = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.topRight())); + m_bottomleft = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.bottomLeft())); + m_bottomright = KisPerspectiveMath::matProd(matrix, KisPoint(m_initialRect.bottomRight())); + m_interractionMode = EDITRECTINTERRACTION; + paintOutline(); + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + transform(); + TQApplication::restoreOverrideCursor(); + } else { + paintOutline(); + } + } + } + break; + case EDITRECTINTERRACTION: + { + if(m_currentSelectedPoint ) + { + m_currentSelectedPoint = 0; + if(m_actualyMoveWhileSelected) + { + paintOutline(); + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + transform(); + TQApplication::restoreOverrideCursor(); + } + } + if(m_handleSelected != NOHANDLE) + { + m_handleSelected = NOHANDLE; + if(m_actualyMoveWhileSelected) + { +// paintOutline(); + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + transform(); + TQApplication::restoreOverrideCursor(); + } + } + } + break; + } + } +} + +void KisToolPerspectiveTransform::paintOutline() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintOutline(gc, rc); + } +} + +void KisToolPerspectiveTransform::paintOutline(KisCanvasPainter& gc, const TQRect&) +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + RasterOp op = gc.rasterOp(); + TQPen old = gc.pen(); + TQPen pen(TQt::SolidLine); + pen.setWidth(1); + Q_ASSERT(controller); + + switch(m_interractionMode) + { + case DRAWRECTINTERRACTION: + { + kdDebug() << "DRAWRECTINTERRACTION paintOutline " << m_points.size() << endl; + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorTQPoint()); + endPos = controller->windowToView(end.floorTQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } + break; + case EDITRECTINTERRACTION: + { + TQPoint topleft = controller->windowToView(m_topleft ).roundTQPoint(); + TQPoint topright = controller->windowToView(m_topright).roundTQPoint(); + TQPoint bottomleft = controller->windowToView(m_bottomleft).roundTQPoint(); + TQPoint bottomright = controller->windowToView(m_bottomright).roundTQPoint(); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawRect(topleft.x()-4, topleft.y()-4, 8, 8); + gc.drawLine(topleft.x(), topleft.y(), (topleft.x()+topright.x())/2, (topleft.y()+topright.y())/2); + gc.drawRect((topleft.x()+topright.x())/2-4, (topleft.y()+topright.y())/2-4, 8, 8); + gc.drawLine((topleft.x()+topright.x())/2, (topleft.y()+topright.y())/2, topright.x(), topright.y()); + gc.drawRect(topright.x()-4, topright.y()-4, 8, 8); + gc.drawLine(topright.x(), topright.y(), (topright.x()+bottomright.x())/2, (topright.y()+bottomright.y())/2); + gc.drawRect((topright.x()+bottomright.x())/2-4, (topright.y()+bottomright.y())/2-4, 8, 8); + gc.drawLine((topright.x()+bottomright.x())/2, (topright.y()+bottomright.y())/2,bottomright.x(), bottomright.y()); + gc.drawRect(bottomright.x()-4, bottomright.y()-4, 8, 8); + gc.drawLine(bottomright.x(), bottomright.y(), (bottomleft.x()+bottomright.x())/2, (bottomleft.y()+bottomright.y())/2); + gc.drawRect((bottomleft.x()+bottomright.x())/2-4, (bottomleft.y()+bottomright.y())/2-4, 8, 8); + gc.drawLine((bottomleft.x()+bottomright.x())/2, (bottomleft.y()+bottomright.y())/2, bottomleft.x(), bottomleft.y()); + gc.drawRect(bottomleft.x()-4, bottomleft.y()-4, 8, 8); + gc.drawLine(bottomleft.x(), bottomleft.y(), (topleft.x()+bottomleft.x())/2, (topleft.y()+bottomleft.y())/2); + gc.drawRect((topleft.x()+bottomleft.x())/2-4, (topleft.y()+bottomleft.y())/2-4, 8, 8); + gc.drawLine((topleft.x()+bottomleft.x())/2, (topleft.y()+bottomleft.y())/2, topleft.x(), topleft.y()); + gc.drawRect((bottomleft.x()+bottomright.x()+topleft.x()+topright.x())/4-4, (bottomleft.y()+bottomright.y()+topleft.y()+topright.y())/4-4, 8, 8); + } + break; + } + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolPerspectiveTransform::transform() +{ + KisImageSP img = m_subject->currentImg(); + + if (!img || !img->activeDevice()) + return; + + KisProgressDisplayInterface *progress = m_subject->progressDisplay(); + + // This mementoes the current state of the active device. + PerspectiveTransformCmd * transaction = new PerspectiveTransformCmd(this, img->activeDevice(), m_origDevice, + m_topleft, m_topright, m_bottomleft, m_bottomright, m_origSelection, m_initialRect); + + // Copy the original state back. + TQRect rc = m_origDevice->extent(); + rc = rc.normalize(); + img->activeDevice()->clear(); + KisPainter gc(img->activeDevice()); + gc.bitBlt(rc.x(), rc.y(), COMPOSITE_COPY, m_origDevice, rc.x(), rc.y(), rc.width(), rc.height()); + gc.end(); + + // Also restore the original selection. + if(m_origSelection) + { + TQRect rc = m_origSelection->selectedRect(); + rc = rc.normalize(); + img->activeDevice()->selection()->clear(); + KisPainter sgc(img->activeDevice()->selection().data()); + sgc.bitBlt(rc.x(), rc.y(), COMPOSITE_COPY, m_origSelection.data(), rc.x(), rc.y(), rc.width(), rc.height()); + sgc.end(); + } + else + if(img->activeDevice()->hasSelection()) + img->activeDevice()->selection()->clear(); + + // Perform the transform. Since we copied the original state back, this doesn't degrade + // after many tweaks. Since we started the transaction before the copy back, the memento + // has the previous state. + KisPerspectiveTransformWorker t(img->activeDevice(),m_topleft, m_topright, m_bottomleft, m_bottomright, progress); + t.run(); + + // If canceled, go back to the memento + if(t.isCanceled()) + { + transaction->unexecute(); + delete transaction; + return; + } + + img->activeDevice()->setDirty(rc); // XXX: This is not enough - should union with new extent + + // Else add the command -- this will have the memento from the previous state, + // and the transformed state from the original device we cached in our activated() + // method. + if (transaction) { + if (img->undo()) + img->undoAdapter()->addCommand(transaction); + else + delete transaction; + } +} + +void KisToolPerspectiveTransform::notifyCommandAdded( KCommand * command) +{ + PerspectiveTransformCmd * cmd = dynamic_cast(command); + if (cmd == 0) { + // The last added command wasn't one of ours; + // we should reset to the new state of the canvas. + // In effect we should treat this as if the tool has been just activated + initHandles(); + } +} + +void KisToolPerspectiveTransform::notifyCommandExecuted( KCommand * command) +{ + Q_UNUSED(command); + PerspectiveTransformCmd * cmd=0; + if(m_subject->currentImg()->undoAdapter()->presentCommand()) + cmd = dynamic_cast(m_subject->currentImg()->undoAdapter()->presentCommand()); + + if (cmd == 0) { + // The command now on the top of the stack isn't one of ours + // We should treat this as if the tool has been just activated + initHandles(); + } + else + { + // One of our commands is now on top + // We should ask for tool args and orig selection + m_origDevice = cmd->origDevice(); + cmd->transformArgs(m_topleft, m_topright, m_bottomleft, m_bottomright); + m_origSelection = cmd->origSelection(m_initialRect); + m_subject->canvasController() ->updateCanvas(); + } +} + +void KisToolPerspectiveTransform::slotLayerActivated(KisLayerSP) +{ + activate(); +} + + +TQWidget* KisToolPerspectiveTransform::createOptionWidget(TQWidget* /*parent*/) +{ +#if 0 + m_optWidget = new WdgToolPerspectiveTransform(parent); + TQ_CHECK_PTR(m_optWidget); + + m_optWidget->cmbFilter->clear(); + m_optWidget->cmbFilter->setIDList(KisFilterStrategyRegistry::instance()->listKeys()); + + m_optWidget->cmbFilter->setCurrentText("Mitchell"); + connect(m_optWidget->cmbFilter, TQT_SIGNAL(activated(const KisID &)), + this, TQT_SLOT(slotSetFilter(const KisID &))); + + KisID filterID = m_optWidget->cmbFilter->currentItem(); + m_filter = KisFilterStrategyRegistry::instance()->get(filterID); + +/* + connect(m_optWidget->intStartX, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setStartX(int))); + connect(m_optWidget->intStartY, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setStartY(int))); + connect(m_optWidget->intEndX, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setEndX(int))); + connect(m_optWidget->intEndY, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setEndY(int))); +*/ + m_optWidget->intStartX->hide(); + m_optWidget->intStartY->hide(); + m_optWidget->intEndX->hide(); + m_optWidget->intEndY->hide(); + m_optWidget->textLabel1->hide(); + m_optWidget->textLabel2->hide(); + m_optWidget->textLabel3->hide(); + m_optWidget->textLabel4->hide(); +#endif + return 0; +} + +TQWidget* KisToolPerspectiveTransform::optionWidget() +{ + return 0; +} + +void KisToolPerspectiveTransform::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new TDERadioAction(i18n("&Perspective Transform"), + "tool_perspectivetransform", + 0, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Perspective transform a layer or a selection")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_perspectivetransform.moc" diff --git a/chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cc b/chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cc deleted file mode 100644 index 0c4023cc..00000000 --- a/chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * tool_perspectivetransform.cc -- Part of Chalk - * - * Copyright (c) 2006 Cyrille Berger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "tool_perspectivetransform.h" -#include "kis_tool_perspectivetransform.h" - - -typedef KGenericFactory ToolPerspectiveTransformFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolperspectivetransform, ToolPerspectiveTransformFactory( "chalk" ) ) - - -ToolPerspectiveTransform::ToolPerspectiveTransform(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolPerspectiveTransformFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - kdDebug() << " add perspective transform tool to the registry" << endl; - KisToolRegistry * r = dynamic_cast(parent); - r->add(new KisToolPerspectiveTransformFactory()); - } - -} - -ToolPerspectiveTransform::~ToolPerspectiveTransform() -{ -} - -#include "tool_perspectivetransform.moc" diff --git a/chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cpp b/chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cpp new file mode 100644 index 00000000..73705264 --- /dev/null +++ b/chalk/plugins/tools/tool_perspectivetransform/tool_perspectivetransform.cpp @@ -0,0 +1,63 @@ +/* + * tool_perspectivetransform.cpp -- Part of Chalk + * + * Copyright (c) 2006 Cyrille Berger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "tool_perspectivetransform.h" +#include "kis_tool_perspectivetransform.h" + + +typedef KGenericFactory ToolPerspectiveTransformFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolperspectivetransform, ToolPerspectiveTransformFactory( "chalk" ) ) + + +ToolPerspectiveTransform::ToolPerspectiveTransform(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolPerspectiveTransformFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + kdDebug() << " add perspective transform tool to the registry" << endl; + KisToolRegistry * r = dynamic_cast(parent); + r->add(new KisToolPerspectiveTransformFactory()); + } + +} + +ToolPerspectiveTransform::~ToolPerspectiveTransform() +{ +} + +#include "tool_perspectivetransform.moc" diff --git a/chalk/plugins/tools/tool_polygon/Makefile.am b/chalk/plugins/tools/tool_polygon/Makefile.am index 555f59a0..4ad417da 100644 --- a/chalk/plugins/tools/tool_polygon/Makefile.am +++ b/chalk/plugins/tools/tool_polygon/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalktoolpolygon_la_SOURCES = \ - tool_polygon.cc \ - kis_tool_polygon.cc + tool_polygon.cpp \ + kis_tool_polygon.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolpolygon.la diff --git a/chalk/plugins/tools/tool_polygon/kis_tool_polygon.cc b/chalk/plugins/tools/tool_polygon/kis_tool_polygon.cc deleted file mode 100644 index a7371e49..00000000 --- a/chalk/plugins/tools/tool_polygon/kis_tool_polygon.cc +++ /dev/null @@ -1,252 +0,0 @@ -/* - * kis_tool_polygon.cc -- part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_doc.h" -#include "kis_view.h" -#include "kis_painter.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop_registry.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" - -#include "kis_tool_polygon.h" - -KisToolPolygon::KisToolPolygon() - : super(i18n ("Polygon")), - m_dragging (false), - m_currentImage (0) -{ - setName("tool_polygon"); - setCursor(KisCursor::load("tool_polygon_cursor.png", 6, 6)); -} - -KisToolPolygon::~KisToolPolygon() -{ -} - -void KisToolPolygon::update (KisCanvasSubject *subject) -{ - super::update (subject); - if (m_subject) - m_currentImage = m_subject->currentImg (); -} - -void KisToolPolygon::buttonPress(KisButtonPressEvent *event) -{ - if (m_currentImage) { - if (event->button() == Qt::LeftButton && event->state() != ShiftButton) { - - m_dragging = true; - - if (m_points.isEmpty()) - { - m_dragStart = event->pos(); - m_dragEnd = event->pos(); - m_points.append(m_dragStart); - } else { - m_dragStart = m_dragEnd; - m_dragEnd = event->pos(); - draw(); - } - } else if (event->button() == Qt::LeftButton && event->state() == ShiftButton) { - finish(); - } - } -} - -void KisToolPolygon::finish() -{ - // erase old lines on canvas - draw(); - m_dragging = false; - - KisPaintDeviceSP device = m_currentImage->activeDevice (); - if (!device) return; - - KisPainter painter (device); - if (m_currentImage->undo()) painter.beginTransaction (i18n ("Polygon")); - - painter.setPaintColor(m_subject->fgColor()); - painter.setBackgroundColor(m_subject->bgColor()); - painter.setFillStyle(fillStyle()); - painter.setBrush(m_subject->currentBrush()); - painter.setPattern(m_subject->currentPattern()); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); - painter.setPaintOp(op); // Painter takes ownership - - painter.paintPolygon(m_points); - - m_points.clear(); - - device->setDirty( painter.dirtyRect() ); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); - } -} - -void KisToolPolygon::doubleClick( KisDoubleClickEvent * ) -{ - finish(); -} - -void KisToolPolygon::move(KisMoveEvent *event) -{ - if (m_dragging) { - // erase old lines on canvas - draw(); - // get current mouse position - m_dragEnd = event->pos(); - // draw new lines on canvas - draw(); - } -} - -void KisToolPolygon::buttonRelease(KisButtonReleaseEvent *event) -{ - if (!m_subject || !m_currentImage) - return; - - if (m_dragging && event->button() == Qt::LeftButton) { - m_dragging = false; - m_points.append (m_dragEnd); - } - - if (m_dragging && event->button() == Qt::RightButton) { - - } -} - -void KisToolPolygon::paint(KisCanvasPainter& gc) -{ - draw(gc); -} - -void KisToolPolygon::paint(KisCanvasPainter& gc, const TQRect&) -{ - draw(gc); -} - -void KisToolPolygon::draw() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - - draw(gc); - } -} - -void KisToolPolygon::draw(KisCanvasPainter& gc) -{ - if (!m_subject || !m_currentImage) - return; - - TQPen pen(TQt::white, 0, TQt::SolidLine); - - gc.setPen(pen); - gc.setRasterOp(TQt::XorROP); - - KisCanvasController *controller = m_subject->canvasController(); - KisPoint start, end; - TQPoint startPos; - TQPoint endPos; - - if (m_dragging) { - startPos = controller->windowToView(m_dragStart.floorTQPoint()); - endPos = controller->windowToView(m_dragEnd.floorTQPoint()); - gc.drawLine(startPos, endPos); - } else { - for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { - - if (it == m_points.begin()) - { - start = (*it); - } else { - end = (*it); - - startPos = controller->windowToView(start.floorTQPoint()); - endPos = controller->windowToView(end.floorTQPoint()); - - gc.drawLine(startPos, endPos); - - start = end; - } - } - } -} - - - -void KisToolPolygon::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("&Polygon"), - "tool_polygon", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Draw a polygon. Shift-mouseclick ends the polygon.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -void KisToolPolygon::keyPress(TQKeyEvent *e) -{ - if (e->key()==TQt::Key_Escape) { - // erase old lines on canvas - draw(); - m_dragging = false; - m_points.clear(); - } -} - - -#include "kis_tool_polygon.moc" diff --git a/chalk/plugins/tools/tool_polygon/kis_tool_polygon.cpp b/chalk/plugins/tools/tool_polygon/kis_tool_polygon.cpp new file mode 100644 index 00000000..601fc690 --- /dev/null +++ b/chalk/plugins/tools/tool_polygon/kis_tool_polygon.cpp @@ -0,0 +1,252 @@ +/* + * kis_tool_polygon.cpp -- part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_doc.h" +#include "kis_view.h" +#include "kis_painter.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop_registry.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" + +#include "kis_tool_polygon.h" + +KisToolPolygon::KisToolPolygon() + : super(i18n ("Polygon")), + m_dragging (false), + m_currentImage (0) +{ + setName("tool_polygon"); + setCursor(KisCursor::load("tool_polygon_cursor.png", 6, 6)); +} + +KisToolPolygon::~KisToolPolygon() +{ +} + +void KisToolPolygon::update (KisCanvasSubject *subject) +{ + super::update (subject); + if (m_subject) + m_currentImage = m_subject->currentImg (); +} + +void KisToolPolygon::buttonPress(KisButtonPressEvent *event) +{ + if (m_currentImage) { + if (event->button() == Qt::LeftButton && event->state() != ShiftButton) { + + m_dragging = true; + + if (m_points.isEmpty()) + { + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.append(m_dragStart); + } else { + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + draw(); + } + } else if (event->button() == Qt::LeftButton && event->state() == ShiftButton) { + finish(); + } + } +} + +void KisToolPolygon::finish() +{ + // erase old lines on canvas + draw(); + m_dragging = false; + + KisPaintDeviceSP device = m_currentImage->activeDevice (); + if (!device) return; + + KisPainter painter (device); + if (m_currentImage->undo()) painter.beginTransaction (i18n ("Polygon")); + + painter.setPaintColor(m_subject->fgColor()); + painter.setBackgroundColor(m_subject->bgColor()); + painter.setFillStyle(fillStyle()); + painter.setBrush(m_subject->currentBrush()); + painter.setPattern(m_subject->currentPattern()); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); + painter.setPaintOp(op); // Painter takes ownership + + painter.paintPolygon(m_points); + + m_points.clear(); + + device->setDirty( painter.dirtyRect() ); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); + } +} + +void KisToolPolygon::doubleClick( KisDoubleClickEvent * ) +{ + finish(); +} + +void KisToolPolygon::move(KisMoveEvent *event) +{ + if (m_dragging) { + // erase old lines on canvas + draw(); + // get current mouse position + m_dragEnd = event->pos(); + // draw new lines on canvas + draw(); + } +} + +void KisToolPolygon::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject || !m_currentImage) + return; + + if (m_dragging && event->button() == Qt::LeftButton) { + m_dragging = false; + m_points.append (m_dragEnd); + } + + if (m_dragging && event->button() == Qt::RightButton) { + + } +} + +void KisToolPolygon::paint(KisCanvasPainter& gc) +{ + draw(gc); +} + +void KisToolPolygon::paint(KisCanvasPainter& gc, const TQRect&) +{ + draw(gc); +} + +void KisToolPolygon::draw() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + draw(gc); + } +} + +void KisToolPolygon::draw(KisCanvasPainter& gc) +{ + if (!m_subject || !m_currentImage) + return; + + TQPen pen(TQt::white, 0, TQt::SolidLine); + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + + KisCanvasController *controller = m_subject->canvasController(); + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + + if (m_dragging) { + startPos = controller->windowToView(m_dragStart.floorTQPoint()); + endPos = controller->windowToView(m_dragEnd.floorTQPoint()); + gc.drawLine(startPos, endPos); + } else { + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorTQPoint()); + endPos = controller->windowToView(end.floorTQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } +} + + + +void KisToolPolygon::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("&Polygon"), + "tool_polygon", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Draw a polygon. Shift-mouseclick ends the polygon.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +void KisToolPolygon::keyPress(TQKeyEvent *e) +{ + if (e->key()==TQt::Key_Escape) { + // erase old lines on canvas + draw(); + m_dragging = false; + m_points.clear(); + } +} + + +#include "kis_tool_polygon.moc" diff --git a/chalk/plugins/tools/tool_polygon/tool_polygon.cc b/chalk/plugins/tools/tool_polygon/tool_polygon.cc deleted file mode 100644 index 626a773d..00000000 --- a/chalk/plugins/tools/tool_polygon/tool_polygon.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * tool_polygon.cc -- Part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "tool_polygon.h" -#include "tool_polygon.moc" -#include "kis_tool_polygon.h" - - -typedef KGenericFactory ToolPolygonFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolpolygon, ToolPolygonFactory( "chalk" ) ) - - -ToolPolygon::ToolPolygon(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolPolygonFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast( parent ); - r->add(new KisToolPolygonFactory()); - } - -} - -ToolPolygon::~ToolPolygon() -{ -} - -//#include "tool_polygon.moc" diff --git a/chalk/plugins/tools/tool_polygon/tool_polygon.cpp b/chalk/plugins/tools/tool_polygon/tool_polygon.cpp new file mode 100644 index 00000000..f903551f --- /dev/null +++ b/chalk/plugins/tools/tool_polygon/tool_polygon.cpp @@ -0,0 +1,62 @@ +/* + * tool_polygon.cpp -- Part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "tool_polygon.h" +#include "tool_polygon.moc" +#include "kis_tool_polygon.h" + + +typedef KGenericFactory ToolPolygonFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolpolygon, ToolPolygonFactory( "chalk" ) ) + + +ToolPolygon::ToolPolygon(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolPolygonFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast( parent ); + r->add(new KisToolPolygonFactory()); + } + +} + +ToolPolygon::~ToolPolygon() +{ +} + +//#include "tool_polygon.moc" diff --git a/chalk/plugins/tools/tool_polyline/Makefile.am b/chalk/plugins/tools/tool_polyline/Makefile.am index 1812b13b..87fa1ce2 100644 --- a/chalk/plugins/tools/tool_polyline/Makefile.am +++ b/chalk/plugins/tools/tool_polyline/Makefile.am @@ -10,8 +10,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalktoolpolyline_la_SOURCES = \ - tool_polyline.cc \ - kis_tool_polyline.cc + tool_polyline.cpp \ + kis_tool_polyline.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolpolyline.la diff --git a/chalk/plugins/tools/tool_polyline/kis_tool_polyline.cc b/chalk/plugins/tools/tool_polyline/kis_tool_polyline.cc deleted file mode 100644 index c99513f4..00000000 --- a/chalk/plugins/tools/tool_polyline/kis_tool_polyline.cc +++ /dev/null @@ -1,271 +0,0 @@ -/* - * kis_tool_polyline.cc -- part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_doc.h" -#include "kis_view.h" -#include "kis_painter.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop_registry.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" - -#include "kis_tool_polyline.h" - -KisToolPolyline::KisToolPolyline() - : super(i18n ("Polyline")), - m_dragging (false), - m_currentImage (0) -{ - setName("tool_polyline"); - setCursor(KisCursor::load("tool_polyline_cursor.png", 6, 6)); -} - -KisToolPolyline::~KisToolPolyline() -{ -} - -void KisToolPolyline::update (KisCanvasSubject *subject) -{ - super::update (subject); - if (m_subject) - m_currentImage = m_subject->currentImg (); -} - -void KisToolPolyline::buttonPress(KisButtonPressEvent *event) -{ - if (m_currentImage) { - if (event->button() == Qt::LeftButton && event->state() != TQt::ShiftButton ) { - - m_dragging = true; - - if (m_points.isEmpty()) - { - m_dragStart = event->pos(); - m_dragEnd = event->pos(); - m_points.append(m_dragStart); - } else { - m_dragStart = m_dragEnd; - m_dragEnd = event->pos(); - draw(); - } - } else if (event->button() == Qt::LeftButton && event->state() == TQt::ShiftButton ) { - finish(); - } - } -} - -void KisToolPolyline::deactivate() -{ - draw(); - m_points.clear(); - m_dragging = false; -} - -void KisToolPolyline::finish() -{ - // erase old lines on canvas - draw(); - m_dragging = false; - - KisPaintDeviceSP device = m_currentImage->activeDevice (); - if (!device) return; - - KisPainter painter (device); - if (m_currentImage->undo()) painter.beginTransaction (i18n ("Polyline")); - - painter.setPaintColor(m_subject->fgColor()); - painter.setBrush(m_subject->currentBrush()); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); - painter.setPaintOp(op); // Painter takes ownership - - KisPoint start,end; - KisPointVector::iterator it; - for( it = m_points.begin(); it != m_points.end(); ++it ) - { - if( it == m_points.begin() ) - { - start = (*it); - } else { - end = (*it); - painter.paintLine(start, PRESSURE_DEFAULT, 0, 0, end, PRESSURE_DEFAULT, 0, 0); - start = end; - } - } - m_points.clear(); - - device->setDirty( painter.dirtyRect() ); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); - } - -} -void KisToolPolyline::move(KisMoveEvent *event) -{ - if (m_dragging) { - // erase old lines on canvas - draw(); - // get current mouse position - m_dragEnd = event->pos(); - // draw new lines on canvas - draw(); - } -} - -void KisToolPolyline::buttonRelease(KisButtonReleaseEvent *event) -{ - if (!m_subject || !m_currentImage) - return; - - if (m_dragging && event->button() == Qt::LeftButton) { - m_dragging = false; - m_points.append (m_dragEnd); - } - - if (m_dragging && event->button() == Qt::RightButton) { - - } -} - - -void KisToolPolyline::doubleClick(KisDoubleClickEvent *) -{ - finish(); -} - - -void KisToolPolyline::paint(KisCanvasPainter& gc) -{ - draw(gc); -} - -void KisToolPolyline::paint(KisCanvasPainter& gc, const TQRect&) -{ - draw(gc); -} - -void KisToolPolyline::draw() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - - draw(gc); - } -} - -void KisToolPolyline::draw(KisCanvasPainter& gc) -{ - if (!m_subject || !m_currentImage) - return; - - TQPen pen(TQt::white, 0, TQt::SolidLine); - - gc.setPen(pen); - gc.setRasterOp(TQt::XorROP); - - KisCanvasController *controller = m_subject->canvasController(); - KisPoint start, end; - TQPoint startPos; - TQPoint endPos; - - if (m_dragging) { - startPos = controller->windowToView(m_dragStart.floorTQPoint()); - endPos = controller->windowToView(m_dragEnd.floorTQPoint()); - gc.drawLine(startPos, endPos); - } else { - for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { - - if (it == m_points.begin()) - { - start = (*it); - } else { - end = (*it); - - startPos = controller->windowToView(start.floorTQPoint()); - endPos = controller->windowToView(end.floorTQPoint()); - - gc.drawLine(startPos, endPos); - - start = end; - } - } - } -} - -void KisToolPolyline::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("&Polyline"), - "polyline", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Draw a polyline. Shift-mouseclick ends the polyline.")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQString KisToolPolyline::quickHelp() const -{ - return i18n("Press shift-mouseclick to end the polyline."); -} - -void KisToolPolyline::keyPress(TQKeyEvent *e) -{ - if (e->key()==TQt::Key_Escape) { - // erase old lines on canvas - draw(); - m_dragging = false; - m_points.clear(); - } -} - -#include "kis_tool_polyline.moc" diff --git a/chalk/plugins/tools/tool_polyline/kis_tool_polyline.cpp b/chalk/plugins/tools/tool_polyline/kis_tool_polyline.cpp new file mode 100644 index 00000000..ab89cf3f --- /dev/null +++ b/chalk/plugins/tools/tool_polyline/kis_tool_polyline.cpp @@ -0,0 +1,271 @@ +/* + * kis_tool_polyline.cpp -- part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_doc.h" +#include "kis_view.h" +#include "kis_painter.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop_registry.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" + +#include "kis_tool_polyline.h" + +KisToolPolyline::KisToolPolyline() + : super(i18n ("Polyline")), + m_dragging (false), + m_currentImage (0) +{ + setName("tool_polyline"); + setCursor(KisCursor::load("tool_polyline_cursor.png", 6, 6)); +} + +KisToolPolyline::~KisToolPolyline() +{ +} + +void KisToolPolyline::update (KisCanvasSubject *subject) +{ + super::update (subject); + if (m_subject) + m_currentImage = m_subject->currentImg (); +} + +void KisToolPolyline::buttonPress(KisButtonPressEvent *event) +{ + if (m_currentImage) { + if (event->button() == Qt::LeftButton && event->state() != TQt::ShiftButton ) { + + m_dragging = true; + + if (m_points.isEmpty()) + { + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.append(m_dragStart); + } else { + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + draw(); + } + } else if (event->button() == Qt::LeftButton && event->state() == TQt::ShiftButton ) { + finish(); + } + } +} + +void KisToolPolyline::deactivate() +{ + draw(); + m_points.clear(); + m_dragging = false; +} + +void KisToolPolyline::finish() +{ + // erase old lines on canvas + draw(); + m_dragging = false; + + KisPaintDeviceSP device = m_currentImage->activeDevice (); + if (!device) return; + + KisPainter painter (device); + if (m_currentImage->undo()) painter.beginTransaction (i18n ("Polyline")); + + painter.setPaintColor(m_subject->fgColor()); + painter.setBrush(m_subject->currentBrush()); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); + painter.setPaintOp(op); // Painter takes ownership + + KisPoint start,end; + KisPointVector::iterator it; + for( it = m_points.begin(); it != m_points.end(); ++it ) + { + if( it == m_points.begin() ) + { + start = (*it); + } else { + end = (*it); + painter.paintLine(start, PRESSURE_DEFAULT, 0, 0, end, PRESSURE_DEFAULT, 0, 0); + start = end; + } + } + m_points.clear(); + + device->setDirty( painter.dirtyRect() ); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); + } + +} +void KisToolPolyline::move(KisMoveEvent *event) +{ + if (m_dragging) { + // erase old lines on canvas + draw(); + // get current mouse position + m_dragEnd = event->pos(); + // draw new lines on canvas + draw(); + } +} + +void KisToolPolyline::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject || !m_currentImage) + return; + + if (m_dragging && event->button() == Qt::LeftButton) { + m_dragging = false; + m_points.append (m_dragEnd); + } + + if (m_dragging && event->button() == Qt::RightButton) { + + } +} + + +void KisToolPolyline::doubleClick(KisDoubleClickEvent *) +{ + finish(); +} + + +void KisToolPolyline::paint(KisCanvasPainter& gc) +{ + draw(gc); +} + +void KisToolPolyline::paint(KisCanvasPainter& gc, const TQRect&) +{ + draw(gc); +} + +void KisToolPolyline::draw() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + draw(gc); + } +} + +void KisToolPolyline::draw(KisCanvasPainter& gc) +{ + if (!m_subject || !m_currentImage) + return; + + TQPen pen(TQt::white, 0, TQt::SolidLine); + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + + KisCanvasController *controller = m_subject->canvasController(); + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + + if (m_dragging) { + startPos = controller->windowToView(m_dragStart.floorTQPoint()); + endPos = controller->windowToView(m_dragEnd.floorTQPoint()); + gc.drawLine(startPos, endPos); + } else { + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorTQPoint()); + endPos = controller->windowToView(end.floorTQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } +} + +void KisToolPolyline::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("&Polyline"), + "polyline", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Draw a polyline. Shift-mouseclick ends the polyline.")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQString KisToolPolyline::quickHelp() const +{ + return i18n("Press shift-mouseclick to end the polyline."); +} + +void KisToolPolyline::keyPress(TQKeyEvent *e) +{ + if (e->key()==TQt::Key_Escape) { + // erase old lines on canvas + draw(); + m_dragging = false; + m_points.clear(); + } +} + +#include "kis_tool_polyline.moc" diff --git a/chalk/plugins/tools/tool_polyline/tool_polyline.cc b/chalk/plugins/tools/tool_polyline/tool_polyline.cc deleted file mode 100644 index a5bfa27f..00000000 --- a/chalk/plugins/tools/tool_polyline/tool_polyline.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * tool_polyline.cc -- Part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "tool_polyline.h" -#include "kis_tool_polyline.h" - - -typedef KGenericFactory ToolPolylineFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolpolyline, ToolPolylineFactory( "chalk" ) ) - - -ToolPolyline::ToolPolyline(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolPolylineFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast(parent); - - r->add(new KisToolPolylineFactory()); - } - -} - -ToolPolyline::~ToolPolyline() -{ -} - -#include "tool_polyline.moc" diff --git a/chalk/plugins/tools/tool_polyline/tool_polyline.cpp b/chalk/plugins/tools/tool_polyline/tool_polyline.cpp new file mode 100644 index 00000000..d6abff71 --- /dev/null +++ b/chalk/plugins/tools/tool_polyline/tool_polyline.cpp @@ -0,0 +1,64 @@ +/* + * tool_polyline.cpp -- Part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "tool_polyline.h" +#include "kis_tool_polyline.h" + + +typedef KGenericFactory ToolPolylineFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolpolyline, ToolPolylineFactory( "chalk" ) ) + + +ToolPolyline::ToolPolyline(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolPolylineFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(parent); + + r->add(new KisToolPolylineFactory()); + } + +} + +ToolPolyline::~ToolPolyline() +{ +} + +#include "tool_polyline.moc" diff --git a/chalk/plugins/tools/tool_selectsimilar/Makefile.am b/chalk/plugins/tools/tool_selectsimilar/Makefile.am index 5c1897f4..224f67ba 100644 --- a/chalk/plugins/tools/tool_selectsimilar/Makefile.am +++ b/chalk/plugins/tools/tool_selectsimilar/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) -chalktoolselectsimilar_la_SOURCES = selectsimilar.cc kis_tool_selectsimilar.cc +chalktoolselectsimilar_la_SOURCES = selectsimilar.cpp kis_tool_selectsimilar.cpp noinst_HEADERS = selectsimilar.h kis_tool_selectsimilar.h kde_module_LTLIBRARIES = chalktoolselectsimilar.la diff --git a/chalk/plugins/tools/tool_selectsimilar/kis_tool_selectsimilar.cc b/chalk/plugins/tools/tool_selectsimilar/kis_tool_selectsimilar.cpp similarity index 100% rename from chalk/plugins/tools/tool_selectsimilar/kis_tool_selectsimilar.cc rename to chalk/plugins/tools/tool_selectsimilar/kis_tool_selectsimilar.cpp diff --git a/chalk/plugins/tools/tool_selectsimilar/selectsimilar.cc b/chalk/plugins/tools/tool_selectsimilar/selectsimilar.cpp similarity index 100% rename from chalk/plugins/tools/tool_selectsimilar/selectsimilar.cc rename to chalk/plugins/tools/tool_selectsimilar/selectsimilar.cpp diff --git a/chalk/plugins/tools/tool_star/Makefile.am b/chalk/plugins/tools/tool_star/Makefile.am index ed88d27e..1f4627dd 100644 --- a/chalk/plugins/tools/tool_star/Makefile.am +++ b/chalk/plugins/tools/tool_star/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalktoolstar_la_SOURCES = \ wdg_tool_star.ui \ - tool_star.cc \ - kis_tool_star.cc + tool_star.cpp \ + kis_tool_star.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktoolstar.la diff --git a/chalk/plugins/tools/tool_star/kis_tool_star.cc b/chalk/plugins/tools/tool_star/kis_tool_star.cc deleted file mode 100644 index cd4bb0b2..00000000 --- a/chalk/plugins/tools/tool_star/kis_tool_star.cc +++ /dev/null @@ -1,245 +0,0 @@ -/* - * kis_tool_star.cc -- part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_doc.h" -#include "kis_view.h" -#include "kis_painter.h" -#include "kis_int_spinbox.h" -#include "kis_canvas_subject.h" -#include "kis_canvas_controller.h" -#include "kis_button_press_event.h" -#include "kis_button_release_event.h" -#include "kis_move_event.h" -#include "kis_paintop_registry.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" -#include "kis_cursor.h" -#include "kis_int_spinbox.h" - -#include "kis_tool_star.h" -#include "wdg_tool_star.h" - -KisToolStar::KisToolStar() - : super(i18n("Star")), - m_dragging (false), - m_currentImage (0) -{ - setName("tool_star"); - setCursor(KisCursor::load("tool_star_cursor.png", 6, 6)); - m_innerOuterRatio=40; - m_vertices=5; -} - -KisToolStar::~KisToolStar() -{ -} - -void KisToolStar::update (KisCanvasSubject *subject) -{ - super::update (subject); - if (m_subject) - m_currentImage = m_subject->currentImg (); -} - -void KisToolStar::buttonPress(KisButtonPressEvent *event) -{ - if (m_currentImage && event->button() == Qt::LeftButton) { - m_dragging = true; - m_dragStart = event->pos(); - m_dragEnd = event->pos(); - m_vertices = m_optWidget->verticesSpinBox->value(); - m_innerOuterRatio = m_optWidget->ratioSpinBox->value(); - } -} - -void KisToolStar::move(KisMoveEvent *event) -{ - if (m_dragging) { - // erase old lines on canvas - draw(m_dragStart, m_dragEnd); - // move (alt) or resize star - if (event->state() & TQt::AltButton) { - KisPoint trans = event->pos() - m_dragEnd; - m_dragStart += trans; - m_dragEnd += trans; - } else { - m_dragEnd = event->pos(); - } - // draw new lines on canvas - draw(m_dragStart, m_dragEnd); - } -} - -void KisToolStar::buttonRelease(KisButtonReleaseEvent *event) -{ - if (!m_subject || !m_currentImage) - return; - - if (m_dragging && event->button() == Qt::LeftButton) { - // erase old lines on canvas - draw(m_dragStart, m_dragEnd); - m_dragging = false; - - if (m_dragStart == m_dragEnd) - return; - - if (!m_currentImage) - return; - - if (!m_currentImage->activeDevice()) - return; - - KisPaintDeviceSP device = m_currentImage->activeDevice ();; - KisPainter painter (device); - if (m_currentImage->undo()) painter.beginTransaction (i18n("Star")); - - painter.setPaintColor(m_subject->fgColor()); - painter.setBackgroundColor(m_subject->bgColor()); - painter.setFillStyle(fillStyle()); - painter.setBrush(m_subject->currentBrush()); - painter.setPattern(m_subject->currentPattern()); - painter.setOpacity(m_opacity); - painter.setCompositeOp(m_compositeOp); - KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); - painter.setPaintOp(op); // Painter takes ownership - - vKisPoint coord = starCoordinates(m_vertices, m_dragStart.x(), m_dragStart.y(), m_dragEnd.x(), m_dragEnd.y()); - - painter.paintPolygon(coord); - - device->setDirty( painter.dirtyRect() ); - notifyModified(); - - if (m_currentImage->undo()) { - m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); - } - } -} - -void KisToolStar::draw(const KisPoint& start, const KisPoint& end ) -{ - if (!m_subject || !m_currentImage) - return; - - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter p (canvas); - TQPen pen(TQt::SolidLine); - - KisPoint startPos; - KisPoint endPos; - startPos = controller->windowToView(start); - endPos = controller->windowToView(end); - - p.setRasterOp(TQt::NotROP); - - vKisPoint points = starCoordinates(m_vertices, startPos.x(), startPos.y(), endPos.x(), endPos.y()); - - for (uint i = 0; i < points.count() - 1; i++) { - p.drawLine(points[i].floorTQPoint(), points[i + 1].floorTQPoint()); - } - p.drawLine(points[points.count() - 1].floorTQPoint(), points[0].floorTQPoint()); - - p.end (); -} - -void KisToolStar::setup(TDEActionCollection *collection) -{ - m_action = static_cast(collection->action(name())); - - if (m_action == 0) { - TDEShortcut shortcut(TQt::Key_Plus); - shortcut.append(TDEShortcut(TQt::Key_F9)); - m_action = new TDERadioAction(i18n("&Star"), - "tool_star", - shortcut, - this, - TQT_SLOT(activate()), - collection, - name()); - TQ_CHECK_PTR(m_action); - - m_action->setToolTip(i18n("Draw a star")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -vKisPoint KisToolStar::starCoordinates(int N, double mx, double my, double x, double y) -{ - double R=0, r=0; - TQ_INT32 n=0; - double angle; - - vKisPoint starCoordinatesArray(2*N); - - // the radius of the outer edges - R=sqrt((x-mx)*(x-mx)+(y-my)*(y-my)); - - // the radius of the inner edges - r=R*m_innerOuterRatio/100.0; - - // the angle - angle=-atan2((x-mx),(y-my)); - - //set outer edges - for(n=0;nratioSpinBox->setValue(m_innerOuterRatio); - - TQGridLayout *optionLayout = new TQGridLayout(widget, 1, 1); - super::addOptionWidgetLayout(optionLayout); - - optionLayout->addWidget(m_optWidget, 0, 0); - - return widget; -} - -#include "kis_tool_star.moc" diff --git a/chalk/plugins/tools/tool_star/kis_tool_star.cpp b/chalk/plugins/tools/tool_star/kis_tool_star.cpp new file mode 100644 index 00000000..3a260545 --- /dev/null +++ b/chalk/plugins/tools/tool_star/kis_tool_star.cpp @@ -0,0 +1,245 @@ +/* + * kis_tool_star.cpp -- part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_doc.h" +#include "kis_view.h" +#include "kis_painter.h" +#include "kis_int_spinbox.h" +#include "kis_canvas_subject.h" +#include "kis_canvas_controller.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_paintop_registry.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" +#include "kis_cursor.h" +#include "kis_int_spinbox.h" + +#include "kis_tool_star.h" +#include "wdg_tool_star.h" + +KisToolStar::KisToolStar() + : super(i18n("Star")), + m_dragging (false), + m_currentImage (0) +{ + setName("tool_star"); + setCursor(KisCursor::load("tool_star_cursor.png", 6, 6)); + m_innerOuterRatio=40; + m_vertices=5; +} + +KisToolStar::~KisToolStar() +{ +} + +void KisToolStar::update (KisCanvasSubject *subject) +{ + super::update (subject); + if (m_subject) + m_currentImage = m_subject->currentImg (); +} + +void KisToolStar::buttonPress(KisButtonPressEvent *event) +{ + if (m_currentImage && event->button() == Qt::LeftButton) { + m_dragging = true; + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_vertices = m_optWidget->verticesSpinBox->value(); + m_innerOuterRatio = m_optWidget->ratioSpinBox->value(); + } +} + +void KisToolStar::move(KisMoveEvent *event) +{ + if (m_dragging) { + // erase old lines on canvas + draw(m_dragStart, m_dragEnd); + // move (alt) or resize star + if (event->state() & TQt::AltButton) { + KisPoint trans = event->pos() - m_dragEnd; + m_dragStart += trans; + m_dragEnd += trans; + } else { + m_dragEnd = event->pos(); + } + // draw new lines on canvas + draw(m_dragStart, m_dragEnd); + } +} + +void KisToolStar::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject || !m_currentImage) + return; + + if (m_dragging && event->button() == Qt::LeftButton) { + // erase old lines on canvas + draw(m_dragStart, m_dragEnd); + m_dragging = false; + + if (m_dragStart == m_dragEnd) + return; + + if (!m_currentImage) + return; + + if (!m_currentImage->activeDevice()) + return; + + KisPaintDeviceSP device = m_currentImage->activeDevice ();; + KisPainter painter (device); + if (m_currentImage->undo()) painter.beginTransaction (i18n("Star")); + + painter.setPaintColor(m_subject->fgColor()); + painter.setBackgroundColor(m_subject->bgColor()); + painter.setFillStyle(fillStyle()); + painter.setBrush(m_subject->currentBrush()); + painter.setPattern(m_subject->currentPattern()); + painter.setOpacity(m_opacity); + painter.setCompositeOp(m_compositeOp); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter); + painter.setPaintOp(op); // Painter takes ownership + + vKisPoint coord = starCoordinates(m_vertices, m_dragStart.x(), m_dragStart.y(), m_dragEnd.x(), m_dragEnd.y()); + + painter.paintPolygon(coord); + + device->setDirty( painter.dirtyRect() ); + notifyModified(); + + if (m_currentImage->undo()) { + m_currentImage->undoAdapter()->addCommand(painter.endTransaction()); + } + } +} + +void KisToolStar::draw(const KisPoint& start, const KisPoint& end ) +{ + if (!m_subject || !m_currentImage) + return; + + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter p (canvas); + TQPen pen(TQt::SolidLine); + + KisPoint startPos; + KisPoint endPos; + startPos = controller->windowToView(start); + endPos = controller->windowToView(end); + + p.setRasterOp(TQt::NotROP); + + vKisPoint points = starCoordinates(m_vertices, startPos.x(), startPos.y(), endPos.x(), endPos.y()); + + for (uint i = 0; i < points.count() - 1; i++) { + p.drawLine(points[i].floorTQPoint(), points[i + 1].floorTQPoint()); + } + p.drawLine(points[points.count() - 1].floorTQPoint(), points[0].floorTQPoint()); + + p.end (); +} + +void KisToolStar::setup(TDEActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + TDEShortcut shortcut(TQt::Key_Plus); + shortcut.append(TDEShortcut(TQt::Key_F9)); + m_action = new TDERadioAction(i18n("&Star"), + "tool_star", + shortcut, + this, + TQT_SLOT(activate()), + collection, + name()); + TQ_CHECK_PTR(m_action); + + m_action->setToolTip(i18n("Draw a star")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +vKisPoint KisToolStar::starCoordinates(int N, double mx, double my, double x, double y) +{ + double R=0, r=0; + TQ_INT32 n=0; + double angle; + + vKisPoint starCoordinatesArray(2*N); + + // the radius of the outer edges + R=sqrt((x-mx)*(x-mx)+(y-my)*(y-my)); + + // the radius of the inner edges + r=R*m_innerOuterRatio/100.0; + + // the angle + angle=-atan2((x-mx),(y-my)); + + //set outer edges + for(n=0;nratioSpinBox->setValue(m_innerOuterRatio); + + TQGridLayout *optionLayout = new TQGridLayout(widget, 1, 1); + super::addOptionWidgetLayout(optionLayout); + + optionLayout->addWidget(m_optWidget, 0, 0); + + return widget; +} + +#include "kis_tool_star.moc" diff --git a/chalk/plugins/tools/tool_star/tool_star.cc b/chalk/plugins/tools/tool_star/tool_star.cc deleted file mode 100644 index 9ac1b62f..00000000 --- a/chalk/plugins/tools/tool_star/tool_star.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * tool_star.cc -- Part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "tool_star.h" -#include "kis_tool_star.h" - - -typedef KGenericFactory ToolStarFactory; -K_EXPORT_COMPONENT_FACTORY( chalktoolstar, ToolStarFactory( "chalk" ) ) - - -ToolStar::ToolStar(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ToolStarFactory::instance()); - - if ( parent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast( parent ); - r->add(new KisToolStarFactory()); - } - -} - -ToolStar::~ToolStar() -{ -} - -#include "tool_star.moc" diff --git a/chalk/plugins/tools/tool_star/tool_star.cpp b/chalk/plugins/tools/tool_star/tool_star.cpp new file mode 100644 index 00000000..7309e8a1 --- /dev/null +++ b/chalk/plugins/tools/tool_star/tool_star.cpp @@ -0,0 +1,62 @@ +/* + * tool_star.cpp -- Part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "tool_star.h" +#include "kis_tool_star.h" + + +typedef KGenericFactory ToolStarFactory; +K_EXPORT_COMPONENT_FACTORY( chalktoolstar, ToolStarFactory( "chalk" ) ) + + +ToolStar::ToolStar(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ToolStarFactory::instance()); + + if ( parent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast( parent ); + r->add(new KisToolStarFactory()); + } + +} + +ToolStar::~ToolStar() +{ +} + +#include "tool_star.moc" diff --git a/chalk/plugins/tools/tool_transform/Makefile.am b/chalk/plugins/tools/tool_transform/Makefile.am index 12a32774..a5adea17 100644 --- a/chalk/plugins/tools/tool_transform/Makefile.am +++ b/chalk/plugins/tools/tool_transform/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalktooltransform_la_SOURCES = \ wdg_tool_transform.ui \ - tool_transform.cc \ - kis_tool_transform.cc + tool_transform.cpp \ + kis_tool_transform.cpp # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = chalktooltransform.la diff --git a/chalk/plugins/tools/tool_transform/kis_tool_transform.cc b/chalk/plugins/tools/tool_transform/kis_tool_transform.cc deleted file mode 100644 index de20ce7f..00000000 --- a/chalk/plugins/tools/tool_transform/kis_tool_transform.cc +++ /dev/null @@ -1,916 +0,0 @@ -/* - * kis_tool_transform.cc -- part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2005 Casper Boemann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kis_tool_transform.h" -#include "wdg_tool_transform.h" -#include "kis_canvas.h" -#include "kis_canvas_painter.h" - -namespace { - class TransformCmd : public KisSelectedTransaction { - typedef KisSelectedTransaction super; - - public: - TransformCmd(KisToolTransform *tool, KisPaintDeviceSP device, KisPaintDeviceSP origDevice, double scaleX, double scaleY, double tX, double tY, double a, KisSelectionSP origSel, TQPoint startPos, TQPoint endPos); - virtual ~TransformCmd(); - - public: - virtual void execute(); - virtual void unexecute(); - void transformArgs(double &sx, double &sy, double &tx, double &ty, double &a); - KisSelectionSP origSelection(TQPoint &startPos, TQPoint &endPos); - KisPaintDeviceSP theDevice(); - KisPaintDeviceSP origDevice(); - - private: - double m_scaleX; - double m_scaleY; - double m_translateX; - double m_translateY; - double m_a; - KisToolTransform *m_tool; - KisSelectionSP m_origSelection; - TQPoint m_startPos; - TQPoint m_endPos; - KisPaintDeviceSP m_device; - KisPaintDeviceSP m_origDevice; - }; - - TransformCmd::TransformCmd(KisToolTransform *tool, KisPaintDeviceSP device, KisPaintDeviceSP origDevice, double scaleX, double scaleY, double tX, double tY, double a, KisSelectionSP origSel, TQPoint startPos, TQPoint endPos) : - super(i18n("Transform"), device) - , m_scaleX(scaleX) - , m_scaleY(scaleY) - , m_translateX(tX) - , m_translateY(tY) - , m_a(a) - , m_tool(tool) - , m_origSelection(origSel) - , m_startPos(startPos) - , m_endPos(endPos) - , m_device(device) - , m_origDevice(origDevice) - { - } - - TransformCmd::~TransformCmd() - { - } - - void TransformCmd::transformArgs(double &sx, double &sy, double &tx, double &ty, double &a) - { - sx = m_scaleX; - sy = m_scaleY; - tx= m_translateX; - ty = m_translateY; - a = m_a; - } - - KisSelectionSP TransformCmd::origSelection(TQPoint &startPos, TQPoint &endPos) - { - startPos = m_startPos; - endPos = m_endPos; - return m_origSelection; - } - - void TransformCmd::execute() - { - super::execute(); - } - - void TransformCmd::unexecute() - { - super::unexecute(); - } - - KisPaintDeviceSP TransformCmd::theDevice() - { - return m_device; - } - - KisPaintDeviceSP TransformCmd::origDevice() - { - return m_origDevice; - } -} - -KisToolTransform::KisToolTransform() - : super(i18n("Transform")) - , m_wasPressed( false ) -{ - setName("tool_transform"); - setCursor(KisCursor::selectCursor()); - m_subject = 0; - m_selecting = false; - m_startPos = TQPoint(0, 0); - m_endPos = TQPoint(0, 0); - m_optWidget = 0; - m_sizeCursors[0] = KisCursor::sizeVerCursor(); - m_sizeCursors[1] = KisCursor::sizeBDiagCursor(); - m_sizeCursors[2] = KisCursor::sizeHorCursor(); - m_sizeCursors[3] = KisCursor::sizeFDiagCursor(); - m_sizeCursors[4] = KisCursor::sizeVerCursor(); - m_sizeCursors[5] = KisCursor::sizeBDiagCursor(); - m_sizeCursors[6] = KisCursor::sizeHorCursor(); - m_sizeCursors[7] = KisCursor::sizeFDiagCursor(); - m_origDevice = 0; - m_origSelection = 0; - -} - -KisToolTransform::~KisToolTransform() -{ -} - -void KisToolTransform::deactivate() -{ - if (m_subject && m_subject->undoAdapter()) m_subject->undoAdapter()->removeCommandHistoryListener( this ); - - KisImageSP img = m_subject->currentImg(); - if (!img) return; - - paintOutline(); - - disconnect(m_subject->currentImg().data(), TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayerActivated(KisLayerSP))); -} - -void KisToolTransform::activate() -{ - if(m_subject && m_subject->currentImg() && m_subject->currentImg()->activeDevice()) - { - //connect(m_subject, commandExecuted(KCommand *c), this, notifyCommandAdded( KCommand * c)); - m_subject->undoAdapter()->setCommandHistoryListener( this ); - - KisToolControllerInterface *controller = m_subject->toolController(); - - if (controller) - controller->setCurrentTool(this); - - TransformCmd * cmd=0; - - if(m_subject->currentImg()->undoAdapter()->presentCommand()) - cmd = dynamic_cast(m_subject->currentImg()->undoAdapter()->presentCommand()); - - if (cmd == 0) { - initHandles(); - } - else - { - // One of our commands is on top - if(cmd->theDevice() == m_subject->currentImg()->activeDevice()) - { - // and it even has the same device - // We should ask for tool args and orig selection - m_origDevice = cmd->origDevice(); - cmd->transformArgs(m_scaleX, m_scaleY, m_translateX, m_translateY, m_a); - m_origSelection = cmd->origSelection(m_startPos, m_endPos); - m_org_cenX = (m_startPos.x() + m_endPos.x()) / 2.0; - m_org_cenY = (m_startPos.y() + m_endPos.y()) / 2.0; - paintOutline(); - } - else - initHandles(); - } - } - connect(m_subject->currentImg(), TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayerActivated(KisLayerSP))); -} - -void KisToolTransform::initHandles() -{ - TQ_INT32 x,y,w,h; - KisImageSP img = m_subject->currentImg(); - - KisPaintDeviceSP dev = img->activeDevice(); - if (!dev ) return; - - // Create a lazy copy of the current state - m_origDevice = new KisPaintDevice(*dev.data()); - Q_ASSERT(m_origDevice); - - if(dev->hasSelection()) - { - KisSelectionSP sel = dev->selection(); - m_origSelection = new KisSelection(*sel.data()); - TQRect r = sel->selectedExactRect(); - r.rect(&x, &y, &w, &h); - } - else { - dev->exactBounds(x,y,w,h); - m_origSelection = 0; - } - m_startPos = TQPoint(x, y); - m_endPos = TQPoint(x+w-1, y+h-1); - m_org_cenX = (m_startPos.x() + m_endPos.x()) / 2.0; - m_org_cenY = (m_startPos.y() + m_endPos.y()) / 2.0; - - m_a = 0.0; - m_scaleX = 1.0; - m_scaleY = 1.0; - m_translateX = m_org_cenX; - m_translateY = m_org_cenY; - - m_subject->canvasController() ->updateCanvas(); -} - -void KisToolTransform::paint(KisCanvasPainter& gc) -{ - paintOutline(gc, TQRect()); -} - -void KisToolTransform::paint(KisCanvasPainter& gc, const TQRect& rc) -{ - paintOutline(gc, rc); -} - - -void KisToolTransform::buttonPress(KisButtonPressEvent *e) -{ - if (m_subject && e->button() == Qt::LeftButton) { - m_wasPressed = true; - } - - if (m_subject) { - KisImageSP img = m_subject->currentImg(); - - if (img && img->activeDevice() && e->button() == Qt::LeftButton) { - switch(m_function) - { - case ROTATE: - m_clickoffset = e->pos().floorTQPoint() - - TQPoint(static_cast(m_translateX),static_cast(m_translateY)); - m_clickangle = -m_a - atan2(m_clickoffset.x(),m_clickoffset.y()); - m_clickoffset = TQPoint(0, 0); - break; - case MOVE: - m_clickoffset = e->pos().floorTQPoint() - - TQPoint(static_cast(m_translateX),static_cast(m_translateY)); - break; - case TOPSCALE: - m_clickoffset = e->pos().floorTQPoint() - - TQPoint((m_topleft + m_topright)/2); - break; - case TOPRIGHTSCALE: - m_clickoffset = e->pos().floorTQPoint() - m_topright; - break; - case RIGHTSCALE: - m_clickoffset = e->pos().floorTQPoint() - - TQPoint((m_topright + m_bottomright)/2); - break; - case BOTTOMRIGHTSCALE: - m_clickoffset = e->pos().floorTQPoint() - m_bottomright; - break; - case BOTTOMSCALE: - m_clickoffset = e->pos().floorTQPoint() - - TQPoint((m_bottomleft + m_bottomright)/2); - break; - case BOTTOMLEFTSCALE: - m_clickoffset = e->pos().floorTQPoint() - m_bottomleft; - break; - case LEFTSCALE: - m_clickoffset = e->pos().floorTQPoint() - - TQPoint((m_topleft + m_bottomleft)/2); - break; - case TOPLEFTSCALE: - m_clickoffset = e->pos().floorTQPoint() - m_topleft; - break; - } - m_selecting = true; - m_actualyMoveWhileSelected = false; - } - } -} - -int KisToolTransform::det(TQPoint v,TQPoint w) -{ - return v.x()*w.y()-v.y()*w.x(); -} -int KisToolTransform::distsq(TQPoint v,TQPoint w) -{ - v -= w; - return v.x()*v.x() + v.y()*v.y(); -} - -void KisToolTransform::setFunctionalCursor() -{ - int rotOctant = 8 + int(8.5 + m_a* 4 / M_PI); - - int s; - if(m_scaleX*m_scaleY<0) - s = -1; - else - s=1; - - switch(m_function) - { - case MOVE: - setCursor(KisCursor::moveCursor()); - break; - case ROTATE: - setCursor(KisCursor::rotateCursor()); - break; - case TOPSCALE: - setCursor(m_sizeCursors[(0*s +rotOctant)%8]); - break; - case TOPRIGHTSCALE: - setCursor(m_sizeCursors[(1*s +rotOctant)%8]); - break; - case RIGHTSCALE: - setCursor(m_sizeCursors[(2*s +rotOctant)%8]); - break; - case BOTTOMRIGHTSCALE: - setCursor(m_sizeCursors[(3*s +rotOctant)%8]); - break; - case BOTTOMSCALE: - setCursor(m_sizeCursors[(4*s +rotOctant)%8]); - break; - case BOTTOMLEFTSCALE: - setCursor(m_sizeCursors[(5*s +rotOctant)%8]); - break; - case LEFTSCALE: - setCursor(m_sizeCursors[(6*s +rotOctant)%8]); - break; - case TOPLEFTSCALE: - setCursor(m_sizeCursors[(7*s +rotOctant)%8]); - break; - } -} - -void KisToolTransform::move(KisMoveEvent *e) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - - Q_ASSERT(controller); - TQPoint topleft = m_topleft; - TQPoint topright = m_topright; - TQPoint bottomleft = m_bottomleft; - TQPoint bottomright = m_bottomright; - - TQPoint mousePos = e->pos().floorTQPoint(); - - if (m_subject && m_selecting) { - paintOutline(); - m_actualyMoveWhileSelected = true; - mousePos -= m_clickoffset; - - // transform mousePos coords, so it seems like it isn't rotated and centered at 0,0 - double newX = invrotX(mousePos.x() - m_translateX, mousePos.y() - m_translateY); - double newY = invrotY(mousePos.x() - m_translateX, mousePos.y() - m_translateY); - double dx=0, dy=0; - double oldScaleX = m_scaleX; - double oldScaleY = m_scaleY; - - if(m_function == MOVE) - { - m_translateX += mousePos.x() - m_translateX; - m_translateY += mousePos.y() - m_translateY; - } - - if(m_function == ROTATE) - { - m_a = -atan2(mousePos.x() - m_translateX, mousePos.y() - m_translateY) - - m_clickangle; - } - - if(m_function == TOPSCALE) - { - dy = (newY - m_scaleY * (m_startPos.y() - m_org_cenY)) / 2; - m_scaleY = (newY - dy) / (m_startPos.y() - m_org_cenY); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleX>0) // handle the mirrored cases - m_scaleX = fabs(m_scaleY); - else - m_scaleX = -fabs(m_scaleY); - } - } - - if(m_function == TOPRIGHTSCALE) - { - dx = (newX - m_scaleX * (m_endPos.x() - m_org_cenX)) / 2; - m_scaleX = (newX - dx) / (m_endPos.x() - m_org_cenX); - - dy = (newY - m_scaleY * (m_startPos.y() - m_org_cenY)) / 2; - m_scaleY = (newY - dy) / (m_startPos.y() - m_org_cenY); - - // enforce same aspect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleX < m_scaleY) - { - if(m_scaleX>0) // handle the mirrored cases - m_scaleX = fabs(m_scaleY); - else - m_scaleX = -fabs(m_scaleY); - dx = (m_scaleX - oldScaleX) * (m_endPos.x() - m_org_cenX); - } - else - { - if(m_scaleY>0) // handle the mirrored cases - m_scaleY = fabs(m_scaleX); - else - m_scaleY = -fabs(m_scaleX); - dy = (m_scaleY - oldScaleY) * (m_startPos.y() - m_org_cenY); - } - } - } - - if(m_function == RIGHTSCALE) - { - dx = (newX - m_scaleX * (m_endPos.x() - m_org_cenX)) / 2; - m_scaleX = (newX - dx) / (m_endPos.x() - m_org_cenX); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleY>0) // handle the mirrored cases - m_scaleY = fabs(m_scaleX); - else - m_scaleY = -fabs(m_scaleX); - } - } - - if(m_function == BOTTOMRIGHTSCALE) - { - dx = (newX - m_scaleX * (m_endPos.x() - m_org_cenX)) / 2; - m_scaleX = (newX - dx) / (m_endPos.x() - m_org_cenX); - - dy = (newY - m_scaleY * (m_endPos.y() - m_org_cenY)) / 2; - m_scaleY = (newY - dy) / (m_endPos.y() - m_org_cenY); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleX < m_scaleY) - { - if(m_scaleX>0) // handle the mirrored cases - m_scaleX = fabs(m_scaleY); - else - m_scaleX = -fabs(m_scaleY); - dx = (m_scaleX - oldScaleX) * (m_endPos.x() - m_org_cenX); - } - else - { - if(m_scaleY>0) // handle the mirrored cases - m_scaleY = fabs(m_scaleX); - else - m_scaleY = -fabs(m_scaleX); - dy = (m_scaleY - oldScaleY) * (m_endPos.y() - m_org_cenY); - } - } - } - - if(m_function == BOTTOMSCALE) - { - dy = (newY - m_scaleY * (m_endPos.y() - m_org_cenY)) / 2; - m_scaleY = (newY - dy) / (m_endPos.y() - m_org_cenY); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleX>0) // handle the mirrored cases - m_scaleX = fabs(m_scaleY); - else - m_scaleX = -fabs(m_scaleY); - } - } - - if(m_function == BOTTOMLEFTSCALE) - { - dx = (newX - m_scaleX * (m_startPos.x() - m_org_cenX)) / 2; - m_scaleX = (newX - dx) / (m_startPos.x() - m_org_cenX); - - dy = (newY - m_scaleY * (m_endPos.y() - m_org_cenY)) / 2; - m_scaleY = (newY - dy) / (m_endPos.y() - m_org_cenY); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleX < m_scaleY) - { - if(m_scaleX>0) // handle the mirrored cases - m_scaleX = fabs(m_scaleY); - else - m_scaleX = -fabs(m_scaleY); - dx = (m_scaleX - oldScaleX) * (m_startPos.x() - m_org_cenX); - } - else - { - if(m_scaleY>0) // handle the mirrored cases - m_scaleY = fabs(m_scaleX); - else - m_scaleY = -fabs(m_scaleX); - dy = (m_scaleY - oldScaleY) * (m_endPos.y() - m_org_cenY); - } - } - } - - if(m_function == LEFTSCALE) - { - dx = (newX - m_scaleX * (m_startPos.x() - m_org_cenX)) / 2; - m_scaleX = (newX - dx) / (m_startPos.x() - m_org_cenX); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleY>0) // handle the mirrored cases - m_scaleY = fabs(m_scaleX); - else - m_scaleY = -fabs(m_scaleX); - } - } - - if(m_function == TOPLEFTSCALE) - { - dx = (newX - m_scaleX * (m_startPos.x() - m_org_cenX)) / 2; - m_scaleX = (newX - dx) / (m_startPos.x() - m_org_cenX); - - dy = (newY - m_scaleY * (m_startPos.y() - m_org_cenY)) / 2; - m_scaleY = (newY - dy) / (m_startPos.y() - m_org_cenY); - - // enforce same acpect if shift button is pressed - if(e->state() & TQt::ShiftButton) - { - if(m_scaleX < m_scaleY) - { - if(m_scaleX>0) // handle the mirrored cases - m_scaleX = fabs(m_scaleY); - else - m_scaleX = -fabs(m_scaleY); - dx = (m_scaleX - oldScaleX) * (m_startPos.x() - m_org_cenX); - } - else - { - if(m_scaleY>0) // handle the mirrored cases - m_scaleY = fabs(m_scaleX); - else - m_scaleY = -fabs(m_scaleX); - dy = (m_scaleY - oldScaleY) * (m_startPos.y() - m_org_cenY); - } - } - } - - m_translateX += rotX(dx, dy); - m_translateY += rotY(dx, dy); - - paintOutline(); - } - else - { - if(det(mousePos - topleft, topright - topleft)>0) - m_function = ROTATE; - else if(det(mousePos - topright, bottomright - topright)>0) - m_function = ROTATE; - else if(det(mousePos - bottomright, bottomleft - bottomright)>0) - m_function = ROTATE; - else if(det(mousePos - bottomleft, topleft - bottomleft)>0) - m_function = ROTATE; - else - m_function = MOVE; - - int handleradius = int( 25 / (m_subject->zoomFactor() * m_subject->zoomFactor()) ); - - if(distsq(mousePos, (m_topleft + m_topright)/2)<=handleradius) - m_function = TOPSCALE; - if(distsq(mousePos, m_topright)<=handleradius) - m_function = TOPRIGHTSCALE; - if(distsq(mousePos, (m_topright + m_bottomright)/2)<=handleradius) - m_function = RIGHTSCALE; - if(distsq(mousePos, m_bottomright)<=handleradius) - m_function = BOTTOMRIGHTSCALE; - if(distsq(mousePos, (m_bottomleft + m_bottomright)/2)<=handleradius) - m_function = BOTTOMSCALE; - if(distsq(mousePos, m_bottomleft)<=handleradius) - m_function = BOTTOMLEFTSCALE; - if(distsq(mousePos, (m_topleft + m_bottomleft)/2)<=handleradius) - m_function = LEFTSCALE; - if(distsq(mousePos, m_topleft)<=handleradius) - m_function = TOPLEFTSCALE; - - setFunctionalCursor(); - } - } -} - -void KisToolTransform::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_subject && e->button() == Qt::LeftButton) { - if(!m_wasPressed) return; - m_wasPressed = false; - - KisImageSP img = m_subject->currentImg(); - - if (!img) - return; - - m_selecting = false; - - if(m_actualyMoveWhileSelected) - { - paintOutline(); - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - transform(); - TQApplication::restoreOverrideCursor(); - } - } -} - -void KisToolTransform::paintOutline() -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - KisCanvas *canvas = controller->kiscanvas(); - KisCanvasPainter gc(canvas); - TQRect rc; - - paintOutline(gc, rc); - } -} - -void KisToolTransform::recalcOutline() -{ - double x,y; - - m_sina = sin(m_a); - m_cosa = cos(m_a); - - x = (m_startPos.x() - m_org_cenX) * m_scaleX; - y = (m_startPos.y() - m_org_cenY) * m_scaleY; - m_topleft = TQPoint(int(rotX(x,y) + m_translateX+0.5), int(rotY(x,y) + m_translateY+0.5)); - - x = (m_endPos.x() - m_org_cenX) * m_scaleX; - y = (m_startPos.y() - m_org_cenY) * m_scaleY; - m_topright = TQPoint(int(rotX(x,y) + m_translateX+0.5), int(rotY(x,y) + m_translateY+0.5)); - - x = (m_startPos.x() - m_org_cenX) * m_scaleX; - y = (m_endPos.y() - m_org_cenY) * m_scaleY; - m_bottomleft = TQPoint(int(rotX(x,y) + m_translateX+0.5), int(rotY(x,y) + m_translateY+0.5)); - - x = (m_endPos.x() - m_org_cenX) * m_scaleX; - y = (m_endPos.y() - m_org_cenY) * m_scaleY; - m_bottomright = TQPoint(int(rotX(x,y) + m_translateX+0.5), int(rotY(x,y) + m_translateY+0.5)); -} - -void KisToolTransform::paintOutline(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::SolidLine); - pen.setWidth(1); - Q_ASSERT(controller); - - recalcOutline(); - TQPoint topleft = controller->windowToView(m_topleft); - TQPoint topright = controller->windowToView(m_topright); - TQPoint bottomleft = controller->windowToView(m_bottomleft); - TQPoint bottomright = controller->windowToView(m_bottomright); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawRect(topleft.x()-4, topleft.y()-4, 8, 8); - gc.drawLine(topleft.x(), topleft.y(), (topleft.x()+topright.x())/2, (topleft.y()+topright.y())/2); - gc.drawRect((topleft.x()+topright.x())/2-4, (topleft.y()+topright.y())/2-4, 8, 8); - gc.drawLine((topleft.x()+topright.x())/2, (topleft.y()+topright.y())/2, topright.x(), topright.y()); - gc.drawRect(topright.x()-4, topright.y()-4, 8, 8); - gc.drawLine(topright.x(), topright.y(), (topright.x()+bottomright.x())/2, (topright.y()+bottomright.y())/2); - gc.drawRect((topright.x()+bottomright.x())/2-4, (topright.y()+bottomright.y())/2-4, 8, 8); - gc.drawLine((topright.x()+bottomright.x())/2, (topright.y()+bottomright.y())/2,bottomright.x(), bottomright.y()); - gc.drawRect(bottomright.x()-4, bottomright.y()-4, 8, 8); - gc.drawLine(bottomright.x(), bottomright.y(), (bottomleft.x()+bottomright.x())/2, (bottomleft.y()+bottomright.y())/2); - gc.drawRect((bottomleft.x()+bottomright.x())/2-4, (bottomleft.y()+bottomright.y())/2-4, 8, 8); - gc.drawLine((bottomleft.x()+bottomright.x())/2, (bottomleft.y()+bottomright.y())/2, bottomleft.x(), bottomleft.y()); - gc.drawRect(bottomleft.x()-4, bottomleft.y()-4, 8, 8); - gc.drawLine(bottomleft.x(), bottomleft.y(), (topleft.x()+bottomleft.x())/2, (topleft.y()+bottomleft.y())/2); - gc.drawRect((topleft.x()+bottomleft.x())/2-4, (topleft.y()+bottomleft.y())/2-4, 8, 8); - gc.drawLine((topleft.x()+bottomleft.x())/2, (topleft.y()+bottomleft.y())/2, topleft.x(), topleft.y()); - gc.setRasterOp(op); - gc.setPen(old); - } -} - -void KisToolTransform::transform() -{ - - KisImageSP img = m_subject->currentImg(); - - if (!img || !img->activeDevice()) - return; - - double tx = m_translateX - rotX(m_org_cenX * m_scaleX, m_org_cenY * m_scaleY); - double ty = m_translateY - rotY(m_org_cenX * m_scaleX, m_org_cenY * m_scaleY); - KisProgressDisplayInterface *progress = m_subject->progressDisplay(); - - // This mementoes the current st