Bug 295600 - Umbrello should be able to export diagrams to graphviz dot format
Summary: Umbrello should be able to export diagrams to graphviz dot format
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Other
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-09 11:58 UTC by Ralf Habacker
Modified: 2012-05-31 12:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Added diagram dot export support. (12.27 KB, patch)
2012-03-09 12:04 UTC, Ralf Habacker
Details
Added state widget type selection to dot generator. (3.74 KB, patch)
2012-03-09 12:05 UTC, Ralf Habacker
Details
Made graphviz generator configurable. (2.82 KB, patch)
2012-03-09 12:05 UTC, Ralf Habacker
Details
Made dot node attributes overridable through config file. (2.39 KB, patch)
2012-03-09 12:06 UTC, Ralf Habacker
Details
Made nodes of state diagram dot export looking better. (1.82 KB, patch)
2012-03-09 12:06 UTC, Ralf Habacker
Details
Added config file for class dot export. (1.95 KB, patch)
2012-03-09 12:07 UTC, Ralf Habacker
Details
Added overriding of dot edges attributes through config file entries (1.55 KB, patch)
2012-03-09 12:07 UTC, Ralf Habacker
Details
Made state diagram dot export looking much better. (1.79 KB, patch)
2012-03-09 12:08 UTC, Ralf Habacker
Details
PNG output of generator with all association types supported by umbrello (34.71 KB, image/png)
2012-03-10 17:11 UTC, Oliver Kellogg
Details
Console debug and error messages on applying layout (2.14 KB, text/plain)
2012-03-10 17:18 UTC, Oliver Kellogg
Details
attachment 69475 after horizontal layout, umbrello diagram exported as picture (685.05 KB, image/bmp)
2012-03-11 09:51 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2012-03-09 11:58:35 UTC
User-Agent:       Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Build Identifier: 

Umbrello should be able to export diagrams to the graphviz dot format. 


Reproducible: Always

Steps to Reproduce:
1. Open or draw a diagram 
2. right click on a diagram and select export diagram to ... 
3. There is not dot file type support 
Actual Results:  
dot export is not possible

Expected Results:  
dot export should be possible 

Recent umbrello contains a dot file generator for automatic diagram layout. 
This generator could also be used to extend umbrello's export file formats with graphviz dot format.
Comment 1 Ralf Habacker 2012-03-09 12:04:56 UTC
Created attachment 69409 [details]
Added diagram dot export support.
Comment 2 Ralf Habacker 2012-03-09 12:05:23 UTC
Created attachment 69410 [details]
Added state widget type selection to dot generator.
Comment 3 Ralf Habacker 2012-03-09 12:05:45 UTC
Created attachment 69411 [details]
Made graphviz generator configurable.
Comment 4 Ralf Habacker 2012-03-09 12:06:10 UTC
Created attachment 69412 [details]
Made dot node attributes overridable through config file.
Comment 5 Ralf Habacker 2012-03-09 12:06:35 UTC
Created attachment 69413 [details]
Made nodes of state diagram dot export looking better.
Comment 6 Ralf Habacker 2012-03-09 12:07:02 UTC
Created attachment 69414 [details]
Added config file for class dot export.
Comment 7 Ralf Habacker 2012-03-09 12:07:44 UTC
Created attachment 69415 [details]
Added overriding of dot edges attributes through config file entries
Comment 8 Ralf Habacker 2012-03-09 12:08:16 UTC
Created attachment 69416 [details]
Made state diagram dot export looking much better.
Comment 9 Ralf Habacker 2012-03-09 12:15:10 UTC
For people having git there is an easier way to fetch this changes by cloning a temporary git repository, to which I pushed these patches. 

run 
1. checkout kdesdk with svn 
2. enter kdesdk 
3. rename subdir umbrello to something else 
4. clone git repo 
    git clone git://gitorious.org/umbrello/test.git umbrello
5. enter subdir umbrello
6. checkout dot-export branch 
     git checkout -b dot-export test/dot-export
Comment 10 Oliver Kellogg 2012-03-10 12:03:06 UTC
(In reply to comment #9)
> For people having git there is an easier way to fetch this changes by
> cloning a temporary git repository, to which I pushed these patches. 
> 
> [...]
> 6. checkout dot-export branch 
>      git checkout -b dot-export test/dot-export

Hmm.. I followed your steps but on this last one git gives me an error:
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'test/dot-export' which can not be resolved as commit?
Comment 11 Ralf Habacker 2012-03-10 12:36:48 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > For people having git there is an easier way to fetch this changes by
> > cloning a temporary git repository, to which I pushed these patches. 
> > 
> > [...]
> > 6. checkout dot-export branch 
> >      git checkout -b dot-export test/dot-export
> 
> Hmm.. I followed your steps but on this last one git gives me an error:
> fatal: git checkout: updating paths is incompatible with switching branches.
> Did you intend to checkout 'test/dot-export' which can not be resolved as
> commit?

I copied this statement from the gitorious repository site. 

Here is what i did recently 
git clone git://gitorious.org/umbrello/test.git test 
cd test
git checkout -b dot-export origin/dot-export

The difference is to use 'origin/dot-export' instead of 'test/dot-export'
Comment 12 Oliver Kellogg 2012-03-10 17:11:23 UTC
Created attachment 69459 [details]
PNG output of generator with all association types supported by umbrello

(In reply to comment #11)
> [...]
> Here is what i did recently 
> git clone git://gitorious.org/umbrello/test.git test 
> cd test
> git checkout -b dot-export origin/dot-export
> 
> The difference is to use 'origin/dot-export' instead of 'test/dot-export'

Thanks, that works for me now.
The attachment shows that all association types are rendered correctly except Containment.
(Class A is nested inside package Pkg and so there should be a containment association between those two.)
Comment 13 Oliver Kellogg 2012-03-10 17:18:26 UTC
Created attachment 69463 [details]
Console debug and error messages on applying layout

However, the diagram displays that I'm seeing in Umbrello don't look right.
In fact, as seen in the attached log of the console messages, many of the computed coordinates are negative.
Does your implementation consider that the Qt coordinate system has its origin at the top left corner (i.e. the Y axis grows "downward") ?
Comment 14 Ralf Habacker 2012-03-10 17:29:51 UTC
(In reply to comment #13)
> Created attachment 69463 [details]
> Console debug and error messages on applying layout
> 
> However, the diagram displays that I'm seeing in Umbrello don't look right.
> In fact, as seen in the attached log of the console messages, many of the
> computed coordinates are negative.
Need to be inspected. As workaround set in the related config file

[X-UMBRELLO-Dot-Settings]
origin=50,50
to a higher value for example 
origin=200,50

> Does your implementation consider that the Qt coordinate system has its
> origin at the top left corner (i.e. the Y axis grows "downward") ?
yes see origin(..)
       QPoint p(m_origin.x() + r.x() - r.width()/2, m_boundingRect.height() - r.y() + r.height()/2 + m_origin.y());
Comment 15 Oliver Kellogg 2012-03-10 18:28:16 UTC
(In reply to comment #14)
> > [...]
> > In fact, as seen in the attached log of the console messages, many of the
> > computed coordinates are negative.
> Need to be inspected. As workaround set in the related config file
> 
> [X-UMBRELLO-Dot-Settings]
> origin=50,50
> to a higher value for example 
> origin=200,50

Did that - but umbrello did not pick up the changed value.
So I just modified the initial value of m_origin in the LayoutGenerator constructor.
And now at least I can see all classes on the diagram.

> yes see origin(..)
> QPoint p(m_origin.x() + r.x() - r.width()/2,
>         m_boundingRect.height() - r.y() + r.height()/2 + m_origin.y());

I did a little debugging and I see some small values for r.x() but larger values for r.width() - which explains why the x coordinate turns out negative when m_origin is not large enough.
Example: m_origin.x() = 50, r.x() = 20 , r.width() = 200
Comment 16 Ralf Habacker 2012-03-10 19:51:10 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > > [...]
> > > In fact, as seen in the attached log of the console messages, many of the
> > > computed coordinates are negative.
> > Need to be inspected. As workaround set in the related config file
> > 
> > [X-UMBRELLO-Dot-Settings]
> > origin=50,50
> > to a higher value for example 
> > origin=200,50
> 
> Did that - but umbrello did not pick up the changed value.
Are using the correct file ? 
I added a debug message with the loaded file, please run 

git pull origin 

to get this and some more fixes. 

> So I just modified the initial value of m_origin in the LayoutGenerator
> constructor.
> And now at least I can see all classes on the diagram.
> 
> > yes see origin(..)
> > QPoint p(m_origin.x() + r.x() - r.width()/2,
> >         m_boundingRect.height() - r.y() + r.height()/2 + m_origin.y());
> 
> I did a little debugging and I see some small values for r.x() but larger
> values for r.width() - which explains why the x coordinate turns out
> negative when m_origin is not large enough.
> Example: m_origin.x() = 50, r.x() = 20 , r.width() = 200
Comment 17 Oliver Kellogg 2012-03-10 20:52:29 UTC
(In reply to comment #16)
> > [...]
> > Did that - but umbrello did not pick up the changed value.
> Are using the correct file ? 
> I added a debug message with the loaded file, [...]

Thanks, that helped:
DotGenerator::readConfigFile: reading config file "/usr/share/kde4/apps/umbrello/layouts/class-horizontal.desktop"

As I could now verify it's picking up the right file, I looked further and found there are two members m_origin defined, one in DotGenerator but one more in LayoutGenerator.
Looking closer at the LayoutGenerator state members, I find that m_origin and m_scale are already present in DotGenerator. IMHO the ones in LayoutGenerator should be removed.
Comment 18 Ralf Habacker 2012-03-10 20:57:13 UTC
(In reply to comment #17)
> (In reply to comment #16)
> > > [...]
> > > Did that - but umbrello did not pick up the changed value.
> > Are using the correct file ? 
> > I added a debug message with the loaded file, [...]
> 
> Thanks, that helped:
> DotGenerator::readConfigFile: reading config file
> "/usr/share/kde4/apps/umbrello/layouts/class-horizontal.desktop"
> 
> As I could now verify it's picking up the right file, I looked further and
> found there are two members m_origin defined, one in DotGenerator but one
> more in LayoutGenerator.
> Looking closer at the LayoutGenerator state members, I find that m_origin
> and m_scale are already present in DotGenerator. IMHO the ones in
> LayoutGenerator should be removed

Thanks for this pointer - i will remove it.
Comment 19 Ralf Habacker 2012-03-11 07:13:52 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > (In reply to comment #14)
> > > > [...]
> > > > In fact, as seen in the attached log of the console messages, many of the
> > > > computed coordinates are negative.
> > > Need to be inspected. As workaround set in the related config file
> > > 
> > > [X-UMBRELLO-Dot-Settings]
> > > origin=50,50
> > > to a higher value for example 
> > > origin=200,50
> > 
> > Did that - but umbrello did not pick up the changed value.
> Are using the correct file ? 
> I added a debug message with the loaded file, please run 
> 
> git pull origin 
> 
> to get this and some more fixes. 
> 
> > So I just modified the initial value of m_origin in the LayoutGenerator
> > constructor.
> > And now at least I can see all classes on the diagram.
> > 
> > > yes see origin(..)
> > > QPoint p(m_origin.x() + r.x() - r.width()/2,
> > >         m_boundingRect.height() - r.y() + r.height()/2 + m_origin.y());
> > 
> > I did a little debugging and I see some small values for r.x() but larger
> > values for r.width() - which explains why the x coordinate turns out
> > negative when m_origin is not large enough.
> > Example: m_origin.x() = 50, r.x() = 20 , r.width() = 200

The negative coordinates comes from the "conteinment" text label which seems to be placed on the left outside of the diagram. To which association you added this label ? Can you send in the related xmi file ?
Comment 20 Ralf Habacker 2012-03-11 08:19:16 UTC
SVN commit 1284923 by habacker:

Removed obsolate members.


 M  +0 -3      layoutgenerator.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1284923
Comment 21 Oliver Kellogg 2012-03-11 09:51:24 UTC
Created attachment 69487 [details]
attachment 69475 [details] after horizontal layout, umbrello diagram exported as picture

(In reply to comment #19)
>  [...]
> The negative coordinates comes from the "conteinment" text label which seems
> to be placed on the left outside of the diagram. To which association you
> added this label ? Can you send in the related xmi file ?

See attachment 69475 [details] at bug 67059. In the comment, I said:
> Applying vertical layout to this class diagram shows a few overlaps in the
> association names.
I am talking about the umbrello diagram not the dot generated PNG file.
The dot generated PNGs that I've seen were MUCH better than the umbrello diagrams.
Marking attachment 69459 [details] as obsoleted by the current attachment because 69459 is the dot output, not the umbrello output.
Comment 22 Ralf Habacker 2012-03-11 15:06:20 UTC
(In reply to comment #21)
> Created attachment 69487 [details]
> attachment 69475 [details] after horizontal layout, umbrello diagram
> exported as picture
> 
> (In reply to comment #19)
> >  [...]
> > The negative coordinates comes from the "conteinment" text label which seems
> > to be placed on the left outside of the diagram. To which association you
> > added this label ? Can you send in the related xmi file ?
> 
> See attachment 69475 [details] at bug 67059. In the comment, I said:
> > Applying vertical layout to this class diagram shows a few overlaps in the
> > association names.
> I am talking about the umbrello diagram not the dot generated PNG file.
> The dot generated PNGs that I've seen were MUCH better than the umbrello
> diagrams.

The reason was that labels are not transfered to the dot file. This is fixes in the gitorious  dot-export branch. 

The remaining overlapping problems are caused by Associationline position magic as far as I can see. 

BTW: Should i merge this branch into trunk, so that all stuff is in trunk ?
Comment 23 Oliver Kellogg 2012-03-11 16:28:01 UTC
(In reply to comment #22)
> > [...]
> > See attachment 69475 [details] at bug 67059. In the comment, I said:
> > > Applying vertical layout to this class diagram shows a few overlaps in the
> > > association names.
> > I am talking about the umbrello diagram not the dot generated PNG file.
> > The dot generated PNGs that I've seen were MUCH better than the umbrello
> > diagrams.
> 
> The reason was that labels are not transferred to the dot file. This is fixed
> in the gitorious  dot-export branch. 

Cool.

> BTW: Should i merge this branch into trunk, so that all stuff is in trunk ?

As far I'm concerned: Positively.
Comment 24 Andi Fischer 2012-03-11 17:28:48 UTC
Am 11.03.2012 16:06, schrieb Ralf Habacker:
> https://bugs.kde.org/show_bug.cgi?id=295600
>
> --- Comment #22 from Ralf Habacker<ralf.habacker@gmail.com>  ---
> (In reply to comment #21)
>> Created attachment 69487 [details]
>> attachment 69475 [details] after horizontal layout, umbrello diagram
>> exported as picture
>>
>> (In reply to comment #19)
>>>   [...]
>>> The negative coordinates comes from the "conteinment" text label which seems
>>> to be placed on the left outside of the diagram. To which association you
>>> added this label ? Can you send in the related xmi file ?
>> See attachment 69475 [details] at bug 67059. In the comment, I said:
>>> Applying vertical layout to this class diagram shows a few overlaps in the
>>> association names.
>> I am talking about the umbrello diagram not the dot generated PNG file.
>> The dot generated PNGs that I've seen were MUCH better than the umbrello
>> diagrams.
> The reason was that labels are not transfered to the dot file. This is fixes in
> the gitorious  dot-export branch.
>
> The remaining overlapping problems are caused by Associationline position magic
> as far as I can see.
>
> BTW: Should i merge this branch into trunk, so that all stuff is in trunk ?
>
Yes - yes - yes,  please.
Comment 25 Ralf Habacker 2012-03-17 08:13:26 UTC
(In reply to comment #24)
> Am 11.03.2012 16:06, schrieb Ralf Habacker:
> > https://bugs.kde.org/show_bug.cgi?id=295600
> >
> > --- Comment #22 from Ralf Habacker<ralf.habacker@gmail.com>  ---
> > The remaining overlapping problems are caused by Associationline position magic
> > as far as I can see.

Seems more to be an issue in AssociationWidget. Found that comment there 
   /** TODO:
        sometimes the x/y values get numbers of <0 and >10000 - which
        is probably due to a bug somewhere in calculating the
        position.  ->workaround till problem is found: define min and
        max limits => if x or y is outside of interval, the position
        is reset ( e.g. by AssociationWidget::resetTextPositions() )
     */> >
Comment 26 Ralf Habacker 2012-03-17 08:28:48 UTC
SVN commit 1285949 by habacker:

Use filled junction state widget on state diagram dot export.


 M  +3 -3      state-export.desktop  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1285949
Comment 27 Ralf Habacker 2012-03-17 09:49:24 UTC
SVN commit 1286041 by habacker:

Use neato generator for state diagram dot export and auto layout, which
gives better layouts.

Related: bug 67059

 M  +3 -3      state-export.desktop  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286041
Comment 28 Ralf Habacker 2012-03-19 11:49:56 UTC
SVN commit 1286276 by habacker:

Made ActivityWidget, StateWidget and SignalWidget type string
accessable by dot export and layout generator config.

Related: bug 67059

 M  +12 -3     dotgenerator.cpp  
 M  +8 -0      widgets/activitywidget.cpp  
 M  +4 -1      widgets/activitywidget.h  
 M  +8 -0      widgets/signalwidget.cpp  
 M  +4 -0      widgets/signalwidget.h  
 M  +8 -0      widgets/statewidget.cpp  
 M  +1 -6      widgets/statewidget.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286276
Comment 29 Ralf Habacker 2012-03-19 11:50:06 UTC
SVN commit 1286277 by habacker:

Added id::type::default to dot export and layout generator config,
which is used in case no explicit id::type::... setting is present.

Related: bug 67059

 M  +11 -2     dotgenerator.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286277
Comment 30 Ralf Habacker 2012-03-19 12:08:06 UTC
SVN commit 1286278 by habacker:

Added layout config for activitiy diagrams.

A few widgets (box, text, region, not anchored notes)
could not be placed correctly yet because off missing links.

For example when placing widgets into a box, the box do not
have any relation to the contained widgets. It would help if
umbrello would track this "visual" containment with an
(probably invisible) association.
For not anchored widgets an invisible "nearest widget" assocation
will help too.

Related: bug 67059

 A             activity-export.desktop  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286278