Bug 373249

Summary: Ports on components are not aligned at component border
Product: [Applications] umbrello Reporter: Ralf Habacker <ralf.habacker>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal CC: clushkou, okellogg, ralf.habacker
Priority: NOR    
Version: 2.20.80 (KDE Applications 16.11.80)   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed In: 2.33.80 (KDE releases 22.03.80)
Sentry Crash Report:
Bug Depends on: 371990    
Bug Blocks:    
Attachments: Place Pins/Ports onto parent border
Place ports onto parent border
Place ports onto parent border
Fix placement of Port when resizing parent.
Fix placement of Port when resizing parent - fixed compile error

Description Ralf Habacker 2016-12-04 13:11:43 UTC
According to http://www.uml-diagrams.org/component-diagrams.html component ports are aligned to the outline border of the related component eg.  -----[]-----. 

With recent umbrello versions the ports are displayed outside of the component  e.g _____[]____. This should be fixed.

How to reproduce:
1. Start umbrello
2. Create a new component diagram
3. Add a component
4. Add a port to the component created at 3.

What happens:
The port displayed at the top outline of the component is not vertical aligned 

What is expected:
The port at the top outline of the component should be aligned vertical
Comment 1 Carsten Clever 2016-12-04 16:03:26 UTC
Created attachment 102618 [details]
Place Pins/Ports onto parent border
Comment 2 Ralf Habacker 2016-12-04 16:23:55 UTC
Comment on attachment 102618 [details]
Place Pins/Ports onto parent border

> Place Pin/Ports onto parent border.

Just to be sure: Your patch limits this behavior to ports only as indicated by the title ?  https://de.wikipedia.org/wiki/Pin_(UML) mentions that pins need to be displayed still outside. I guess the class PinPortBase needs to have a protected member to be able to switch on this new behavior only in the derived PortWidget constructor.
Comment 3 Carsten Clever 2016-12-04 20:05:01 UTC
(In reply to #2)
The patch changes PinPortBase, so affects both Components and Activities.
I wasn't aware that they need to be handled differently. I'll rework the patch.
Comment 4 Carsten Clever 2016-12-06 22:06:30 UTC
Created attachment 102655 [details]
Place ports onto parent border

Pins stay attached to outside shape.
Comment 5 Ralf Habacker 2016-12-07 13:09:34 UTC
Comment on attachment 102655 [details]
Place ports onto parent border

Works as expected

Below are some notes relating to code style: 


+#ifndef CHILDWIDGETPLACEMENT_H__

please remove the traling '__

+class ChildWidgetPlacement

can you add some docs to the class and 

+#define CHILDWIDGETPLACEMENTPIN_H__

dito 


+#include <umlwidgets/childwidgetplacement.h>

either 
#include "umlwidgets/childwidgetplacement.h"
or 
#include "childwidgetplacement.h"


+#include <umlwidgets/umlwidget.h>

use "" instead of <> because the related headers are local
Comment 6 Carsten Clever 2016-12-07 19:17:46 UTC
Created attachment 102666 [details]
Place ports onto parent border
Comment 7 Carsten Clever 2016-12-07 19:18:09 UTC
Fix review findings.
Comment 8 Ralf Habacker 2016-12-08 22:25:16 UTC
Git commit d2b7dc0a71e75e2f65f18c0d4f1452bf7544bea5 by Ralf Habacker, on behalf of Carsten Clever.
Committed on 08/12/2016 at 22:25.
Pushed by habacker into branch 'master'.

Place ports onto parent border.

M  +3    -0    umbrello/CMakeLists.txt
A  +64   -0    umbrello/umlwidgets/childwidgetplacement.cpp     [License: GPL (v2+)]
A  +62   -0    umbrello/umlwidgets/childwidgetplacement.h     [License: GPL (v2+)]
A  +148  -0    umbrello/umlwidgets/childwidgetplacementpin.cpp     [License: GPL (v2+)]
A  +47   -0    umbrello/umlwidgets/childwidgetplacementpin.h     [License: GPL (v2+)]
A  +190  -0    umbrello/umlwidgets/childwidgetplacementport.cpp     [License: GPL (v2+)]
A  +36   -0    umbrello/umlwidgets/childwidgetplacementport.h     [License: GPL (v2+)]
M  +23   -115  umbrello/umlwidgets/pinportbase.cpp
M  +5    -18   umbrello/umlwidgets/pinportbase.h

https://commits.kde.org/umbrello/d2b7dc0a71e75e2f65f18c0d4f1452bf7544bea5
Comment 9 Carsten Clever 2016-12-17 12:33:47 UTC
Created attachment 102835 [details]
Fix placement of Port when resizing parent.

When Port is placed on Upper-Right or Lower-Left corner of parent,
it is now moved correctly when the parent is resized.
Comment 10 Ralf Habacker 2016-12-19 17:26:04 UTC
Comment on attachment 102666 [details]
Place ports onto parent border

committed to git master
Comment 11 Ralf Habacker 2016-12-19 17:36:04 UTC
Comment on attachment 102835 [details]
Fix placement of Port when resizing parent.

I applied this patch to recent git master and tried to compile, which fails with the following errors:

/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:49:22: error: assignment of read-only variable ‘newY’
                 newY = minY();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:63:22: error: assignment of read-only variable ‘newY’
                 newY = maxY();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:77:22: error: assignment of read-only variable ‘newX’
                 newX = minX();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:91:22: error: assignment of read-only variable ‘newX’
                 newX = maxX();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:100:22: error: assignment of read-only variable ‘newY’
                 newY = minY();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:104:22: error: assignment of read-only variable ‘newX’
                 newX = minX();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:113:22: error: assignment of read-only variable ‘newY’
                 newY = minY();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:117:22: error: assignment of read-only variable ‘newX’
                 newX = maxX();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:126:22: error: assignment of read-only variable ‘newY’
                 newY = maxY();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:130:22: error: assignment of read-only variable ‘newX’
                 newX = maxX();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:139:22: error: assignment of read-only variable ‘newY’
                 newY = maxY();
                      ^
/home/xxx/src/umbrello-master/umbrello/umlwidgets/childwidgetplacementport.cpp:143:22: error: assignment of read-only variable ‘newX’
                 newX = minX();
                      ^
Comment 12 Carsten Clever 2016-12-19 18:22:15 UTC
Created attachment 102879 [details]
Fix placement of Port when resizing parent - fixed compile error

When Port is placed on Upper-Right or Lower-Left corner of parent,
it is now moved correctly when the parent is resized.
Comment 13 Carsten Clever 2016-12-19 18:23:47 UTC
(In reply to #11)
Indeed - I forgot to rebuild after refactoring. Patch updated.
Comment 14 Ralf Habacker 2016-12-19 19:20:11 UTC
Git commit b4126d84c6f38d07e0b787902ecdd8e2c725f79c by Ralf Habacker, on behalf of Carsten Clever.
Committed on 19/12/2016 at 19:19.
Pushed by habacker into branch 'master'.

Fix placement of Port when resizing parent.

When Port is placed on Upper-Right or Lower-Left corner of parent,
it is now moved correctly when the parent is resized.

M  +96   -47   umbrello/umlwidgets/childwidgetplacementport.cpp
M  +5    -1    umbrello/umlwidgets/childwidgetplacementport.h

https://commits.kde.org/umbrello/b4126d84c6f38d07e0b787902ecdd8e2c725f79c
Comment 15 Ralf Habacker 2019-08-05 14:04:26 UTC
These patches also introduced a previously non-existent problem: The created ports are not located at the cursor position when clicking on the component, but always in the upper left corner.
Comment 16 Oliver Kellogg 2022-02-16 20:09:33 UTC
(In reply to Ralf Habacker from comment #15)
> These patches also introduced a previously non-existent problem: The created
> ports are not located at the cursor position when clicking on the component,
> but always in the upper left corner.

Cannot reproduce this problem with current git master.
The new port is created near the mouse release location, i.e. usually inside the component.
After dragging the port to a component edge, it stays in place and moves in sync with the component.

This was fixed on addressing bug 403692.