From ecfd4bf4389606427b373f412c6028c6a03b33eb Mon Sep 17 00:00:00 2001 From: joye Date: Wed, 16 Apr 2014 19:08:03 +0000 Subject: *** empty log message *** --- src/bltGrAxisOp.C | 8 ++-- src/bltGrElemOp.C | 15 +++---- src/bltGrElemOption.C | 2 +- src/bltGrLegdOp.C | 2 +- src/bltGrMarkerOp.C | 6 +-- src/bltGrPenOp.C | 4 +- src/bltGrXAxisOp.C | 2 +- src/bltGraph.C | 117 +++++++++++++++++++++++++------------------------- src/bltGraph.h | 4 +- src/bltGraphOp.C | 17 +++++--- 10 files changed, 89 insertions(+), 88 deletions(-) diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C index bff30ce..017b2cd 100644 --- a/src/bltGrAxisOp.C +++ b/src/bltGrAxisOp.C @@ -82,7 +82,7 @@ static int AxisObjConfigure(Tcl_Interp* interp, Axis* axisPtr, graphPtr->flags |= REDRAW_WORLD | MAP_WORLD | RESET_AXES | CACHE_DIRTY; if (axisPtr->configure() != TCL_OK) return TCL_ERROR; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); break; } @@ -155,7 +155,7 @@ int AxisActivateOp(Tcl_Interp* interp, Axis* axisPtr, if (!ops->hide && axisPtr->use_) { graphPtr->flags |= DRAW_MARGINS | CACHE_DIRTY; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); } return TCL_OK; @@ -330,7 +330,7 @@ int AxisViewOp(Tcl_Interp* interp, Axis* axisPtr, ops->reqMax = EXP10(ops->reqMax); } graphPtr->flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | RESET_AXES); - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); return TCL_OK; } @@ -447,7 +447,7 @@ static int DeleteOp(Tcl_Interp* interp, Graph* graphPtr, axisPtr->flags |= DELETE_PENDING; if (axisPtr->refCount_ == 0) { Tcl_EventuallyFree(axisPtr, FreeAxis); - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); } return TCL_OK; diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 1a294a8..bf58437 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -81,7 +81,7 @@ static int ElementObjConfigure(Tcl_Interp* interp, Graph* graphPtr, graphPtr->flags |= RESET_WORLD | CACHE_DIRTY; if (elemPtr->configure() != TCL_OK) return TCL_ERROR; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); break; } @@ -248,7 +248,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp, elemPtr->activeIndices_ = indices; elemPtr->flags |= ACTIVE | ACTIVE_PENDING; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); return TCL_OK; } @@ -366,8 +366,7 @@ static int DeactivateOp(Graph* graphPtr, Tcl_Interp* interp, elemPtr->nActiveIndices_ = 0; elemPtr->flags &= ~(ACTIVE | ACTIVE_PENDING); } - - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); return TCL_OK; } @@ -388,7 +387,7 @@ static int DeleteOp(Graph* graphPtr, Tcl_Interp* interp, } graphPtr->flags |= RESET_WORLD; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); return TCL_OK; } @@ -439,7 +438,7 @@ static int LowerOp(Graph* graphPtr, Tcl_Interp* interp, Blt_Chain_Destroy(chain); graphPtr->flags |= RESET_WORLD; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); Tcl_SetObjResult(interp, DisplayListObj(graphPtr)); return TCL_OK; @@ -501,7 +500,7 @@ static int RaiseOp(Graph* graphPtr, Tcl_Interp* interp, Blt_Chain_Destroy(chain); graphPtr->flags |= RESET_WORLD; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); Tcl_SetObjResult(interp, DisplayListObj(graphPtr)); return TCL_OK; @@ -542,7 +541,7 @@ static int ShowOp(Graph* graphPtr, Tcl_Interp* interp, } graphPtr->flags |= RESET_WORLD; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); Tcl_SetObjResult(interp, DisplayListObj(graphPtr)); return TCL_OK; diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C index 41c407e..181a00c 100644 --- a/src/bltGrElemOption.C +++ b/src/bltGrElemOption.C @@ -431,7 +431,7 @@ static void VectorChangedProc(Tcl_Interp* interp, ClientData clientData, elemPtr->flags |= MAP_ITEM; if (elemPtr->link && !(elemPtr->flags & DELETE_PENDING)) { graphPtr->flags |= CACHE_DIRTY; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); } } diff --git a/src/bltGrLegdOp.C b/src/bltGrLegdOp.C index a757e50..2a7b081 100644 --- a/src/bltGrLegdOp.C +++ b/src/bltGrLegdOp.C @@ -65,7 +65,7 @@ static int LegendObjConfigure(Tcl_Interp* interp, Graph* graphPtr, graphPtr->flags |= mask; graphPtr->flags |= (RESET_WORLD | CACHE_DIRTY); legendPtr->configure(); - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); break; } diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C index 7db4a7c..8590781 100644 --- a/src/bltGrMarkerOp.C +++ b/src/bltGrMarkerOp.C @@ -76,7 +76,7 @@ static int MarkerObjConfigure( Tcl_Interp* interp, Graph* graphPtr, graphPtr->flags |= CACHE_DIRTY; if (markerPtr->configure() != TCL_OK) return TCL_ERROR; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); break; } @@ -244,8 +244,8 @@ static int DeleteOp(Graph* graphPtr, Tcl_Interp* interp, markerPtr->flags |= DELETE_PENDING; Tcl_EventuallyFree(markerPtr, FreeMarker); } + graphPtr->eventuallyRedraw(); - Blt_EventuallyRedrawGraph(graphPtr); return TCL_OK; } @@ -397,8 +397,8 @@ static int RelinkOp(Graph* graphPtr, Tcl_Interp* interp, if (ops->drawUnder) graphPtr->flags |= CACHE_DIRTY; + graphPtr->eventuallyRedraw(); - Blt_EventuallyRedrawGraph(graphPtr); return TCL_OK; } diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index 630f529..5fd0b95 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -65,7 +65,7 @@ static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr, graphPtr->flags |= CACHE_DIRTY; if (penPtr->configure() != TCL_OK) return TCL_ERROR; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); break; } @@ -117,7 +117,7 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, } graphPtr->flags |= CACHE_DIRTY; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); return TCL_OK; } diff --git a/src/bltGrXAxisOp.C b/src/bltGrXAxisOp.C index e3f2c24..2330930 100644 --- a/src/bltGrXAxisOp.C +++ b/src/bltGrXAxisOp.C @@ -174,7 +174,7 @@ static int UseOp(Tcl_Interp* interp, Axis* axisPtr, graphPtr->flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | RESET_AXES); /* When any axis changes, we need to layout the entire graph. */ graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD); - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); return TCL_OK; } diff --git a/src/bltGraph.C b/src/bltGraph.C index 6cb2471..dcc39a5 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -62,7 +62,6 @@ static Blt_BindPickProc PickEntry; static void AdjustAxisPointers(Graph* graphPtr); static void UpdateMarginTraces(Graph* graphPtr); -static void DrawMargins(Graph*, Drawable); // OptionSpecs @@ -534,7 +533,7 @@ void Graph::map() void Graph::drawPlot(Drawable drawable) { GraphOptions* ops = (GraphOptions*)ops_; - DrawMargins(this, drawable); + drawMargins(drawable); // Draw the background of the plotting area with 3D border Tk_Fill3DRectangle(tkwin_, drawable, ops->plotBg, @@ -564,36 +563,6 @@ void Graph::drawPlot(Drawable drawable) Blt_DrawElements(this, drawable); } -// Support - -void Blt_EventuallyRedrawGraph(Graph* graphPtr) -{ - if ((graphPtr->flags & GRAPH_DELETED) || !Tk_IsMapped(graphPtr->tkwin_)) - return; - - if (!(graphPtr->flags & REDRAW_PENDING)) { - graphPtr->flags |= REDRAW_PENDING; - Tcl_DoWhenIdle(DisplayGraph, graphPtr); - } -} - -static void AdjustAxisPointers(Graph* graphPtr) -{ - GraphOptions* ops = (GraphOptions*)graphPtr->ops_; - if (ops->inverted) { - ops->leftMargin.axes = graphPtr->axisChain_[0]; - ops->bottomMargin.axes = graphPtr->axisChain_[1]; - ops->rightMargin.axes = graphPtr->axisChain_[2]; - ops->topMargin.axes = graphPtr->axisChain_[3]; - } - else { - ops->leftMargin.axes = graphPtr->axisChain_[1]; - ops->bottomMargin.axes = graphPtr->axisChain_[0]; - ops->rightMargin.axes = graphPtr->axisChain_[3]; - ops->topMargin.axes = graphPtr->axisChain_[2]; - } -} - /* *--------------------------------------------------------------------------- * @@ -639,9 +608,9 @@ static void AdjustAxisPointers(Graph* graphPtr) * *--------------------------------------------------------------------------- */ -static void DrawMargins(Graph* graphPtr, Drawable drawable) +void Graph::drawMargins(Drawable drawable) { - GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + GraphOptions* ops = (GraphOptions*)ops_; XRectangle rects[4]; /* @@ -649,26 +618,26 @@ static void DrawMargins(Graph* graphPtr, Drawable drawable) * surface. This clears the surrounding area and clips the plot. */ rects[0].x = rects[0].y = rects[3].x = rects[1].x = 0; - rects[0].width = rects[3].width = (short int)graphPtr->width_; - rects[0].height = (short int)graphPtr->top_; - rects[3].y = graphPtr->bottom_; - rects[3].height = graphPtr->height_ - graphPtr->bottom_; - rects[2].y = rects[1].y = graphPtr->top_; - rects[1].width = graphPtr->left_; - rects[2].height = rects[1].height = graphPtr->bottom_ - graphPtr->top_; - rects[2].x = graphPtr->right_; - rects[2].width = graphPtr->width_ - graphPtr->right_; - - Tk_Fill3DRectangle(graphPtr->tkwin_, drawable, ops->normalBg, + rects[0].width = rects[3].width = (short int)width_; + rects[0].height = (short int)top_; + rects[3].y = bottom_; + rects[3].height = height_ - bottom_; + rects[2].y = rects[1].y = top_; + rects[1].width = left_; + rects[2].height = rects[1].height = bottom_ - top_; + rects[2].x = right_; + rects[2].width = width_ - right_; + + Tk_Fill3DRectangle(tkwin_, drawable, ops->normalBg, rects[0].x, rects[0].y, rects[0].width, rects[0].height, 0, TK_RELIEF_FLAT); - Tk_Fill3DRectangle(graphPtr->tkwin_, drawable, ops->normalBg, + Tk_Fill3DRectangle(tkwin_, drawable, ops->normalBg, rects[1].x, rects[1].y, rects[1].width, rects[1].height, 0, TK_RELIEF_FLAT); - Tk_Fill3DRectangle(graphPtr->tkwin_, drawable, ops->normalBg, + Tk_Fill3DRectangle(tkwin_, drawable, ops->normalBg, rects[2].x, rects[2].y, rects[2].width, rects[2].height, 0, TK_RELIEF_FLAT); - Tk_Fill3DRectangle(graphPtr->tkwin_, drawable, ops->normalBg, + Tk_Fill3DRectangle(tkwin_, drawable, ops->normalBg, rects[3].x, rects[3].y, rects[3].width, rects[3].height, 0, TK_RELIEF_FLAT); @@ -677,33 +646,63 @@ static void DrawMargins(Graph* graphPtr, Drawable drawable) if (ops->plotBW > 0) { int x, y, w, h; - x = graphPtr->left_ - ops->plotBW; - y = graphPtr->top_ - ops->plotBW; - w = (graphPtr->right_ - graphPtr->left_) + (2*ops->plotBW); - h = (graphPtr->bottom_ - graphPtr->top_) + (2*ops->plotBW); - Tk_Draw3DRectangle(graphPtr->tkwin_, drawable, ops->normalBg, + x = left_ - ops->plotBW; + y = top_ - ops->plotBW; + w = (right_ - left_) + (2*ops->plotBW); + h = (bottom_ - top_) + (2*ops->plotBW); + Tk_Draw3DRectangle(tkwin_, drawable, ops->normalBg, x, y, w, h, ops->plotBW, ops->plotRelief); } - switch (graphPtr->legend_->position()) { + switch (legend_->position()) { case Legend::TOP: case Legend::BOTTOM: case Legend::RIGHT: case Legend::LEFT: - graphPtr->legend_->draw(drawable); + legend_->draw(drawable); break; default: break; } if (ops->title != NULL) - Blt_DrawText(graphPtr->tkwin_, drawable, ops->title, - &ops->titleTextStyle, graphPtr->titleX_, graphPtr->titleY_); + Blt_DrawText(tkwin_, drawable, ops->title, + &ops->titleTextStyle, titleX_, titleY_); - Blt_DrawAxes(graphPtr, drawable); - graphPtr->flags &= ~DRAW_MARGINS; + Blt_DrawAxes(this, drawable); + flags &= ~DRAW_MARGINS; +} + +void Graph::eventuallyRedraw() +{ + if ((flags & GRAPH_DELETED) || !Tk_IsMapped(tkwin_)) + return; + + if (!(flags & REDRAW_PENDING)) { + flags |= REDRAW_PENDING; + Tcl_DoWhenIdle(DisplayGraph, this); + } } +static void AdjustAxisPointers(Graph* graphPtr) +{ + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + if (ops->inverted) { + ops->leftMargin.axes = graphPtr->axisChain_[0]; + ops->bottomMargin.axes = graphPtr->axisChain_[1]; + ops->rightMargin.axes = graphPtr->axisChain_[2]; + ops->topMargin.axes = graphPtr->axisChain_[3]; + } + else { + ops->leftMargin.axes = graphPtr->axisChain_[1]; + ops->bottomMargin.axes = graphPtr->axisChain_[0]; + ops->rightMargin.axes = graphPtr->axisChain_[3]; + ops->topMargin.axes = graphPtr->axisChain_[2]; + } +} + +// Support + static void UpdateMarginTraces(Graph* graphPtr) { GraphOptions* ops = (GraphOptions*)graphPtr->ops_; diff --git a/src/bltGraph.h b/src/bltGraph.h index 4fe387f..211db66 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -195,7 +195,7 @@ class Graph { protected: void drawPlot(Drawable); - + void drawMargins(Drawable); public: Graph(ClientData clientData, Tcl_Interp*interp, @@ -205,11 +205,11 @@ class Graph { void configure(); void display(); void map(); + void eventuallyRedraw(); }; extern void Blt_ReconfigureGraph(Graph* graphPtr); extern void Blt_GraphExtents(Graph* graphPtr, Region2d *extsPtr); -extern void Blt_EventuallyRedrawGraph(Graph* graphPtr); typedef ClientData (MakeTagProc)(Graph* graphPtr, const char *tagName); extern MakeTagProc Blt_MakeElementTag; diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index eb305e7..a901a3d 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -122,7 +122,7 @@ int GraphObjConfigure(Tcl_Interp* interp, Graph* graphPtr, graphPtr->flags |= mask; graphPtr->configure(); - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); break; } @@ -451,20 +451,22 @@ void GraphEventProc(ClientData clientData, XEvent* eventPtr) if (eventPtr->type == Expose) { if (eventPtr->xexpose.count == 0) { graphPtr->flags |= REDRAW_WORLD; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); } - } else if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) { + } + else if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) { if (eventPtr->xfocus.detail != NotifyInferior) { if (eventPtr->type == FocusIn) graphPtr->flags |= FOCUS; else graphPtr->flags &= ~FOCUS; graphPtr->flags |= REDRAW_WORLD; - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); } - } else if (eventPtr->type == DestroyNotify) { + } + else if (eventPtr->type == DestroyNotify) { if (!(graphPtr->flags & GRAPH_DELETED)) { graphPtr->flags |= GRAPH_DELETED; Tcl_DeleteCommandFromToken(graphPtr->interp_, graphPtr->cmdToken_); @@ -472,9 +474,10 @@ void GraphEventProc(ClientData clientData, XEvent* eventPtr) Tcl_CancelIdleCall(DisplayGraph, graphPtr); Tcl_EventuallyFree(graphPtr, DestroyGraph); } - } else if (eventPtr->type == ConfigureNotify) { + } + else if (eventPtr->type == ConfigureNotify) { graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD); - Blt_EventuallyRedrawGraph(graphPtr); + graphPtr->eventuallyRedraw(); } } -- cgit v0.12