From cff1b47d05e28e69193701b1d8dd5326a3657138 Mon Sep 17 00:00:00 2001 From: joye Date: Thu, 17 Apr 2014 18:04:10 +0000 Subject: *** empty log message *** --- src/bltGrElemBar.C | 114 ++++++++++++++++++------------- src/bltGrElemLine.C | 191 +++++++++++++++++++++++++++------------------------- src/bltGraph.C | 31 ++------- 3 files changed, 175 insertions(+), 161 deletions(-) diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 1faf7fb..d372528 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -258,6 +258,9 @@ void BarElement::map() BarElementOptions* ops = (BarElementOptions*)ops_; GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; + if (!link || (flags & DELETE_PENDING)) + return; + ResetBar(); if (!ops->coords.x || !ops->coords.y || !ops->coords.x->nValues || !ops->coords.y->nValues) @@ -666,34 +669,13 @@ void BarElement::closest() } } -void BarElement::drawActive(Drawable drawable) -{ - BarElementOptions* ops = (BarElementOptions*)ops_; - - if (ops->activePenPtr) { - BarPen* penPtr = ops->activePenPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); - - if (nActiveIndices_ > 0) { - if (flags & ACTIVE_PENDING) { - MapActiveBars(); - } - DrawBarSegments(drawable, penPtr, activeRects_, nActive_); - if (penOps->valueShow != SHOW_NONE) - DrawBarValues(drawable, penPtr, activeRects_, nActive_, activeToData_); - } - else if (nActiveIndices_ < 0) { - DrawBarSegments(drawable, penPtr, bars_, nBars_); - if (penOps->valueShow != SHOW_NONE) - DrawBarValues(drawable, penPtr, bars_, nBars_, barToData_); - } - } -} - void BarElement::draw(Drawable drawable) { BarElementOptions* ops = (BarElementOptions*)ops_; + if (hide_ || (flags & DELETE_PENDING)) + return; + int count = 0; for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link; link = Blt_Chain_NextLink(link)) { @@ -721,6 +703,33 @@ void BarElement::draw(Drawable drawable) } } +void BarElement::drawActive(Drawable drawable) +{ + BarElementOptions* ops = (BarElementOptions*)ops_; + + if (hide_ || (flags & DELETE_PENDING) || !(flags & ACTIVE)) + return; + + BarPen* penPtr = (BarPen*)ops->activePenPtr; + if (!penPtr) + return; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); + + if (nActiveIndices_ > 0) { + if (flags & ACTIVE_PENDING) + MapActiveBars(); + + DrawBarSegments(drawable, penPtr, activeRects_, nActive_); + if (penOps->valueShow != SHOW_NONE) + DrawBarValues(drawable, penPtr, activeRects_, nActive_, activeToData_); + } + else if (nActiveIndices_ < 0) { + DrawBarSegments(drawable, penPtr, bars_, nBars_); + if (penOps->valueShow != SHOW_NONE) + DrawBarValues(drawable, penPtr, bars_, nBars_, barToData_); + } +} + void BarElement::drawSymbol(Drawable drawable, int x, int y, int size) { BarElementOptions* ops = (BarElementOptions*)ops_; @@ -752,33 +761,16 @@ void BarElement::drawSymbol(Drawable drawable, int x, int y, int size) XSetTSOrigin(graphPtr_->display_, penPtr->fillGC_, 0, 0); } -void BarElement::printActive(Blt_Ps ps) -{ - BarElementOptions* ops = (BarElementOptions*)ops_; - - if (ops->activePenPtr) { - BarPen* penPtr = ops->activePenPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); - - if (nActiveIndices_ > 0) { - if (flags & ACTIVE_PENDING) - MapActiveBars(); - SegmentsToPostScript(ps, penPtr, activeRects_, nActive_); - if (penOps->valueShow != SHOW_NONE) - BarValuesToPostScript(ps, penPtr, activeRects_, nActive_,activeToData_); - } - else if (nActiveIndices_ < 0) { - SegmentsToPostScript(ps, penPtr, bars_, nBars_); - if (penOps->valueShow != SHOW_NONE) - BarValuesToPostScript(ps, penPtr, bars_, nBars_, barToData_); - } - } -} - void BarElement::print(Blt_Ps ps) { BarElementOptions* ops = (BarElementOptions*)ops_; + if (hide_ || (flags & DELETE_PENDING)) + return; + + // Comment the PostScript to indicate the start of the element + Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", name()); + int count = 0; for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link; link = Blt_Chain_NextLink(link)) { @@ -815,6 +807,34 @@ void BarElement::print(Blt_Ps ps) } } +void BarElement::printActive(Blt_Ps ps) +{ + BarElementOptions* ops = (BarElementOptions*)ops_; + + if (hide_ || (flags & DELETE_PENDING) || !(flags & ACTIVE)) + return; + + BarPen* penPtr = (BarPen*)ops->activePenPtr; + if (!penPtr) + return; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); + + Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", name()); + + if (nActiveIndices_ > 0) { + if (flags & ACTIVE_PENDING) + MapActiveBars(); + SegmentsToPostScript(ps, penPtr, activeRects_, nActive_); + if (penOps->valueShow != SHOW_NONE) + BarValuesToPostScript(ps, penPtr, activeRects_, nActive_,activeToData_); + } + else if (nActiveIndices_ < 0) { + SegmentsToPostScript(ps, penPtr, bars_, nBars_); + if (penOps->valueShow != SHOW_NONE) + BarValuesToPostScript(ps, penPtr, bars_, nBars_, barToData_); + } +} + void BarElement::printSymbol(Blt_Ps ps, double x, double y, int size) { BarElementOptions* ops = (BarElementOptions*)ops_; diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index ae2ed0a..be1c63d 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -348,6 +348,9 @@ void LineElement::map() { LineElementOptions* ops = (LineElementOptions*)ops_; + if (!link || (flags & DELETE_PENDING)) + return; + ResetLine(); if (!ops->coords.x || !ops->coords.y || !ops->coords.x->nValues || !ops->coords.y->nValues) @@ -569,57 +572,12 @@ void LineElement::closest() } } -void LineElement::drawActive(Drawable drawable) +void LineElement::draw(Drawable drawable) { LineElementOptions* ops = (LineElementOptions*)ops_; - LinePen* penPtr = (LinePen *)ops->activePenPtr; - if (!penPtr) + if (hide_ || (flags & DELETE_PENDING)) return; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); - - int symbolSize = ScaleSymbol(penOps->symbol.size); - - /* - * nActiveIndices - * > 0 Some points are active. Uses activeArr. - * < 0 All points are active. - * == 0 No points are active. - */ - if (nActiveIndices_ > 0) { - if (flags & ACTIVE_PENDING) - MapActiveSymbols(); - - if (penOps->symbol.type != SYMBOL_NONE) - DrawSymbols(drawable, penPtr, symbolSize, activePts_.length, - activePts_.points); - if (penOps->valueShow != SHOW_NONE) - DrawValues(drawable, penPtr, activePts_.length, activePts_.points, - activePts_.map); - } - else if (nActiveIndices_ < 0) { - if (penOps->traceWidth > 0) { - if (lines_.length > 0) - Blt_Draw2DSegments(graphPtr_->display_, drawable, - penPtr->traceGC_, lines_.segments, - lines_.length); - else if (Blt_Chain_GetLength(traces_) > 0) - DrawTraces(drawable, penPtr); - } - if (penOps->symbol.type != SYMBOL_NONE) - DrawSymbols(drawable, penPtr, symbolSize, symbolPts_.length, - symbolPts_.points); - - if (penOps->valueShow != SHOW_NONE) { - DrawValues(drawable, penPtr, symbolPts_.length, symbolPts_.points, - symbolPts_.map); - } - } -} - -void LineElement::draw(Drawable drawable) -{ - LineElementOptions* ops = (LineElementOptions*)ops_; // Fill area under the curve if (fillPts_) { @@ -705,77 +663,84 @@ void LineElement::draw(Drawable drawable) symbolInterval_ = 0; } -void LineElement::drawSymbol(Drawable drawable, int x, int y, int size) +void LineElement::drawActive(Drawable drawable) { LineElementOptions* ops = (LineElementOptions*)ops_; - LinePen* penPtr = NORMALPEN(ops); - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); - - if (penOps->traceWidth > 0) { - /* - * Draw an extra line offset by one pixel from the previous to give a - * thicker appearance. This is only for the legend entry. This routine - * is never called for drawing the actual line segments. - */ - XDrawLine(graphPtr_->display_, drawable, penPtr->traceGC_, x - size, y, - x + size, y); - XDrawLine(graphPtr_->display_, drawable, penPtr->traceGC_, x - size, y + 1, - x + size, y + 1); - } - if (penOps->symbol.type != SYMBOL_NONE) { - Point2d point; - point.x = x; - point.y = y; - DrawSymbols(drawable, penPtr, size, 1, &point); - } -} - -void LineElement::printActive(Blt_Ps ps) -{ - LineElementOptions* ops = (LineElementOptions*)ops_; + if (hide_ || (flags & DELETE_PENDING) || !(flags & ACTIVE)) + return; - LinePen* penPtr = (LinePen *)ops->activePenPtr; + LinePen* penPtr = (LinePen*)ops->activePenPtr; if (!penPtr) return; LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); int symbolSize = ScaleSymbol(penOps->symbol.size); + if (nActiveIndices_ > 0) { if (flags & ACTIVE_PENDING) MapActiveSymbols(); if (penOps->symbol.type != SYMBOL_NONE) - SymbolsToPostScript(ps, penPtr, symbolSize, activePts_.length, - activePts_.points); - + DrawSymbols(drawable, penPtr, symbolSize, activePts_.length, + activePts_.points); if (penOps->valueShow != SHOW_NONE) - ValuesToPostScript(ps, penPtr, activePts_.length, activePts_.points, - activePts_.map); + DrawValues(drawable, penPtr, activePts_.length, activePts_.points, + activePts_.map); } - else if (nActiveIndices_ < 0) { + else if (nActiveIndices_ < 0) { if (penOps->traceWidth > 0) { - if (lines_.length > 0) { - SetLineAttributes(ps, penPtr); - Blt_Ps_Draw2DSegments(ps, lines_.segments, lines_.length); - } - if (Blt_Chain_GetLength(traces_) > 0) - TracesToPostScript(ps, (LinePen*)penPtr); + if (lines_.length > 0) + Blt_Draw2DSegments(graphPtr_->display_, drawable, + penPtr->traceGC_, lines_.segments, + lines_.length); + else if (Blt_Chain_GetLength(traces_) > 0) + DrawTraces(drawable, penPtr); } if (penOps->symbol.type != SYMBOL_NONE) - SymbolsToPostScript(ps, penPtr, symbolSize, symbolPts_.length, - symbolPts_.points); + DrawSymbols(drawable, penPtr, symbolSize, symbolPts_.length, + symbolPts_.points); + if (penOps->valueShow != SHOW_NONE) { - ValuesToPostScript(ps, penPtr, symbolPts_.length, - symbolPts_.points, symbolPts_.map); + DrawValues(drawable, penPtr, symbolPts_.length, symbolPts_.points, + symbolPts_.map); } } } +void LineElement::drawSymbol(Drawable drawable, int x, int y, int size) +{ + LineElementOptions* ops = (LineElementOptions*)ops_; + + LinePen* penPtr = NORMALPEN(ops); + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); + + if (penOps->traceWidth > 0) { + // Draw an extra line offset by one pixel from the previous to give a + // thicker appearance. This is only for the legend entry. This routine + // is never called for drawing the actual line segments. + XDrawLine(graphPtr_->display_, drawable, penPtr->traceGC_, x - size, y, + x + size, y); + XDrawLine(graphPtr_->display_, drawable, penPtr->traceGC_, x - size, y + 1, + x + size, y + 1); + } + if (penOps->symbol.type != SYMBOL_NONE) { + Point2d point; + point.x = x; + point.y = y; + DrawSymbols(drawable, penPtr, size, 1, &point); + } +} + void LineElement::print(Blt_Ps ps) { LineElementOptions* ops = (LineElementOptions*)ops_; + if (hide_ || (flags & DELETE_PENDING)) + return; + + Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", name()); + // Draw fill area if (fillPts_) { // Create a path to use for both the polygon and its outline @@ -864,6 +829,52 @@ void LineElement::print(Blt_Ps ps) } } +void LineElement::printActive(Blt_Ps ps) +{ + LineElementOptions* ops = (LineElementOptions*)ops_; + + if (hide_ || (flags & DELETE_PENDING) || !(flags & ACTIVE)) + return; + + LinePen* penPtr = (LinePen *)ops->activePenPtr; + if (!penPtr) + return; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); + + Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", name()); + + int symbolSize = ScaleSymbol(penOps->symbol.size); + if (nActiveIndices_ > 0) { + if (flags & ACTIVE_PENDING) + MapActiveSymbols(); + + if (penOps->symbol.type != SYMBOL_NONE) + SymbolsToPostScript(ps, penPtr, symbolSize, activePts_.length, + activePts_.points); + + if (penOps->valueShow != SHOW_NONE) + ValuesToPostScript(ps, penPtr, activePts_.length, activePts_.points, + activePts_.map); + } + else if (nActiveIndices_ < 0) { + if (penOps->traceWidth > 0) { + if (lines_.length > 0) { + SetLineAttributes(ps, penPtr); + Blt_Ps_Draw2DSegments(ps, lines_.segments, lines_.length); + } + if (Blt_Chain_GetLength(traces_) > 0) + TracesToPostScript(ps, (LinePen*)penPtr); + } + if (penOps->symbol.type != SYMBOL_NONE) + SymbolsToPostScript(ps, penPtr, symbolSize, symbolPts_.length, + symbolPts_.points); + if (penOps->valueShow != SHOW_NONE) { + ValuesToPostScript(ps, penPtr, symbolPts_.length, + symbolPts_.points, symbolPts_.map); + } + } +} + void LineElement::printSymbol(Blt_Ps ps, double x, double y, int size) { LineElementOptions* ops = (LineElementOptions*)ops_; diff --git a/src/bltGraph.C b/src/bltGraph.C index 94b3869..815feab 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -823,13 +823,11 @@ void Graph::destroyPens() void Graph::destroyElements() { - Tcl_HashEntry *hPtr; Tcl_HashSearch iter; - for (hPtr = Tcl_FirstHashEntry(&elements_.table, &iter); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { + for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&elements_.table, &iter); + hPtr; hPtr = Tcl_NextHashEntry(&iter)) { Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr); - if (elemPtr) - Blt_DestroyElement(elemPtr); + Blt_DestroyElement(elemPtr); } Tcl_DeleteHashTable(&elements_.table); Tcl_DeleteHashTable(&elements_.tagTable); @@ -852,10 +850,8 @@ void Graph::mapElements() Blt_ResetBarGroups(this); for (Blt_ChainLink link =Blt_Chain_FirstLink(elements_.displayList); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); - if (!elemPtr->link || (elemPtr->flags & DELETE_PENDING)) - continue; if ((flags & MAP_ALL) || (elemPtr->flags & MAP_ITEM)) { elemPtr->map(); @@ -870,8 +866,7 @@ void Graph::drawElements(Drawable drawable) for (Blt_ChainLink link=Blt_Chain_LastLink(elements_.displayList); link; link = Blt_Chain_PrevLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); - if (!(elemPtr->flags & DELETE_PENDING) && !elemPtr->hide()) - elemPtr->draw(drawable); + elemPtr->draw(drawable); } } @@ -880,9 +875,7 @@ void Graph::drawActiveElements(Drawable drawable) for (Blt_ChainLink link=Blt_Chain_LastLink(elements_.displayList); link; link = Blt_Chain_PrevLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); - if (!(elemPtr->flags & DELETE_PENDING) && (elemPtr->flags & ACTIVE) && - !elemPtr->hide()) - elemPtr->drawActive(drawable); + elemPtr->drawActive(drawable); } } @@ -891,11 +884,6 @@ void Graph::printElements(Blt_Ps ps) for (Blt_ChainLink link=Blt_Chain_LastLink(elements_.displayList); link != NULL; link = Blt_Chain_PrevLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); - if (!(elemPtr->flags & DELETE_PENDING) && !elemPtr->hide()) - continue; - - // Comment the PostScript to indicate the start of the element - Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", elemPtr->name()); elemPtr->print(ps); } } @@ -905,12 +893,7 @@ void Graph::printActiveElements(Blt_Ps ps) for (Blt_ChainLink link=Blt_Chain_LastLink(elements_.displayList); link; link = Blt_Chain_PrevLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); - if (!(elemPtr->flags & DELETE_PENDING) && - (elemPtr->flags & ACTIVE) && - !elemPtr->hide()) { - Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", elemPtr->name()); - elemPtr->printActive(ps); - } + elemPtr->printActive(ps); } } -- cgit v0.12