︙ | | | ︙ | |
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
"wrong # coordinates: expected at least 4, got %d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
return TCL_ERROR;
}
numPoints = objc/2;
if (linePtr->numPoints != numPoints) {
coordPtr = ckalloc(sizeof(double) * objc);
if (linePtr->coordPtr != NULL) {
ckfree(linePtr->coordPtr);
}
linePtr->coordPtr = coordPtr;
linePtr->numPoints = numPoints;
}
coordPtr = linePtr->coordPtr;
|
|
|
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
"wrong # coordinates: expected at least 4, got %d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
return TCL_ERROR;
}
numPoints = objc/2;
if (linePtr->numPoints != numPoints) {
coordPtr = (double *)ckalloc(sizeof(double) * objc);
if (linePtr->coordPtr != NULL) {
ckfree(linePtr->coordPtr);
}
linePtr->coordPtr = coordPtr;
linePtr->numPoints = numPoints;
}
coordPtr = linePtr->coordPtr;
|
︙ | | | ︙ | |
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
static void
DeleteLine(
Tk_Canvas canvas, /* Info about overall canvas widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
Display *display) /* Display containing window for canvas. */
{
LineItem *linePtr = (LineItem *) itemPtr;
Tk_DeleteOutline(display, &linePtr->outline);
if (linePtr->coordPtr != NULL) {
ckfree(linePtr->coordPtr);
}
if (linePtr->arrowGC != NULL) {
Tk_FreeGC(display, linePtr->arrowGC);
|
>
|
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
|
static void
DeleteLine(
Tk_Canvas canvas, /* Info about overall canvas widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
Display *display) /* Display containing window for canvas. */
{
LineItem *linePtr = (LineItem *) itemPtr;
(void)canvas;
Tk_DeleteOutline(display, &linePtr->outline);
if (linePtr->coordPtr != NULL) {
ckfree(linePtr->coordPtr);
}
if (linePtr->arrowGC != NULL) {
Tk_FreeGC(display, linePtr->arrowGC);
|
︙ | | | ︙ | |
839
840
841
842
843
844
845
846
847
848
849
850
851
852
|
{
LineItem *linePtr = (LineItem *) itemPtr;
XPoint staticPoints[MAX_STATIC_POINTS*3];
XPoint *pointPtr;
double linewidth;
int numPoints;
Tk_State state = itemPtr->state;
if (!linePtr->numPoints || (linePtr->outline.gc == NULL)) {
return;
}
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
|
>
>
>
>
|
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
|
{
LineItem *linePtr = (LineItem *) itemPtr;
XPoint staticPoints[MAX_STATIC_POINTS*3];
XPoint *pointPtr;
double linewidth;
int numPoints;
Tk_State state = itemPtr->state;
(void)x;
(void)y;
(void)width;
(void)height;
if (!linePtr->numPoints || (linePtr->outline.gc == NULL)) {
return;
}
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
|
︙ | | | ︙ | |
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
|
} else {
numPoints = linePtr->numPoints;
}
if (numPoints <= MAX_STATIC_POINTS) {
pointPtr = staticPoints;
} else {
pointPtr = ckalloc(numPoints * 3 * sizeof(XPoint));
}
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, pointPtr, NULL);
} else {
numPoints = TkCanvTranslatePath((TkCanvas *) canvas, numPoints,
|
|
|
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
|
} else {
numPoints = linePtr->numPoints;
}
if (numPoints <= MAX_STATIC_POINTS) {
pointPtr = staticPoints;
} else {
pointPtr = (XPoint *)ckalloc(numPoints * 3 * sizeof(XPoint));
}
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, pointPtr, NULL);
} else {
numPoints = TkCanvTranslatePath((TkCanvas *) canvas, numPoints,
|
︙ | | | ︙ | |
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
|
linePtr->coordPtr[0] = linePtr->firstArrowPtr[0];
linePtr->coordPtr[1] = linePtr->firstArrowPtr[1];
}
if (linePtr->lastArrowPtr != NULL) {
linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0];
linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
}
newCoordPtr = ckalloc(sizeof(double) * (length + objc));
for (i=0; i<beforeThis; i++) {
newCoordPtr[i] = linePtr->coordPtr[i];
}
for (i=0; i<objc; i++) {
if (Tcl_GetDoubleFromObj(NULL, objv[i],
&newCoordPtr[i + beforeThis]) != TCL_OK) {
Tcl_ResetResult(Canvas(canvas)->interp);
|
|
|
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
|
linePtr->coordPtr[0] = linePtr->firstArrowPtr[0];
linePtr->coordPtr[1] = linePtr->firstArrowPtr[1];
}
if (linePtr->lastArrowPtr != NULL) {
linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0];
linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
}
newCoordPtr = (double *)ckalloc(sizeof(double) * (length + objc));
for (i=0; i<beforeThis; i++) {
newCoordPtr[i] = linePtr->coordPtr[i];
}
for (i=0; i<objc; i++) {
if (Tcl_GetDoubleFromObj(NULL, objv[i],
&newCoordPtr[i + beforeThis]) != TCL_OK) {
Tcl_ResetResult(Canvas(canvas)->interp);
|
︙ | | | ︙ | |
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
|
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static double
LineToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against point. */
double *pointPtr) /* Pointer to x and y coordinates. */
{
Tk_State state = itemPtr->state;
|
<
|
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
|
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static double
LineToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against point. */
double *pointPtr) /* Pointer to x and y coordinates. */
{
Tk_State state = itemPtr->state;
|
︙ | | | ︙ | |
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
|
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
numPoints = linePtr->smooth->coordProc(canvas, NULL,
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
if (numPoints <= MAX_STATIC_POINTS) {
linePoints = staticSpace;
} else {
linePoints = ckalloc(2 * numPoints * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
} else {
numPoints = linePtr->numPoints;
linePoints = linePtr->coordPtr;
}
|
|
|
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
|
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
numPoints = linePtr->smooth->coordProc(canvas, NULL,
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
if (numPoints <= MAX_STATIC_POINTS) {
linePoints = staticSpace;
} else {
linePoints = (double *)ckalloc(2 * numPoints * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
} else {
numPoints = linePtr->numPoints;
linePoints = linePtr->coordPtr;
}
|
︙ | | | ︙ | |
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
|
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static int
LineToArea(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against line. */
double *rectPtr)
{
LineItem *linePtr = (LineItem *) itemPtr;
|
<
|
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
|
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static int
LineToArea(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against line. */
double *rectPtr)
{
LineItem *linePtr = (LineItem *) itemPtr;
|
︙ | | | ︙ | |
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
|
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
numPoints = linePtr->smooth->coordProc(canvas, NULL,
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
if (numPoints <= MAX_STATIC_POINTS) {
linePoints = staticSpace;
} else {
linePoints = ckalloc(2 * numPoints * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
} else {
numPoints = linePtr->numPoints;
linePoints = linePtr->coordPtr;
}
|
|
|
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
|
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
numPoints = linePtr->smooth->coordProc(canvas, NULL,
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
if (numPoints <= MAX_STATIC_POINTS) {
linePoints = staticSpace;
} else {
linePoints = (double *)ckalloc(2 * numPoints * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
} else {
numPoints = linePtr->numPoints;
linePoints = linePtr->coordPtr;
}
|
︙ | | | ︙ | |
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
|
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item for which the index is being
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
int *indexPtr) /* Where to store converted index. */
{
LineItem *linePtr = (LineItem *) itemPtr;
const char *string = Tcl_GetString(obj);
if (string[0] == 'e') {
if (strncmp(string, "end", obj->length) == 0) {
*indexPtr = 2*linePtr->numPoints;
} else {
goto badIndex;
}
} else if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
char *end;
const char *p;
p = string+1;
x = strtod(p, &end);
|
>
|
>
>
|
|
>
|
>
>
>
>
>
|
>
|
|
|
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
|
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item for which the index is being
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
int *indexPtr) /* Where to store converted index. */
{
TkSizeT idx, length;
LineItem *linePtr = (LineItem *) itemPtr;
const char *string;
(void)canvas;
if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 0, &idx)) {
if (idx == TCL_INDEX_NONE) {
idx = 0;
} else if (idx > (2*(TkSizeT)linePtr->numPoints)) {
idx = 2*linePtr->numPoints;
} else {
idx &= (TkSizeT)-2; /* If index is odd, make it even. */
}
*indexPtr = (int)idx;
return TCL_OK;
}
string = TkGetStringFromObj(obj, &length);
if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
char *end;
const char *p;
p = string+1;
x = strtod(p, &end);
|
︙ | | | ︙ | |
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
|
if (dist < bestDist) {
bestDist = dist;
*indexPtr = 2*i;
}
coordPtr += 2;
}
} else {
if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
goto badIndex;
}
*indexPtr &= -2; /* If index is odd, make it even. */
if (*indexPtr < 0){
*indexPtr = 0;
} else if (*indexPtr > (2*linePtr->numPoints)) {
*indexPtr = (2*linePtr->numPoints);
}
}
return TCL_OK;
/*
* Some of the paths here leave messages in interp->result, so we have to
* clear it out before storing our own message.
*/
badIndex:
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
return TCL_ERROR;
}
/*
*--------------------------------------------------------------
*
* TranslateLine --
*
|
<
<
|
<
<
<
<
<
<
<
<
<
|
|
|
|
|
<
|
|
|
>
>
|
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
|
if (dist < bestDist) {
bestDist = dist;
*indexPtr = 2*i;
}
coordPtr += 2;
}
} else {
/*
* Some of the paths here leave messages in interp->result, so we have to
* clear it out before storing our own message.
*/
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* TranslateLine --
*
|
︙ | | | ︙ | |
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
|
*
* Side effects:
* Arrow information in recordPtr is updated.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static int
ParseArrowShape(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Window tkwin, /* Not used. */
const char *value, /* Textual specification of arrow shape. */
char *recordPtr, /* Pointer to item record in which to store
* arrow information. */
int offset) /* Offset of shape information in widget
* record. */
{
LineItem *linePtr = (LineItem *) recordPtr;
double a, b, c;
int argc;
const char **argv = NULL;
if ((size_t)offset != offsetof(LineItem, arrowShapeA)) {
Tcl_Panic("ParseArrowShape received bogus offset");
}
if (Tcl_SplitList(interp, (char *) value, &argc, &argv) != TCL_OK) {
goto syntaxError;
|
<
|
>
>
|
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
|
*
* Side effects:
* Arrow information in recordPtr is updated.
*
*--------------------------------------------------------------
*/
static int
ParseArrowShape(
ClientData dummy, /* Not used. */
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Window tkwin, /* Not used. */
const char *value, /* Textual specification of arrow shape. */
char *recordPtr, /* Pointer to item record in which to store
* arrow information. */
int offset) /* Offset of shape information in widget
* record. */
{
LineItem *linePtr = (LineItem *) recordPtr;
double a, b, c;
int argc;
const char **argv = NULL;
(void)dummy;
(void)tkwin;
if ((size_t)offset != offsetof(LineItem, arrowShapeA)) {
Tcl_Panic("ParseArrowShape received bogus offset");
}
if (Tcl_SplitList(interp, (char *) value, &argc, &argv) != TCL_OK) {
goto syntaxError;
|
︙ | | | ︙ | |
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
|
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static const char *
PrintArrowShape(
ClientData clientData, /* Not used. */
Tk_Window tkwin, /* Window associated with linePtr's widget. */
char *recordPtr, /* Pointer to item record containing current
* shape information. */
int offset, /* Offset of arrow information in record. */
Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free
* string here. */
{
LineItem *linePtr = (LineItem *) recordPtr;
char *buffer = ckalloc(120);
sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA,
linePtr->arrowShapeB, linePtr->arrowShapeC);
*freeProcPtr = TCL_DYNAMIC;
return buffer;
}
|
<
|
|
>
>
>
|
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
|
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static const char *
PrintArrowShape(
ClientData dummy, /* Not used. */
Tk_Window tkwin, /* Window associated with linePtr's widget. */
char *recordPtr, /* Pointer to item record containing current
* shape information. */
int offset, /* Offset of arrow information in record. */
Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free
* string here. */
{
LineItem *linePtr = (LineItem *) recordPtr;
char *buffer = (char *)ckalloc(120);
(void)dummy;
(void)tkwin;
(void)offset;
sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA,
linePtr->arrowShapeB, linePtr->arrowShapeC);
*freeProcPtr = TCL_DYNAMIC;
return buffer;
}
|
︙ | | | ︙ | |
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
|
* value argument.
*
*--------------------------------------------------------------
*/
static int
ArrowParseProc(
ClientData clientData, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
{
int c;
size_t length;
register Arrows *arrowPtr = (Arrows *) (widgRec + offset);
if (value == NULL || *value == 0) {
*arrowPtr = ARROWS_NONE;
return TCL_OK;
}
c = value[0];
|
|
<
|
>
>
|
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
|
* value argument.
*
*--------------------------------------------------------------
*/
static int
ArrowParseProc(
ClientData dummy, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
{
int c;
size_t length;
Arrows *arrowPtr = (Arrows *) (widgRec + offset);
(void)dummy;
(void)tkwin;
if (value == NULL || *value == 0) {
*arrowPtr = ARROWS_NONE;
return TCL_OK;
}
c = value[0];
|
︙ | | | ︙ | |
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
|
* None.
*
*--------------------------------------------------------------
*/
static const char *
ArrowPrintProc(
ClientData clientData, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
register Arrows *arrowPtr = (Arrows *) (widgRec + offset);
switch (*arrowPtr) {
case ARROWS_FIRST:
return "first";
case ARROWS_LAST:
return "last";
case ARROWS_BOTH:
|
|
|
>
>
>
|
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
|
* None.
*
*--------------------------------------------------------------
*/
static const char *
ArrowPrintProc(
ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
Arrows *arrowPtr = (Arrows *) (widgRec + offset);
(void)dummy;
(void)tkwin;
(void)freeProcPtr;
switch (*arrowPtr) {
case ARROWS_FIRST:
return "first";
case ARROWS_LAST:
return "last";
case ARROWS_BOTH:
|
︙ | | | ︙ | |
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
|
* firstArrowPtr and lastArrowPtr polygons are allocated and initialized,
* if need be, and the end points of the line are adjusted so that a
* thick line doesn't stick out past the arrowheads.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static int
ConfigureArrows(
Tk_Canvas canvas, /* Canvas in which arrows will be displayed
* (interp and tkwin fields are needed). */
LineItem *linePtr) /* Item to configure for arrows. */
{
double *poly, *coordPtr;
|
<
|
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
|
* firstArrowPtr and lastArrowPtr polygons are allocated and initialized,
* if need be, and the end points of the line are adjusted so that a
* thick line doesn't stick out past the arrowheads.
*
*--------------------------------------------------------------
*/
static int
ConfigureArrows(
Tk_Canvas canvas, /* Canvas in which arrows will be displayed
* (interp and tkwin fields are needed). */
LineItem *linePtr) /* Item to configure for arrows. */
{
double *poly, *coordPtr;
|
︙ | | | ︙ | |
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
|
*/
fracHeight = (width/2.0)/shapeC;
backup = fracHeight*shapeB + shapeA*(1.0 - fracHeight)/2.0;
if (linePtr->arrow != ARROWS_LAST) {
poly = linePtr->firstArrowPtr;
if (poly == NULL) {
poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double));
poly[0] = poly[10] = linePtr->coordPtr[0];
poly[1] = poly[11] = linePtr->coordPtr[1];
linePtr->firstArrowPtr = poly;
}
dx = poly[0] - linePtr->coordPtr[2];
dy = poly[1] - linePtr->coordPtr[3];
length = hypot(dx, dy);
|
|
|
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
|
*/
fracHeight = (width/2.0)/shapeC;
backup = fracHeight*shapeB + shapeA*(1.0 - fracHeight)/2.0;
if (linePtr->arrow != ARROWS_LAST) {
poly = linePtr->firstArrowPtr;
if (poly == NULL) {
poly = (double *)ckalloc(2 * PTS_IN_ARROW * sizeof(double));
poly[0] = poly[10] = linePtr->coordPtr[0];
poly[1] = poly[11] = linePtr->coordPtr[1];
linePtr->firstArrowPtr = poly;
}
dx = poly[0] - linePtr->coordPtr[2];
dy = poly[1] - linePtr->coordPtr[3];
length = hypot(dx, dy);
|
︙ | | | ︙ | |
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
|
* Similar arrowhead calculation for the last point of the line.
*/
if (linePtr->arrow != ARROWS_FIRST) {
coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2);
poly = linePtr->lastArrowPtr;
if (poly == NULL) {
poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double));
poly[0] = poly[10] = coordPtr[2];
poly[1] = poly[11] = coordPtr[3];
linePtr->lastArrowPtr = poly;
}
dx = poly[0] - coordPtr[0];
dy = poly[1] - coordPtr[1];
length = hypot(dx, dy);
|
|
|
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
|
* Similar arrowhead calculation for the last point of the line.
*/
if (linePtr->arrow != ARROWS_FIRST) {
coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2);
poly = linePtr->lastArrowPtr;
if (poly == NULL) {
poly = (double *)ckalloc(2 * PTS_IN_ARROW * sizeof(double));
poly[0] = poly[10] = coordPtr[2];
poly[1] = poly[11] = coordPtr[3];
linePtr->lastArrowPtr = poly;
}
dx = poly[0] - coordPtr[0];
dy = poly[1] - coordPtr[1];
length = hypot(dx, dy);
|
︙ | | | ︙ | |
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
|
int style;
double width;
XColor *color;
Pixmap stipple;
Tk_State state = itemPtr->state;
Tcl_Obj *psObj;
Tcl_InterpState interpState;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
width = linePtr->outline.width;
color = linePtr->outline.color;
|
>
|
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
|
int style;
double width;
XColor *color;
Pixmap stipple;
Tk_State state = itemPtr->state;
Tcl_Obj *psObj;
Tcl_InterpState interpState;
(void)prepass;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
width = linePtr->outline.width;
color = linePtr->outline.color;
|
︙ | | | ︙ | |
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
|
double *pointPtr;
int numPoints;
numPoints = linePtr->smooth->coordProc(canvas, NULL,
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
pointPtr = staticPoints;
if (numPoints > MAX_STATIC_POINTS) {
pointPtr = ckalloc(numPoints * 2 * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr);
Tk_CanvasPsPath(interp, canvas, pointPtr, numPoints);
if (pointPtr != staticPoints) {
ckfree(pointPtr);
}
|
|
|
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
|
double *pointPtr;
int numPoints;
numPoints = linePtr->smooth->coordProc(canvas, NULL,
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
pointPtr = staticPoints;
if (numPoints > MAX_STATIC_POINTS) {
pointPtr = (double *)ckalloc(numPoints * 2 * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr);
Tk_CanvasPsPath(interp, canvas, pointPtr, numPoints);
if (pointPtr != staticPoints) {
ckfree(pointPtr);
}
|
︙ | | | ︙ | |