summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bltGrMarkerBitmap.C7
-rw-r--r--bltGrMarkerBitmap.h71
-rwxr-xr-xconfigure1
-rwxr-xr-xconfigure.in1
-rw-r--r--src/bltGrMarker.C9
-rw-r--r--src/bltGrMarker.h105
-rw-r--r--src/bltGrMarkerLine.C7
-rw-r--r--src/bltGrMarkerLine.h68
-rw-r--r--src/bltGrMarkerOp.C187
-rw-r--r--src/bltGrMarkerOp.h22
-rw-r--r--src/bltGrMarkerOption.C212
-rw-r--r--src/bltGrMarkerOption.h39
-rw-r--r--src/bltGrMarkerPolygon.C7
-rw-r--r--src/bltGrMarkerPolygon.h82
-rw-r--r--src/bltGrMarkerText.C5
-rw-r--r--src/bltGrMarkerText.h66
-rw-r--r--src/bltGraph.C2
17 files changed, 471 insertions, 420 deletions
diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C
index afdb049..c7a9bdd 100644
--- a/bltGrMarkerBitmap.C
+++ b/bltGrMarkerBitmap.C
@@ -27,16 +27,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-extern "C" {
-#include "bltGraph.h"
-};
-
#include "bltGrMarkerBitmap.h"
+#include "bltGrMarkerOption.h"
using namespace Blt;
-// OptionSpecs
-
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
"center", -1, Tk_Offset(BitmapMarkerOptions, anchor), 0, NULL, 0},
diff --git a/bltGrMarkerBitmap.h b/bltGrMarkerBitmap.h
index 1242e27..8451070 100644
--- a/bltGrMarkerBitmap.h
+++ b/bltGrMarkerBitmap.h
@@ -31,49 +31,48 @@
#define __bltgrmarkerbitmap_h__
#include "bltGrMarker.h"
-#define MAX_OUTLINE_POINTS 12
namespace Blt {
-typedef struct {
- const char** tags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ typedef struct {
+ const char** tags;
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
- Tk_Anchor anchor;
- Pixmap bitmap;
- XColor* fillColor;
- XColor* outlineColor;
-} BitmapMarkerOptions;
+ Tk_Anchor anchor;
+ Pixmap bitmap;
+ XColor* fillColor;
+ XColor* outlineColor;
+ } BitmapMarkerOptions;
-class BitmapMarker : public Marker {
- public:
- Point2d anchorPt_;
- GC gc_;
- GC fillGC_;
- Point2d outline_[MAX_OUTLINE_POINTS];
- int nOutlinePts_;
- int width_;
- int height_;
+ class BitmapMarker : public Marker {
+ public:
+ Point2d anchorPt_;
+ GC gc_;
+ GC fillGC_;
+ Point2d outline_[12];
+ int nOutlinePts_;
+ int width_;
+ int height_;
- private:
- int configure();
- void draw(Drawable);
- void map();
- int pointIn(Point2d*);
- int regionIn(Region2d*, int);
- void postscript(Blt_Ps);
+ private:
+ int configure();
+ void draw(Drawable);
+ void map();
+ int pointIn(Point2d*);
+ int regionIn(Region2d*, int);
+ void postscript(Blt_Ps);
- public:
- BitmapMarker(Graph*, const char*, Tcl_HashEntry*);
- virtual ~BitmapMarker();
-};
+ public:
+ BitmapMarker(Graph*, const char*, Tcl_HashEntry*);
+ virtual ~BitmapMarker();
+ };
};
diff --git a/configure b/configure
index 8577b1a..d8b5425 100755
--- a/configure
+++ b/configure
@@ -5537,6 +5537,7 @@ done
bltGrHairs.C
bltGrLegd.C
bltGrMarkerOp.C
+ bltGrMarkerOption.C
bltGrMarker.C
bltGrMarkerBitmap.C
bltGrMarkerLine.C
diff --git a/configure.in b/configure.in
index b16a302..0f3666d 100755
--- a/configure.in
+++ b/configure.in
@@ -82,6 +82,7 @@ TEA_ADD_SOURCES([
bltGrHairs.C
bltGrLegd.C
bltGrMarkerOp.C
+ bltGrMarkerOption.C
bltGrMarker.C
bltGrMarkerBitmap.C
bltGrMarkerLine.C
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C
index 3a0bc2e..6d55ac1 100644
--- a/src/bltGrMarker.C
+++ b/src/bltGrMarker.C
@@ -27,10 +27,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-extern "C" {
-#include "bltGraph.h"
-};
-
#include "bltGrMarker.h"
using namespace Blt;
@@ -52,11 +48,6 @@ Marker::Marker(Graph* gPtr, const char* nPtr, Tcl_HashEntry* hPtr)
Marker::~Marker()
{
- // If the marker to be deleted is currently displayed below the
- // elements, then backing store needs to be repaired.
- if (((MarkerOptions*)ops_)->drawUnder)
- graphPtr_->flags |= CACHE_DIRTY;
-
Blt_DeleteBindings(graphPtr_->bindTable, this);
if (className_)
diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h
index c27829b..7752d56 100644
--- a/src/bltGrMarker.h
+++ b/src/bltGrMarker.h
@@ -30,56 +30,75 @@
#ifndef __bltgrmarker_h__
#define __bltgrmarker_h__
-#include "bltGrMarkerOp.h"
-
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;
+extern "C" {
+#include "bltGraph.h"
+};
+
namespace Blt {
- class Marker {
- protected:
- ClassId classId_;
- const char *name_;
- const char *className_;
- Tk_OptionTable optionTable_;
- void* ops_;
- Graph* graphPtr_;
- Tcl_HashEntry* hashPtr_;
- int clipped_;
-
- public:
- Blt_ChainLink link;
- unsigned int flags;
-
- private:
- double HMap(Axis*, double);
- double VMap(Axis*, double);
-
- protected:
- Point2d mapPoint(Point2d*, Axis2d*);
- int boxesDontOverlap(Graph*, Region2d*);
-
- public:
- Marker(Graph*, const char*, Tcl_HashEntry*);
- virtual ~Marker();
-
- virtual int configure() =0;
- virtual void draw(Drawable) =0;
- virtual void map() =0;
- virtual int pointIn(Point2d*) =0;
- virtual int regionIn(Region2d*, int) =0;
- virtual void postscript(Blt_Ps) =0;
-
- ClassId classId() {return classId_;}
- const char* name() {return name_;}
- const char* className() {return className_;}
- int clipped() {return clipped_;}
- Tk_OptionTable optionTable() {return optionTable_;}
- MarkerOptions* ops() {return (MarkerOptions*)ops_;}
- };
+ typedef struct {
+ Point2d* points;
+ int num;
+ } Coords;
+
+ typedef struct {
+ const char** tags;
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
+ } MarkerOptions;
+
+ class Marker {
+ protected:
+ ClassId classId_;
+ const char *name_;
+ const char *className_;
+ Tk_OptionTable optionTable_;
+ void* ops_;
+ Graph* graphPtr_;
+ Tcl_HashEntry* hashPtr_;
+ int clipped_;
+
+ public:
+ Blt_ChainLink link;
+ unsigned int flags;
+
+ private:
+ double HMap(Axis*, double);
+ double VMap(Axis*, double);
+
+ protected:
+ Point2d mapPoint(Point2d*, Axis2d*);
+ int boxesDontOverlap(Graph*, Region2d*);
+
+ public:
+ Marker(Graph*, const char*, Tcl_HashEntry*);
+ virtual ~Marker();
+
+ virtual int configure() =0;
+ virtual void draw(Drawable) =0;
+ virtual void map() =0;
+ virtual int pointIn(Point2d*) =0;
+ virtual int regionIn(Region2d*, int) =0;
+ virtual void postscript(Blt_Ps) =0;
+
+ ClassId classId() {return classId_;}
+ const char* name() {return name_;}
+ const char* className() {return className_;}
+ int clipped() {return clipped_;}
+ Tk_OptionTable optionTable() {return optionTable_;}
+ void* ops() {return ops_;}
+ };
};
diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C
index 59d73bf..efd6cde 100644
--- a/src/bltGrMarkerLine.C
+++ b/src/bltGrMarkerLine.C
@@ -27,16 +27,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-extern "C" {
-#include "bltGraph.h"
-};
-
#include "bltGrMarkerLine.h"
+#include "bltGrMarkerOption.h"
using namespace Blt;
-// OptionSpecs
-
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
"Line all", -1, Tk_Offset(LineMarkerOptions, tags),
diff --git a/src/bltGrMarkerLine.h b/src/bltGrMarkerLine.h
index d613547..5311139 100644
--- a/src/bltGrMarkerLine.h
+++ b/src/bltGrMarkerLine.h
@@ -34,44 +34,44 @@
namespace Blt {
-typedef struct {
- const char** tags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ typedef struct {
+ const char** tags;
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
- int capStyle;
- Blt_Dashes dashes;
- XColor* fillColor;
- int joinStyle;
- int lineWidth;
- XColor* outlineColor;
- int xorr;
-} LineMarkerOptions;
+ int capStyle;
+ Blt_Dashes dashes;
+ XColor* fillColor;
+ int joinStyle;
+ int lineWidth;
+ XColor* outlineColor;
+ int xorr;
+ } LineMarkerOptions;
-class LineMarker : public Marker {
- private:
- GC gc_;
- Segment2d* segments_;
- int nSegments_;
+ class LineMarker : public Marker {
+ private:
+ GC gc_;
+ Segment2d* segments_;
+ int nSegments_;
- private:
- int configure();
- void draw(Drawable);
- void map();
- int pointIn(Point2d*);
- int regionIn(Region2d*, int);
- void postscript(Blt_Ps);
+ private:
+ int configure();
+ void draw(Drawable);
+ void map();
+ int pointIn(Point2d*);
+ int regionIn(Region2d*, int);
+ void postscript(Blt_Ps);
- public:
- LineMarker(Graph*, const char*, Tcl_HashEntry*);
- virtual ~LineMarker();
-};
+ public:
+ LineMarker(Graph*, const char*, Tcl_HashEntry*);
+ virtual ~LineMarker();
+ };
};
#endif
diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C
index b76df6a..cb5fcd2 100644
--- a/src/bltGrMarkerOp.C
+++ b/src/bltGrMarkerOp.C
@@ -32,6 +32,7 @@
extern "C" {
#include "bltGraph.h"
#include "bltOp.h"
+#include "bltGrMarkerOption.h"
};
#include "bltConfig.h"
@@ -54,8 +55,6 @@ static int MarkerObjConfigure( Tcl_Interp* interp, Graph* graphPtr,
int objc, Tcl_Obj* const objv[]);
static int GetMarkerFromObj(Tcl_Interp* interp, Graph* graphPtr,
Tcl_Obj* objPtr, Marker** markerPtrPtr);
-static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr);
-static Tcl_Obj* PrintCoordinate(double x);
static int IsElementHidden(Graph*, Marker*);
extern "C" {
@@ -69,151 +68,6 @@ extern "C" {
void* Blt_NearestMarker(Graph* graphPtr, int x, int y, int under);
};
-// OptionSpecs
-
-static Tk_CustomOptionSetProc CoordsSetProc;
-static Tk_CustomOptionGetProc CoordsGetProc;
-static Tk_CustomOptionFreeProc CoordsFreeProc;
-Tk_ObjCustomOption coordsObjOption =
- {
- "coords", CoordsSetProc, CoordsGetProc, RestoreProc, CoordsFreeProc, NULL
- };
-
-static int CoordsSetProc(ClientData clientData, Tcl_Interp* interp,
- Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
- int offset, char* savePtr, int flags)
-{
- Coords** coordsPtrPtr = (Coords**)(widgRec + offset);
- *(double*)savePtr = *(double*)coordsPtrPtr;
-
- if (!coordsPtrPtr)
- return TCL_OK;
-
- int objc;
- Tcl_Obj** objv;
- if (Tcl_ListObjGetElements(interp, *objPtr, &objc, &objv) != TCL_OK)
- return TCL_ERROR;
-
- if (objc == 0) {
- *coordsPtrPtr = NULL;
- return TCL_OK;
- }
-
- if (objc & 1) {
- Tcl_AppendResult(interp, "odd number of marker coordinates specified",NULL);
- return TCL_ERROR;
- }
-
- Coords* coordsPtr = (Coords*)calloc(1,sizeof(Coords));
- coordsPtr->num = objc/2;
- coordsPtr->points = (Point2d*)calloc(coordsPtr->num, sizeof(Point2d));
-
- Point2d* pp = coordsPtr->points;
- for (int ii=0; ii<objc; ii+=2) {
- double x, y;
- if ((GetCoordinate(interp, objv[ii], &x) != TCL_OK) ||
- (GetCoordinate(interp, objv[ii+1], &y) != TCL_OK))
- return TCL_ERROR;
- pp->x = x;
- pp->y = y;
- pp++;
- }
-
- *coordsPtrPtr = coordsPtr;
- return TCL_OK;
-}
-
-static Tcl_Obj* CoordsGetProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset)
-{
- Coords* coordsPtr = *(Coords**)(widgRec + offset);
-
- if (!coordsPtr)
- return Tcl_NewListObj(0, NULL);
-
- int cnt = coordsPtr->num*2;
- Tcl_Obj** ll = (Tcl_Obj**)calloc(cnt, sizeof(Tcl_Obj*));
-
- Point2d* pp = coordsPtr->points;
- for (int ii=0; ii<cnt; pp++) {
- ll[ii++] = PrintCoordinate(pp->x);
- ll[ii++] = PrintCoordinate(pp->y);
- }
-
- Tcl_Obj* listObjPtr = Tcl_NewListObj(cnt, ll);
- free(ll);
- return listObjPtr;
-}
-
-static void CoordsFreeProc(ClientData clientData, Tk_Window tkwin,
- char *ptr)
-{
- Coords* coordsPtr = *(Coords**)ptr;
- if (coordsPtr) {
- if (coordsPtr->points)
- free(coordsPtr->points);
- free(coordsPtr);
- }
-}
-
-static Tk_CustomOptionSetProc CapStyleSetProc;
-static Tk_CustomOptionGetProc CapStyleGetProc;
-Tk_ObjCustomOption capStyleObjOption =
- {
- "capStyle", CapStyleSetProc, CapStyleGetProc, NULL, NULL, NULL
- };
-
-static int CapStyleSetProc(ClientData clientData, Tcl_Interp* interp,
- Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
- int offset, char* save, int flags)
-{
- int* ptr = (int*)(widgRec + offset);
-
- Tk_Uid uid = Tk_GetUid(Tcl_GetString(*objPtr));
- int cap;
- if (Tk_GetCapStyle(interp, uid, &cap) != TCL_OK)
- return TCL_ERROR;
- *ptr = cap;
-
- return TCL_OK;
-}
-
-static Tcl_Obj* CapStyleGetProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset)
-{
- int* ptr = (int*)(widgRec + offset);
- return Tcl_NewStringObj(Tk_NameOfCapStyle(*ptr), -1);
-}
-
-static Tk_CustomOptionSetProc JoinStyleSetProc;
-static Tk_CustomOptionGetProc JoinStyleGetProc;
-Tk_ObjCustomOption joinStyleObjOption =
- {
- "joinStyle", JoinStyleSetProc, JoinStyleGetProc, NULL, NULL, NULL
- };
-
-static int JoinStyleSetProc(ClientData clientData, Tcl_Interp* interp,
- Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
- int offset, char* save, int flags)
-{
- int* ptr = (int*)(widgRec + offset);
-
- Tk_Uid uid = Tk_GetUid(Tcl_GetString(*objPtr));
- int join;
- if (Tk_GetJoinStyle(interp, uid, &join) != TCL_OK)
- return TCL_ERROR;
- *ptr = join;
-
- return TCL_OK;
-}
-
-static Tcl_Obj* JoinStyleGetProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset)
-{
- int* ptr = (int*)(widgRec + offset);
- return Tcl_NewStringObj(Tk_NameOfJoinStyle(*ptr), -1);
-}
-
// Create
static int CreateMarker(Graph* graphPtr, Tcl_Interp* interp,
@@ -471,7 +325,7 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp,
for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers.displayList);
link; link = Blt_Chain_NextLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
if ((markerPtr->flags & DELETE_PENDING) || ops->hide) {
continue;
}
@@ -541,7 +395,7 @@ static int RelinkOp(Graph* graphPtr, Tcl_Interp* interp,
Marker* markerPtr;
if (GetMarkerFromObj(interp, graphPtr, objv[3], &markerPtr) != TCL_OK)
return TCL_ERROR;
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
Marker* placePtr =NULL;
if (objc == 5)
@@ -626,7 +480,7 @@ int Blt_MarkerOp(Graph* graphPtr, Tcl_Interp* interp,
static int IsElementHidden(Graph* graphPtr, Marker* markerPtr)
{
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
if (ops->elemName) {
Tcl_HashEntry *hPtr
@@ -662,7 +516,7 @@ void Blt_MarkersToPostScript(Graph* graphPtr, Blt_Ps ps, int under)
for (Blt_ChainLink link = Blt_Chain_LastLink(graphPtr->markers.displayList);
link; link = Blt_Chain_PrevLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
if (ops->drawUnder != under)
continue;
@@ -683,7 +537,7 @@ void Blt_DrawMarkers(Graph* graphPtr, Drawable drawable, int under)
for (Blt_ChainLink link = Blt_Chain_LastLink(graphPtr->markers.displayList);
link; link = Blt_Chain_PrevLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
if ((ops->drawUnder != under) || (markerPtr->clipped()) ||
(markerPtr->flags & DELETE_PENDING) || (ops->hide))
@@ -710,7 +564,7 @@ void Blt_MapMarkers(Graph* graphPtr)
for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers.displayList);
link; link = Blt_Chain_NextLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
if ((markerPtr->flags & DELETE_PENDING) || ops->hide)
continue;
@@ -746,7 +600,7 @@ void* Blt_NearestMarker(Graph* graphPtr, int x, int y, int under)
for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers.displayList);
link; link = Blt_Chain_NextLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
if ((markerPtr->flags & (DELETE_PENDING|MAP_ITEM)) ||
(ops->hide))
@@ -776,28 +630,3 @@ void Blt_FreeMarker(char* dataPtr)
delete markerPtr;
}
-static Tcl_Obj* PrintCoordinate(double x)
-{
- if (x == DBL_MAX)
- return Tcl_NewStringObj("+Inf", -1);
- else if (x == -DBL_MAX)
- return Tcl_NewStringObj("-Inf", -1);
- else
- return Tcl_NewDoubleObj(x);
-}
-
-static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr)
-{
- const char* expr = Tcl_GetString(objPtr);
- char c = expr[0];
- if ((c == 'I') && (strcmp(expr, "Inf") == 0))
- *valuePtr = DBL_MAX; /* Elastic upper bound */
- else if ((c == '-') && (expr[1] == 'I') && (strcmp(expr, "-Inf") == 0))
- *valuePtr = -DBL_MAX; /* Elastic lower bound */
- else if ((c == '+') && (expr[1] == 'I') && (strcmp(expr, "+Inf") == 0))
- *valuePtr = DBL_MAX; /* Elastic upper bound */
- else if (Blt_ExprDoubleFromObj(interp, objPtr, valuePtr) != TCL_OK)
- return TCL_ERROR;
-
- return TCL_OK;
-}
diff --git a/src/bltGrMarkerOp.h b/src/bltGrMarkerOp.h
index 825d125..d9191d3 100644
--- a/src/bltGrMarkerOp.h
+++ b/src/bltGrMarkerOp.h
@@ -32,29 +32,7 @@
namespace Blt {
-typedef struct {
- Point2d* points;
- int num;
-} Coords;
-
-typedef struct {
- const char** tags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
-} MarkerOptions;
};
-extern Tk_ObjCustomOption coordsObjOption;
-extern Tk_ObjCustomOption capStyleObjOption;
-extern Tk_ObjCustomOption joinStyleObjOption;
-extern Tk_ObjCustomOption xAxisObjOption;
-extern Tk_ObjCustomOption yAxisObjOption;
-
#endif
diff --git a/src/bltGrMarkerOption.C b/src/bltGrMarkerOption.C
new file mode 100644
index 0000000..ff57784
--- /dev/null
+++ b/src/bltGrMarkerOption.C
@@ -0,0 +1,212 @@
+/*
+ * Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+ * This code has been modified under the terms listed below and is made
+ * available under the same terms.
+ */
+
+/*
+ * Copyright 1993-2004 George A Howlett.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "bltC.h"
+
+extern "C" {
+#include "bltGraph.h"
+#include "bltGrMarkerOption.h"
+};
+
+#include "bltConfig.h"
+#include "bltGrMarker.h"
+
+using namespace Blt;
+
+static Tcl_Obj* PrintCoordinate(double x);
+static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr);
+
+static Tk_CustomOptionSetProc CoordsSetProc;
+static Tk_CustomOptionGetProc CoordsGetProc;
+static Tk_CustomOptionFreeProc CoordsFreeProc;
+Tk_ObjCustomOption coordsObjOption =
+ {
+ "coords", CoordsSetProc, CoordsGetProc, RestoreProc, CoordsFreeProc, NULL
+ };
+
+static int CoordsSetProc(ClientData clientData, Tcl_Interp* interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* savePtr, int flags)
+{
+ Coords** coordsPtrPtr = (Coords**)(widgRec + offset);
+ *(double*)savePtr = *(double*)coordsPtrPtr;
+
+ if (!coordsPtrPtr)
+ return TCL_OK;
+
+ int objc;
+ Tcl_Obj** objv;
+ if (Tcl_ListObjGetElements(interp, *objPtr, &objc, &objv) != TCL_OK)
+ return TCL_ERROR;
+
+ if (objc == 0) {
+ *coordsPtrPtr = NULL;
+ return TCL_OK;
+ }
+
+ if (objc & 1) {
+ Tcl_AppendResult(interp, "odd number of marker coordinates specified",NULL);
+ return TCL_ERROR;
+ }
+
+ Coords* coordsPtr = (Coords*)calloc(1,sizeof(Coords));
+ coordsPtr->num = objc/2;
+ coordsPtr->points = (Point2d*)calloc(coordsPtr->num, sizeof(Point2d));
+
+ Point2d* pp = coordsPtr->points;
+ for (int ii=0; ii<objc; ii+=2) {
+ double x, y;
+ if ((GetCoordinate(interp, objv[ii], &x) != TCL_OK) ||
+ (GetCoordinate(interp, objv[ii+1], &y) != TCL_OK))
+ return TCL_ERROR;
+ pp->x = x;
+ pp->y = y;
+ pp++;
+ }
+
+ *coordsPtrPtr = coordsPtr;
+ return TCL_OK;
+}
+
+static Tcl_Obj* CoordsGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ Coords* coordsPtr = *(Coords**)(widgRec + offset);
+
+ if (!coordsPtr)
+ return Tcl_NewListObj(0, NULL);
+
+ int cnt = coordsPtr->num*2;
+ Tcl_Obj** ll = (Tcl_Obj**)calloc(cnt, sizeof(Tcl_Obj*));
+
+ Point2d* pp = coordsPtr->points;
+ for (int ii=0; ii<cnt; pp++) {
+ ll[ii++] = PrintCoordinate(pp->x);
+ ll[ii++] = PrintCoordinate(pp->y);
+ }
+
+ Tcl_Obj* listObjPtr = Tcl_NewListObj(cnt, ll);
+ free(ll);
+ return listObjPtr;
+}
+
+static void CoordsFreeProc(ClientData clientData, Tk_Window tkwin,
+ char *ptr)
+{
+ Coords* coordsPtr = *(Coords**)ptr;
+ if (coordsPtr) {
+ if (coordsPtr->points)
+ free(coordsPtr->points);
+ free(coordsPtr);
+ }
+}
+
+static Tk_CustomOptionSetProc CapStyleSetProc;
+static Tk_CustomOptionGetProc CapStyleGetProc;
+Tk_ObjCustomOption capStyleObjOption =
+ {
+ "capStyle", CapStyleSetProc, CapStyleGetProc, NULL, NULL, NULL
+ };
+
+static int CapStyleSetProc(ClientData clientData, Tcl_Interp* interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
+{
+ int* ptr = (int*)(widgRec + offset);
+
+ Tk_Uid uid = Tk_GetUid(Tcl_GetString(*objPtr));
+ int cap;
+ if (Tk_GetCapStyle(interp, uid, &cap) != TCL_OK)
+ return TCL_ERROR;
+ *ptr = cap;
+
+ return TCL_OK;
+}
+
+static Tcl_Obj* CapStyleGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ int* ptr = (int*)(widgRec + offset);
+ return Tcl_NewStringObj(Tk_NameOfCapStyle(*ptr), -1);
+}
+
+static Tk_CustomOptionSetProc JoinStyleSetProc;
+static Tk_CustomOptionGetProc JoinStyleGetProc;
+Tk_ObjCustomOption joinStyleObjOption =
+ {
+ "joinStyle", JoinStyleSetProc, JoinStyleGetProc, NULL, NULL, NULL
+ };
+
+static int JoinStyleSetProc(ClientData clientData, Tcl_Interp* interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
+{
+ int* ptr = (int*)(widgRec + offset);
+
+ Tk_Uid uid = Tk_GetUid(Tcl_GetString(*objPtr));
+ int join;
+ if (Tk_GetJoinStyle(interp, uid, &join) != TCL_OK)
+ return TCL_ERROR;
+ *ptr = join;
+
+ return TCL_OK;
+}
+
+static Tcl_Obj* JoinStyleGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ int* ptr = (int*)(widgRec + offset);
+ return Tcl_NewStringObj(Tk_NameOfJoinStyle(*ptr), -1);
+}
+
+static Tcl_Obj* PrintCoordinate(double x)
+{
+ if (x == DBL_MAX)
+ return Tcl_NewStringObj("+Inf", -1);
+ else if (x == -DBL_MAX)
+ return Tcl_NewStringObj("-Inf", -1);
+ else
+ return Tcl_NewDoubleObj(x);
+}
+
+static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr)
+{
+ const char* expr = Tcl_GetString(objPtr);
+ char c = expr[0];
+ if ((c == 'I') && (strcmp(expr, "Inf") == 0))
+ *valuePtr = DBL_MAX; /* Elastic upper bound */
+ else if ((c == '-') && (expr[1] == 'I') && (strcmp(expr, "-Inf") == 0))
+ *valuePtr = -DBL_MAX; /* Elastic lower bound */
+ else if ((c == '+') && (expr[1] == 'I') && (strcmp(expr, "+Inf") == 0))
+ *valuePtr = DBL_MAX; /* Elastic upper bound */
+ else if (Blt_ExprDoubleFromObj(interp, objPtr, valuePtr) != TCL_OK)
+ return TCL_ERROR;
+
+ return TCL_OK;
+}
diff --git a/src/bltGrMarkerOption.h b/src/bltGrMarkerOption.h
new file mode 100644
index 0000000..afe0653
--- /dev/null
+++ b/src/bltGrMarkerOption.h
@@ -0,0 +1,39 @@
+/*
+ * Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+ * This code has been modified under the terms listed below and is made
+ * available under the same terms.
+ */
+
+/*
+ * Copyright 1993-2004 George A Howlett.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __blt_grmarkeroption_h__
+#define __blt_grmarkeroption_h__
+
+extern Tk_ObjCustomOption coordsObjOption;
+extern Tk_ObjCustomOption capStyleObjOption;
+extern Tk_ObjCustomOption joinStyleObjOption;
+extern Tk_ObjCustomOption xAxisObjOption;
+extern Tk_ObjCustomOption yAxisObjOption;
+
+#endif
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 02eb231..e9085dd 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -27,16 +27,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-extern "C" {
-#include "bltGraph.h"
-};
-
#include "bltGrMarkerPolygon.h"
+#include "bltGrMarkerOption.h"
using namespace Blt;
-// OptionSpecs
-
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
"Polygon all", -1, Tk_Offset(PolygonMarkerOptions, tags),
diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h
index cecfe53..8a2b607 100644
--- a/src/bltGrMarkerPolygon.h
+++ b/src/bltGrMarkerPolygon.h
@@ -34,51 +34,51 @@
namespace Blt {
-typedef struct {
- const char** tags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ typedef struct {
+ const char** tags;
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
- int capStyle;
- Blt_Dashes dashes;
- XColor* fill;
- XColor* fillBg;
- int joinStyle;
- int lineWidth;
- XColor* outline;
- XColor* outlineBg;
- Pixmap stipple;
- int xorr;
-} PolygonMarkerOptions;
+ int capStyle;
+ Blt_Dashes dashes;
+ XColor* fill;
+ XColor* fillBg;
+ int joinStyle;
+ int lineWidth;
+ XColor* outline;
+ XColor* outlineBg;
+ Pixmap stipple;
+ int xorr;
+ } PolygonMarkerOptions;
-class PolygonMarker : public Marker {
- private:
- Point2d *screenPts_;
- GC outlineGC_;
- GC fillGC_;
- Point2d *fillPts_;
- int nFillPts_;
- Segment2d *outlinePts_;
- int nOutlinePts_;
+ class PolygonMarker : public Marker {
+ private:
+ Point2d *screenPts_;
+ GC outlineGC_;
+ GC fillGC_;
+ Point2d *fillPts_;
+ int nFillPts_;
+ Segment2d *outlinePts_;
+ int nOutlinePts_;
- private:
- int configure();
- void draw(Drawable);
- void map();
- int pointIn(Point2d*);
- int regionIn(Region2d*, int);
- void postscript(Blt_Ps);
+ private:
+ int configure();
+ void draw(Drawable);
+ void map();
+ int pointIn(Point2d*);
+ int regionIn(Region2d*, int);
+ void postscript(Blt_Ps);
- public:
- PolygonMarker(Graph*, const char*, Tcl_HashEntry*);
- virtual ~PolygonMarker();
-};
+ public:
+ PolygonMarker(Graph*, const char*, Tcl_HashEntry*);
+ virtual ~PolygonMarker();
+ };
};
diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C
index 8ad104c..f5c945f 100644
--- a/src/bltGrMarkerText.C
+++ b/src/bltGrMarkerText.C
@@ -27,11 +27,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-extern "C" {
-#include "bltGraph.h"
-};
-
#include "bltGrMarkerText.h"
+#include "bltGrMarkerOption.h"
using namespace Blt;
diff --git a/src/bltGrMarkerText.h b/src/bltGrMarkerText.h
index 6b5fc85..b6250bf 100644
--- a/src/bltGrMarkerText.h
+++ b/src/bltGrMarkerText.h
@@ -34,43 +34,43 @@
namespace Blt {
-typedef struct {
- const char** tags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ typedef struct {
+ const char** tags;
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
- Tk_Anchor anchor;
- XColor* fillColor;
- TextStyle style;
- const char* string;
-} TextMarkerOptions;
+ Tk_Anchor anchor;
+ XColor* fillColor;
+ TextStyle style;
+ const char* string;
+ } TextMarkerOptions;
-class TextMarker : public Marker {
- private:
- Point2d anchorPt_;
- int width_;
- int height_;
- GC fillGC_;
- Point2d outline_[5];
+ class TextMarker : public Marker {
+ private:
+ Point2d anchorPt_;
+ int width_;
+ int height_;
+ GC fillGC_;
+ Point2d outline_[5];
- private:
- int configure();
- void draw(Drawable);
- void map();
- int pointIn(Point2d*);
- int regionIn(Region2d*, int);
- void postscript(Blt_Ps);
+ private:
+ int configure();
+ void draw(Drawable);
+ void map();
+ int pointIn(Point2d*);
+ int regionIn(Region2d*, int);
+ void postscript(Blt_Ps);
- public:
- TextMarker(Graph*, const char*, Tcl_HashEntry*);
- virtual ~TextMarker();
-};
+ public:
+ TextMarker(Graph*, const char*, Tcl_HashEntry*);
+ virtual ~TextMarker();
+ };
};
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 43c6a78..5e14cf0 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -986,7 +986,7 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
case CID_MARKER_WINDOW:
{
Marker* markerPtr = (Marker*)object;
- MarkerOptions* ops = markerPtr->ops();
+ MarkerOptions* ops = (MarkerOptions*)markerPtr->ops();
MakeTagProc* tagProc = Blt_MakeMarkerTag;
Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, markerPtr->name()), 0);
Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, markerPtr->className()), 0);