[Kst] branches/work/kst/portto4/kst/src/libkstapp
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Jun 18 17:42:00 UTC 2013
SVN commit 1358012 by netterfield:
A little bit of re-factoring...
M +42 -37 plotrenderitem.cpp
M +2 -0 plotrenderitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #1358011:1358012
@@ -486,15 +486,11 @@
view()->setCursor(Qt::SizeHorCursor);
} else {
view()->setCursor(Qt::CrossCursor);
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(true, true);
foreach (PlotItem *plot, plots) {
plot->renderItem()->resetSelectionRect();
}
- } else {
- resetSelectionRect();
}
- }
ViewItem::keyReleaseEvent(event);
}
@@ -573,25 +569,16 @@
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
view()->setCursor(Qt::SizeVerCursor);
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(false, true);
foreach (PlotItem *plot, plots) {
plot->renderItem()->dragYZoomMouseCursor(y);
}
- } else {
- dragYZoomMouseCursor(y);
- }
} else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(true, false);
foreach (PlotItem *plot, plots) {
plot->renderItem()->dragXZoomMouseCursor(x);
}
} else {
- dragXZoomMouseCursor(x);
- }
-
- } else {
_selectionRect.setTo(p);
}
@@ -660,14 +647,10 @@
updateCursor(event->pos());
const QRectF projection = plotItem()->mapToProjection(_selectionRect.rect());
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(true, true);
foreach (PlotItem *plot, plots) {
plot->renderItem()->_selectionRect.reset();
}
- } else {
- _selectionRect.reset();
- }
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
plotItem()->zoomYRange(projection);
@@ -730,6 +713,41 @@
update(); //FIXME should optimize instead of redrawing entire curve!
}
+
+QList<PlotItem*> PlotRenderItem::sharedOrTiedPlots(bool sharedX, bool sharedY) {
+ QList<PlotItem*> plots;
+ QList<PlotItem*> shared_plots;
+ QList<PlotItem*> tied_plots;
+
+ if (plotItem()->isInSharedAxisBox()) {
+ shared_plots = plotItem()->sharedAxisBox()->getSharedPlots();
+ bool keep;
+ foreach (PlotItem *plot, shared_plots) {
+ keep = (sharedX && plotItem()->sharedAxisBox()->isXAxisShared()) ||
+ (sharedY && plotItem()->sharedAxisBox()->isYAxisShared());
+ if (keep) {
+ plots.append(plot);
+ }
+ }
+ }
+
+ if (plotItem()->isTiedZoom()) {
+ tied_plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ foreach (PlotItem *plot, tied_plots) {
+ if (!plots.contains(plot)) {
+ plots.append(plot);
+ }
+ }
+ }
+
+ if (plots.size()<1) {
+ plots.append(plotItem());
+ }
+
+ return plots;
+}
+
+
//FIXME: store event or pos, and re-call this when window is redrawn
void PlotRenderItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
@@ -750,35 +768,22 @@
if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
_lastPos = p;
view()->setCursor(Qt::SizeVerCursor);
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(false,true);
foreach (PlotItem *plot, plots) {
plot->renderItem()->hoverYZoomMouseCursor(y);
}
- } else {
- hoverYZoomMouseCursor(y);
- }
} else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
_lastPos = p;
view()->setCursor(Qt::SizeHorCursor);
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(true,false);
foreach (PlotItem *plot, plots) {
plot->renderItem()->hoverXZoomMouseCursor(x);
}
} else {
- hoverXZoomMouseCursor(x);
- }
- } else {
- if (plotItem()->isTiedZoom()) {
- QList<PlotItem*> plots = PlotItemManager::self()->tiedZoomPlotsForView(view());
+ QList<PlotItem*> plots = sharedOrTiedPlots(true,true);
foreach (PlotItem *plot, plots) {
plot->renderItem()->resetSelectionRect();
}
- } else {
- resetSelectionRect();
- }
-
updateCursor(p);
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #1358011:1358012
@@ -71,6 +71,8 @@
virtual bool tryShortcut(const QString &keySequence);
+ QList<PlotItem*> sharedOrTiedPlots(bool sharedX, bool sharedY);
+
void hoverYZoomMouseCursor(double y);
void hoverXZoomMouseCursor(double x);
More information about the Kst
mailing list