{"action":"created","issue":{"url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/issues/47","repository_url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals","labels_url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/issues/47/comments","events_url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/issues/47/events","html_url":"https://github.com/qgis/QGIS-Enhancement-Proposals/issues/47","id":114028662,"number":47,"title":"QEP 28: Label connectors","user":{"login":"mhugo","id":1618556,"avatar_url":"https://avatars.githubusercontent.com/u/1618556?v=3","gravatar_id":"","url":"https://api.github.com/users/mhugo","html_url":"https://github.com/mhugo","followers_url":"https://api.github.com/users/mhugo/followers","following_url":"https://api.github.com/users/mhugo/following{/other_user}","gists_url":"https://api.github.com/users/mhugo/gists{/gist_id}","starred_url":"https://api.github.com/users/mhugo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhugo/subscriptions","organizations_url":"https://api.github.com/users/mhugo/orgs","repos_url":"https://api.github.com/users/mhugo/repos","events_url":"https://api.github.com/users/mhugo/events{/privacy}","received_events_url":"https://api.github.com/users/mhugo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/labels/Final%20Draft","name":"Final Draft","color":"eb6420"},{"url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/labels/Type/Software","name":"Type/Software","color":"fef2c0"}],"state":"open","locked":false,"assignee":{"login":"mhugo","id":1618556,"avatar_url":"https://avatars.githubusercontent.com/u/1618556?v=3","gravatar_id":"","url":"https://api.github.com/users/mhugo","html_url":"https://github.com/mhugo","followers_url":"https://api.github.com/users/mhugo/followers","following_url":"https://api.github.com/users/mhugo/following{/other_user}","gists_url":"https://api.github.com/users/mhugo/gists{/gist_id}","starred_url":"https://api.github.com/users/mhugo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhugo/subscriptions","organizations_url":"https://api.github.com/users/mhugo/orgs","repos_url":"https://api.github.com/users/mhugo/repos","events_url":"https://api.github.com/users/mhugo/events{/privacy}","received_events_url":"https://api.github.com/users/mhugo/received_events","type":"User","site_admin":false},"milestone":null,"comments":19,"created_at":"2015-10-29T11:17:40Z","updated_at":"2016-03-18T15:33:38Z","closed_at":null,"body":"========================================================================\r\nQGIS Enhancement 28: Label connectors\r\n========================================================================\r\n\r\n**Date** October 2015\r\n**Author** Hugo Mercier\r\n**Contact** hugo dot mercier at oslandia dot com\r\n**Last Edited** \r\n**Status**  \r\n**Version** QGIS 2.14\r\n\r\nSummary\r\n-------\r\n\r\nThis proposal is aiming at adding to the labeling display engine the possibility for the user to define\r\n\"connectors\" between labels and the features they label.\r\n\r\nCurrent state\r\n-------------\r\n\r\nThe current version of QGIS allows to manually place labels when the output of the automatic placement mechanism is not enough.\r\n\r\nIt relies on \"data defined\" properties. Indeed, the X and Y positions of a label as well as its rotation angle can be defined by a data column or any expression.\r\n\r\nSome graphical controls allow then to manually manipulate these properties. The state of a label can be changed from being automatically placed to being manually placed (pinning/unpinning). When they are pinned, labels can then be moved or rotated by interaction of the user. Positions and rotations data are then updated in columns of the layer.\r\n\r\nProposed improvements\r\n---------------------\r\n\r\nIt may be desirable to have visual \"connectors\" between the label and the feature it refers to. They are a generalization of \"arrows\", as it can be found in drawing programs: single arrows, straight lines or curves. Connectors are \"attached\" to a label: if one of the two endings (either the label or the feature) is moved, the shape of the connector is recomputed and a display refresh is needed.\r\n\r\nThis QEP is not meant to give an exhaustive list of possible connectors. The idea is to have a generic implementation with the most common types of connectors and everything needed in the code to be able to add new types in the future.\r\n\r\nPossible types of connectors:\r\n- a straight line\r\n- two connected straight lines, with an horizontal part and a free part\r\n- three connected straight lines, with two horizontal parts and a vertical part\r\n- a curve with one bending point\r\n- a curve with two bending points\r\n\r\n![Connector types](https://raw.githubusercontent.com/mhugo/QGIS-Enhancement-Proposals/adv_labeling/connector_types.jpg)\r\n\r\nTo actually draw the connectors, additional properties (aside X and Y position) are needed like:\r\n- style of the line (plain, dotted, dashed, etc.)\r\n- thickness of the line\r\n- color of the line\r\n- presence of arrow heads on both ends\r\n- style of the arrow heads\r\n- size of the arrow heads (absolute or relative)\r\n- color of the arrow heads\r\n\r\nPlacement of the two ends also need additional properties:\r\n- position of the ending on the side of the label, with different options\r\n  - simple positioning: up, down, right, left, center, etc.\r\n    - for each possible position, an optional x/y offset may be specified\r\n  - \"intelligent\" quadrant positioning (see below)\r\n- position of the ending on the side of the feature:\r\n  - for points: it targets the point in itself and an x/y offset may be specified\r\n  - for lines: beginning, middle, center\r\n    -  for each possible position, an optional x/y offset may be specified\r\n  - for polygons: top-left, top-right, bottom-left, bottom-right, centroid of the polygon or on the border\r\n    -  for each possible position, an optional x/y offset may be specified\r\n\r\nIllustration of the \"intelligent\" quadrant positioning. The positioning on the side of the label depends on the position on the side of the feature. It is chosen in order to minimize the length / complexity of the connector.\r\n![Intelligent quadrant positioning](https://cloud.githubusercontent.com/assets/1629853/10848034/370e3abe-7f1a-11e5-87d9-e68f61f06530.png)\r\n\r\nCertain types of connectors may also need specific properties like coordinates of the control points for curves (Bézier or B-splines). Coordinates of control points can only be data-defined or defined by 'null' which will make the display engine use 'best' coordinates.\r\n\r\nConnector must be drawn with respect to the current **map canvas rotation**. If parts of the connector is supposed to be drawn \"straight\" (horizontally or vertically), they must be updated when the canvas is rotated\r\n\r\nImplementation details\r\n----------------------\r\n\r\nConnectors are drawn to the Qt canvas, using the QPainter API. The existing symbology code will be reused when possible.\r\nIn particular, lines of the connector will be drawn thanks to a QgsLineSymbolV2 with properly defined symbol layers (QgsMarkerLineSymbolLayerV2 for instance for head and tails)\r\n\r\nThe following classes / methods would be modified:\r\n- QgsVectorLayerLabelProvider : \r\n  - extract necessary property values and data-defined values for connectors\r\n  - draw connectors\r\n- QgsLabelFeature: new attributes for connectors\r\n\r\nGUI Changes\r\n-----------\r\n\r\nThe labeling part of the \"properties\" dialog of a layer will need a new entry for connector-related properties. These properties will be available only if X and Y positions are data-defined (i.e. manual placement). The User Interface for properties of connectors will be in the same style of what is found for line symbols.\r\n\r\n(UI sketchup, not the final one)\r\n![Connector style](https://raw.githubusercontent.com/mhugo/QGIS-Enhancement-Proposals/adv_labeling/connector_properties.png)\r\n\r\nSome new symbol layers dedicated to connectors will be added, similar to this one:\r\n![Connector symbol layer](https://raw.githubusercontent.com/mhugo/QGIS-Enhancement-Proposals/adv_labeling/connector_symbol_layer.png)\r\n\r\nEach of the property could also be data-defined (not represented here).\r\n\r\nFrom the user perspective, new tools will be available to easily manipulate label connectors. To be consistent with current label manual placement toolboxes, new controls will be added to manually place control points for connector types that need them.\r\n\r\nOptionally, it would be nice for the user to be able to edit per-connector properties, i.e. properties that are data-defined via a GUI dialog. This could be achieved by reusing the connector properties dialog and connecting it to one particular feature.\r\n\r\nAutomatic creation of connectors\r\n----------------------------------------\r\n\r\nA new labeling option will allow to automatically create a label connector if the label is manually placed at some distance from its feature.\r\nAutomatic creation of fields for the handling of connector properties would be provided through the use of auxiliary fields (see corresponding QEP), meaning it would be transparent for the user to move a label from its automatic placement and see a connector appear (with default options)\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/issues/comments/198410769","html_url":"https://github.com/qgis/QGIS-Enhancement-Proposals/issues/47#issuecomment-198410769","issue_url":"https://api.github.com/repos/qgis/QGIS-Enhancement-Proposals/issues/47","id":198410769,"user":{"login":"haubourg","id":1629853,"avatar_url":"https://avatars.githubusercontent.com/u/1629853?v=3","gravatar_id":"","url":"https://api.github.com/users/haubourg","html_url":"https://github.com/haubourg","followers_url":"https://api.github.com/users/haubourg/followers","following_url":"https://api.github.com/users/haubourg/following{/other_user}","gists_url":"https://api.github.com/users/haubourg/gists{/gist_id}","starred_url":"https://api.github.com/users/haubourg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haubourg/subscriptions","organizations_url":"https://api.github.com/users/haubourg/orgs","repos_url":"https://api.github.com/users/haubourg/repos","events_url":"https://api.github.com/users/haubourg/events{/privacy}","received_events_url":"https://api.github.com/users/haubourg/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T15:33:38Z","updated_at":"2016-03-18T15:33:38Z","body":"@nyalldawson @mhugo  Hi guys, I may have not understood things well, but currently user do not have to rotate marker angle manually to draw an arrow. A simple line + a symbol maker line on end point with rotation option enabled does the trick\r\n\r\nSaving a few default \"arrow\" styles in symbol library could be enough. "}}