diff options
author | joye <joye> | 2014-06-20 16:10:53 (GMT) |
---|---|---|
committer | joye <joye> | 2014-06-20 16:10:53 (GMT) |
commit | 53f38470ce5ce69cdd1c706fe4848ce70bc089e7 (patch) | |
tree | 179fd7419b246784f66042c39ff6b9b4636e8720 /src | |
parent | 472d825d2666b06a63770c012a929ce18c370ad3 (diff) | |
download | blt-53f38470ce5ce69cdd1c706fe4848ce70bc089e7.zip blt-53f38470ce5ce69cdd1c706fe4848ce70bc089e7.tar.gz blt-53f38470ce5ce69cdd1c706fe4848ce70bc089e7.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrHairs.C | 1 | ||||
-rw-r--r-- | src/bltGrHairs.h | 13 | ||||
-rw-r--r-- | src/bltGrHairsOp.C | 20 | ||||
-rw-r--r-- | src/bltGraph.C | 29 | ||||
-rw-r--r-- | src/bltGraphOp.C | 11 |
5 files changed, 25 insertions, 49 deletions
diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C index 7f77670..8de15ab 100644 --- a/src/bltGrHairs.C +++ b/src/bltGrHairs.C @@ -34,7 +34,6 @@ #include "bltGraph.h" #include "bltGrHairs.h" -#include "bltGrMisc.h" #include "bltConfig.h" using namespace Blt; diff --git a/src/bltGrHairs.h b/src/bltGrHairs.h index 63fa54b..f445f18 100644 --- a/src/bltGrHairs.h +++ b/src/bltGrHairs.h @@ -42,7 +42,6 @@ class Graph; typedef struct { XColor* colorPtr; Dashes dashes; - int hide; int lineWidth; int x; int y; @@ -50,14 +49,12 @@ typedef struct { class Crosshairs { protected: + Graph* graphPtr_; Tk_OptionTable optionTable_; void* ops_; - GC gc_; - - public: - Graph* graphPtr_; int visible_; + GC gc_; XSegment segArr_[2]; public: @@ -65,10 +62,12 @@ class Crosshairs { virtual ~Crosshairs(); int configure(); + void map(); + void draw(Drawable); + void on(); void off(); - void enable(); - void disable(); + int isOn() {return visible_;} Tk_OptionTable optionTable() {return optionTable_;} void* ops() {return ops_;} diff --git a/src/bltGrHairsOp.C b/src/bltGrHairsOp.C index 21f3871..96a6df1 100644 --- a/src/bltGrHairsOp.C +++ b/src/bltGrHairsOp.C @@ -60,6 +60,8 @@ static int CrosshairsObjConfigure(Graph* graphPtr, Tcl_Interp* interp, if (chPtr->configure() != TCL_OK) return TCL_ERROR; + graphPtr->flags |= mask; + graphPtr->eventuallyRedraw(); break; } @@ -121,12 +123,9 @@ static int OnOp(ClientData clientData, Tcl_Interp* interp, { Graph* graphPtr = (Graph*)clientData; Crosshairs *chPtr = graphPtr->crosshairs_; - CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops(); - if (ops->hide) { - chPtr->on(); - ops->hide = 0; - } + chPtr->on(); + return TCL_OK; } @@ -135,12 +134,9 @@ static int OffOp(ClientData clientData, Tcl_Interp* interp, { Graph* graphPtr = (Graph*)clientData; Crosshairs *chPtr = graphPtr->crosshairs_; - CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops(); - if (!ops->hide) { - chPtr->off(); - ops->hide = 1; - } + chPtr->off(); + return TCL_OK; } @@ -149,10 +145,8 @@ static int ToggleOp(ClientData clientData, Tcl_Interp* interp, { Graph* graphPtr = (Graph*)clientData; Crosshairs *chPtr = graphPtr->crosshairs_; - CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops(); - ops->hide = (ops->hide == 0); - if (ops->hide) + if (chPtr->isOn()) chPtr->off(); else chPtr->on(); diff --git a/src/bltGraph.C b/src/bltGraph.C index 6fa89b4..6050f96 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -210,16 +210,18 @@ int Graph::configure() void Graph::map() { + // cerr << '.'; if (flags & RESET) { - // cerr << "RESET" << endl; + // cerr << 'r'; resetAxes(); flags &= ~RESET; flags |= LAYOUT; } if (flags & LAYOUT) { - // cerr << "LAYOUT" << endl; + // cerr << 'l'; layoutGraph(); + crosshairs_->map(); mapAxes(); mapElements(); flags &= ~LAYOUT; @@ -263,7 +265,7 @@ void Graph::draw() // Update cache if needed if (flags & CACHE) { - // cerr << "CACHE" << endl; + // cerr << 'c'; drawMargins(cache_); switch (legend_->position()) { @@ -337,12 +339,12 @@ void Graph::draw() Tk_DrawFocusHighlight(tkwin_, gc, ops->highlightWidth, drawable); } - // Disable crosshairs before redisplaying to the screen - disableCrosshairs(); + // crosshairs + crosshairs_->draw(drawable); + XCopyArea(display_, drawable, Tk_WindowId(tkwin_), drawGC_, 0, 0, width_, height_, 0, 0); - enableCrosshairs(); Tk_FreePixmap(display_, drawable); } @@ -368,7 +370,7 @@ int Graph::print(const char* ident, PostScript* psPtr) psPtr->computeBBox(width_, height_); flags |= RESET; - /* Turn on PostScript measurements when computing the graph's layout. */ + // Turn on PostScript measurements when computing the graph's layout. reconfigure(); map(); @@ -601,18 +603,6 @@ void Graph::printMargins(PostScript* psPtr) } } -// Crosshairs - -void Graph::enableCrosshairs() -{ - crosshairs_->enable(); -} - -void Graph::disableCrosshairs() -{ - crosshairs_->disable(); -} - // Pens void Graph::destroyPens() @@ -779,7 +769,6 @@ void Graph::mapMarkers() continue; if ((flags & MAP_MARKERS) || (markerPtr->flags & MAP_ITEM)) { - // cerr << "MAP_MARKERS" << endl; markerPtr->map(); markerPtr->flags &= ~MAP_ITEM; } diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index cb597bb..8880522 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -57,10 +57,6 @@ static Tcl_ObjCmdProc GraphObjCmd; static Axis* GetFirstAxis(Blt_Chain chain); -#define PointInRegion(e,x,y) \ - (((x) <= (e)->right) && ((x) >= (e)->left) && \ - ((y) <= (e)->bottom) && ((y) >= (e)->top)) - int GraphObjConfigure(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { @@ -244,7 +240,7 @@ static int InsideOp(ClientData clientData, Tcl_Interp* interp, int objc, Region2d exts; graphPtr->extents(&exts); - int result = PointInRegion(&exts, x, y); + int result = (x<=exts.right && x>=exts.left && y<=exts.bottom && y>=exts.top); Tcl_SetBooleanObj(Tcl_GetObjResult(interp), result); return TCL_OK; @@ -418,11 +414,10 @@ void GraphEventProc(ClientData clientData, XEvent* eventPtr) Graph* graphPtr = (Graph*)clientData; if (eventPtr->type == Expose) { - if (eventPtr->xexpose.count == 0) { + if (eventPtr->xexpose.count == 0) 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; |