Skip to content

Commit

Permalink
Xic: in progress, handle all PCell stretch locations, draw glyph if
Browse files Browse the repository at this point in the history
not on rectangle edge center.
  • Loading branch information
wrcad committed Sep 6, 2019
1 parent e8e16d5 commit 4261e99
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 18 deletions.
14 changes: 13 additions & 1 deletion xic/include/grip.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
#ifndef GRIP_H
#define GRIP_H

// Ciranova Location enum.
enum cnLocation {
CN_LL, // lower_left
CN_CL, // center left
CN_UL, // upper_left
CN_LC, // lower_center
CN_CC, // center_center
CN_UC, // upper_center
CN_LR, // lower_right
CN_CR, // center_right
CN_UR // upper_right
};

// This struct holds parameters obtained from parsing a Ciranova
// stretch handle property. We will follow this methodology in Xic.
Expand Down Expand Up @@ -86,7 +98,7 @@ struct sCniGripDesc
double gd_maxval; // Parameter maximum value.
double gd_scale; // Scale factgor for parameter value.
double gd_snap; // Snap grid for parameter value.
int gd_loc; // Object active edge: 0-3 for LBRT.
cnLocation gd_loc; // Object active edge/ grip location.
bool gd_absolute; // True if increment measured with absolute
// coordinates, otherwise increment is
// meaasured relative to object center.
Expand Down
9 changes: 8 additions & 1 deletion xic/src/display/dsp_mark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4576,7 +4576,13 @@ sMark_Fence::show(WindowDesc *wdesc, bool display)
int x1, y1, x2, y2;
wdesc->LToP(mX, mY, x1, y1);
wdesc->LToP(mEndX, mEndY, x2, y2);
if (x1 == x2) {
if (x1 == x2 && y1 == y2) {
show_line(wdesc, x1-3, y1, x1, y1+3);
show_line(wdesc, x1, y1+3, x1+3, y1);
show_line(wdesc, x1+3, y1, x1, y1-3);
show_line(wdesc, x1, y1-3, x1-3, y1);
}
else if (x1 == x2) {
show_line(wdesc, x1-1, y1, x1-1, y2);
show_line(wdesc, x1+1, y1, x1+1, y2);
}
Expand All @@ -4585,6 +4591,7 @@ sMark_Fence::show(WindowDesc *wdesc, bool display)
show_line(wdesc, x1, y1+1, x2, y1+1);
}
else {
// shouldn't get here
show_line(wdesc, x1, y1, x2, y2);
}
}
Expand Down
72 changes: 56 additions & 16 deletions xic/src/edit/grip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ sCniGripDesc::sCniGripDesc()
gd_maxval = 0.0;
gd_scale = 1.0;
gd_snap = 0.0;
gd_loc = 0;
gd_loc = CN_LL;
gd_absolute = false;
gd_vert = false;
}
Expand Down Expand Up @@ -489,14 +489,24 @@ sCniGripDesc::parse(const char **pstr)
char *t = tok;
if (lstring::ciprefix("location:", t))
t += strlen("location:");
if (!strcasecmp(t, "lower_left"))
gd_loc = CN_LL;
if (!strcasecmp(t, "center_left"))
gd_loc = 0; // L
gd_loc = CN_CL; // L
if (!strcasecmp(t, "upper_left"))
gd_loc = CN_UL;
else if (!strcasecmp(t, "lower_center"))
gd_loc = 1; // B
else if (!strcasecmp(t, "center_right"))
gd_loc = 2; // R
gd_loc = CN_LC; // B
else if (!strcasecmp(t, "center_center"))
gd_loc = CN_CC;
else if (!strcasecmp(t, "upper_center"))
gd_loc = 3; // T
gd_loc = CN_UC; // T
else if (!strcasecmp(t, "lower_right"))
gd_loc = CN_LR;
else if (!strcasecmp(t, "center_right"))
gd_loc = CN_CR; // R
else if (!strcasecmp(t, "upper_right"))
gd_loc = CN_UR;
else {
Errs()->add_error("Unsupported location \"%s\".", t);
delete [] tok;
Expand Down Expand Up @@ -708,30 +718,60 @@ sGrip::setup(const sCniGripDesc &gd, const BBox &BB)

int x1, y1, x2, y2;
switch (gd_loc) {
default:
case 0: // L
case CN_LL:
x1 = BB.left;
y1 = BB.bottom;
x2 = BB.left;
y2 = BB.bottom;
break;
case CN_CL: // L
x1 = BB.left;
y1 = BB.top;
x2 = x1;
x2 = BB.left;
y2 = BB.bottom;
break;
case 1: // B
case CN_UL:
x1 = BB.left;
y1 = BB.top;
x2 = BB.left;
y2 = BB.top;
break;
case CN_LC: // B
x1 = BB.left;
y1 = BB.bottom;
x2 = BB.right;
y2 = y1;
y2 = BB.bottom;
break;
case 2: // R
default:
case CN_CC:
x1 = (BB.left + BB.right)/2;
y1 = (BB.bottom + BB.top)/2;
x2 = (BB.left + BB.right)/2;
y2 = (BB.bottom + BB.top)/2;
break;
case CN_UC: // T
x1 = BB.right;
y1 = BB.top;
x2 = BB.left;
y2 = BB.top;
break;
case CN_LR:
x1 = BB.right;
y1 = BB.bottom;
x2 = x1;
x2 = BB.right;
y2 = BB.bottom;
break;
case CN_CR: // R
x1 = BB.right;
y1 = BB.bottom;
x2 = BB.right;
y2 = BB.top;
break;
case 3: // T
case CN_UR:
x1 = BB.right;
y1 = BB.top;
x2 = BB.left;
y2 = y1;
x2 = BB.right;
y2 = BB.top;
break;
}

Expand Down

0 comments on commit 4261e99

Please sign in to comment.