summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-04-17 17:05:42 (GMT)
committerjoye <joye>2014-04-17 17:05:42 (GMT)
commit5203b01c7d32185f31ad84a0cf1040b90adb1d42 (patch)
treecf710852e5731bb3f0b2c9568b664ce945197e47 /src
parentb6a17c50c2b0722cec7c63876ac28f3f66e47293 (diff)
downloadblt-5203b01c7d32185f31ad84a0cf1040b90adb1d42.zip
blt-5203b01c7d32185f31ad84a0cf1040b90adb1d42.tar.gz
blt-5203b01c7d32185f31ad84a0cf1040b90adb1d42.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrAxis.C48
-rw-r--r--src/bltGrAxis.h2
-rw-r--r--src/bltGrAxisOp.C60
-rw-r--r--src/bltGrAxisOp.h1
-rw-r--r--src/bltGraph.C63
-rw-r--r--src/bltGraph.h1
6 files changed, 87 insertions, 88 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C
index fed9fb9..49552f8 100644
--- a/src/bltGrAxis.C
+++ b/src/bltGrAxis.C
@@ -499,6 +499,9 @@ void Axis::draw(Drawable drawable)
{
AxisOptions* ops = (AxisOptions*)ops_;
+ if (ops->hide || !use_ || (flags & DELETE_PENDING))
+ return;
+
if (ops->normalBg) {
Tk_Fill3DRectangle(graphPtr_->tkwin_, drawable, ops->normalBg,
left_, top_, right_ - left_, bottom_ - top_,
@@ -622,11 +625,29 @@ void Axis::draw(Drawable drawable)
}
}
+void Axis::drawGrids(Drawable drawable)
+{
+ AxisOptions* ops = (AxisOptions*)ops_;
+
+ if (ops->hide || !ops->showGrid || !use_ || (flags & DELETE_PENDING))
+ return;
+
+ Blt_Draw2DSegments(graphPtr_->display_, drawable, ops->major.gc,
+ ops->major.segments, ops->major.nUsed);
+
+ if (ops->showGridMinor)
+ Blt_Draw2DSegments(graphPtr_->display_, drawable, ops->minor.gc,
+ ops->minor.segments, ops->minor.nUsed);
+}
+
void Axis::drawLimits(Drawable drawable)
{
AxisOptions* ops = (AxisOptions*)ops_;
GraphOptions* gops = (GraphOptions*)graphPtr_->ops_;
+ if ((flags & DELETE_PENDING) || (!ops->limitsFormat))
+ return;
+
int vMin = graphPtr_->left_ + gops->xPad + 2;
int vMax = vMin;
int hMin = graphPtr_->bottom_ - gops->yPad - 2;
@@ -1670,6 +1691,9 @@ void Axis::print(Blt_Ps ps)
{
AxisOptions* ops = (AxisOptions*)ops_;
+ if (ops->hide || !use_ || (flags & DELETE_PENDING))
+ return;
+
Blt_Ps_Format(ps, "%% Axis \"%s\"\n", name());
if (ops->normalBg)
Blt_Ps_Fill3DRectangle(ps, ops->normalBg, left_, top_,
@@ -1718,11 +1742,35 @@ void Axis::print(Blt_Ps ps)
}
}
+void Axis::printGrids(Blt_Ps ps)
+{
+ AxisOptions* ops = (AxisOptions*)ops_;
+
+ if (ops->hide || !ops->showGrid || !use_ || (flags & DELETE_PENDING))
+ continue;
+
+ Blt_Ps_Format(ps, "%% Axis %s: grid line attributes\n", name());
+ Blt_Ps_XSetLineAttributes(ps, ops->major.color, ops->major.lineWidth,
+ &ops->major.dashes, CapButt, JoinMiter);
+ Blt_Ps_Format(ps, "%% Axis %s: major grid line segments\n", name());
+ Blt_Ps_Draw2DSegments(ps, ops->major.segments, ops->major.nUsed);
+
+ if (ops->showGridMinor) {
+ Blt_Ps_XSetLineAttributes(ps, ops->minor.color, ops->minor.lineWidth,
+ &ops->minor.dashes, CapButt, JoinMiter);
+ Blt_Ps_Format(ps, "%% Axis %s: minor grid line segments\n", name());
+ Blt_Ps_Draw2DSegments(ps, ops->minor.segments, ops->minor.nUsed);
+ }
+}
+
void Axis::printLimits(Blt_Ps ps)
{
AxisOptions* ops = (AxisOptions*)ops_;
GraphOptions* gops = (GraphOptions*)graphPtr_->ops_;
+ if ((flags & DELETE_PENDING) || (!ops->limitsFormat))
+ return;
+
double vMin = graphPtr_->left_ + gops->xPad + 2;
double vMax = vMin;
double hMin = graphPtr_->bottom_ - gops->yPad - 2;
diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h
index fa42aa0..f698db7 100644
--- a/src/bltGrAxis.h
+++ b/src/bltGrAxis.h
@@ -224,8 +224,10 @@ class Axis {
int configure();
void map(int, int);
void draw(Drawable);
+ void drawGrids(Drawable);
void drawLimits(Drawable);
void print(Blt_Ps);
+ void printGrids(Blt_Ps);
void printLimits(Blt_Ps);
void mapStacked(int, int);
diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C
index 2ff33f5..789aa59 100644
--- a/src/bltGrAxisOp.C
+++ b/src/bltGrAxisOp.C
@@ -687,66 +687,6 @@ Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr)
return point;
}
-void Blt_DrawGrids(Graph* graphPtr, Drawable drawable)
-{
- GraphOptions* gops = (GraphOptions*)graphPtr->ops_;
- for (int i = 0; i < 4; i++) {
- for (Blt_ChainLink link = Blt_Chain_FirstLink(gops->margins[i].axes); link != NULL;
- link = Blt_Chain_NextLink(link)) {
- Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
- if (ops->hide || (axisPtr->flags & DELETE_PENDING))
- continue;
-
- if (axisPtr->use_ && ops->showGrid) {
- Blt_Draw2DSegments(graphPtr->display_, drawable,
- ops->major.gc, ops->major.segments,
- ops->major.nUsed);
-
- if (ops->showGridMinor)
- Blt_Draw2DSegments(graphPtr->display_, drawable,
- ops->minor.gc, ops->minor.segments,
- ops->minor.nUsed);
- }
- }
- }
-}
-
-void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps)
-{
- GraphOptions* gops = (GraphOptions*)graphPtr->ops_;
- for (int i = 0; i < 4; i++) {
- for (Blt_ChainLink link = Blt_Chain_FirstLink(gops->margins[i].axes); link != NULL; link = Blt_Chain_NextLink(link)) {
- Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
- if (ops->hide || !ops->showGrid || !axisPtr->use_ ||
- (axisPtr->flags & DELETE_PENDING))
- continue;
-
- Blt_Ps_Format(ps, "%% Axis %s: grid line attributes\n",
- axisPtr->name());
- Blt_Ps_XSetLineAttributes(ps, ops->major.color,
- ops->major.lineWidth,
- &ops->major.dashes, CapButt,
- JoinMiter);
- Blt_Ps_Format(ps, "%% Axis %s: major grid line segments\n",
- axisPtr->name());
- Blt_Ps_Draw2DSegments(ps, ops->major.segments,
- ops->major.nUsed);
- if (ops->showGridMinor) {
- Blt_Ps_XSetLineAttributes(ps, ops->minor.color,
- ops->minor.lineWidth,
- &ops->minor.dashes, CapButt,
- JoinMiter);
- Blt_Ps_Format(ps, "%% Axis %s: minor grid line segments\n",
- axisPtr->name());
- Blt_Ps_Draw2DSegments(ps, ops->minor.segments,
- ops->minor.nUsed);
- }
- }
- }
-}
-
Axis *Blt_GetFirstAxis(Blt_Chain chain)
{
Blt_ChainLink link = Blt_Chain_FirstLink(chain);
diff --git a/src/bltGrAxisOp.h b/src/bltGrAxisOp.h
index 50ea064..6d33664 100644
--- a/src/bltGrAxisOp.h
+++ b/src/bltGrAxisOp.h
@@ -42,7 +42,6 @@ extern Point2d Blt_Map2D(Graph* graphPtr, double x, double y,
Axis2d *pairPtr);
extern void Blt_AdjustAxisPointers(Graph* graphPtr);
-extern void Blt_DrawGrids(Graph* graphPtr, Drawable drawable);
extern void Blt_UpdateAxisBackgrounds(Graph* graphPtr);
extern void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps);
extern Axis *Blt_GetFirstAxis(Blt_Chain chain);
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 0a14ed8..c30f7f5 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -437,28 +437,23 @@ void Graph::display()
drawable = Tk_WindowId(tkwin_);
if (ops->backingStore) {
- if ((cache_ == None) ||
- (cacheWidth_ != width_) ||
- (cacheHeight_ != height_)) {
+ if ((cache_ == None)||(cacheWidth_ != width_)||(cacheHeight_ != height_)) {
if (cache_ != None)
Tk_FreePixmap(display_, cache_);
- cache_ = Tk_GetPixmap(display_,
- Tk_WindowId(tkwin_),
- width_, height_,
- Tk_Depth(tkwin_));
+ cache_ = Tk_GetPixmap(display_, Tk_WindowId(tkwin_), width_, height_,
+ Tk_Depth(tkwin_));
cacheWidth_ = width_;
cacheHeight_ = height_;
flags |= CACHE_DIRTY;
}
}
+
if (ops->backingStore) {
if (flags & CACHE_DIRTY) {
drawPlot(cache_);
flags &= ~CACHE_DIRTY;
}
-
- // Copy the pixmap to the one used for drawing the entire graph
XCopyArea(display_, cache_, drawable, drawGC_, 0, 0, Tk_Width(tkwin_),
Tk_Height(tkwin_), 0, 0);
}
@@ -469,7 +464,6 @@ void Graph::display()
drawMarkers(drawable, MARKER_ABOVE);
drawActiveElements(drawable);
- // Don't draw legend in the plot area.
if (legend_->isRaised()) {
switch (legend_->position()) {
case Legend::PLOT:
@@ -545,7 +539,7 @@ void Graph::drawPlot(Drawable drawable)
// Draw the elements, markers, legend, and axis limits
drawAxes(drawable);
- Blt_DrawGrids(this, drawable);
+ drawAxesGrids(drawable);
drawMarkers(drawable, MARKER_UNDER);
if (!legend_->isRaised()) {
@@ -1182,13 +1176,12 @@ void Graph::mapAxes()
void Graph::drawAxes(Drawable drawable)
{
GraphOptions* gops = (GraphOptions*)ops_;
- for (int i = 0; i < 4; i++) {
- for (Blt_ChainLink link = Blt_Chain_LastLink(gops->margins[i].axes);
+
+ for (int ii=0; ii<4; ii++) {
+ for (Blt_ChainLink link = Blt_Chain_LastLink(gops->margins[ii].axes);
link != NULL; link = Blt_Chain_PrevLink(link)) {
Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
- if (!ops->hide && axisPtr->use_ && !(axisPtr->flags & DELETE_PENDING))
- axisPtr->draw(drawable);
+ axisPtr->draw(drawable);
}
}
}
@@ -1199,14 +1192,23 @@ void Graph::drawAxesLimits(Drawable drawable)
for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
-
- if ((axisPtr->flags & DELETE_PENDING) || (!ops->limitsFormat))
- continue;
axisPtr->drawLimits(drawable);
}
}
+void Graph::drawAxesGrids(Drawable drawable)
+{
+ GraphOptions* gops = (GraphOptions*)ops_;
+
+ for (int ii=0; ii<4; ii++) {
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(gops->margins[ii].axes);
+ link; link = Blt_Chain_NextLink(link)) {
+ Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link);
+ axisPtr->drawGrids(drawable);
+ }
+ }
+}
+
void Graph::printAxes(Blt_Ps ps)
{
GraphOptions* gops = (GraphOptions*)ops_;
@@ -1216,9 +1218,20 @@ void Graph::printAxes(Blt_Ps ps)
for (Blt_ChainLink link=Blt_Chain_FirstLink(mp->axes); link;
link = Blt_Chain_NextLink(link)) {
Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
- if (!ops->hide && axisPtr->use_ && !(axisPtr->flags & DELETE_PENDING))
- axisPtr->print(ps);
+ axisPtr->print(ps);
+ }
+ }
+}
+
+void Graph::printAxesGrids(Blt_Ps ps)
+{
+ GraphOptions* gops = (GraphOptions*)graphPtr->ops_;
+
+ for (int ii=0; ii<4; ii++) {
+ for (Blt_ChainLink link=Blt_Chain_FirstLink(gops->margins[ii].axes);
+ link; link = Blt_Chain_NextLink(link)) {
+ Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link);
+ axisPtr->printGrids(ps);
}
}
}
@@ -1229,10 +1242,6 @@ void Graph::printAxesLimits(Blt_Ps ps)
for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
-
- if ((axisPtr->flags & DELETE_PENDING) || (!ops->limitsFormat))
- continue;
axisPtr->printLimits(ps);
}
}
diff --git a/src/bltGraph.h b/src/bltGraph.h
index e0ca4db..6c3795d 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -223,6 +223,7 @@ class Graph {
void mapAxes();
void drawAxes(Drawable);
void drawAxesLimits(Drawable);
+ void drawAxesGrids(Drawable);
public:
Graph(ClientData clientData, Tcl_Interp*interp,