summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-04-15 19:05:14 (GMT)
committerjoye <joye>2014-04-15 19:05:14 (GMT)
commitc7750f7bc01b1ba30caee48a2ab237697988c2dc (patch)
tree88cc8550f1b6f91436712f90680a7bcdb73b5e9c
parent65775139542a4541f41f400724cc683a9edc8262 (diff)
downloadblt-c7750f7bc01b1ba30caee48a2ab237697988c2dc.zip
blt-c7750f7bc01b1ba30caee48a2ab237697988c2dc.tar.gz
blt-c7750f7bc01b1ba30caee48a2ab237697988c2dc.tar.bz2
*** empty log message ***
-rw-r--r--src/bltConfig.C40
-rw-r--r--src/bltConfig.h3
-rw-r--r--src/bltGrHairs.C21
-rw-r--r--src/bltGrHairs.h3
-rw-r--r--src/bltGrMisc.C35
-rw-r--r--src/bltGrMisc.h4
-rw-r--r--src/bltGrPSOutput.C11
-rw-r--r--src/bltGraph.h1
-rw-r--r--tests/crosshairs.tcl8
9 files changed, 39 insertions, 87 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C
index 1c838fd..8cb5666 100644
--- a/src/bltConfig.C
+++ b/src/bltConfig.C
@@ -38,8 +38,6 @@
#include <stdarg.h>
-#include "bltC.h"
-
extern "C" {
#include "bltInt.h"
};
@@ -59,44 +57,6 @@ const char* fillObjOption[] = {"none", "x", "y", "both", NULL};
// State
const char* stateObjOption[] = {"normal", "active", "disabled", NULL};
-// Point
-static Tk_CustomOptionSetProc PointSetProc;
-static Tk_CustomOptionGetProc PointGetProc;
-Tk_ObjCustomOption pointObjOption =
- {
- "point", PointSetProc, PointGetProc, NULL, NULL, NULL
- };
-
-static int PointSetProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
- int offset, char* save, int flags)
-{
- XPoint* pointPtr = (XPoint*)(widgRec + offset);
-
- int x, y;
- if (Blt_GetXY(interp, tkwin, Tcl_GetString(*objPtr), &x, &y) != TCL_OK)
- return TCL_ERROR;
-
- pointPtr->x = x;
- pointPtr->y = y;
-
- return TCL_OK;
-};
-
-static Tcl_Obj* PointGetProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset)
-{
- XPoint* pointPtr = (XPoint*)(widgRec + offset);
-
- if ((pointPtr->x != -SHRT_MAX) && (pointPtr->y != -SHRT_MAX)) {
- char string[200];
- sprintf_s(string, 200, "@%d,%d", pointPtr->x, pointPtr->y);
- return Tcl_NewStringObj(string, -1);
- }
- else
- return Tcl_NewStringObj("", -1);
-};
-
// Dashes
static Tk_CustomOptionSetProc DashesSetProc;
static Tk_CustomOptionGetProc DashesGetProc;
diff --git a/src/bltConfig.h b/src/bltConfig.h
index bb6d4d0..4bb0ce5 100644
--- a/src/bltConfig.h
+++ b/src/bltConfig.h
@@ -47,7 +47,6 @@ typedef struct {
#define LineIsDashed(d) ((d).values[0] != 0)
-extern Tk_ObjCustomOption pointObjOption;
extern Tk_ObjCustomOption dashesObjOption;
extern Tk_ObjCustomOption listObjOption;
@@ -57,4 +56,4 @@ extern "C" {
extern void Blt_SetDashes (Display *display, GC gc, Blt_Dashes *dashesPtr);
-#endif /* BLT_CONFIG_H */
+#endif
diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C
index 87401a1..fd8991e 100644
--- a/src/bltGrHairs.C
+++ b/src/bltGrHairs.C
@@ -49,24 +49,21 @@ static Tk_OptionSpec optionSpecs[] = {
"yes", -1, Tk_Offset(CrosshairsOptions, hide), 0, NULL, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "Linewidth",
"0", -1, Tk_Offset(CrosshairsOptions, lineWidth), 0, NULL, 0},
- {TK_OPTION_CUSTOM, "-position", "position", "Position",
- NULL, -1, Tk_Offset(CrosshairsOptions, hotSpot),
- TK_OPTION_NULL_OK, &pointObjOption, 0},
+ {TK_OPTION_PIXELS, "-x", "x", "X",
+ "0", -1, Tk_Offset(CrosshairsOptions, x), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-y", "y", "Y",
+ "0", -1, Tk_Offset(CrosshairsOptions, y), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
Crosshairs::Crosshairs(Graph* graphPtr)
{
ops_ = (CrosshairsOptions*)calloc(1, sizeof(CrosshairsOptions));
- CrosshairsOptions* ops = (CrosshairsOptions*)ops_;
graphPtr_ = graphPtr;
visible_ =0;
gc_ =NULL;
- ops->hotSpot.x =-1;
- ops->hotSpot.y =-1;
-
optionTable_ = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
Tk_InitOptions(graphPtr->interp, (char*)ops_, optionTable_, graphPtr->tkwin);
}
@@ -116,12 +113,12 @@ void Crosshairs::configure()
gc_ = newGC;
// Are the new coordinates on the graph?
- segArr_[0].x1 = ops->hotSpot.x;
- segArr_[0].x2 = ops->hotSpot.x;
+ segArr_[0].x1 = ops->x;
+ segArr_[0].x2 = ops->x;
segArr_[0].y1 = graphPtr_->bottom;
segArr_[0].y2 = graphPtr_->top;
- segArr_[1].y1 = ops->hotSpot.y;
- segArr_[1].y2 = ops->hotSpot.y;
+ segArr_[1].y1 = ops->y;
+ segArr_[1].y2 = ops->y;
segArr_[1].x1 = graphPtr_->left;
segArr_[1].x2 = graphPtr_->right;
@@ -143,7 +140,7 @@ void Crosshairs::on()
CrosshairsOptions* ops = (CrosshairsOptions*)ops_;
if (Tk_IsMapped(graphPtr_->tkwin) && (!visible_)) {
- if (!PointInGraph(graphPtr_, ops->hotSpot.x, ops->hotSpot.y))
+ if (!PointInGraph(graphPtr_, ops->x, ops->y))
return;
XDrawSegments(graphPtr_->display, Tk_WindowId(graphPtr_->tkwin),
diff --git a/src/bltGrHairs.h b/src/bltGrHairs.h
index a330b0d..a7307f6 100644
--- a/src/bltGrHairs.h
+++ b/src/bltGrHairs.h
@@ -47,7 +47,8 @@ typedef struct {
Blt_Dashes dashes;
int hide;
int lineWidth;
- XPoint hotSpot;
+ int x;
+ int y;
} CrosshairsOptions;
class Crosshairs {
diff --git a/src/bltGrMisc.C b/src/bltGrMisc.C
index 244352e..0213aaf 100644
--- a/src/bltGrMisc.C
+++ b/src/bltGrMisc.C
@@ -29,52 +29,43 @@
#include <stdarg.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include "bltC.h"
-
extern "C" {
#include "bltInt.h"
#include "bltGraph.h"
};
-// Converts a string in the form "@x,y" into an XPoint structure of the x
-// and y coordinates.
int Blt_GetXY(Tcl_Interp* interp, Tk_Window tkwin, const char* string,
int* xPtr, int* yPtr)
{
- char *comma;
- int result;
- int x, y;
-
if ((string == NULL) || (*string == '\0')) {
*xPtr = *yPtr = -SHRT_MAX;
return TCL_OK;
}
+
if (*string != '@') {
- goto badFormat;
+ Tcl_AppendResult(interp, "bad position \"", string,
+ "\": should be \"@x,y\"", (char *)NULL);
+ return TCL_ERROR;
}
- comma = (char*)strchr(string + 1, ',');
+
+ char *comma = (char*)strchr(string + 1, ',');
if (comma == NULL) {
- goto badFormat;
}
+
*comma = '\0';
- result = ((Tk_GetPixels(interp, tkwin, string + 1, &x) == TCL_OK) &&
- (Tk_GetPixels(interp, tkwin, comma + 1, &y) == TCL_OK));
+ int x, y;
+ int result = ((Tk_GetPixels(interp, tkwin, string + 1, &x) == TCL_OK) &&
+ (Tk_GetPixels(interp, tkwin, comma + 1, &y) == TCL_OK));
*comma = ',';
if (!result) {
Tcl_AppendResult(interp, ": can't parse position \"", string, "\"",
(char *)NULL);
return TCL_ERROR;
}
- *xPtr = x, *yPtr = y;
- return TCL_OK;
- badFormat:
- Tcl_AppendResult(interp, "bad position \"", string,
- "\": should be \"@x,y\"", (char *)NULL);
- return TCL_ERROR;
+ *xPtr = x;
+ *yPtr = y;
+ return TCL_OK;
}
int Blt_PointInPolygon(Point2d *s, Point2d *points, int nPoints)
diff --git a/src/bltGrMisc.h b/src/bltGrMisc.h
index 5d21f58..4c2e8e3 100644
--- a/src/bltGrMisc.h
+++ b/src/bltGrMisc.h
@@ -40,6 +40,10 @@
#include <tkInt.h>
#endif
+typedef struct {
+ Point2d p, q;
+} Segment2d;
+
extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts,
int nScreenPts);
extern int Blt_GetXY(Tcl_Interp* interp, Tk_Window tkwin,
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index 5076afd..f6af644 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -30,12 +30,6 @@
#include <stdarg.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-
-#include "bltC.h"
-
extern "C" {
#include <tkPort.h>
#include <tkInt.h>
@@ -46,6 +40,11 @@ extern "C" {
extern "C" {
#include "bltInt.h"
+};
+
+#include "bltGrMisc.h"
+
+extern "C" {
#include "bltPsInt.h"
};
diff --git a/src/bltGraph.h b/src/bltGraph.h
index 4955ddf..e832e56 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -31,6 +31,7 @@
#define __BltGraph_h__
#include "bltInt.h"
+#include "bltGrMisc.h"
#include "bltBind.h"
#include "bltChain.h"
#include "bltPs.h"
diff --git a/tests/crosshairs.tcl b/tests/crosshairs.tcl
index ee4da4c..e0a0926 100644
--- a/tests/crosshairs.tcl
+++ b/tests/crosshairs.tcl
@@ -6,14 +6,14 @@ set graph [bltLineGraph $w]
echo "Testing Crosshairs..."
$graph crosshairs configure -hide no
-$graph crosshairs configure -position "@200,200"
+$graph crosshairs configure -x 200 -y 200
bltTest2 $graph crosshairs -color green
-bltTest2 $graph crosshairs -dashes "dashdot"
-bltTest2 $graph crosshairs -dashes "5 8 3"
+bltTest2 $graph crosshairs -dashes "8 3"
bltTest2 $graph crosshairs -hide yes
bltTest2 $graph crosshairs -linewidth 3
-bltTest2 $graph crosshairs -position "@100,100"
+bltTest2 $graph crosshairs -x 100
+bltTest2 $graph crosshairs -y 100
bltCmd $graph crosshairs cget -color
bltCmd $graph crosshairs configure