After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 314379 - Allow stroking as outline (not with a paint tool) via the PDB
Allow stroking as outline (not with a paint tool) via the PDB
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: libgimp
2.2.x
Other All
: High enhancement
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks: 101604
 
 
Reported: 2005-08-24 12:45 UTC by Lance Dockins
Modified: 2015-11-10 23:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for adding a procedure for libart stroke (7.25 KB, patch)
2009-05-15 09:51 UTC, LightningIsMyName
needs-work Details | Review
A fixed patch - renamed to stroke_line (7.54 KB, patch)
2009-05-16 18:48 UTC, LightningIsMyName
rejected Details | Review

Description Lance Dockins 2005-08-24 12:45:44 UTC
Right now gimp-edit-stroke only allows you to use this procedure with a brush. 
It would be beneficial if gimp-edit-stroke could use the same line-stroke method
that is available if you manually stroke a selection.
Comment 1 LightningIsMyName 2009-04-26 08:55:48 UTC
I tried to add this, and here is my code up to here:

    @inargs = (
	{ name => 'drawable', type => 'drawable',
	  desc => 'The drawable to stroke to' },
	{ name => 'vectors', type => 'vectors',
      desc => 'The vectors object' },
	{ name => 'width', type => 'float'
	  desc => 'The width of the stroke in pixels' },
        { name => 'style', type => 'enum GimpStrokeStyle'
	  desc => 'Fill the stroke with the Foreground color or with a pattern' },
        { name => 'cap_style', type => 'enum GimpCapStyle'
	  desc => "The style of the stroke's cap" },
	{ name => 'join_style', type => 'enum GimpJoinStyle'
	  desc => "The style of the stroke's join" },
	{ name => 'miter_limit', type => 'float'
	  desc => 'Convert a mitered join to a bevelled join if the miter would
	          extend to a distance of more than miter-limit * line-width from
			  the actual join point' },
	{ name => 'dash_offser', type => 'float'
	  desc => "The offset for using the dash array" },
	{ name => 'dash_info', type => 'floatarray'
	  desc => "An array with the dash lengths and space lengths alternatly"
	  array => { type => '2 <= int32',
                 desc => 'Number of lengths to use from the array' } }
    );

    %invoke = (
	headers => [ qw("core/gimpstrokeoptions.h") ],
	code => <<'CODE'
{
  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), error) &&
      gimp_pdb_item_is_attached (GIMP_ITEM (vectors), error))
    {
	  GimpPaintInfo *paint_info;
	  GimpPaintCore *core;
	  GimpStrokeOptions *options;

	  options = gimp_stroke_options_new (gimp, context, TRUE);

  	  g_object_set (options,
                "method", GIMP_STROKE_METHOD_LIBART,
				"width", width,
				"style", style,
				"cap-style", cap_style,
				"join-style", join_style,
				"miter-limit", miter_limit,
				"dash-offset", dash_offset,
                NULL);

	  paint_info = gimp_context_get_paint_info (GIMP_CONTEXT (options));
          core = g_object_new (paint_info->paint_type, NULL);

	  success = gimp_paint_core_stroke_vectors (core, drawable,
                                               options->paint_options,
                                               options->emulate_dynamics,
                                               vectors, error);

      g_object_unref (core);
	  g_object_unref (options);


    }
  else
    success = FALSE;
}
CODE
    );
}


However, I have several questions:
1. Should we combine the option to stroke using a paint tool in the same PDB procedure?
2. How do I convert the float array dash_info into a GValueArray array?!
3. Should I write a similar function for selection stroking or do we want to merge both calls one call (something like gimp-edit-stroke-libart)?
Comment 2 LightningIsMyName 2009-05-15 09:51:57 UTC
Created attachment 134695 [details] [review]
Patch for adding a procedure for libart stroke

This is my patch, which hopefully should work (I can't build GIMP on my computer, so I can't test it).

It adds 2 procedures - gimp_edit_stroke_libart and gimp_edit_stroke_vectors_libart which should be enough (if they work) to close this bug.
Comment 3 Sven Neumann 2009-05-16 17:57:46 UTC
We need a different name for this. GIMP doesn't use libart any longer to render this stroke. Since GIMP 2.6, Cairo is being used. But we should not call it stroke_cairo then. We might switch to a different stroke engine at some point.
Comment 4 LightningIsMyName 2009-05-16 18:48:16 UTC
Created attachment 134772 [details] [review]
A fixed patch - renamed to stroke_line

In that case, I renamed the new procedures to be gimp_edit_stroke_line and edit_stroke_vectors_line (since gimp calls it "Stroke Line" in the stroke dialog).

I also fixed a little bug in my previous patch which forgot to register the procedures at the bottom of the file with all the other procedures.
Comment 5 Sven Neumann 2009-05-17 09:33:10 UTC
Looks OK, but it should be tested first.

If you could create a patch using 'git format-patch', that would make our life easier. But it is not a necessity.
Comment 6 Michael Natterer 2009-05-17 21:48:16 UTC
Looks indeed ok, but IMHO we should use a entirely different approach here.
Just as the paint tool to stroke with can be set via the PDB's context
API, I would prefer to use contect API for this.

You would set the properties of the stroke, (gimp-contect-set-paint-foo)
and then just call gimp-edit-stroke.

Comment 7 LightningIsMyName 2009-05-19 09:53:49 UTC
The paint-tool to stroke with can't be set  via the PDB context in GIMP 2.6 (if it should be, then this is a bug - since calling gimp-context-set-paint-method and the gimp-edit-stroke doesn't change anything). However, by browsing the code I see that it should work in GIMP 2.8.

We must add this to the release notes!
Since I haven't seen any plugin that uses gimp-context-set-paint-method, THIS IS GOING TO BRAKE MANY PLUGINS who stroke in various ways (some of them which are shipped with gimp, such as the frosty-logo script fu).

I'll create a bug report for frosty logo and fix it in a moment (I found some more bugs in it so I'm going to open a report anyway), but I still think it's a bad idea to modify the gimp-edit-stroke...
Comment 8 Sven Neumann 2009-05-20 23:31:12 UTC
The ability to set the paint-tool to stroke with using gimp-context-set-paint-method exists since GIMP 2.4.
Comment 9 LightningIsMyName 2009-05-21 08:25:03 UTC
Nevermind gimp-context-set-paint-method works for me now (it didn't work previously for some reason).

However this wasn't my point - my point is that now We'll have to implement gimp-context-set-stroke-method which means that other plugins that existed before the implentation of this procedure will not necessaraly use the stroke method they meant (since before the implentation of this procedure only one way was available).

If we wish to solver this by implementing this as a part of gimp-context-set-paint-method, it will sound a bit wrong (since we don't really set a paint method - we set a stroke method since it's only relevant for stroking).

In addition, the GimpContext object does not have a GimpStrokeOptions property. This means that in order to make it possible to update the stroke options and only then to stroke, we would need to change GimpContext to implement a GimpStrokeOptions property (and then we would have to replace all the appearances of "gimp_stroke_options_new" with gimp_context_get_stroke_options).

Do we really want to do it this way? (creating gimp-context-set-stroke-foo and then updating the core everywhere?)
Comment 10 Sven Neumann 2009-05-21 17:41:44 UTC
Still sounds like the best solution to me. The context passed to plug-ins will always have the paint-tool set as the stroke method. So this change is not going to change the behavior of any plug-ins.
Comment 11 Michael Natterer 2009-05-21 18:14:27 UTC
Just because the API for plug-ins is called "context" this doesn't mean
all that additional stuff *must* live in the GimpContext object in the
core. Besides, we have discussed APIs for painting and stroking so often
in the past, and doing it this way was the outcome.
Comment 12 Martin Nordholts 2009-07-20 23:49:00 UTC
Changing patch state to reflect feedback.
Comment 13 LightningIsMyName 2009-07-23 09:41:13 UTC
Hello,

I wanted to inform you that I'm currently not working on a patch for this. Modifying the GimpContext object is probably above my knowledge of GIMP's core, and it requires lots of time which I currently don't have.

Since I see this was marked for 2.8, I thought I should inform you that someone else will have to work on it if we want it done for 2.8.
If there will be any change in this, I'll inform you, but right now I don't think I can work on this.
Comment 14 Martin Nordholts 2010-01-23 09:36:46 UTC
Thanks for telling. Moving to Future for now.
Comment 15 Ben Scholzen 2015-11-02 12:14:57 UTC
This has been sitting around for quite long now, is there any update on this?
Comment 16 Michael Natterer 2015-11-08 18:59:46 UTC
No, except you just made it appear on my radar again, and I spend quite
some time thinking about it already. This should be done for 2.10 because 
filling/stroking vector shapes is really a missing basic functionality.
Comment 17 Michael Natterer 2015-11-08 19:01:17 UTC
Comment on attachment 134772 [details] [review]
A fixed patch - renamed to stroke_line

This will be done by setting context properties, not by adding new
dedicated line stroke API.
Comment 18 Michael Natterer 2015-11-09 00:51:43 UTC
This technically fixes the bug, but let's keep the bug open until
all the GimpStrokeOption's properties (line width etc) have their
PDB API.

commit 8fa7bc3622c67313e97664eea87abc696fd4a5ce
Author: Michael Natterer <mitch@gimp.org>
Date:   Mon Nov 9 01:46:07 2015 +0100

    Bug 314379 - Allow stroking as outline (not with a paint tool) via the PDB
    
    Add new PDB procedures gimp-context-get/set-stroke-method and honor
    the new setting in gimp-edit-stroke and gimp-edit-stroke-vectors.
    
    Internally, keep a GimpStrokeOptions around in GimpPDBContext to keep
    track of the newly added PDB state, and use it for the stroke
    operations instead of creating a scratch GimpStrokeOptions.

 app/pdb/context-cmds.c       | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 app/pdb/edit-cmds.c          | 14 ++-------
 app/pdb/gimppdbcontext.c     | 29 ++++++++++++++++++
 app/pdb/gimppdbcontext.h     | 17 ++++++-----
 app/pdb/internal-procs.c     |  2 +-
 libgimp/gimp.def             |  2 ++
 libgimp/gimpcontext_pdb.c    | 63 +++++++++++++++++++++++++++++++++++++++
 libgimp/gimpcontext_pdb.h    |  2 ++
 tools/pdbgen/pdb/context.pdb | 58 ++++++++++++++++++++++++++++++++++++
 tools/pdbgen/pdb/edit.pdb    | 14 ++-------
 10 files changed, 270 insertions(+), 30 deletions(-)
Comment 19 Michael Natterer 2015-11-10 23:50:04 UTC
Fixed in master:

commit 7d1a47a5540629b94737388c27abd4bf99a1e0f7
Author: Michael Natterer <mitch@gimp.org>
Date:   Wed Nov 11 00:47:31 2015 +0100

    Bug 314379 - Allow stroking as outline (not with a paint tool) via the PDB
    
    Add PDB API to configure/query all aspects of line stroking.

 app/pdb/context-cmds.c       | 724 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 app/pdb/internal-procs.c     |   2 +-
 libgimp/gimp.def             |  14 ++
 libgimp/gimpcontext_pdb.c    | 474 +++++++++++++++++++++++++++++++++++++++-
 libgimp/gimpcontext_pdb.h    |  16 ++
 tools/pdbgen/pdb/context.pdb | 495 +++++++++++++++++++++++++++++++++++++++---
 6 files changed, 1695 insertions(+), 30 deletions(-)