[dia] [cleanup] more use of element_update_connections_rectangle()
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [cleanup] more use of element_update_connections_rectangle()
- Date: Sun, 2 Nov 2014 14:11:18 +0000 (UTC)
commit 541f210b3106959ba0c43e57a68ea7045c0be11d
Author: Hans Breuer <hans breuer org>
Date: Sun Nov 2 15:01:22 2014 +0100
[cleanup] more use of element_update_connections_rectangle()
rather than having 27 lines of code pasted for these objects
objects/network/basestation.c | 28 +---------------------------
objects/standard/box.c | 28 +---------------------------
2 files changed, 2 insertions(+), 54 deletions(-)
---
diff --git a/objects/network/basestation.c b/objects/network/basestation.c
index 87be947..91d662c 100644
--- a/objects/network/basestation.c
+++ b/objects/network/basestation.c
@@ -322,33 +322,7 @@ basestation_update_data(Basestation *basestation)
text_calc_boundingbox(basestation->text, &text_box);
/* Update connections: */
- basestation->connections[0].pos.x = elem->corner.x;
- basestation->connections[0].pos.y = elem->corner.y;
- basestation->connections[0].directions = DIR_NORTH|DIR_WEST;
- basestation->connections[1].pos.x = elem->corner.x + elem->width / 2.0;
- basestation->connections[1].pos.y = elem->corner.y;
- basestation->connections[1].directions = DIR_NORTH;
- basestation->connections[2].pos.x = elem->corner.x + elem->width;
- basestation->connections[2].pos.y = elem->corner.y;
- basestation->connections[2].directions = DIR_NORTH|DIR_EAST;
- basestation->connections[3].pos.x = elem->corner.x;
- basestation->connections[3].pos.y = elem->corner.y + elem->height / 2.0;
- basestation->connections[3].directions = DIR_WEST;
- basestation->connections[4].pos.x = elem->corner.x + elem->width;
- basestation->connections[4].pos.y = elem->corner.y + elem->height / 2.0;
- basestation->connections[4].directions = DIR_EAST;
- basestation->connections[5].pos.x = elem->corner.x;
- basestation->connections[5].pos.y = elem->corner.y + elem->height;
- basestation->connections[5].directions = DIR_SOUTH|DIR_WEST;
- basestation->connections[6].pos.x = elem->corner.x + elem->width / 2.0;
- basestation->connections[6].pos.y = elem->corner.y + elem->height;
- basestation->connections[6].directions = DIR_SOUTH;
- basestation->connections[7].pos.x = elem->corner.x + elem->width;
- basestation->connections[7].pos.y = elem->corner.y + elem->height;
- basestation->connections[7].directions = DIR_SOUTH|DIR_EAST;
- basestation->connections[8].pos.x = elem->corner.x + elem->width / 2.0;
- basestation->connections[8].pos.y = elem->corner.y + elem->height / 2.0;
- basestation->connections[8].directions = DIR_ALL;
+ element_update_connections_rectangle (elem, basestation->connections);
element_update_boundingbox(elem);
diff --git a/objects/standard/box.c b/objects/standard/box.c
index e855d02..2992b6a 100644
--- a/objects/standard/box.c
+++ b/objects/standard/box.c
@@ -412,24 +412,7 @@ box_update_data(Box *box)
radius *= (1-M_SQRT1_2);
/* Update connections: */
- box->connections[0].pos.x = elem->corner.x + radius;
- box->connections[0].pos.y = elem->corner.y + radius;
- box->connections[1].pos.x = elem->corner.x + elem->width / 2.0;
- box->connections[1].pos.y = elem->corner.y;
- box->connections[2].pos.x = elem->corner.x + elem->width - radius;
- box->connections[2].pos.y = elem->corner.y + radius;
- box->connections[3].pos.x = elem->corner.x;
- box->connections[3].pos.y = elem->corner.y + elem->height / 2.0;
- box->connections[4].pos.x = elem->corner.x + elem->width;
- box->connections[4].pos.y = elem->corner.y + elem->height / 2.0;
- box->connections[5].pos.x = elem->corner.x + radius;
- box->connections[5].pos.y = elem->corner.y + elem->height - radius;
- box->connections[6].pos.x = elem->corner.x + elem->width / 2.0;
- box->connections[6].pos.y = elem->corner.y + elem->height;
- box->connections[7].pos.x = elem->corner.x + elem->width - radius;
- box->connections[7].pos.y = elem->corner.y + elem->height - radius;
- box->connections[8].pos.x = elem->corner.x + elem->width / 2.0;
- box->connections[8].pos.y = elem->corner.y + elem->height / 2.0;
+ element_update_connections_rectangle (elem, box->connections);
if (box->angle != 0) {
real cx = elem->corner.x + elem->width / 2.0;
@@ -443,15 +426,6 @@ box_update_data(Box *box)
for (i = 0; i < 8; ++i)
transform_point (&box->connections[i].pos, &m);
}
- box->connections[0].directions = DIR_NORTH|DIR_WEST;
- box->connections[1].directions = DIR_NORTH;
- box->connections[2].directions = DIR_NORTH|DIR_EAST;
- box->connections[3].directions = DIR_WEST;
- box->connections[4].directions = DIR_EAST;
- box->connections[5].directions = DIR_SOUTH|DIR_WEST;
- box->connections[6].directions = DIR_SOUTH;
- box->connections[7].directions = DIR_SOUTH|DIR_EAST;
- box->connections[8].directions = DIR_ALL;
extra->border_trans = box->border_width / 2.0;
element_update_boundingbox(elem);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]