diff options
author | joye <joye> | 2014-03-28 20:18:43 (GMT) |
---|---|---|
committer | joye <joye> | 2014-03-28 20:18:43 (GMT) |
commit | 01082bf9a06f36853fe3b0b4a2f1709adcc3c9c9 (patch) | |
tree | 4341733a8c187249a77fd87510e8ed94229d18e9 | |
parent | 74050d79a4b0d0a97c5f9f2530a17cde9ca004c5 (diff) | |
download | blt-01082bf9a06f36853fe3b0b4a2f1709adcc3c9c9.zip blt-01082bf9a06f36853fe3b0b4a2f1709adcc3c9c9.tar.gz blt-01082bf9a06f36853fe3b0b4a2f1709adcc3c9c9.tar.bz2 |
*** empty log message ***
-rw-r--r-- | src/bltConfig.C | 3 | ||||
-rw-r--r-- | src/bltConfig.h | 1 | ||||
-rw-r--r-- | src/bltGrElemBar.C | 231 | ||||
-rw-r--r-- | src/bltGrElemBar.h | 55 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 332 | ||||
-rw-r--r-- | src/bltGrElemOp.C | 5 | ||||
-rw-r--r-- | src/bltGrElemOp.h | 30 | ||||
-rw-r--r-- | src/bltGrMarkerOp.C | 8 | ||||
-rw-r--r-- | src/bltGrPen.h | 21 | ||||
-rw-r--r-- | src/bltGrPenBar.C | 129 | ||||
-rw-r--r-- | src/bltGrPenBar.h | 40 | ||||
-rw-r--r-- | src/bltGrPenLine.C | 321 | ||||
-rw-r--r-- | src/bltGrPenLine.h | 8 | ||||
-rw-r--r-- | src/bltGrPenOp.C | 32 | ||||
-rw-r--r-- | src/bltGrPenOp.h | 2 | ||||
-rw-r--r-- | src/bltGraph.h | 224 |
16 files changed, 710 insertions, 732 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C index 331961d..b1b35e1 100644 --- a/src/bltConfig.C +++ b/src/bltConfig.C @@ -52,6 +52,9 @@ void RestoreProc(ClientData clientData, Tk_Window tkwin, *(double*)ptr = *(double*)savePtr; } +// Fill +const char* fillObjOption[] = {"none", "x", "y", "both", NULL}; + // State const char* stateObjOption[] = {"normal", "active", "disabled", NULL}; diff --git a/src/bltConfig.h b/src/bltConfig.h index 3ebe626..bb6d4d0 100644 --- a/src/bltConfig.h +++ b/src/bltConfig.h @@ -37,6 +37,7 @@ #define BLT_STATE_ACTIVE (1<<0) #define BLT_STATE_DISABLED (1<<1) +extern const char* fillObjOption[]; extern const char* stateObjOption[]; typedef struct { diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index d64004f..02177f6 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -38,8 +38,8 @@ extern "C" { #include "bltGraph.h" }; +#include "bltGrElemBar.h" #include "bltConfig.h" -#include "bltGrElemOp.h" #define CLAMP(x,l,h) ((x) = (((x)<(l))? (l) : ((x)>(h)) ? (h) : (x))) @@ -52,40 +52,6 @@ typedef struct { } BarRegion; typedef struct { - const char *name; - ClassId classId; - const char *typeId; - unsigned int flags; - int refCount; - Tcl_HashEntry *hashPtr; - Tk_OptionTable optionTable; - PenConfigureProc *configProc; - PenDestroyProc *destroyProc; - Graph* graphPtr; - - // Barchart specific pen fields start here - XColor* outlineColor; - Tk_3DBorder fill; - int borderWidth; - int relief; - Pixmap stipple; - GC fillGC; - GC outlineGC; - - // Error bar attributes - int errorBarShow; - int errorBarLineWidth; - int errorBarCapWidth; - XColor* errorBarColor; - GC errorBarGC; - - // Show value attributes - int valueShow; - const char *valueFormat; - TextStyle valueStyle; -} BarPen; - -typedef struct { Weight weight; BarPen* penPtr; XRectangle *bars; @@ -96,65 +62,10 @@ typedef struct { int errorBarCapWidth; } BarStyle; -typedef struct { - GraphObj obj; - unsigned int flags; - int hide; - Tcl_HashEntry *hashPtr; - - // Fields specific to elements - const char *label; - unsigned short row; - unsigned short col; - int legendRelief; - Axis2d axes; - ElemCoords coords; - ElemValues* w; - int *activeIndices; - int nActiveIndices; - ElementProcs *procsPtr; - Tk_OptionTable optionTable; - BarPen *activePenPtr; - BarPen *normalPenPtr; - BarPen *builtinPenPtr; - Blt_Chain stylePalette; - - // Symbol scaling - int scaleSymbols; - double xRange; - double yRange; - int state; - Blt_ChainLink link; - - // Fields specific to the barchart element - double barWidth; - const char *groupName; - int *barToData; - XRectangle *bars; - int *activeToData; - XRectangle *activeRects; - int nBars; - int nActive; - int xPad; - ElemValues* xError; - ElemValues* yError; - ElemValues* xHigh; - ElemValues* xLow; - ElemValues* yHigh; - ElemValues* yLow; - BarPen builtinPen; - GraphSegments xeb; - GraphSegments yeb; - int errorBarCapWidth; -} BarElement; - // Defs -static void InitBarPen(Graph* graphPtr, BarPen* penPtr); static void ResetBar(BarElement* elemPtr); -static PenConfigureProc ConfigurePenProc; -static PenDestroyProc DestroyPenProc; static ElementClosestProc ClosestBarProc; static ElementConfigProc ConfigureBarProc; static ElementDestroyProc DestroyBarProc; @@ -302,49 +213,6 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static Tk_OptionSpec barPenOptionSpecs[] = { - {TK_OPTION_BORDER, "-background", "background", "Background", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, fill), - TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, -1, 0, 0, "-borderwidth", 0}, - {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, - {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - STD_BORDERWIDTH, -1, Tk_Offset(BarPen, borderWidth), 0, NULL, 0}, - {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", - NULL, -1, Tk_Offset(BarPen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth","ErrorBarWidth", - "1", -1, Tk_Offset(BarPen, errorBarLineWidth), 0, NULL, 0}, - {TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap", - "2", -1, Tk_Offset(BarPen, errorBarCapWidth), 0, NULL, 0}, - {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, - {TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, - {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, outlineColor), - TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, - {TK_OPTION_RELIEF, "-relief", "relief", "Relief", - "raised", -1, Tk_Offset(BarPen, relief), 0, NULL, 0}, - {TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars", - "both", -1, Tk_Offset(BarPen, errorBarShow), 0, &fillObjOption, 0}, - {TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues", - "none", -1, Tk_Offset(BarPen, valueShow), 0, &fillObjOption, 0}, - {TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple", - NULL, -1, Tk_Offset(BarPen, stipple), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_STRING, "-type", "type", "Type", - "bar", -1, Tk_Offset(BarPen, typeId), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor", - "s", -1, Tk_Offset(BarPen, valueStyle.anchor), 0, NULL, 0}, - {TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, valueStyle.color), 0, NULL, 0}, - {TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont", - STD_FONT_SMALL, -1, Tk_Offset(BarPen, valueStyle.font), 0, NULL, 0}, - {TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat", - "%g", -1, Tk_Offset(BarPen, valueFormat), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate", - "0", -1, Tk_Offset(BarPen, valueStyle.angle), 0, NULL, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} -}; - // Create Element* Blt_BarElement(Graph* graphPtr) @@ -361,31 +229,11 @@ Element* Blt_BarElement(Graph* graphPtr) return (Element*)elemPtr; } -Pen* Blt_BarPen(Graph* graphPtr, const char *penName) -{ - BarPen* penPtr = (BarPen*)calloc(1, sizeof(BarPen)); - InitBarPen(graphPtr, penPtr); - penPtr->name = Blt_Strdup(penName); - - return (Pen*)penPtr; -} - -static void InitBarPen(Graph* graphPtr, BarPen* penPtr) -{ - penPtr->configProc = ConfigurePenProc; - penPtr->destroyProc = DestroyPenProc; - - Blt_Ts_InitStyle(penPtr->valueStyle); - - penPtr->optionTable = - Tk_CreateOptionTable(graphPtr->interp, barPenOptionSpecs); -} - static void DestroyBarProc(Graph* graphPtr, Element* basePtr) { BarElement* elemPtr = (BarElement*)basePtr; - DestroyPenProc(graphPtr, (Pen*)&elemPtr->builtinPen); + DestroyBarPenProc(graphPtr, (Pen*)&elemPtr->builtinPen); if (elemPtr->activePenPtr) Blt_FreePen((Pen *)elemPtr->activePenPtr); @@ -403,23 +251,6 @@ static void DestroyBarProc(Graph* graphPtr, Element* basePtr) free(elemPtr->activeIndices); } -static void DestroyPenProc(Graph* graphPtr, Pen* basePtr) -{ - BarPen* penPtr = (BarPen*)basePtr; - - Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle); - if (penPtr->outlineGC) - Tk_FreeGC(graphPtr->display, penPtr->outlineGC); - - if (penPtr->fillGC) - Tk_FreeGC(graphPtr->display, penPtr->fillGC); - - if (penPtr->errorBarGC) - Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - - Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin); -} - // Configure static int ConfigureBarProc(Graph* graphPtr, Element *basePtr) @@ -428,7 +259,7 @@ static int ConfigureBarProc(Graph* graphPtr, Element *basePtr) Blt_ChainLink link; BarStyle *stylePtr; - if (ConfigurePenProc(graphPtr, (Pen*)&elemPtr->builtinPen)!= TCL_OK) + if (ConfigureBarPenProc(graphPtr, (Pen*)&elemPtr->builtinPen)!= TCL_OK) return TCL_ERROR; // Point to the static normal pen if no external pens have been selected. @@ -443,62 +274,6 @@ static int ConfigureBarProc(Graph* graphPtr, Element *basePtr) return TCL_OK; } -static int ConfigurePenProc(Graph* graphPtr, Pen *basePtr) -{ - BarPen* penPtr = (BarPen*)basePtr; - int screenNum = Tk_ScreenNumber(graphPtr->tkwin); - XGCValues gcValues; - unsigned long gcMask; - GC newGC; - - // outlineGC - gcMask = GCForeground | GCLineWidth; - gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); - - if (penPtr->outlineColor) - gcValues.foreground = penPtr->outlineColor->pixel; - else if (penPtr->fill) - gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; - - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (penPtr->outlineGC) - Tk_FreeGC(graphPtr->display, penPtr->outlineGC); - penPtr->outlineGC = newGC; - - newGC = NULL; - if (penPtr->stipple != None) { - // Handle old-style -stipple specially - gcMask = GCForeground | GCBackground | GCFillStyle | GCStipple; - gcValues.foreground = BlackPixel(graphPtr->display, screenNum); - gcValues.background = WhitePixel(graphPtr->display, screenNum); - if (penPtr->fill) - gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; - else if (penPtr->outlineColor) - gcValues.foreground = penPtr->outlineColor->pixel; - - gcValues.stipple = penPtr->stipple; - gcValues.fill_style = FillStippled; - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - } - if (penPtr->fillGC) - Tk_FreeGC(graphPtr->display, penPtr->fillGC); - penPtr->fillGC = newGC; - - // errorBarGC - gcMask = GCForeground | GCLineWidth; - XColor* colorPtr = penPtr->errorBarColor; - if (!colorPtr) - colorPtr = penPtr->outlineColor; - gcValues.foreground = colorPtr->pixel; - gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (penPtr->errorBarGC) - Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - penPtr->errorBarGC = newGC; - - return TCL_OK; -} - // Support static void ResetStylePalette(Blt_Chain stylePalette) diff --git a/src/bltGrElemBar.h b/src/bltGrElemBar.h index 1c31094..93596e4 100644 --- a/src/bltGrElemBar.h +++ b/src/bltGrElemBar.h @@ -35,6 +35,59 @@ #include <iomanip> using namespace std; -}; +#include "bltGrElem.h" +#include "bltGrPenBar.h" + +typedef struct { + GraphObj obj; + unsigned int flags; + int hide; + Tcl_HashEntry *hashPtr; + + // Fields specific to elements + const char *label; + unsigned short row; + unsigned short col; + int legendRelief; + Axis2d axes; + ElemCoords coords; + ElemValues* w; + int *activeIndices; + int nActiveIndices; + ElementProcs *procsPtr; + Tk_OptionTable optionTable; + BarPen *activePenPtr; + BarPen *normalPenPtr; + BarPen *builtinPenPtr; + Blt_Chain stylePalette; + + // Symbol scaling + int scaleSymbols; + double xRange; + double yRange; + int state; + Blt_ChainLink link; + + // Fields specific to the barchart element + double barWidth; + const char *groupName; + int *barToData; + XRectangle *bars; + int *activeToData; + XRectangle *activeRects; + int nBars; + int nActive; + int xPad; + ElemValues* xError; + ElemValues* yError; + ElemValues* xHigh; + ElemValues* xLow; + ElemValues* yHigh; + ElemValues* yLow; + BarPen builtinPen; + GraphSegments xeb; + GraphSegments yeb; + int errorBarCapWidth; +} BarElement; #endif diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 4514749..339e5e8 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -81,13 +81,9 @@ typedef struct { // Defs -static void DestroySymbol(Display *display, Symbol *symbolPtr); typedef double (DistanceProc)(int x, int y, Point2d *p, Point2d *q, Point2d *t); -static void InitLinePen(Graph* graphPtr, LinePen* penPtr); static void ResetLine(LineElement* elemPtr); -static PenConfigureProc ConfigurePenProc; -static PenDestroyProc DestroyPenProc; static ElementClosestProc ClosestLineProc; static ElementConfigProc ConfigureLineProc; static ElementDestroyProc DestroyLineProc; @@ -141,122 +137,6 @@ static Tk_ObjCustomOption styleObjOption = }; -typedef struct { - const char* name; - unsigned int minChars; - SymbolType type; -} GraphSymbolType; - -static GraphSymbolType graphSymbols[] = { - { "arrow", 1, SYMBOL_ARROW, }, - { "circle", 2, SYMBOL_CIRCLE, }, - { "cross", 2, SYMBOL_CROSS, }, - { "diamond", 1, SYMBOL_DIAMOND, }, - { "none", 1, SYMBOL_NONE, }, - { "plus", 1, SYMBOL_PLUS, }, - { "scross", 2, SYMBOL_SCROSS, }, - { "splus", 2, SYMBOL_SPLUS, }, - { "square", 2, SYMBOL_SQUARE, }, - { "triangle", 1, SYMBOL_TRIANGLE, }, - { NULL, 0, SYMBOL_NONE, }, -}; - -static Tk_CustomOptionSetProc SymbolSetProc; -static Tk_CustomOptionGetProc SymbolGetProc; -Tk_ObjCustomOption symbolObjOption = - { - "symbol", SymbolSetProc, SymbolGetProc, NULL, NULL, NULL - }; - -static int SymbolSetProc(ClientData clientData, Tcl_Interp* interp, - Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec, - int offset, char* save, int flags) -{ - Symbol* symbolPtr = (Symbol*)(widgRec + offset); - const char* string; - - // string - { - int length; - string = Tcl_GetStringFromObj(*objPtr, &length); - if (length == 0) { - DestroySymbol(Tk_Display(tkwin), symbolPtr); - symbolPtr->type = SYMBOL_NONE; - return TCL_OK; - } - char c = string[0]; - - for (GraphSymbolType* p = graphSymbols; p->name; p++) { - if (length < p->minChars) { - continue; - } - if ((c == p->name[0]) && (strncmp(string, p->name, length) == 0)) { - DestroySymbol(Tk_Display(tkwin), symbolPtr); - symbolPtr->type = p->type; - return TCL_OK; - } - } - } - - // bitmap - { - Tcl_Obj **objv; - int objc; - if ((Tcl_ListObjGetElements(NULL, *objPtr, &objc, &objv) != TCL_OK) || - (objc > 2)) { - goto error; - } - Pixmap bitmap = None; - Pixmap mask = None; - if (objc > 0) { - bitmap = Tk_AllocBitmapFromObj((Tcl_Interp*)NULL, tkwin, objv[0]); - if (!bitmap) - goto error; - - } - if (objc > 1) { - mask = Tk_AllocBitmapFromObj((Tcl_Interp*)NULL, tkwin, objv[1]); - if (!mask) - goto error; - } - DestroySymbol(Tk_Display(tkwin), symbolPtr); - symbolPtr->bitmap = bitmap; - symbolPtr->mask = mask; - symbolPtr->type = SYMBOL_BITMAP; - - return TCL_OK; - } - error: - Tcl_AppendResult(interp, "bad symbol \"", string, - "\": should be \"none\", \"circle\", \"square\", \"diamond\", " - "\"plus\", \"cross\", \"splus\", \"scross\", \"triangle\", " - "\"arrow\" or the name of a bitmap", NULL); - return TCL_ERROR; -} - -static Tcl_Obj* SymbolGetProc(ClientData clientData, Tk_Window tkwin, - char* widgRec, int offset) -{ - Symbol* symbolPtr = (Symbol*)(widgRec + offset); - - Tcl_Obj* ll[2]; - if (symbolPtr->type == SYMBOL_BITMAP) { - ll[0] = - Tcl_NewStringObj(Tk_NameOfBitmap(Tk_Display(tkwin),symbolPtr->bitmap),-1); - ll[1] = symbolPtr->mask ? - Tcl_NewStringObj(Tk_NameOfBitmap(Tk_Display(tkwin),symbolPtr->mask),-1) : - Tcl_NewStringObj("", -1); - return Tcl_NewListObj(2, ll); - } - else { - for (GraphSymbolType* p = graphSymbols; p->name; p++) { - if (p->type == symbolPtr->type) - return Tcl_NewStringObj(p->name, -1); - } - return Tcl_NewStringObj("?unknown symbol type?", -1); - } -} - extern Tk_ObjCustomOption linePenObjOption; extern Tk_ObjCustomOption pairsObjOption; extern Tk_ObjCustomOption valuesObjOption; @@ -391,52 +271,6 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static Tk_OptionSpec linePenOptionSpecs[] = { - {TK_OPTION_COLOR, "-color", "color", "Color", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePen, traceColor), 0, NULL, 0}, - {TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes", - NULL, -1, Tk_Offset(LinePen, traceDashes), - TK_OPTION_NULL_OK, &dashesObjOption, 0}, - {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", - NULL, -1, Tk_Offset(LinePen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth", "ErrorBarWidth", - "1", -1, Tk_Offset(LinePen, errorBarLineWidth), 0, NULL, 0}, - {TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap", - "2", -1, Tk_Offset(LinePen, errorBarCapWidth), 0, NULL, 0}, - {TK_OPTION_COLOR, "-fill", "fill", "Fill", - NULL, -1, Tk_Offset(LinePen, symbol.fillColor), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth", - "1", -1, Tk_Offset(LinePen, traceWidth), 0, NULL, 0}, - {TK_OPTION_COLOR, "-offdash", "offDash", "OffDash", - NULL, -1, Tk_Offset(LinePen, traceOffColor), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_COLOR, "-outline", "outline", "Outline", - NULL, -1, Tk_Offset(LinePen, symbol.outlineColor), - TK_OPTION_NULL_OK, NULL,0}, - {TK_OPTION_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth", - "1", -1, Tk_Offset(LinePen, symbol.outlineWidth), 0, NULL, 0}, - {TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels", - "0.1i", -1, Tk_Offset(LinePen, symbol.size), 0, NULL, 0}, - {TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars", - "both", -1, Tk_Offset(LinePen, errorBarShow), 0, &fillObjOption, 0}, - {TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues", - "none", -1, Tk_Offset(LinePen, valueShow), 0, &fillObjOption, 0}, - {TK_OPTION_CUSTOM, "-symbol", "symbol", "Symbol", - "none", -1, Tk_Offset(LinePen, symbol), 0, &symbolObjOption, 0}, - {TK_OPTION_STRING, "-type", "type", "Type", - "line", -1, Tk_Offset(Pen, typeId), 0, NULL, 0}, - {TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor", - "s", -1, Tk_Offset(LinePen, valueStyle.anchor), 0, NULL, 0}, - {TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePen, valueStyle.color), 0, NULL, 0}, - {TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont", - STD_FONT_SMALL, -1, Tk_Offset(LinePen, valueStyle.font), 0, NULL, 0}, - {TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat", - "%g", -1, Tk_Offset(LinePen, valueFormat), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate", - "0", -1, Tk_Offset(LinePen, valueStyle.angle), 0, NULL, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} -}; - // Create Element* Blt_LineElement(Graph* graphPtr) @@ -454,35 +288,11 @@ Element* Blt_LineElement(Graph* graphPtr) return (Element*)elemPtr; } -Pen* Blt_LinePen(Graph* graphPtr, const char* penName) -{ - LinePen* penPtr = (LinePen*)calloc(1, sizeof(LinePen)); - InitLinePen(graphPtr, penPtr); - penPtr->name = Blt_Strdup(penName); - penPtr->classId = CID_ELEM_LINE; - - return (Pen*)penPtr; -} - -static void InitLinePen(Graph* graphPtr, LinePen* penPtr) -{ - penPtr->configProc = ConfigurePenProc; - penPtr->destroyProc = DestroyPenProc; - - Blt_Ts_InitStyle(penPtr->valueStyle); - penPtr->symbol.bitmap = None; - penPtr->symbol.mask = None; - penPtr->symbol.type = SYMBOL_NONE; - - penPtr->optionTable = - Tk_CreateOptionTable(graphPtr->interp, linePenOptionSpecs); -} - static void DestroyLineProc(Graph* graphPtr, Element* basePtr) { LineElement* elemPtr = (LineElement*)basePtr; - DestroyPenProc(graphPtr, (Pen *)&elemPtr->builtinPen); + DestroyLinePenProc(graphPtr, (Pen *)&elemPtr->builtinPen); if (elemPtr->activePenPtr) Blt_FreePen((Pen *)elemPtr->activePenPtr); if (elemPtr->normalPenPtr) @@ -503,42 +313,13 @@ static void DestroyLineProc(Graph* graphPtr, Element* basePtr) Tk_FreeGC(graphPtr->display, elemPtr->fillGC); } -static void DestroyPenProc(Graph* graphPtr, Pen* basePtr) -{ - LinePen* penPtr = (LinePen*)basePtr; - - Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle); - if (penPtr->symbol.outlineGC) - Tk_FreeGC(graphPtr->display, penPtr->symbol.outlineGC); - - if (penPtr->symbol.fillGC) - Tk_FreeGC(graphPtr->display, penPtr->symbol.fillGC); - - if (penPtr->errorBarGC) - Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - - if (penPtr->traceGC) - Blt_FreePrivateGC(graphPtr->display, penPtr->traceGC); - - if (penPtr->symbol.bitmap != None) { - Tk_FreeBitmap(graphPtr->display, penPtr->symbol.bitmap); - penPtr->symbol.bitmap = None; - } - if (penPtr->symbol.mask != None) { - Tk_FreeBitmap(graphPtr->display, penPtr->symbol.mask); - penPtr->symbol.mask = None; - } - - Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin); -} - // Configure static int ConfigureLineProc(Graph* graphPtr, Element *basePtr) { LineElement* elemPtr = (LineElement *)basePtr; - if (ConfigurePenProc(graphPtr, (Pen *)&elemPtr->builtinPen) != TCL_OK) + if (ConfigureLinePenProc(graphPtr, (Pen *)&elemPtr->builtinPen) != TCL_OK) return TCL_ERROR; // Point to the static normal/active pens if no external pens have been @@ -571,117 +352,8 @@ static int ConfigureLineProc(Graph* graphPtr, Element *basePtr) return TCL_OK; } -static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) -{ - LinePen* lpPtr = (LinePen*)basePtr; - - // symbol outline - unsigned long gcMask = (GCLineWidth | GCForeground); - XColor* colorPtr = lpPtr->symbol.outlineColor; - if (!colorPtr) - colorPtr = lpPtr->traceColor; - - XGCValues gcValues; - gcValues.foreground = colorPtr->pixel; - if (lpPtr->symbol.type == SYMBOL_BITMAP) { - colorPtr = lpPtr->symbol.fillColor; - if (!colorPtr) - colorPtr = lpPtr->traceColor; - - if (colorPtr) { - gcValues.background = colorPtr->pixel; - gcMask |= GCBackground; - if (lpPtr->symbol.mask != None) { - gcValues.clip_mask = lpPtr->symbol.mask; - gcMask |= GCClipMask; - } - } - else { - gcValues.clip_mask = lpPtr->symbol.bitmap; - gcMask |= GCClipMask; - } - } - gcValues.line_width = LineWidth(lpPtr->symbol.outlineWidth); - GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (lpPtr->symbol.outlineGC) - Tk_FreeGC(graphPtr->display, lpPtr->symbol.outlineGC); - lpPtr->symbol.outlineGC = newGC; - - // symbol fill - gcMask = (GCLineWidth | GCForeground); - colorPtr = lpPtr->symbol.fillColor; - if (!colorPtr) - colorPtr = lpPtr->traceColor; - - newGC = NULL; - if (colorPtr) { - gcValues.foreground = colorPtr->pixel; - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - } - if (lpPtr->symbol.fillGC) - Tk_FreeGC(graphPtr->display, lpPtr->symbol.fillGC); - lpPtr->symbol.fillGC = newGC; - - // trace - gcMask = (GCLineWidth | GCForeground | GCLineStyle | GCCapStyle | - GCJoinStyle); - gcValues.cap_style = CapButt; - gcValues.join_style = JoinRound; - gcValues.line_style = LineSolid; - gcValues.line_width = LineWidth(lpPtr->traceWidth); - - gcValues.foreground = lpPtr->traceColor->pixel; - colorPtr = lpPtr->traceOffColor; - if (colorPtr) { - gcMask |= GCBackground; - gcValues.background = colorPtr->pixel; - } - if (LineIsDashed(lpPtr->traceDashes)) { - gcValues.line_width = lpPtr->traceWidth; - gcValues.line_style = !colorPtr ? LineOnOffDash : LineDoubleDash; - } - newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); - if (lpPtr->traceGC) - Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC); - - if (LineIsDashed(lpPtr->traceDashes)) { - lpPtr->traceDashes.offset = lpPtr->traceDashes.values[0] / 2; - Blt_SetDashes(graphPtr->display, newGC, &lpPtr->traceDashes); - } - lpPtr->traceGC = newGC; - - // errorbar - gcMask = (GCLineWidth | GCForeground); - colorPtr = lpPtr->errorBarColor; - if (!colorPtr) - colorPtr = lpPtr->traceColor; - - gcValues.line_width = LineWidth(lpPtr->errorBarLineWidth); - gcValues.foreground = colorPtr->pixel; - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (lpPtr->errorBarGC) { - Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC); - } - lpPtr->errorBarGC = newGC; - - return TCL_OK; -} - // Support -static void DestroySymbol(Display *display, Symbol *symbolPtr) -{ - if (symbolPtr->bitmap != None) { - Tk_FreeBitmap(display, symbolPtr->bitmap); - symbolPtr->bitmap = None; - } - if (symbolPtr->mask != None) { - Tk_FreeBitmap(display, symbolPtr->mask); - symbolPtr->mask = None; - } - symbolPtr->type = SYMBOL_NONE; -} - static void ResetStylePalette(Blt_Chain styles) { for (Blt_ChainLink link = Blt_Chain_FirstLink(styles); link; diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 81b51a3..bd1a262 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -45,6 +45,9 @@ extern "C" { // Defs +extern int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, + Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr); + static Tcl_Obj *DisplayListObj(Graph* graphPtr); static void DestroyElement(Element* elemPtr); static int ElementObjConfigure(Tcl_Interp* interp, Graph* graphPtr, @@ -68,8 +71,6 @@ typedef int (GraphElementProc)(Graph* graphPtr, Tcl_Interp* interp, int objc, // OptionSpecs -const char* fillObjOption[] = {"none", "x", "y", "both", NULL}; - static Tk_CustomOptionSetProc ValuesSetProc; static Tk_CustomOptionGetProc ValuesGetProc; static Tk_CustomOptionFreeProc ValuesFreeProc; diff --git a/src/bltGrElemOp.h b/src/bltGrElemOp.h index b2c9db4..740b2b9 100644 --- a/src/bltGrElemOp.h +++ b/src/bltGrElemOp.h @@ -34,6 +34,11 @@ extern "C" { #include <bltVector.h> }; +#include "bltGrPen.h" + +extern void Blt_FreePen(Pen* penPtr); + + #define ELEM_SOURCE_VALUES 0 #define ELEM_SOURCE_VECTOR 1 @@ -85,24 +90,6 @@ typedef struct { int nSegments; } ErrorBarSegments; -struct _Pen { - const char *name; - ClassId classId; - const char *typeId; - unsigned int flags; - int refCount; - Tcl_HashEntry *hashPtr; - Tk_OptionTable optionTable; - PenConfigureProc *configProc; - PenDestroyProc *destroyProc; - Graph *graphPtr; -}; - -typedef struct { - Weight weight; - Pen* penPtr; -} PenStyle; - typedef struct { XColor* color; int lineWidth; @@ -159,6 +146,11 @@ typedef struct { ElemValues* y; } ElemCoords; +typedef struct { + Weight weight; + Pen* penPtr; +} PenStyle; + extern const char* fillObjOption[]; extern Tk_CustomOptionSetProc StyleSetProc; extern Tk_CustomOptionGetProc StyleGetProc; @@ -167,8 +159,6 @@ extern Tk_CustomOptionFreeProc StyleFreeProc; extern double Blt_FindElemValuesMinimum(ElemValues *vecPtr, double minLimit); extern void Blt_ResizeStatusArray(Element* elemPtr, int nPoints); -extern int Blt_GetPenStyle(Graph *graphPtr, char *name, size_t classId, - PenStyle *stylePtr); extern void Blt_FreeStylePalette (Blt_Chain stylePalette); extern PenStyle** Blt_StyleMap (Element* elemPtr); extern void Blt_MapErrorBars(Graph *graphPtr, Element* elemPtr, diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C index 7ff6e3a..b76df6a 100644 --- a/src/bltGrMarkerOp.C +++ b/src/bltGrMarkerOp.C @@ -46,18 +46,16 @@ using namespace Blt; // Defs -void Blt_FreeMarker(char* dataPtr); -static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr); -static Tcl_Obj* PrintCoordinate(double x); - typedef int (GraphMarkerProc)(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); - +void Blt_FreeMarker(char* dataPtr); static int MarkerObjConfigure( Tcl_Interp* interp, Graph* graphPtr, Marker* markerPtr, 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" { diff --git a/src/bltGrPen.h b/src/bltGrPen.h index fb59b2a..bd1bb6e 100644 --- a/src/bltGrPen.h +++ b/src/bltGrPen.h @@ -35,6 +35,25 @@ #include <iomanip> using namespace std; -}; +#include "bltGrPenOp.h" + +typedef struct _Pen Pen; + +typedef Pen* (PenCreateProc)(void); +typedef int (PenConfigureProc)(Graph* graphPtr, Pen* penPtr); +typedef void (PenDestroyProc)(Graph* graphPtr, Pen* penPtr); + +typedef struct _Pen { + const char *name; + ClassId classId; + const char *typeId; + unsigned int flags; + int refCount; + Tcl_HashEntry *hashPtr; + Tk_OptionTable optionTable; + PenConfigureProc *configProc; + PenDestroyProc *destroyProc; + Graph* graphPtr; +} Pen; #endif diff --git a/src/bltGrPenBar.C b/src/bltGrPenBar.C index d798d38..ed5beb1 100644 --- a/src/bltGrPenBar.C +++ b/src/bltGrPenBar.C @@ -27,3 +27,132 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "bltGrPenBar.h" + +static Tk_OptionSpec barPenOptionSpecs[] = { + {TK_OPTION_BORDER, "-background", "background", "Background", + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, fill), + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, -1, 0, 0, "-borderwidth", 0}, + {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, + {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + STD_BORDERWIDTH, -1, Tk_Offset(BarPen, borderWidth), 0, NULL, 0}, + {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", + NULL, -1, Tk_Offset(BarPen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth","ErrorBarWidth", + "1", -1, Tk_Offset(BarPen, errorBarLineWidth), 0, NULL, 0}, + {TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap", + "2", -1, Tk_Offset(BarPen, errorBarCapWidth), 0, NULL, 0}, + {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, + {TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, + {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, outlineColor), + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, + {TK_OPTION_RELIEF, "-relief", "relief", "Relief", + "raised", -1, Tk_Offset(BarPen, relief), 0, NULL, 0}, + {TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars", + "both", -1, Tk_Offset(BarPen, errorBarShow), 0, &fillObjOption, 0}, + {TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues", + "none", -1, Tk_Offset(BarPen, valueShow), 0, &fillObjOption, 0}, + {TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple", + NULL, -1, Tk_Offset(BarPen, stipple), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_STRING, "-type", "type", "Type", + "bar", -1, Tk_Offset(BarPen, typeId), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor", + "s", -1, Tk_Offset(BarPen, valueStyle.anchor), 0, NULL, 0}, + {TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor", + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, valueStyle.color), 0, NULL, 0}, + {TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont", + STD_FONT_SMALL, -1, Tk_Offset(BarPen, valueStyle.font), 0, NULL, 0}, + {TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat", + "%g", -1, Tk_Offset(BarPen, valueFormat), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate", + "0", -1, Tk_Offset(BarPen, valueStyle.angle), 0, NULL, 0}, + {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} +}; + +int ConfigureBarPenProc(Graph* graphPtr, Pen *basePtr) +{ + BarPen* penPtr = (BarPen*)basePtr; + int screenNum = Tk_ScreenNumber(graphPtr->tkwin); + XGCValues gcValues; + unsigned long gcMask; + GC newGC; + + // outlineGC + gcMask = GCForeground | GCLineWidth; + gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); + + if (penPtr->outlineColor) + gcValues.foreground = penPtr->outlineColor->pixel; + else if (penPtr->fill) + gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; + + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (penPtr->outlineGC) + Tk_FreeGC(graphPtr->display, penPtr->outlineGC); + penPtr->outlineGC = newGC; + + newGC = NULL; + if (penPtr->stipple != None) { + // Handle old-style -stipple specially + gcMask = GCForeground | GCBackground | GCFillStyle | GCStipple; + gcValues.foreground = BlackPixel(graphPtr->display, screenNum); + gcValues.background = WhitePixel(graphPtr->display, screenNum); + if (penPtr->fill) + gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; + else if (penPtr->outlineColor) + gcValues.foreground = penPtr->outlineColor->pixel; + + gcValues.stipple = penPtr->stipple; + gcValues.fill_style = FillStippled; + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + } + if (penPtr->fillGC) + Tk_FreeGC(graphPtr->display, penPtr->fillGC); + penPtr->fillGC = newGC; + + // errorBarGC + gcMask = GCForeground | GCLineWidth; + XColor* colorPtr = penPtr->errorBarColor; + if (!colorPtr) + colorPtr = penPtr->outlineColor; + gcValues.foreground = colorPtr->pixel; + gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (penPtr->errorBarGC) + Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); + penPtr->errorBarGC = newGC; + + return TCL_OK; +} + +void InitBarPen(Graph* graphPtr, BarPen* penPtr) +{ + penPtr->configProc = ConfigureBarPenProc; + penPtr->destroyProc = DestroyBarPenProc; + + Blt_Ts_InitStyle(penPtr->valueStyle); + + penPtr->optionTable = + Tk_CreateOptionTable(graphPtr->interp, barPenOptionSpecs); +} + +void DestroyBarPenProc(Graph* graphPtr, Pen* basePtr) +{ + BarPen* penPtr = (BarPen*)basePtr; + + Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle); + if (penPtr->outlineGC) + Tk_FreeGC(graphPtr->display, penPtr->outlineGC); + + if (penPtr->fillGC) + Tk_FreeGC(graphPtr->display, penPtr->fillGC); + + if (penPtr->errorBarGC) + Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); + + Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin); +} + diff --git a/src/bltGrPenBar.h b/src/bltGrPenBar.h index 00dd290..7fd831b 100644 --- a/src/bltGrPenBar.h +++ b/src/bltGrPenBar.h @@ -35,6 +35,44 @@ #include <iomanip> using namespace std; -}; +#include "bltGrPen.h" + +typedef struct { + const char *name; + ClassId classId; + const char *typeId; + unsigned int flags; + int refCount; + Tcl_HashEntry *hashPtr; + Tk_OptionTable optionTable; + PenConfigureProc *configProc; + PenDestroyProc *destroyProc; + Graph* graphPtr; + + // Barchart specific pen fields start here + XColor* outlineColor; + Tk_3DBorder fill; + int borderWidth; + int relief; + Pixmap stipple; + GC fillGC; + GC outlineGC; + + // Error bar attributes + int errorBarShow; + int errorBarLineWidth; + int errorBarCapWidth; + XColor* errorBarColor; + GC errorBarGC; + + // Show value attributes + int valueShow; + const char *valueFormat; + TextStyle valueStyle; +} BarPen; + +extern void InitBarPen(Graph* graphPtr, BarPen* penPtr); +extern int ConfigureBarPenProc(Graph* graphPtr, Pen *basePtr); +extern void DestroyBarPenProc(Graph* graphPtr, Pen* basePtr); #endif diff --git a/src/bltGrPenLine.C b/src/bltGrPenLine.C index d798d38..e070f5a 100644 --- a/src/bltGrPenLine.C +++ b/src/bltGrPenLine.C @@ -27,3 +27,324 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "bltGrPenLine.h" + +typedef struct { + const char* name; + unsigned int minChars; + SymbolType type; +} GraphSymbolType; + +static GraphSymbolType graphSymbols[] = { + { "arrow", 1, SYMBOL_ARROW, }, + { "circle", 2, SYMBOL_CIRCLE, }, + { "cross", 2, SYMBOL_CROSS, }, + { "diamond", 1, SYMBOL_DIAMOND, }, + { "none", 1, SYMBOL_NONE, }, + { "plus", 1, SYMBOL_PLUS, }, + { "scross", 2, SYMBOL_SCROSS, }, + { "splus", 2, SYMBOL_SPLUS, }, + { "square", 2, SYMBOL_SQUARE, }, + { "triangle", 1, SYMBOL_TRIANGLE, }, + { NULL, 0, SYMBOL_NONE, }, +}; + +// Defs + +static void DestroySymbol(Display *display, Symbol *symbolPtr); + +static Tk_CustomOptionSetProc SymbolSetProc; +static Tk_CustomOptionGetProc SymbolGetProc; +Tk_ObjCustomOption symbolObjOption = + { + "symbol", SymbolSetProc, SymbolGetProc, NULL, NULL, NULL + }; + +static int SymbolSetProc(ClientData clientData, Tcl_Interp* interp, + Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec, + int offset, char* save, int flags) +{ + Symbol* symbolPtr = (Symbol*)(widgRec + offset); + const char* string; + + // string + { + int length; + string = Tcl_GetStringFromObj(*objPtr, &length); + if (length == 0) { + DestroySymbol(Tk_Display(tkwin), symbolPtr); + symbolPtr->type = SYMBOL_NONE; + return TCL_OK; + } + char c = string[0]; + + for (GraphSymbolType* p = graphSymbols; p->name; p++) { + if (length < p->minChars) { + continue; + } + if ((c == p->name[0]) && (strncmp(string, p->name, length) == 0)) { + DestroySymbol(Tk_Display(tkwin), symbolPtr); + symbolPtr->type = p->type; + return TCL_OK; + } + } + } + + // bitmap + { + Tcl_Obj **objv; + int objc; + if ((Tcl_ListObjGetElements(NULL, *objPtr, &objc, &objv) != TCL_OK) || + (objc > 2)) { + goto error; + } + Pixmap bitmap = None; + Pixmap mask = None; + if (objc > 0) { + bitmap = Tk_AllocBitmapFromObj((Tcl_Interp*)NULL, tkwin, objv[0]); + if (!bitmap) + goto error; + + } + if (objc > 1) { + mask = Tk_AllocBitmapFromObj((Tcl_Interp*)NULL, tkwin, objv[1]); + if (!mask) + goto error; + } + DestroySymbol(Tk_Display(tkwin), symbolPtr); + symbolPtr->bitmap = bitmap; + symbolPtr->mask = mask; + symbolPtr->type = SYMBOL_BITMAP; + + return TCL_OK; + } + error: + Tcl_AppendResult(interp, "bad symbol \"", string, + "\": should be \"none\", \"circle\", \"square\", \"diamond\", " + "\"plus\", \"cross\", \"splus\", \"scross\", \"triangle\", " + "\"arrow\" or the name of a bitmap", NULL); + return TCL_ERROR; +} + +static Tcl_Obj* SymbolGetProc(ClientData clientData, Tk_Window tkwin, + char* widgRec, int offset) +{ + Symbol* symbolPtr = (Symbol*)(widgRec + offset); + + Tcl_Obj* ll[2]; + if (symbolPtr->type == SYMBOL_BITMAP) { + ll[0] = + Tcl_NewStringObj(Tk_NameOfBitmap(Tk_Display(tkwin),symbolPtr->bitmap),-1); + ll[1] = symbolPtr->mask ? + Tcl_NewStringObj(Tk_NameOfBitmap(Tk_Display(tkwin),symbolPtr->mask),-1) : + Tcl_NewStringObj("", -1); + return Tcl_NewListObj(2, ll); + } + else { + for (GraphSymbolType* p = graphSymbols; p->name; p++) { + if (p->type == symbolPtr->type) + return Tcl_NewStringObj(p->name, -1); + } + return Tcl_NewStringObj("?unknown symbol type?", -1); + } +} + +static Tk_OptionSpec linePenOptionSpecs[] = { + {TK_OPTION_COLOR, "-color", "color", "Color", + STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePen, traceColor), 0, NULL, 0}, + {TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes", + NULL, -1, Tk_Offset(LinePen, traceDashes), + TK_OPTION_NULL_OK, &dashesObjOption, 0}, + {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", + NULL, -1, Tk_Offset(LinePen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth", "ErrorBarWidth", + "1", -1, Tk_Offset(LinePen, errorBarLineWidth), 0, NULL, 0}, + {TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap", + "2", -1, Tk_Offset(LinePen, errorBarCapWidth), 0, NULL, 0}, + {TK_OPTION_COLOR, "-fill", "fill", "Fill", + NULL, -1, Tk_Offset(LinePen, symbol.fillColor), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth", + "1", -1, Tk_Offset(LinePen, traceWidth), 0, NULL, 0}, + {TK_OPTION_COLOR, "-offdash", "offDash", "OffDash", + NULL, -1, Tk_Offset(LinePen, traceOffColor), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_COLOR, "-outline", "outline", "Outline", + NULL, -1, Tk_Offset(LinePen, symbol.outlineColor), + TK_OPTION_NULL_OK, NULL,0}, + {TK_OPTION_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth", + "1", -1, Tk_Offset(LinePen, symbol.outlineWidth), 0, NULL, 0}, + {TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels", + "0.1i", -1, Tk_Offset(LinePen, symbol.size), 0, NULL, 0}, + {TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars", + "both", -1, Tk_Offset(LinePen, errorBarShow), 0, &fillObjOption, 0}, + {TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues", + "none", -1, Tk_Offset(LinePen, valueShow), 0, &fillObjOption, 0}, + {TK_OPTION_CUSTOM, "-symbol", "symbol", "Symbol", + "none", -1, Tk_Offset(LinePen, symbol), 0, &symbolObjOption, 0}, + {TK_OPTION_STRING, "-type", "type", "Type", + "line", -1, Tk_Offset(Pen, typeId), 0, NULL, 0}, + {TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor", + "s", -1, Tk_Offset(LinePen, valueStyle.anchor), 0, NULL, 0}, + {TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor", + STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePen, valueStyle.color), 0, NULL, 0}, + {TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont", + STD_FONT_SMALL, -1, Tk_Offset(LinePen, valueStyle.font), 0, NULL, 0}, + {TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat", + "%g", -1, Tk_Offset(LinePen, valueFormat), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate", + "0", -1, Tk_Offset(LinePen, valueStyle.angle), 0, NULL, 0}, + {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} +}; + +int ConfigureLinePenProc(Graph* graphPtr, Pen* basePtr) +{ + LinePen* lpPtr = (LinePen*)basePtr; + + // symbol outline + unsigned long gcMask = (GCLineWidth | GCForeground); + XColor* colorPtr = lpPtr->symbol.outlineColor; + if (!colorPtr) + colorPtr = lpPtr->traceColor; + + XGCValues gcValues; + gcValues.foreground = colorPtr->pixel; + if (lpPtr->symbol.type == SYMBOL_BITMAP) { + colorPtr = lpPtr->symbol.fillColor; + if (!colorPtr) + colorPtr = lpPtr->traceColor; + + if (colorPtr) { + gcValues.background = colorPtr->pixel; + gcMask |= GCBackground; + if (lpPtr->symbol.mask != None) { + gcValues.clip_mask = lpPtr->symbol.mask; + gcMask |= GCClipMask; + } + } + else { + gcValues.clip_mask = lpPtr->symbol.bitmap; + gcMask |= GCClipMask; + } + } + gcValues.line_width = LineWidth(lpPtr->symbol.outlineWidth); + GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (lpPtr->symbol.outlineGC) + Tk_FreeGC(graphPtr->display, lpPtr->symbol.outlineGC); + lpPtr->symbol.outlineGC = newGC; + + // symbol fill + gcMask = (GCLineWidth | GCForeground); + colorPtr = lpPtr->symbol.fillColor; + if (!colorPtr) + colorPtr = lpPtr->traceColor; + + newGC = NULL; + if (colorPtr) { + gcValues.foreground = colorPtr->pixel; + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + } + if (lpPtr->symbol.fillGC) + Tk_FreeGC(graphPtr->display, lpPtr->symbol.fillGC); + lpPtr->symbol.fillGC = newGC; + + // trace + gcMask = (GCLineWidth | GCForeground | GCLineStyle | GCCapStyle | + GCJoinStyle); + gcValues.cap_style = CapButt; + gcValues.join_style = JoinRound; + gcValues.line_style = LineSolid; + gcValues.line_width = LineWidth(lpPtr->traceWidth); + + gcValues.foreground = lpPtr->traceColor->pixel; + colorPtr = lpPtr->traceOffColor; + if (colorPtr) { + gcMask |= GCBackground; + gcValues.background = colorPtr->pixel; + } + if (LineIsDashed(lpPtr->traceDashes)) { + gcValues.line_width = lpPtr->traceWidth; + gcValues.line_style = !colorPtr ? LineOnOffDash : LineDoubleDash; + } + newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); + if (lpPtr->traceGC) + Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC); + + if (LineIsDashed(lpPtr->traceDashes)) { + lpPtr->traceDashes.offset = lpPtr->traceDashes.values[0] / 2; + Blt_SetDashes(graphPtr->display, newGC, &lpPtr->traceDashes); + } + lpPtr->traceGC = newGC; + + // errorbar + gcMask = (GCLineWidth | GCForeground); + colorPtr = lpPtr->errorBarColor; + if (!colorPtr) + colorPtr = lpPtr->traceColor; + + gcValues.line_width = LineWidth(lpPtr->errorBarLineWidth); + gcValues.foreground = colorPtr->pixel; + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (lpPtr->errorBarGC) { + Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC); + } + lpPtr->errorBarGC = newGC; + + return TCL_OK; +} + +void InitLinePen(Graph* graphPtr, LinePen* penPtr) +{ + penPtr->configProc = ConfigureLinePenProc; + penPtr->destroyProc = DestroyLinePenProc; + + Blt_Ts_InitStyle(penPtr->valueStyle); + penPtr->symbol.bitmap = None; + penPtr->symbol.mask = None; + penPtr->symbol.type = SYMBOL_NONE; + + penPtr->optionTable = + Tk_CreateOptionTable(graphPtr->interp, linePenOptionSpecs); +} + +void DestroyLinePenProc(Graph* graphPtr, Pen* basePtr) +{ + LinePen* penPtr = (LinePen*)basePtr; + + Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle); + if (penPtr->symbol.outlineGC) + Tk_FreeGC(graphPtr->display, penPtr->symbol.outlineGC); + + if (penPtr->symbol.fillGC) + Tk_FreeGC(graphPtr->display, penPtr->symbol.fillGC); + + if (penPtr->errorBarGC) + Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); + + if (penPtr->traceGC) + Blt_FreePrivateGC(graphPtr->display, penPtr->traceGC); + + if (penPtr->symbol.bitmap != None) { + Tk_FreeBitmap(graphPtr->display, penPtr->symbol.bitmap); + penPtr->symbol.bitmap = None; + } + if (penPtr->symbol.mask != None) { + Tk_FreeBitmap(graphPtr->display, penPtr->symbol.mask); + penPtr->symbol.mask = None; + } + + Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin); +} + +static void DestroySymbol(Display *display, Symbol *symbolPtr) +{ + if (symbolPtr->bitmap != None) { + Tk_FreeBitmap(display, symbolPtr->bitmap); + symbolPtr->bitmap = None; + } + if (symbolPtr->mask != None) { + Tk_FreeBitmap(display, symbolPtr->mask); + symbolPtr->mask = None; + } + symbolPtr->type = SYMBOL_NONE; +} + + diff --git a/src/bltGrPenLine.h b/src/bltGrPenLine.h index 75e7ba2..e171ba8 100644 --- a/src/bltGrPenLine.h +++ b/src/bltGrPenLine.h @@ -35,6 +35,8 @@ #include <iomanip> using namespace std; +#include "bltGrPen.h" + typedef enum { SYMBOL_NONE, SYMBOL_SQUARE, SYMBOL_CIRCLE, SYMBOL_DIAMOND, SYMBOL_PLUS, SYMBOL_CROSS, SYMBOL_SPLUS, SYMBOL_SCROSS, SYMBOL_TRIANGLE, SYMBOL_ARROW, @@ -90,4 +92,10 @@ typedef struct { TextStyle valueStyle; } LinePen; +extern Tk_ObjCustomOption symbolObjOption; + +extern void InitLinePen(Graph* graphPtr, LinePen* penPtr); +extern int ConfigureLinePenProc(Graph* graphPtr, Pen *basePtr); +extern void DestroyLinePenProc(Graph* graphPtr, Pen* basePtr); + #endif diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index 8da39ec..4273ebb 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -38,10 +38,17 @@ extern "C" { #include "bltOp.h" }; -#include "bltGrElem.h" +#include "bltGrPenOp.h" +#include "bltGrPenLine.h" +#include "bltGrPenBar.h" // Defs +extern int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr); +extern void Blt_FreePen(Pen* penPtr); + +static Pen* CreateBarPen(Graph* graphPtr, const char *penName); +static Pen* CreateLinePen(Graph* graphPtr, const char* penName); static void DestroyPen(Pen* penPtr); static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, Pen **penPtrPtr); @@ -129,10 +136,10 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, Pen* penPtr; switch (classId) { case CID_ELEM_BAR: - penPtr = Blt_BarPen(graphPtr, penName); + penPtr = CreateBarPen(graphPtr, penName); break; case CID_ELEM_LINE: - penPtr = Blt_LinePen(graphPtr, penName); + penPtr = CreateLinePen(graphPtr, penName); break; default: return TCL_ERROR; @@ -441,3 +448,22 @@ static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, return TCL_OK; } +static Pen* CreateBarPen(Graph* graphPtr, const char *penName) +{ + BarPen* penPtr = (BarPen*)calloc(1, sizeof(BarPen)); + InitBarPen(graphPtr, penPtr); + penPtr->name = Blt_Strdup(penName); + + return (Pen*)penPtr; +} + +static Pen* CreateLinePen(Graph* graphPtr, const char* penName) +{ + LinePen* penPtr = (LinePen*)calloc(1, sizeof(LinePen)); + InitLinePen(graphPtr, penPtr); + penPtr->name = Blt_Strdup(penName); + penPtr->classId = CID_ELEM_LINE; + + return (Pen*)penPtr; +} + diff --git a/src/bltGrPenOp.h b/src/bltGrPenOp.h index 7ef7df0..ca22b60 100644 --- a/src/bltGrPenOp.h +++ b/src/bltGrPenOp.h @@ -35,6 +35,8 @@ #include <iomanip> using namespace std; +extern "C" { +#include "bltGraph.h" }; #endif diff --git a/src/bltGraph.h b/src/bltGraph.h index 804b585..1520a24 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -50,7 +50,6 @@ typedef struct _Graph Graph; typedef struct _Legend Legend; typedef struct _Crosshairs Crosshairs; typedef struct _Element Element; -typedef struct _Pen Pen; typedef enum { CID_NONE, CID_AXIS_X, CID_AXIS_Y, CID_ELEM_BAR, CID_ELEM_LINE, @@ -131,10 +130,6 @@ typedef enum BarModes { BARS_INFRONT, BARS_STACKED, BARS_ALIGNED, BARS_OVERLAP } BarMode; -typedef Pen *(PenCreateProc)(void); -typedef int (PenConfigureProc)(Graph* graphPtr, Pen* penPtr); -typedef void (PenDestroyProc)(Graph* graphPtr, Pen* penPtr); - typedef struct { short int width, height; /* Dimensions of the margin */ short int axesOffset; @@ -389,171 +384,118 @@ struct _Graph { #define REDRAW_WORLD (DRAW_LEGEND) #define RESET_WORLD (REDRAW_WORLD | MAP_WORLD) -extern int Blt_CreateCrosshairs(Graph* graphPtr); -extern int Blt_CreatePageSetup(Graph* graphPtr); - -extern void Blt_ConfigureAxes(Graph* graphPtr); - -extern void Blt_DestroyCrosshairs(Graph* graphPtr); - -extern double Blt_InvHMap(Axis *axisPtr, double x); - -extern double Blt_InvVMap(Axis *axisPtr, double x); - -extern double Blt_HMap(Axis *axisPtr, double x); - -extern double Blt_VMap(Axis *axisPtr, double y); - -extern Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, - Axis2d *pairPtr); - -extern Point2d Blt_Map2D(Graph* graphPtr, double x, double y, - Axis2d *pairPtr); - -extern Graph *Blt_GetGraphFromWindowData(Tk_Window tkwin); - -extern void Blt_AdjustAxisPointers(Graph* graphPtr); - -extern int Blt_PolyRectClip(Region2d *extsPtr, Point2d *inputPts, - int nInputPts, Point2d *outputPts); - -extern void Blt_ComputeBarStacks(Graph* graphPtr); - -extern void Blt_ReconfigureGraph(Graph* graphPtr); - -extern void Blt_DestroyAxes(Graph* graphPtr); +// Markers +extern int Blt_MarkerOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]); +extern void Blt_DestroyMarkers(Graph* graphPtr); +extern void Blt_DrawMarkers(Graph* graphPtr, Drawable drawable, int under); +extern void Blt_MapMarkers(Graph* graphPtr); +extern void Blt_MarkersToPostScript(Graph* graphPtr, Blt_Ps ps, int under); +extern ClientData Blt_MakeMarkerTag(Graph* graphPtr, const char* tagName); +extern void* Blt_NearestMarker(Graph* graphPtr, int x, int y, int under); +extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts, + int nScreenPts); +extern int Blt_RegionInPolygon(Region2d *extsPtr, Point2d *points, + int nPoints, int enclosed); +extern int Blt_PointInSegments(Point2d *samplePtr, Segment2d *segments, + int nSegments, double halo); +// Pens +extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[]); +extern int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, + const char* penName, ClassId classId, + int objc, Tcl_Obj* const objv[]); +extern void Blt_DestroyPens(Graph* graphPtr); +// Elements +extern int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[], ClassId classId); extern void Blt_DestroyElements(Graph* graphPtr); - -extern void Blt_DestroyPageSetup(Graph* graphPtr); - -extern void Blt_DrawAxes(Graph* graphPtr, Drawable drawable); - -extern void Blt_DrawAxisLimits(Graph* graphPtr, Drawable drawable); - extern void Blt_DrawElements(Graph* graphPtr, Drawable drawable); - extern void Blt_DrawActiveElements(Graph* graphPtr, Drawable drawable); - -extern void Blt_DrawGraph(Graph* graphPtr, Drawable drawable); - -extern void Blt_Draw2DSegments(Display *display, Drawable drawable, GC gc, - Segment2d *segments, int nSegments); - -extern int Blt_GetCoordinate(Tcl_Interp* interp, const char *string, - double *valuePtr); - -extern void Blt_InitBarSetTable(Graph* graphPtr); - -extern void Blt_LayoutGraph(Graph* graphPtr); - -extern void Blt_EventuallyRedrawGraph(Graph* graphPtr); - -extern void Blt_ResetAxes(Graph* graphPtr); - -extern void Blt_ResetBarGroups(Graph* graphPtr); - -extern void Blt_GraphExtents(Graph* graphPtr, Region2d *extsPtr); - -extern void Blt_DisableCrosshairs(Graph* graphPtr); - -extern void Blt_EnableCrosshairs(Graph* graphPtr); - -extern void Blt_MapGraph(Graph* graphPtr); - -extern void Blt_MapAxes(Graph* graphPtr); - extern void Blt_MapElements(Graph* graphPtr); +extern void Blt_ElementsToPostScript(Graph* graphPtr, Blt_Ps ps); +extern void Blt_ActiveElementsToPostScript(Graph* graphPtr, Blt_Ps ps); -extern void Blt_DestroyPens(Graph* graphPtr); - -extern int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, - Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr); - -extern Pen* Blt_BarPen(Graph* graphPtr, const char* penName); - -extern Pen* Blt_LinePen(Graph* graphPtr, const char* penName); - -extern int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, - const char* penName, ClassId classId, - int objc, Tcl_Obj* const objv[]); - -extern int Blt_InitLinePens(Graph* graphPtr); - -extern int Blt_InitBarPens(Graph* graphPtr); +// Line Element +extern Element *Blt_LineElement(Graph* graphPtr); -extern void Blt_FreePen(Pen* penPtr); +// Bar Element +extern Element *Blt_BarElement(Graph* graphPtr); +extern void Blt_DestroyBarSets(Graph* graphPtr); +extern void Blt_ResetBarGroups(Graph* graphPtr); +extern void Blt_InitBarSetTable(Graph* graphPtr); +// Axis extern int Blt_AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); - extern int Blt_DefAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, int objc, Tcl_Obj* const objv[]); +extern void Blt_MapAxes(Graph* graphPtr); +extern void Blt_ConfigureAxes(Graph* graphPtr); +extern void Blt_AdjustAxisPointers(Graph* graphPtr); +extern void Blt_DestroyAxes(Graph* graphPtr); +extern void Blt_DrawAxes(Graph* graphPtr, Drawable drawable); +extern void Blt_DrawAxisLimits(Graph* graphPtr, Drawable drawable); +extern void Blt_DrawGrids(Graph* graphPtr, Drawable drawable); +extern int Blt_CreateAxes(Graph* graphPtr); +extern void Blt_UpdateAxisBackgrounds(Graph* graphPtr); +extern void Blt_AxesToPostScript(Graph* graphPtr, Blt_Ps ps); +extern void Blt_AxisLimitsToPostScript(Graph* graphPtr, Blt_Ps ps); +extern void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps); -extern int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[], ClassId classId); +extern Axis *Blt_GetFirstAxis(Blt_Chain chain); +extern Axis *Blt_NearestAxis(Graph* graphPtr, int x, int y); +extern void Blt_ResetAxes(Graph* graphPtr); +// Crosshairs extern int Blt_CrosshairsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); +extern int Blt_CreateCrosshairs(Graph* graphPtr); +extern void Blt_DestroyCrosshairs(Graph* graphPtr); +extern void Blt_DisableCrosshairs(Graph* graphPtr); +extern void Blt_EnableCrosshairs(Graph* graphPtr); -extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]); - -extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts, - int nScreenPts); - -extern int Blt_RegionInPolygon(Region2d *extsPtr, Point2d *points, - int nPoints, int enclosed); - -extern int Blt_PointInSegments(Point2d *samplePtr, Segment2d *segments, - int nSegments, double halo); +// Legend +extern void Blt_LegendToPostScript(Graph* graphPtr, Blt_Ps ps); +// Postscript extern int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); - -extern int Blt_GraphUpdateNeeded(Graph* graphPtr); - -extern int Blt_CreateAxes(Graph* graphPtr); - -extern Axis *Blt_GetFirstAxis(Blt_Chain chain); - -extern void Blt_UpdateAxisBackgrounds(Graph* graphPtr); - -extern Axis *Blt_NearestAxis(Graph* graphPtr, int x, int y); +extern int Blt_CreatePageSetup(Graph* graphPtr); +extern void Blt_DestroyPageSetup(Graph* graphPtr); typedef ClientData (MakeTagProc)(Graph* graphPtr, const char *tagName); - extern MakeTagProc Blt_MakeElementTag; extern MakeTagProc Blt_MakeAxisTag; extern Blt_BindTagProc Blt_GraphTags; extern Blt_BindTagProc Blt_AxisTags; +extern double Blt_InvHMap(Axis *axisPtr, double x); +extern double Blt_InvVMap(Axis *axisPtr, double x); +extern double Blt_HMap(Axis *axisPtr, double x); +extern double Blt_VMap(Axis *axisPtr, double y); +extern Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, + Axis2d *pairPtr); +extern Point2d Blt_Map2D(Graph* graphPtr, double x, double y, + Axis2d *pairPtr); +extern Graph *Blt_GetGraphFromWindowData(Tk_Window tkwin); +extern int Blt_PolyRectClip(Region2d *extsPtr, Point2d *inputPts, + int nInputPts, Point2d *outputPts); +extern void Blt_ComputeBarStacks(Graph* graphPtr); +extern void Blt_ReconfigureGraph(Graph* graphPtr); +extern void Blt_DrawGraph(Graph* graphPtr, Drawable drawable); +extern void Blt_Draw2DSegments(Display *display, Drawable drawable, GC gc, + Segment2d *segments, int nSegments); +extern int Blt_GetCoordinate(Tcl_Interp* interp, const char *string, + double *valuePtr); +extern void Blt_LayoutGraph(Graph* graphPtr); +extern void Blt_EventuallyRedrawGraph(Graph* graphPtr); +extern void Blt_GraphExtents(Graph* graphPtr, Region2d *extsPtr); +extern void Blt_MapGraph(Graph* graphPtr); +extern int Blt_GraphUpdateNeeded(Graph* graphPtr); extern void Blt_GraphSetObjectClass(GraphObj *graphObjPtr,ClassId classId); - -extern void Blt_ElementsToPostScript(Graph* graphPtr, Blt_Ps ps); -extern void Blt_ActiveElementsToPostScript(Graph* graphPtr, Blt_Ps ps); -extern void Blt_LegendToPostScript(Graph* graphPtr, Blt_Ps ps); -extern void Blt_AxesToPostScript(Graph* graphPtr, Blt_Ps ps); -extern void Blt_AxisLimitsToPostScript(Graph* graphPtr, Blt_Ps ps); -extern Element *Blt_LineElement(Graph* graphPtr); -extern Element *Blt_BarElement(Graph* graphPtr); - -extern void Blt_DrawGrids(Graph* graphPtr, Drawable drawable); - -extern void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps); -extern void Blt_InitBarSetTable(Graph* graphPtr); -extern void Blt_DestroyBarSets(Graph* graphPtr); - extern const char *Blt_GraphClassName(ClassId classId); -extern void Blt_DestroyMarkers(Graph* graphPtr); -extern void Blt_DrawMarkers(Graph* graphPtr, Drawable drawable, int under); -extern ClientData Blt_MakeMarkerTag(Graph* graphPtr, const char* tagName); -extern void Blt_MapMarkers(Graph* graphPtr); -extern int Blt_MarkerOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj* const objv[]); -extern void Blt_MarkersToPostScript(Graph* graphPtr, Blt_Ps ps, int under); -extern void* Blt_NearestMarker(Graph* graphPtr, int x, int y, int under); - #endif |