[Kst] [Bug 111239] Ability to easily setup supressed axis plots
Andrew Walker
arwalker at sumusltd.com
Wed Jun 21 22:17:38 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-21 22:17 -------
SVN commit 553711 by arwalker:
CCBUG:111239 Feature complete barring architectural requirements from George and additions to JS.
M +147 -1 ksttoplevelview.cpp
M +2 -0 ksttoplevelview.h
--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.cpp #553710:553711
@ -1190,7 +1190,25 @
menu->insertSeparator();
}
- KPopupMenu *subMenu = new KPopupMenu(menu);
+ KPopupMenu *subMenu;
+ int numPlots = 0;
+
+ for (KstViewObjectList::ConstIterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
+ if (kst_cast<Kst2DPlot>(*i)) {
+ numPlots++;
+ if (numPlots > 1) {
+ break;
+ }
+ }
+ }
+ if (numPlots > 1) {
+ subMenu = new KPopupMenu(menu);
+ subMenu->insertItem(i18n("X-axis"), this, SLOT(condenseXAxis()));
+ subMenu->insertItem(i18n("Y-axis"), this, SLOT(condenseYAxis()));
+ menu->insertItem(i18n("Condense"), subMenu);
+ }
+
+ subMenu = new KPopupMenu(menu);
subMenu->insertItem(i18n("Width"), this, SLOT(makeSameWidth()));
subMenu->insertItem(i18n("Height"), this, SLOT(makeSameHeight()));
subMenu->insertItem(i18n("Size"), this, SLOT(makeSameSize()));
@ -1231,6 +1249,134 @
}
+void KstTopLevelView::condenseXAxis() {
+ if (_pressTarget) {
+ KstApp::inst()->document()->setModified();
+ Kst2DPlotList plots;
+ Kst2DPlotList plotsProcess;
+ QRect geom;
+ bool processed = false;
+
+ // 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());
+ geom = plots.first()->geometry();
+ plots.pop_front();
+ bool added = true;
+
+ // find all the plots that are attached to this one
+ while (added && plots.count() > 0) {
+ 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());
+ plotsProcess.append(*i);
+ plots.remove(*i);
+ added = true;
+ break;
+ } else if ((*i)->geometry().top() - geom.bottom() == 1) {
+ geom = geom.unite((*i)->geometry());
+ plotsProcess.prepend(*i);
+ plots.remove(*i);
+ added = true;
+ break;
+ }
+ }
+ }
+ }
+
+ // modify the plot properties appropriately
+ if (plotsProcess.count() > 1) {
+ plotsProcess.first()->setSuppressTop(true);
+ plotsProcess.pop_front();
+ plotsProcess.last()->setSuppressBottom(true);
+ plotsProcess.pop_back();
+
+ for (Kst2DPlotList::Iterator i = plotsProcess.begin(); i != plotsProcess.end(); ++i) {
+ (*i)->setSuppressTop(true);
+ (*i)->setSuppressBottom(true);
+ }
+
+ processed = true;
+ }
+ }
+
+ if (processed) {
+ widget()->paint(QRegion());
+ }
+ }
+}
+
+
+void KstTopLevelView::condenseYAxis() {
+ if (_pressTarget) {
+ KstApp::inst()->document()->setModified();
+ Kst2DPlotList plots;
+ Kst2DPlotList plotsProcess;
+ QRect geom;
+ bool processed = false;
+
+ // create a list of all plot objects
+ plots = kstObjectSubList<KstViewObject, Kst2DPlot>(_selectionList);
+
+ while (plots.count() > 1) {
+ plotsProcess.clear();
+ plotsProcess.append(plots.first());
+ geom = plots.first()->geometry();
+ plots.pop_front();
+ bool added = true;
+
+ // find all the plots that are attached to this one
+ while (added && plots.count() > 0) {
+ 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());
+ plotsProcess.append(*i);
+ plots.remove(*i);
+ added = true;
+ break;
+ } else if ((*i)->geometry().left() - geom.right() == 1) {
+ geom = geom.unite((*i)->geometry());
+ plotsProcess.prepend(*i);
+ plots.remove(*i);
+ added = true;
+ break;
+ }
+ }
+ }
+ }
+
+ // modify the plot properties appropriately
+ if (plotsProcess.count() > 1) {
+ plotsProcess.first()->setSuppressLeft(true);
+ plotsProcess.pop_front();
+ plotsProcess.last()->setSuppressRight(true);
+ plotsProcess.pop_back();
+
+ for (Kst2DPlotList::Iterator i = plotsProcess.begin(); i != plotsProcess.end(); ++i) {
+ (*i)->setSuppressLeft(true);
+ (*i)->setSuppressRight(true);
+ }
+
+ processed = true;
+ }
+ }
+
+ if (processed) {
+ widget()->paint(QRegion());
+ }
+ }
+}
+
+
void KstTopLevelView::makeSameWidth() {
if (_pressTarget) {
KstApp::inst()->document()->setModified();
--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.h #553710:553711
@ -81,6 +81,8 @
private slots:
void menuClosed();
+ void condenseXAxis();
+ void condenseYAxis();
void makeSameWidth();
void makeSameHeight();
void makeSameSize();
More information about the Kst
mailing list