+ bool freeBorder[4]; // 0 = east, 1 = north, 2 = west, 3 = south
+ Parameters::Direction dirs[4];
+ for(int i=0;i<4;i++) {
+ freeBorder[i] = true;
+ }
+ dirs[0] = Parameters::East;
+ dirs[1] = Parameters::North;
+ dirs[2] = Parameters::West;
+ dirs[3] = Parameters::South;
+
+
+ if (position == Top) {
+ freeBorder[1] = false;
+ }
+ if (position == Bottom) {
+ freeBorder[3] = false;
+ }
+ if (position == Left) {
+ freeBorder[2] = false;
+ }
+ if (position == Right) {
+ freeBorder[0] = false;
+ }
+ if (span == HSpan) {
+ freeBorder[2] = false;
+ freeBorder[0] = false;
+ }
+ if (span == VSpan) {
+ freeBorder[1] = false;
+ freeBorder[3] = false;
+ }
+ Parameters::Direction dIn = Parameters::West;
+ Parameters::Direction dOut = Parameters::East;
+ Parameters::Direction dBi = Parameters::South;
+ if (freeBorder[2] == false) {
+ int i=3;
+ while (freeBorder[i] == false) {
+ i = (i+1)%4;
+ }
+ dIn = dirs[i];
+ }
+ if (freeBorder[0] == false) {
+ int i=1;
+ while (freeBorder[i] == false) {
+ i = (i+1)%4;
+ }
+ dOut = dirs[i];
+ }
+ if (freeBorder[3] == false) {
+ int i=0;
+ while (freeBorder[i] == false) {
+ i = (i+1)%4;
+ }
+ dBi = dirs[i];
+ }
+
+ createInterfaceItems(dIn,dOut,dBi);
+ updateGeometry(Creation);
+
+ // position the item
+ int groupWidth = getScene()->getGroupItem()->getWidth();
+ int groupHeight = getScene()->getGroupItem()->getHeight();
+ double xx = 0.0,yy = 0.0;
+ if ((position == BoxItem::Left) || (position == BoxItem::TopLeft) || (position == BoxItem::BottomLeft)) {
+ xx = 0;
+ if ((span == VSpan) || (position == BoxItem::TopLeft)) {
+ yy = 0;
+ }
+ else if (position == BoxItem::BottomLeft) {
+ yy = groupHeight-totalHeight;
+ }
+ else {
+ yy = (groupHeight-totalHeight)/2.0;
+ }
+ }
+ else if ((position == BoxItem::Right) || (position == BoxItem::TopRight) || (position == BoxItem::BottomRight)) {
+ xx = groupWidth-totalWidth;
+ if (xx < 0) xx = 0;
+ if ((span == VSpan) || (position == BoxItem::TopRight)) {
+ yy = 0;
+ }
+ else if (position == BoxItem::BottomRight) {
+ yy = groupHeight-totalHeight;
+ }
+ else {
+ yy = (groupHeight-totalHeight)/2.0;
+ }
+ }
+ else if ((position == BoxItem::Top) || (position == BoxItem::TopLeft) || (position == BoxItem::TopRight)) {
+ yy = 0;
+ if ((span == HSpan) || (position == BoxItem::TopLeft)) {
+ xx = 0;
+ }
+ else if (position == BoxItem::TopRight) {
+ xx = groupWidth-totalWidth;
+ }
+ else {
+ xx = (groupWidth-totalWidth)/2.0;
+ }
+ }
+ else if ((position == BoxItem::Bottom) || (position == BoxItem::BottomLeft) || (position == BoxItem::BottomRight)) {
+ yy = groupHeight-totalHeight;
+ if ((span == HSpan) || (position == BoxItem::BottomLeft)) {
+ xx = 0;
+ }
+ else if (position == BoxItem::BottomRight) {
+ xx = groupWidth-totalWidth;
+ }
+ else {
+ xx = (groupWidth-totalWidth)/2.0;
+ }
+ }
+ else {
+ int marginConn = 2*(params->arrowWidth+params->arrowLineLength);
+ xx = (groupWidth-totalWidth)/2.0;
+ if (xx < marginConn) xx = marginConn;
+ yy = (groupHeight-totalHeight)/2.0;
+ if (yy < marginConn) yy = marginConn;
+ }
+ cout << "setting raw pos to " << xx << "," << yy << endl;
+ QPointF initPos(xx,yy);
+ initPos = initPos-originPoint;