From ea220a1484f01869322a3e5653d43a31c145cbca Mon Sep 17 00:00:00 2001 From: joye Date: Tue, 15 Apr 2014 17:52:55 +0000 Subject: *** empty log message *** --- bltGrMarkerBitmap.C | 1 + src/bltConfig.C | 1 + src/bltGrAxisOp.C | 1 + src/bltGrElemLine.C | 1 + src/bltGrLegd.C | 1 + src/bltGrMarker.C | 1 + src/bltGrMarkerPolygon.C | 1 + src/bltGrMarkerText.C | 1 + src/bltGrMisc.h | 40 ++++++++++++++++++++++++++ src/bltGraph.C | 73 ++++++++---------------------------------------- src/bltGraph.h | 16 ----------- src/bltGraphOp.C | 17 +++++++++-- 12 files changed, 74 insertions(+), 80 deletions(-) create mode 100644 src/bltGrMisc.h diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C index 7c3a4a3..cd12103 100644 --- a/bltGrMarkerBitmap.C +++ b/bltGrMarkerBitmap.C @@ -29,6 +29,7 @@ #include "bltGrMarkerBitmap.h" #include "bltGrMarkerOption.h" +#include "bltGrMisc.h" using namespace Blt; diff --git a/src/bltConfig.C b/src/bltConfig.C index b1b35e1..1c838fd 100644 --- a/src/bltConfig.C +++ b/src/bltConfig.C @@ -45,6 +45,7 @@ extern "C" { }; #include "bltConfig.h" +#include "bltGrMisc.h" void RestoreProc(ClientData clientData, Tk_Window tkwin, char *ptr, char *savePtr) diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C index 58e5e46..9420ca1 100644 --- a/src/bltGrAxisOp.C +++ b/src/bltGrAxisOp.C @@ -38,6 +38,7 @@ extern "C" { #include "bltGrAxisOp.h" #include "bltGrElem.h" #include "bltGrLegd.h" +#include "bltGrMisc.h" #define AXIS_PAD_TITLE 2 diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 770ede5..7241473 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -38,6 +38,7 @@ extern "C" { #include "bltGrPenOp.h" #include "bltGrAxis.h" #include "bltGrAxisOp.h" +#include "bltGrMisc.h" #define SEARCH_X 0 #define SEARCH_Y 1 diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 00d3dcb..ab5a91d 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -35,6 +35,7 @@ extern "C" { #include "bltGrElem.h" #include "bltGrElemOp.h" #include "bltGrHairsOp.h" +#include "bltGrMisc.h" static void SelectCmdProc(ClientData); static Tcl_IdleProc DisplayProc; diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 3a32589..6332386 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -29,6 +29,7 @@ #include "bltGrMarker.h" #include "bltGrAxis.h" +#include "bltGrMisc.h" using namespace Blt; diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C index 8b2c1da..d18af99 100644 --- a/src/bltGrMarkerPolygon.C +++ b/src/bltGrMarkerPolygon.C @@ -29,6 +29,7 @@ #include "bltGrMarkerPolygon.h" #include "bltGrMarkerOption.h" +#include "bltGrMisc.h" using namespace Blt; diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C index db34af8..e5ade3f 100644 --- a/src/bltGrMarkerText.C +++ b/src/bltGrMarkerText.C @@ -29,6 +29,7 @@ #include "bltGrMarkerText.h" #include "bltGrMarkerOption.h" +#include "bltGrMisc.h" using namespace Blt; diff --git a/src/bltGrMisc.h b/src/bltGrMisc.h new file mode 100644 index 0000000..31fe319 --- /dev/null +++ b/src/bltGrMisc.h @@ -0,0 +1,40 @@ +/* + * 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 __BltGrMisc_h__ +#define __BltGrMisc_h__ + +extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts, + int nScreenPts); +extern int Blt_GetXY(Tcl_Interp* interp, Tk_Window tkwin, + const char *string, int *xPtr, int *yPtr); +extern int Blt_PolyRectClip(Region2d *extsPtr, Point2d *inputPts, + int nInputPts, Point2d *outputPts); + +#endif diff --git a/src/bltGraph.C b/src/bltGraph.C index 121e672..438c445 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -27,13 +27,8 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "bltMath.h" - extern "C" { -#include "bltInt.h" -#include "bltList.h" #include "bltGraph.h" -#include "bltOp.h" } #include "bltGraphOp.h" @@ -54,13 +49,13 @@ extern "C" { using namespace Blt; -#define MARKER_UNDER 1 /* Draw markers designated to lie underneath - * elements, grids, legend, etc. */ -#define MARKER_ABOVE 0 /* Draw markers designated to rest above - * elements, grids, legend, etc. */ - -extern void ConfigureGraph(Graph* graphPtr); +#define MARKER_ABOVE 0 +#define MARKER_UNDER 1 +extern void GraphConfigure(Graph* graphPtr); +extern void GraphDestroy(Graph* graphPtr); +extern int Blt_CreatePageSetup(Graph* graphPtr); +extern void Blt_DestroyPageSetup(Graph* graphPtr); static Blt_BindPickProc PickEntry; @@ -190,18 +185,11 @@ static Tk_OptionSpec optionSpecs[] = { int NewGraph(ClientData clientData, Tcl_Interp*interp, int objc, Tcl_Obj* const objv[], ClassId classId) { - if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); - return TCL_ERROR; - } - Tk_Window tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), Tcl_GetString(objv[1]), NULL); if (!tkwin) return TCL_ERROR; - Tk_OptionTable optionTable = Tk_CreateOptionTable(interp, optionSpecs); - switch (classId) { case CID_ELEM_LINE: Tk_SetClass(tkwin, "Graph"); @@ -213,6 +201,8 @@ int NewGraph(ClientData clientData, Tcl_Interp*interp, break; } + Tk_OptionTable optionTable = Tk_CreateOptionTable(interp, optionSpecs); + Graph* graphPtr = (Graph*)calloc(1, sizeof(Graph)); ((TkWindow*)tkwin)->instanceData = graphPtr; @@ -288,7 +278,7 @@ int NewGraph(ClientData clientData, Tcl_Interp*interp, return TCL_OK; error: - DestroyGraph((char*)graphPtr); + GraphDestroy(graphPtr); return TCL_ERROR; } @@ -323,7 +313,7 @@ void GraphDestroy(Graph* graphPtr) free(graphPtr); } -void ConfigureGraph(Graph* graphPtr) +void GraphConfigure(Graph* graphPtr) { // Don't allow negative bar widths. Reset to an arbitrary value (0.1) if (graphPtr->barWidth <= 0.0f) { @@ -371,8 +361,6 @@ void ConfigureGraph(Graph* graphPtr) } } -// Support - void GraphDisplay(Graph* graphPtr) { Tk_Window tkwin = graphPtr->tkwin; @@ -481,8 +469,6 @@ void GraphDisplay(Graph* graphPtr) UpdateMarginTraces(graphPtr); } -// Ops - // Support void Blt_EventuallyRedrawGraph(Graph* graphPtr) @@ -797,43 +783,6 @@ void Blt_MapGraph(Graph* graphPtr) } } -void Blt_DrawGraph(Graph* graphPtr, Drawable drawable) -{ - DrawPlot(graphPtr, drawable); - // Draw markers above elements - Blt::DrawMarkers(graphPtr, drawable, MARKER_ABOVE); - Blt_DrawActiveElements(graphPtr, drawable); - - // Don't draw legend in the plot area - if (graphPtr->legend->isRaised()) { - switch (graphPtr->legend->position()) { - case Legend::PLOT: - case Legend::XY: - graphPtr->legend->draw(drawable); - break; - default: - break; - } - } - - // Draw 3D border just inside of the focus highlight ring - if ((graphPtr->borderWidth > 0) && (graphPtr->relief != TK_RELIEF_FLAT)) { - Tk_Draw3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, - graphPtr->highlightWidth, graphPtr->highlightWidth, - graphPtr->width - 2*graphPtr->highlightWidth, - graphPtr->height - 2*graphPtr->highlightWidth, - graphPtr->borderWidth, graphPtr->relief); - } - /* Draw focus highlight ring. */ - if ((graphPtr->highlightWidth > 0) && (graphPtr->flags & FOCUS)) { - GC gc; - - gc = Tk_GCForColor(graphPtr->highlightColor, drawable); - Tk_DrawFocusHighlight(graphPtr->tkwin, gc, graphPtr->highlightWidth, - drawable); - } -} - static void UpdateMarginTraces(Graph* graphPtr) { Margin* marginPtr; @@ -872,7 +821,7 @@ Graph* Blt_GetGraphFromWindowData(Tk_Window tkwin) void Blt_ReconfigureGraph(Graph* graphPtr) { - ConfigureGraph(graphPtr); + GraphConfigure(graphPtr); graphPtr->legend->configure(); // Blt_ConfigureElements(graphPtr); Blt_ConfigureAxes(graphPtr); diff --git a/src/bltGraph.h b/src/bltGraph.h index cfe6507..f2095c4 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -386,17 +386,6 @@ struct _Graph { #define REDRAW_WORLD (DRAW_LEGEND) #define RESET_WORLD (REDRAW_WORLD | MAP_WORLD) -// Misc -extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts, - int nScreenPts); - - -// Postscript -extern int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]); -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; @@ -404,14 +393,9 @@ extern Blt_BindTagProc Blt_GraphTags; extern Blt_BindTagProc Blt_AxisTags; extern Graph *Blt_GetGraphFromWindowData(Tk_Window tkwin); -extern int Blt_PolyRectClip(Region2d *extsPtr, Point2d *inputPts, - int nInputPts, Point2d *outputPts); 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); diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index d06577a..8249f7e 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -56,13 +56,16 @@ using namespace Blt; extern void GraphDisplay(Graph* graphPtr); extern void GraphDestroy(Graph* graphPtr); -extern void ConfigureGraph(Graph* graphPtr); +extern void GraphConfigure(Graph* graphPtr); extern int NewGraph(ClientData clientData, Tcl_Interp*interp, int objc, Tcl_Obj* const objv[], ClassId classId); static Tcl_ObjCmdProc BarchartObjCmd; static Tcl_ObjCmdProc GraphObjCmd; +extern int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[]); + int Blt_GraphCmdInitProc(Tcl_Interp* interp) { static Blt_InitCmdSpec graphSpec = @@ -81,12 +84,22 @@ int Blt_GraphCmdInitProc(Tcl_Interp* interp) static int GraphObjCmd(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + return NewGraph(clientData, interp, objc, objv, CID_ELEM_LINE); } static int BarchartObjCmd(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + return NewGraph(clientData, interp, objc, objv, CID_ELEM_BAR); } @@ -112,7 +125,7 @@ int GraphObjConfigure(Tcl_Interp* interp, Graph* graphPtr, } graphPtr->flags |= mask; - ConfigureGraph(graphPtr); + GraphConfigure(graphPtr); Blt_EventuallyRedrawGraph(graphPtr); break; -- cgit v0.12