[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Apr 8 16:55:03 CEST 2010
SVN commit 1112570 by netterfield:
Fix some bugs with shared axis.
Fix a bug with log axis.
M devel-docs/Kst2Specs/Zoom Modes.pdf
M devel-docs/Kst2Specs/src/Zoom Modes.odt
M +1 -1 src/libkstapp/plotaxis.cpp
M +24 -10 src/libkstapp/plotitem.cpp
M +207 -42 src/libkstapp/sharedaxisboxitem.cpp
M +2 -1 src/libkstapp/sharedaxisboxitem.h
M +1 -1 src/libkstapp/viewitem.cpp
M +6 -6 tests/dirfile_maker/dirfile_maker.c
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #1112569:1112570
@@ -702,7 +702,7 @@
}
}
}
- if (minorLabels && minTicks.isEmpty()) {
+ if (minorLabels && !minTicks.isEmpty()) {
qreal lastMinorTick = minTicks.last();
if (ticks.isEmpty() || ticks.last() < lastMinorTick) {
if (labels.contains(lastMinorTick)) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1112569:1112570
@@ -731,28 +731,40 @@
_serialOfLastChange = serial;
+ QRectF compute = computedProjectionRect();
+ QRectF newProjectionRec = projectionRect();
+
if (isInSharedAxisBox()) {
// Need to update the box's projectionRect.
sharedAxisBox()->updateZoomForDataUpdate();
- } else {
- if ((xAxis()->axisZoomMode() == PlotAxis::Auto) ||
+ }
+ if ((xAxis()->axisZoomMode() == PlotAxis::Auto) ||
(xAxis()->axisZoomMode() == PlotAxis::MeanCentered) ||
(xAxis()->axisZoomMode() == PlotAxis::AutoBorder) ||
(xAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive)) {
- if ((yAxis()->axisZoomMode() == PlotAxis::AutoBorder) ||
- (yAxis()->axisZoomMode() == PlotAxis::Auto) ||
- (yAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive) ||
- (yAxis()->axisZoomMode() == PlotAxis::MeanCentered)) {
- setProjectionRect(computedProjectionRect());
- } else {
- QRectF compute = computedProjectionRect();
+
+ newProjectionRec.setLeft(compute.x());
+ newProjectionRec.setWidth(compute.width());
+ }
+
+ if ((yAxis()->axisZoomMode() == PlotAxis::AutoBorder) ||
+ (yAxis()->axisZoomMode() == PlotAxis::Auto) ||
+ (yAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive) ||
+ (yAxis()->axisZoomMode() == PlotAxis::MeanCentered)) {
+ newProjectionRec.setTop(compute.y());
+ newProjectionRec.setHeight(compute.height());
+ }
+
+ setProjectionRect(newProjectionRec);
+
+#if 0
+ else {
setProjectionRect(QRectF(compute.x(),
projectionRect().y(),
compute.width(),
projectionRect().height()));
}
} else if (yAxis()->axisZoomMode() == PlotAxis::Auto) {
- QRectF compute = computedProjectionRect();
setProjectionRect(QRectF(projectionRect().x(),
compute.y(),
projectionRect().width(),
@@ -761,6 +773,8 @@
update();
}
}
+#endif
+
setLabelsDirty();
return true;
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #1112569:1112570
@@ -207,6 +207,8 @@
plotItem->setPos(mapToParent(plotItem->pos()));
plotItem->setSharedAxisBox(0);
plotItem->setLabelsVisible(true);
+ plotItem->xAxis()->setAxisZoomMode(xAxisZoomMode());
+ plotItem->yAxis()->setAxisZoomMode(yAxisZoomMode());
plotItem->update();
}
}
@@ -342,15 +344,22 @@
}
+QList<PlotItem*> SharedAxisBoxItem::getAllPlots() {
+ QList<PlotItem*> plots = _sharedPlots;
+ //plots << PlotItemManager::tiedZoomPlotsForView(parentView());
+
+ return plots;
+}
+
QList<PlotItem*> SharedAxisBoxItem::getSharedPlots() {
return _sharedPlots;
}
+QList<PlotItem*> SharedAxisBoxItem::getTiedPlots(PlotItem* originPlotItem) {
+ QList<PlotItem*> plots;
-QList<PlotItem*> SharedAxisBoxItem::getTiedPlots() {
- QList<PlotItem*> plots = getSharedPlots();
- if (isTiedZoom()) {
- plots << PlotItemManager::tiedZoomPlotsForView(parentView());
+ if (originPlotItem) {
+ return PlotItemManager::tiedZoomPlotsForView(parentView());
}
return plots;
}
@@ -379,28 +388,58 @@
void SharedAxisBoxItem::applyZoom(const QRectF &projection, PlotItem* originPlotItem, bool applyX, bool applyY) {
- QList<PlotItem*> allPlots = getTiedPlots();
+ QList<PlotItem*> allPlots = getAllPlots();
QList<PlotItem*> plotTied;
- if (originPlotItem && originPlotItem->isTiedZoom() && originPlotItem->isInSharedAxisBox() && (originPlotItem->sharedAxisBox() == this)) {
+ if (originPlotItem &&
+ originPlotItem->isTiedZoom() &&
+ originPlotItem->isInSharedAxisBox() &&
+ (originPlotItem->sharedAxisBox() == this)) {
plotTied = PlotItemManager::tiedZoomPlotsForView(parentView());
+ foreach (PlotItem* plotItem, plotTied) {
+ // tie only changes the unshared axis for shared plots
+ if (!_shareX || !plotItem->isInSharedAxisBox()) {
+ switch (xAxisZoomMode()) {
+ case PlotAxis::Auto:
+ plotItem->zoomXMaximum(true);
+ break;
+ case PlotAxis::AutoBorder:
+ plotItem->zoomXAutoBorder(true);
+ break;
+ case PlotAxis::SpikeInsensitive:
+ plotItem->zoomXNoSpike(true);
+ break;
+ default:
+ plotItem->zoomXRange(projection,true);
+ break;
- foreach (PlotItem* plotItem, plotTied) {
- if ((originPlotItem->isXTiedZoom() && plotItem->isXTiedZoom()) && (originPlotItem->isYTiedZoom() && plotItem->isYTiedZoom())) {
- plotItem->zoomFixedExpression(projection, true);
- } else if (originPlotItem->isXTiedZoom() && plotItem->isXTiedZoom()) {
- plotItem->zoomFixedExpression(QRectF(projection.x(), plotItem->projectionRect().y(), projection.width(), plotItem->projectionRect().height()), true);
- } else if (originPlotItem->isYTiedZoom() && plotItem->isYTiedZoom()) {
- plotItem->zoomFixedExpression(QRectF(plotItem->projectionRect().x(), projection.y(), plotItem->projectionRect().width(), projection.height()), true);
+ }
}
+
+ if (!_shareY || !plotItem->isInSharedAxisBox()) {
+ switch (yAxisZoomMode()) {
+ case PlotAxis::Auto:
+ plotItem->zoomYMaximum(true);
+ break;
+ case PlotAxis::AutoBorder:
+ plotItem->zoomYAutoBorder(true);
+ break;
+ case PlotAxis::SpikeInsensitive:
+ plotItem->zoomYNoSpike(true);
+ break;
+ default:
+ plotItem->zoomYRange(projection,true);
+ break;
+ }
+ }
}
}
foreach (PlotItem* plotItem, allPlots) {
if ((applyX && applyY) && ((_shareX && _shareY) || (isXTiedZoom() && isYTiedZoom()))) {
plotItem->zoomFixedExpression(projection, true);
} else if (applyX && (_shareX || isXTiedZoom() || (plotItem == originPlotItem))) {
- plotItem->zoomFixedExpression(QRectF(projection.x(), plotItem->projectionRect().y(), projection.width(), plotItem->projectionRect().height()), true);
+ plotItem->zoomXRange(QRectF(projection.x(), plotItem->projectionRect().y(), projection.width(), plotItem->projectionRect().height()), true);
} else if (applyY && (_shareY || isYTiedZoom() || (plotItem == originPlotItem))) {
- plotItem->zoomFixedExpression(QRectF(plotItem->projectionRect().x(), projection.y(), plotItem->projectionRect().width(), projection.height()), true);
+ plotItem->zoomYRange(QRectF(plotItem->projectionRect().x(), projection.y(), plotItem->projectionRect().width(), projection.height()), true);
}
}
}
@@ -565,8 +604,19 @@
#if DEBUG_ZOOM
qDebug() << "zoomXRight" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareX || isXTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareX) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareX || origin_tied)) {
if (originPlotItem) {
originPlotItem->zoomXRight(true);
}
@@ -593,8 +643,19 @@
#if DEBUG_ZOOM
qDebug() << "zoomXLeft" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareX || isXTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareX) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareX || origin_tied)) {
if (originPlotItem) {
originPlotItem->zoomXLeft(true);
}
@@ -620,8 +681,19 @@
#if DEBUG_ZOOM
qDebug() << "zoomXOut" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareX || isXTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareX) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareX || origin_tied)) {
if (originPlotItem) {
originPlotItem->zoomXOut(true);
}
@@ -648,8 +720,19 @@
#if DEBUG_ZOOM
qDebug() << "zoomXIn" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareX || isXTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareX) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareX || origin_tied)) {
if (originPlotItem) {
originPlotItem->zoomXIn(true);
}
@@ -709,14 +792,25 @@
#if DEBUG_ZOOM
qDebug() << "zoomLogX" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
bool enableLog;
if (autoEnable && originPlotItem) {
enableLog = !originPlotItem->xAxis()->axisLog();
} else {
enableLog = enable;
}
- if (!(_shareX || isXTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareX) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareX || origin_tied)) {
if (originPlotItem) {
originPlotItem->zoomLogX(true, false, enableLog);
}
@@ -741,7 +835,14 @@
#if DEBUG_ZOOM
qDebug() << "zoomYLocalMaximum" << endl;
#endif
- if (!(_shareY || isYTiedZoom())) {
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
+
if (originPlotItem) {
originPlotItem->zoomYLocalMaximum(true);
}
@@ -812,8 +913,19 @@
#if DEBUG_ZOOM
qDebug() << "zoomYUp" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareY || isYTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareY) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
if (originPlotItem) {
originPlotItem->zoomYUp(true);
}
@@ -839,8 +951,20 @@
#if DEBUG_ZOOM
qDebug() << "zoomYDown" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareY || isYTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareY) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
+
if (originPlotItem) {
originPlotItem->zoomYDown(true);
}
@@ -866,8 +990,20 @@
#if DEBUG_ZOOM
qDebug() << "zoomYOut" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareY || isYTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareY) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
+
if (originPlotItem) {
originPlotItem->zoomYOut(true);
}
@@ -893,8 +1029,20 @@
#if DEBUG_ZOOM
qDebug() << "zoomYIn" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
- if (!(_shareY || isYTiedZoom())) {
+ QList<PlotItem*> allPlots;
+ if (_shareY) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
+
if (originPlotItem) {
originPlotItem->zoomYIn(true);
}
@@ -923,7 +1071,14 @@
#if DEBUG_ZOOM
qDebug() << "zoomNormalizeYtoX" << endl;
#endif
- if (!(_shareY || isYTiedZoom())) {
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
+
if (originPlotItem) {
originPlotItem->zoomNormalizeXtoY(true);
}
@@ -955,7 +1110,12 @@
#if DEBUG_ZOOM
qDebug() << "zoomLogY" << endl;
#endif
- QList<PlotItem*> allPlots = getTiedPlots();
+ QList<PlotItem*> allPlots;
+ if (_shareY) {
+ allPlots = getSharedPlots();
+ } else {
+ allPlots = getTiedPlots(originPlotItem);
+ }
bool enableLog;
if (autoEnable && originPlotItem) {
enableLog = !originPlotItem->yAxis()->axisLog();
@@ -963,7 +1123,14 @@
enableLog = enable;
}
- if (!(_shareY || isYTiedZoom())) {
+
+ bool origin_tied = false;
+ if (originPlotItem) {
+ origin_tied = originPlotItem->isTiedZoom();
+ }
+
+ if (!(_shareY || origin_tied)) {
+
if (originPlotItem) {
originPlotItem->zoomLogY(true, false, enableLog);
}
@@ -985,11 +1152,7 @@
void SharedAxisBoxItem::updateZoomForDataUpdate() {
- if (xAxisZoomMode() == PlotAxis::Auto && yAxisZoomMode() == PlotAxis::AutoBorder) {
- zoomMaximum(0);
- } else if (xAxisZoomMode() == PlotAxis::Auto && yAxisZoomMode() == PlotAxis::SpikeInsensitive) {
- zoomMaxSpikeInsensitive(0);
- } else {
+ if (_shareX) {
switch (xAxisZoomMode()) {
case PlotAxis::Auto:
zoomXMaximum(0);
@@ -1003,6 +1166,8 @@
default:
break;
}
+ }
+ if (_shareY) {
switch (yAxisZoomMode()) {
case PlotAxis::Auto:
zoomYMaximum(0);
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.h #1112569:1112570
@@ -103,7 +103,8 @@
void applyZoom(const QRectF &projection, PlotItem* originPlotItem, bool applyX = true, bool applyY = true);
QList<PlotItem*> getSharedPlots();
- QList<PlotItem*> getTiedPlots();
+ QList<PlotItem*> getTiedPlots(PlotItem* originPlotItem);
+ QList<PlotItem*> getAllPlots();
QAction *_breakAction;
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1112569:1112570
@@ -1850,7 +1850,7 @@
void ViewItem::setTiedZoom(bool tiedXZoom, bool tiedYZoom, bool checkAllTied) {
Q_UNUSED(checkAllTied)
-
+qDebug() << "setting tied zoom: " << tiedXZoom << " " << tiedYZoom;
if ((_isXTiedZoom == tiedXZoom) && (_isYTiedZoom == tiedYZoom))
return;
--- branches/work/kst/portto4/kst/tests/dirfile_maker/dirfile_maker.c #1112569:1112570
@@ -96,22 +96,22 @@
/* write 'sine' */
for (i=0; i<df[SINE].spf; i++) {
- x = count*df[SINE].spf+i;
- x = sin(2.0*M_PI*x/100.0);
+ dx = count*df[SINE].spf+i;
+ x = sin(2.0*M_PI*dx/100.0);
write(df[SINE].fp, &x, sizeof(float));
}
/* write 'ssine' */
for (i=0; i<df[SSINE].spf; i++) {
- x = count*df[SSINE].spf+i;
- x = sin(2.0*M_PI*x/100.0);
+ dx = count*df[SSINE].spf+i;
+ x = sin(2.0*M_PI*dx/100.0);
write(df[SSINE].fp, &x, sizeof(float));
}
/* write 'cos' */
for (i=0; i<df[COS].spf; i++) {
- x = count*df[COS].spf+i;
- x = cos(2.0*M_PI*x/100.0);
+ dx = count*df[COS].spf+i;
+ x = cos(2.0*M_PI*dx/100.0);
write(df[COS].fp, &x, sizeof(float));
}
More information about the Kst
mailing list