[Kst] [Bug 111239] Ability to easily setup supressed axis plots
Andrew Walker
arwalker at sumusltd.com
Thu Jun 22 19:18:22 CEST 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=111239
------- Additional Comments From arwalker sumusltd com 2006-06-22 19:18 -------
SVN commit 553965 by arwalker:
CCBUG:111239 Make everything suitably fuzzy for axes condensation so that the user can be off by a few pixels when aligning plots and still have the axes condense as expected.
M +76 -15 ksttoplevelview.cpp
--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.cpp #553964:553965
@ -1256,15 +1256,20 @
KstApp::inst()->document()->setModified();
Kst2DPlotList plots;
Kst2DPlotList plotsProcess;
+ KstAspectRatio aspect;
+ KstAspectRatio aspectItem;
QRect geom;
+ QRect geomItem;
bool processed = false;
-
+ const double close = 0.02;
+
// create a list of all plot objects in this view
plots = kstObjectSubList<KstViewObject, Kst2DPlot>(_selectionList);
while (plots.count() > 1) {
plotsProcess.clear();
plotsProcess.append(plots.first());
+ aspect = plots.first()->aspectRatio();
geom = plots.first()->geometry();
plots.pop_front();
bool added = true;
@ -1274,22 +1279,46 @
added = false;
for (Kst2DPlotList::ConstIterator i = plots.begin(); i != plots.end(); ++i) {
- if ((*i)->geometry().left() == geom.left() && (*i)->geometry().right() == geom.right()) {
- if (geom.top() - (*i)->geometry().bottom() == 1) {
- geom = geom.unite((*i)->geometry());
+ aspectItem = (*i)->aspectRatio();
+ geomItem = (*i)->geometry();
+
+ if ((geomItem.left() == geom.left() && geomItem.right() == geom.right()) ||
+ (fabs(aspectItem.x - aspect.x) < close && fabs(aspectItem.w - aspect.w) < close)) {
+ if (geom.top() - geomItem.bottom() == 1) {
+ geom = geom.unite(geomItem);
plotsProcess.append(*i);
plots.remove(*i);
added = true;
break;
- } else if ((*i)->geometry().top() - geom.bottom() == 1) {
- geom = geom.unite((*i)->geometry());
+ } else if (geomItem.top() - geom.bottom() == 1) {
plotsProcess.prepend(*i);
- plots.remove(*i);
+ plots.remove(*i);
added = true;
break;
+ } else if (fabs(aspect.y - (aspectItem.y + aspectItem.h)) < close) {
+ plotsProcess.append(*i);
+ plots.remove(*i);
+ added = true;
+ break;
+ } else if (fabs(aspectItem.y - (aspect.y + aspect.h)) < close) {
+ plotsProcess.prepend(*i);
+ plots.remove(*i);
+ added = true;
+ break;
}
}
}
+
+ if (added) {
+ geom = geom.unite(geomItem);
+
+ if (aspect.y < aspectItem.y) {
+ aspect.y = aspectItem.y;
+ }
+ if (aspect.y + aspect.h > aspectItem.y + aspectItem.h) {
+ aspect.h = (aspectItem.y + aspectItem.h) - aspect.y;
+ }
+ }
}
// modify the plot properties appropriately
@ -1324,15 +1353,20 @
KstApp::inst()->document()->setModified();
Kst2DPlotList plots;
Kst2DPlotList plotsProcess;
+ KstAspectRatio aspect;
+ KstAspectRatio aspectItem;
QRect geom;
+ QRect geomItem;
bool processed = false;
-
+ const double close = 0.02;
+
// create a list of all plot objects
plots = kstObjectSubList<KstViewObject, Kst2DPlot>(_selectionList);
while (plots.count() > 1) {
plotsProcess.clear();
plotsProcess.append(plots.first());
+ aspect = plots.first()->aspectRatio();
geom = plots.first()->geometry();
plots.pop_front();
bool added = true;
@ -1342,40 +1376,67 @
added = false;
for (Kst2DPlotList::ConstIterator i = plots.begin(); i != plots.end(); ++i) {
- if ((*i)->geometry().top() == geom.top() && (*i)->geometry().bottom() == geom.bottom()) {
- if (geom.left() - (*i)->geometry().right() == 1) {
- geom = geom.unite((*i)->geometry());
+ aspectItem = (*i)->aspectRatio();
+ geomItem = (*i)->geometry();
+
+ if ((geomItem.top() == geom.top() && geomItem.bottom() == geom.bottom()) ||
+ (fabs(aspectItem.y - aspect.y) < close && fabs(aspectItem.h - aspect.h) < close)) {
+ if (geom.left() - geomItem.right() == 1) {
plotsProcess.append(*i);
plots.remove(*i);
added = true;
break;
- } else if ((*i)->geometry().left() - geom.right() == 1) {
- geom = geom.unite((*i)->geometry());
+ } else if (geomItem.left() - geom.right() == 1) {
plotsProcess.prepend(*i);
plots.remove(*i);
added = true;
break;
+ } else if (fabs(aspect.x - (aspectItem.x + aspectItem.w)) < close) {
+ plotsProcess.append(*i);
+ plots.remove(*i);
+ added = true;
+ break;
+ } else if (fabs(aspectItem.x - (aspect.x + aspect.w)) < close) {
+ plotsProcess.prepend(*i);
+ plots.remove(*i);
+ added = true;
+ break;
}
}
}
+
+ if (added) {
+ geom = geom.unite(geomItem);
+
+ if (aspect.x < aspectItem.x) {
+ aspect.x = aspectItem.x;
+ }
+ if (aspect.x + aspect.w > aspectItem.x + aspectItem.w) {
+ aspect.w = (aspectItem.x + aspectItem.w) - aspect.x;
+ }
+ }
}
// modify the plot properties appropriately
if (plotsProcess.count() > 1) {
plotsProcess.first()->setSuppressLeft(true);
+ plotsProcess.first()->setDirty();
plotsProcess.pop_front();
+
plotsProcess.last()->setSuppressRight(true);
+ plotsProcess.last()->setDirty();
plotsProcess.pop_back();
-
+
for (Kst2DPlotList::Iterator i = plotsProcess.begin(); i != plotsProcess.end(); ++i) {
(*i)->setSuppressLeft(true);
(*i)->setSuppressRight(true);
+ (*i)->setDirty();
}
processed = true;
}
}
-
+
if (processed) {
widget()->paint(QRegion());
}
More information about the Kst
mailing list