diff options
author | joye <joye> | 2014-04-16 20:38:59 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-16 20:38:59 (GMT) |
commit | 109f822c3115a18a7d94bd343a17a329010e0e9a (patch) | |
tree | 3fba7b5923661b2d1261146fb7b9a97bb184c8e2 /src | |
parent | 7c708cc37a25c6da17a401dc75ecc09c3776ae8e (diff) | |
download | blt-109f822c3115a18a7d94bd343a17a329010e0e9a.zip blt-109f822c3115a18a7d94bd343a17a329010e0e9a.tar.gz blt-109f822c3115a18a7d94bd343a17a329010e0e9a.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrMarkerOp.C | 104 | ||||
-rw-r--r-- | src/bltGrMarkerOp.h | 8 | ||||
-rw-r--r-- | src/bltGrPenOp.C | 11 | ||||
-rw-r--r-- | src/bltGrPenOp.h | 2 | ||||
-rw-r--r-- | src/bltGraph.C | 124 | ||||
-rw-r--r-- | src/bltGraph.h | 14 |
6 files changed, 136 insertions, 127 deletions
diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C index 8590781..1d2c072 100644 --- a/src/bltGrMarkerOp.C +++ b/src/bltGrMarkerOp.C @@ -45,7 +45,6 @@ using namespace Blt; static int GetMarkerFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj* objPtr, Marker** markerPtrPtr); -static int IsElementHidden(Graph*, Marker*); static void FreeMarker(char* dataPtr); static int MarkerObjConfigure( Tcl_Interp* interp, Graph* graphPtr, @@ -311,7 +310,7 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp, if ((markerPtr->flags & DELETE_PENDING) || ops->hide) continue; - if (IsElementHidden(graphPtr, markerPtr)) + if (graphPtr->isElementHidden(markerPtr)) continue; if (markerPtr->regionIn(&extents, enclosed)) { @@ -445,22 +444,6 @@ int Blt::MarkerOp(Graph* graphPtr, Tcl_Interp* interp, // Support -static int IsElementHidden(Graph* graphPtr, Marker* markerPtr) -{ - MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - - if (ops->elemName) { - Tcl_HashEntry *hPtr - = Tcl_FindHashEntry(&graphPtr->elements_.table, ops->elemName); - if (hPtr) { - Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr); - if (!elemPtr->link || elemPtr->hide()) - return 1; - } - } - return 0; -} - static int GetMarkerFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, Marker** markerPtrPtr) { @@ -484,89 +467,6 @@ static void FreeMarker(char* dataPtr) delete markerPtr; } -// export - -void Blt::MarkersToPostScript(Graph* graphPtr, Blt_Ps ps, int under) -{ - for (Blt_ChainLink link = Blt_Chain_LastLink(graphPtr->markers_.displayList); - link; link = Blt_Chain_PrevLink(link)) { - Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); - MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - if (ops->drawUnder != under) - continue; - - if ((markerPtr->flags & DELETE_PENDING) || ops->hide) - continue; - - if (IsElementHidden(graphPtr, markerPtr)) - continue; - - Blt_Ps_VarAppend(ps, "\n% Marker \"", markerPtr->name(), - "\" is a ", markerPtr->className(), ".\n", (char*)NULL); - markerPtr->postscript(ps); - } -} - -void Blt::DrawMarkers(Graph* graphPtr, Drawable drawable, int under) -{ - for (Blt_ChainLink link = Blt_Chain_LastLink(graphPtr->markers_.displayList); - link; link = Blt_Chain_PrevLink(link)) { - Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); - MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - - if ((ops->drawUnder != under) || (markerPtr->clipped()) || - (markerPtr->flags & DELETE_PENDING) || (ops->hide)) - continue; - - if (IsElementHidden(graphPtr, markerPtr)) - continue; - - markerPtr->draw(drawable); - } -} - -void Blt::ConfigureMarkers(Graph* graphPtr) -{ - for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers_.displayList); - link; link = Blt_Chain_NextLink(link)) { - Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); - markerPtr->configure(); - } -} - -void Blt::MapMarkers(Graph* graphPtr) -{ - for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers_.displayList); - link; link = Blt_Chain_NextLink(link)) { - Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); - MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - - if ((markerPtr->flags & DELETE_PENDING) || ops->hide) - continue; - - if ((graphPtr->flags & MAP_ALL) || (markerPtr->flags & MAP_ITEM)) { - markerPtr->map(); - markerPtr->flags &= ~MAP_ITEM; - } - } -} - -void Blt::DestroyMarkers(Graph* graphPtr) -{ - Tcl_HashSearch iter; - for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&graphPtr->markers_.table, &iter); - hPtr; hPtr = Tcl_NextHashEntry(&iter)) { - Marker* markerPtr = (Marker*)Tcl_GetHashValue(hPtr); - - // Dereferencing the pointer to the hash table prevents the hash table - // entry from being automatically deleted. - delete markerPtr; - } - Tcl_DeleteHashTable(&graphPtr->markers_.table); - Tcl_DeleteHashTable(&graphPtr->markers_.tagTable); - Blt_Chain_Destroy(graphPtr->markers_.displayList); -} - void* Blt::NearestMarker(Graph* graphPtr, int x, int y, int under) { Point2d point; @@ -580,7 +480,7 @@ void* Blt::NearestMarker(Graph* graphPtr, int x, int y, int under) if ((markerPtr->flags & (DELETE_PENDING|MAP_ITEM)) || (ops->hide)) continue; - if (IsElementHidden(graphPtr, markerPtr)) + if (graphPtr->isElementHidden(markerPtr)) continue; if ((ops->drawUnder == under) && (ops->state == BLT_STATE_NORMAL)) diff --git a/src/bltGrMarkerOp.h b/src/bltGrMarkerOp.h index 3be315c..54b9485 100644 --- a/src/bltGrMarkerOp.h +++ b/src/bltGrMarkerOp.h @@ -31,14 +31,10 @@ #define __Blt_GrMarkerOp_h__ namespace Blt { - extern void DestroyMarkers(Graph* graphPtr); - extern void DrawMarkers(Graph* graphPtr, Drawable drawable, int under); - extern ClientData MakeMarkerTag(Graph* graphPtr, const char* tagName); - extern void MapMarkers(Graph* graphPtr); - extern void ConfigureMarkers(Graph*); extern int MarkerOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); - extern void MarkersToPostScript(Graph* graphPtr, Blt_Ps ps, int under); + + extern ClientData MakeMarkerTag(Graph* graphPtr, const char* tagName); extern void* NearestMarker(Graph* graphPtr, int x, int y, int under); }; diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index 5fd0b95..d073560 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -274,17 +274,6 @@ int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, // Support -void Blt_DestroyPens(Graph* graphPtr) -{ - Tcl_HashSearch iter; - for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->penTable_, &iter); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { - Pen* penPtr = (Pen*)Tcl_GetHashValue(hPtr); - delete penPtr; - } - Tcl_DeleteHashTable(&graphPtr->penTable_); -} - void Blt_FreePen(Pen* penPtr) { if (penPtr != NULL) { diff --git a/src/bltGrPenOp.h b/src/bltGrPenOp.h index 57e0360..9b8835c 100644 --- a/src/bltGrPenOp.h +++ b/src/bltGrPenOp.h @@ -37,6 +37,4 @@ extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc, 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); - #endif diff --git a/src/bltGraph.C b/src/bltGraph.C index 5beff47..3a35d18 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -326,7 +326,7 @@ Graph::~Graph() { GraphOptions* ops = (GraphOptions*)ops_; - Blt::DestroyMarkers(this); + destroyMarkers(); destroyElements(); // must come before legend and others if (crosshairs_) @@ -335,7 +335,7 @@ Graph::~Graph() delete legend_; destroyAxes(); - Blt_DestroyPens(this); + destroyPens(); Blt_DestroyPageSetup(this); Blt_DestroyBarSets(this); @@ -466,7 +466,7 @@ void Graph::display() drawPlot(drawable); // Draw markers above elements - Blt::DrawMarkers(this, drawable, MARKER_ABOVE); + drawMarkers(drawable, MARKER_ABOVE); drawActiveElements(drawable); // Don't draw legend in the plot area. @@ -525,7 +525,7 @@ void Graph::map() mapAxes(); mapElements(); - Blt::MapMarkers(this); + mapMarkers(); flags &= ~(MAP_ALL); } } @@ -546,7 +546,7 @@ void Graph::drawPlot(Drawable drawable) // Draw the elements, markers, legend, and axis limits drawAxes(drawable); Blt_DrawGrids(this, drawable); - Blt::DrawMarkers(this, drawable, MARKER_UNDER); + drawMarkers(drawable, MARKER_UNDER); if (!legend_->isRaised()) { switch (legend_->position()) { @@ -738,7 +738,7 @@ void Graph::reconfigure() legend_->configure(); configureElements(); configureAxes(); - Blt::ConfigureMarkers(this); + configureMarkers(); } // Support @@ -884,6 +884,19 @@ void Graph::disableCrosshairs() crosshairs_->off(); } +// Pens + +void Graph::destroyPens() +{ + Tcl_HashSearch iter; + for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&penTable_, &iter); + hPtr; hPtr = Tcl_NextHashEntry(&iter)) { + Pen* penPtr = (Pen*)Tcl_GetHashValue(hPtr); + delete penPtr; + } + Tcl_DeleteHashTable(&penTable_); +} + // Elements void Graph::destroyElements() @@ -979,6 +992,105 @@ void Graph::printActiveElements(Blt_Ps ps) } } +// Markers + +void Graph::destroyMarkers() +{ + Tcl_HashSearch iter; + for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&markers_.table, &iter); + hPtr; hPtr = Tcl_NextHashEntry(&iter)) { + Marker* markerPtr = (Marker*)Tcl_GetHashValue(hPtr); + + // Dereferencing the pointer to the hash table prevents the hash table + // entry from being automatically deleted. + delete markerPtr; + } + Tcl_DeleteHashTable(&markers_.table); + Tcl_DeleteHashTable(&markers_.tagTable); + Blt_Chain_Destroy(markers_.displayList); +} + + +void Graph::configureMarkers() +{ + for (Blt_ChainLink link = Blt_Chain_FirstLink(markers_.displayList); + link; link = Blt_Chain_NextLink(link)) { + Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); + markerPtr->configure(); + } +} + +void Graph::mapMarkers() +{ + for (Blt_ChainLink link = Blt_Chain_FirstLink(markers_.displayList); + link; link = Blt_Chain_NextLink(link)) { + Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); + MarkerOptions* mops = (MarkerOptions*)markerPtr->ops(); + + if ((markerPtr->flags & DELETE_PENDING) || mops->hide) + continue; + + if ((flags & MAP_ALL) || (markerPtr->flags & MAP_ITEM)) { + markerPtr->map(); + markerPtr->flags &= ~MAP_ITEM; + } + } +} + +void Graph::drawMarkers(Drawable drawable, int under) +{ + for (Blt_ChainLink link = Blt_Chain_LastLink(markers_.displayList); + link; link = Blt_Chain_PrevLink(link)) { + Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); + MarkerOptions* mops = (MarkerOptions*)markerPtr->ops(); + + if ((mops->drawUnder != under) || (markerPtr->clipped()) || + (markerPtr->flags & DELETE_PENDING) || (mops->hide)) + continue; + + if (isElementHidden(markerPtr)) + continue; + + markerPtr->draw(drawable); + } +} + +void Graph::printMarkers(Blt_Ps ps, int under) +{ + for (Blt_ChainLink link = Blt_Chain_LastLink(markers_.displayList); + link; link = Blt_Chain_PrevLink(link)) { + Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); + MarkerOptions* mops = (MarkerOptions*)markerPtr->ops(); + if (mops->drawUnder != under) + continue; + + if ((markerPtr->flags & DELETE_PENDING) || mops->hide) + continue; + + if (isElementHidden(markerPtr)) + continue; + + Blt_Ps_VarAppend(ps, "\n% Marker \"", markerPtr->name(), + "\" is a ", markerPtr->className(), ".\n", (char*)NULL); + markerPtr->postscript(ps); + } +} + +int Graph::isElementHidden(Marker* markerPtr) +{ + MarkerOptions* mops = (MarkerOptions*)markerPtr->ops(); + + if (mops->elemName) { + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&elements_.table, mops->elemName); + if (hPtr) { + Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr); + if (!elemPtr->link || elemPtr->hide()) + return 1; + } + } + return 0; +} + // Axis void Graph::destroyAxes() diff --git a/src/bltGraph.h b/src/bltGraph.h index b440acc..efd8937 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -44,6 +44,10 @@ class Axis; class Element; class Legend; +namespace Blt { +class Marker; +}; + typedef struct { Axis *x, *y; } Axis2d; @@ -198,6 +202,8 @@ class Graph { void drawMargins(Drawable); void updateMarginTraces(); + void destroyPens(); + void destroyElements(); void configureElements(); void mapElements(); @@ -206,6 +212,12 @@ class Graph { void printElements(Blt_Ps); void printActiveElements(Blt_Ps); + void destroyMarkers(); + void configureMarkers(); + void mapMarkers(); + void drawMarkers(Drawable, int); + void printMarkers(Blt_Ps, int); + void destroyAxes(); void configureAxes(); void mapAxes(); @@ -229,6 +241,8 @@ class Graph { void resetAxes(); void printAxes(Blt_Ps); + + int isElementHidden(Blt::Marker*); }; extern void Blt_ReconfigureGraph(Graph* graphPtr); |