[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Tue Mar 9 02:18:29 CET 2004
CVS commit by staikos:
tried to implement axis matching, but it still doesn't work. KstPlot needs
to be documented.
M +0 -1 kstplot.h 1.21
M +42 -7 kstview.cpp 1.81
M +3 -2 kstview.h 1.25
--- kdeextragear-2/kst/kst/kstview.cpp #1.80:1.81
@@ -73,6 +73,12 @@ KstView::KstView(KstApp *parent, const c
popupmenu = new KPopupMenu(this);
QPopupMenu *submenu;
- submenu = new KPopupMenu(this);
+
_titleId = popupmenu->insertTitle(i18n("Plot"));
+
+ _matchMenu = new KPopupMenu(this);
+ _matchMenuId = popupmenu->insertItem(i18n("&Match Axis"), _matchMenu);
+ popupmenu->setItemEnabled(_matchMenuId, false);
+
+ submenu = new KPopupMenu(this);
popupmenu->insertItem(i18n("Z&oom"), submenu);
submenu->insertItem(i18n("Zoom &Maximum"), this, SLOT(zoomMaxSlot()), Key_M);
@@ -702,18 +708,19 @@ void KstView::mousePressEvent(QMouseEven
_removeMenu->clear();
_editCurveMenu->clear();
+ _matchMenu->clear();
_currentPlot = p;
int id = 100;
bool addItemEnabled = false, removeItemEnabled = false;
KstBaseCurveList curves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
- for (KstBaseCurveList::Iterator i = curves.begin(); i != curves.end(); ++i) {
- if (!p->Curves.contains((*i).data())) {
- _addMenu->insertItem((*i)->tagName(), this, SLOT(dynamicMenuAdd(int)), 0, id);
+ for (KstBaseCurveList::Iterator it = curves.begin(); it != curves.end(); ++it) {
+ if (!p->Curves.contains((*it).data())) {
+ _addMenu->insertItem((*it)->tagName(), this, SLOT(dynamicMenuAdd(int)), 0, id);
addItemEnabled = true;
} else {
- _removeMenu->insertItem((*i)->tagName(), this, SLOT(dynamicMenuRemove(int)), 0, id);
+ _removeMenu->insertItem((*it)->tagName(), this, SLOT(dynamicMenuRemove(int)), 0, id);
removeItemEnabled = true;
- _editCurveMenu->insertItem((*i)->tagName(), this, SLOT(dynamicMenuEdit(int)), 0, id);
+ _editCurveMenu->insertItem((*it)->tagName(), this, SLOT(dynamicMenuEdit(int)), 0, id);
}
- _curveIds[id] = (*i)->tagName();
+ _curveIds[id] = (*it)->tagName();
++id;
}
@@ -723,4 +730,14 @@ void KstView::mousePressEvent(QMouseEven
popupmenu->setItemEnabled(_editCurveMenuId, removeItemEnabled);
+ for (uint j = 0; j < KST::plotList.count(); ++j) {
+ if (j != i) {
+ _matchMenu->insertItem(KST::plotList.at(j)->tagName(), this, SLOT(dynamicMenuMatch(int)), 0, id);
+ // Yeah, we reuse _curveIds here
+ _curveIds[id] = KST::plotList.at(j)->tagName();
+ ++id;
+ }
+ }
+ popupmenu->setItemEnabled(_matchMenuId, KST::plotList.count() > 1);
+
popupmenu->popup(mapToGlobal(e->pos()));
return;
@@ -1427,4 +1444,22 @@ void KstView::dynamicMenuRemove(int id)
}
+void KstView::dynamicMenuMatch(int id) {
+ KstPlot *p = KST::plotList.FindKstPlot(_curveIds[id]);
+ if (p) {
+ double lx0, lx1, ly0, ly1;
+ p->getLScale(lx0, lx1, ly0, ly1);
+ _currentPlot->setLog(p->isXLog(), p->isYLog());
+ _currentPlot->setXScaleMode(p->getXScaleMode());
+ _currentPlot->setYScaleMode(p->getYScaleMode());
+ _currentPlot->setLXScale(lx0, lx1);
+ _currentPlot->setLYScale(ly0, ly1);
+ _currentPlot->pushScale();
+ MouseInfo->setMode(INACTIVE);
+ needrecreate = true;
+ update();
+ }
+ _currentPlot = 0L;
+}
+
void KstView::dynamicMenuEdit(int id) {
KstDataObjectList::Iterator i = KST::dataObjectList.findTag(_curveIds[id]);
--- kdeextragear-2/kst/kst/kstview.h #1.24:1.25
@@ -135,6 +135,6 @@ private:
QPoint _draggablePoint;
- KPopupMenu *_addMenu, *_removeMenu, *_editCurveMenu;
- int _addMenuId, _removeMenuId, _editCurveMenuId;
+ KPopupMenu *_addMenu, *_removeMenu, *_editCurveMenu, *_matchMenu;
+ int _addMenuId, _removeMenuId, _editCurveMenuId, _matchMenuId;
KstPlot *_currentPlot;
QMap<int,QString> _curveIds;
@@ -146,4 +146,5 @@ private slots:
void dynamicMenuRemove(int);
void dynamicMenuEdit(int);
+ void dynamicMenuMatch(int);
void deleteCurrentPlot();
void updateMouse();
More information about the Kst
mailing list