Version: trunk (using KDE KDE 3.4.3KDE 1.2) OS: Linux ability to match X axis only not both If I have to align 2 plots and wish the X axis at the same units and range I might not want the Y axis to be in the same range.
SVN commit 477668 by staikos: Add a match X axis tool - will reorganize menu later possibly. FEATURE: 115664 M +27 -5 kst2dplot.cpp M +2 -1 kst2dplot.h --- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #477667:477668 @@ -3098,7 +3098,7 @@ } -void Kst2DPlot::matchAxis(int id) { +void Kst2DPlot::matchAxes(int id) { Kst2DPlotPtr p = (Kst2DPlot*)_plotMap[id]; if (p) { double x0, x1, y0, y1; @@ -3117,6 +3117,23 @@ } +void Kst2DPlot::matchXAxis(int id) { + Kst2DPlotPtr p = (Kst2DPlot*)_plotMap[id]; + if (p) { + double x0, x1, y0, y1; + p->getScale(x0, y0, x1, y1); + setLog(p->isXLog(), isYLog()); + setXScaleMode(FIXED); + setXScale(x0, x1); + pushScale(); + setDirty(); + if (_menuView) { + _menuView->paint(); + } + } +} + + void Kst2DPlot::copyObject() { if (_layoutMenuView) { KstTopLevelViewPtr tlv = _layoutMenuView->viewObject(); @@ -3173,21 +3190,26 @@ KstViewObject::popupMenu(menu, pos, topLevelParent); KPopupMenu *submenu = new KPopupMenu(menu); - int id = menu->insertItem(i18n("&Match Axis"), submenu); + KPopupMenu *submenu2 = new KPopupMenu(menu); Kst2DPlotList pl = globalPlotList(); int i = 0; _plotMap.clear(); - for (Kst2DPlotList::Iterator j = pl.begin(); j != pl.end(); ++j) { + for (Kst2DPlotList::ConstIterator j = pl.begin(); j != pl.end(); ++j) { if ((*j).data() != this) { _plotMap[i] = *j; // don't think there is any way around this. // We have to hope that it's safe until the menu is // done. submenu->insertItem((*j)->tagName(), i); - submenu->connectItem(i++, this, SLOT(matchAxis(int))); + submenu->connectItem(i, this, SLOT(matchAxes(int))); + submenu2->insertItem((*j)->tagName(), i); + submenu2->connectItem(i++, this, SLOT(matchXAxis(int))); hasEntry = true; } } + int id = menu->insertItem(i18n("&Match Axes"), submenu); menu->setItemEnabled(id, hasEntry); + id = menu->insertItem(i18n("&Match X Axis"), submenu2); + menu->setItemEnabled(id, hasEntry); hasEntry = false; submenu = new KPopupMenu(menu); @@ -3262,7 +3284,7 @@ // Fit menu KPopupMenu *submenu4 = new KPopupMenu(menu); // Filter menu - KPopupMenu *submenu2 = new KPopupMenu(menu); + submenu2 = new KPopupMenu(menu); // Remove menu KPopupMenu *submenu3 = new KPopupMenu(menu); hasEntry = false; --- trunk/extragear/graphics/kst/kst/kst2dplot.h #477667:477668 @@ -364,7 +364,8 @@ void editObject(int id); void editVector(int id); void editMatrix(int id); - void matchAxis(int id); + void matchAxes(int id); + void matchXAxis(int id); void fitCurve(int id); void filterCurve(int id); void removeCurve(int id);