[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Fri Oct 5 16:51:22 CEST 2007
SVN commit 721572 by treat:
* Implement shift/ctrl modified selection zoom.
* Painting and clipping fixes.
* Don't hardcode pen width.
* Set the foreground and background colors of the curve context.
M +28 -6 plotrenderitem.cpp
M +3 -1 vectorcurverenderitem.cpp
M +1 -0 view.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #721571:721572
@@ -276,21 +276,21 @@
void PlotRenderItem::paint(QPainter *painter) {
painter->setRenderHint(QPainter::Antialiasing, false);
painter->drawRect(rect());
- painter->setClipRect(rect());
#ifdef CURVE_DRAWING_TIME
QTime time;
time.start();
#endif
+ painter->save();
+ painter->setClipRect(rect());
paintRelations(painter);
if (_selectionRect.isValid()) {
- painter->save();
- painter->setPen(Qt::black);
+ painter->setPen(QPen(QBrush(Qt::black), 1.0, Qt::DotLine));
painter->drawRect(_selectionRect.rect());
- painter->restore();
}
+ painter->restore();
#ifdef CURVE_DRAWING_TIME
int elapsed = time.elapsed();
@@ -474,7 +474,16 @@
return;
}
- _selectionRect.setTo(event->pos());
+ const QPointF p = event->pos();
+ const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
+ if (modifiers & Qt::ShiftModifier) {
+ _selectionRect.setTo(QPointF(rect().right(), p.y()));
+ } else if (modifiers & Qt::ControlModifier) {
+ _selectionRect.setTo(QPointF(p.x(), rect().bottom()));
+ } else {
+ _selectionRect.setTo(p);
+ }
+
if (_selectionRect.isValid()) {
update(); //FIXME should optimize instead of redrawing entire curve?
}
@@ -487,7 +496,19 @@
return;
}
- _selectionRect.setFrom(event->pos());
+ const QPointF p = event->pos();
+ const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
+ if (modifiers & Qt::ShiftModifier) {
+ setCursor(Qt::SizeVerCursor);
+ _selectionRect.setFrom(QPointF(rect().left(), p.y()));
+ _selectionRect.setTo(QPointF(rect().right(), p.y()));
+ } else if (modifiers & Qt::ControlModifier) {
+ setCursor(Qt::SizeHorCursor);
+ _selectionRect.setFrom(QPointF(p.x(), rect().top()));
+ _selectionRect.setTo(QPointF(p.x(), rect().bottom()));
+ } else {
+ _selectionRect.setFrom(p);
+ }
}
@@ -497,6 +518,7 @@
return;
}
+ setCursor(Qt::CrossCursor);
const QRectF projection = mapToProjection(_selectionRect.rect());
_selectionRect.reset();
setProjectionRect(projection);
--- branches/work/kst/portto4/kst/src/libkstapp/vectorcurverenderitem.cpp #721571:721572
@@ -45,11 +45,13 @@
KstCurveRenderContext context;
context.painter = painter;
context.window = QRect(); //no idea if this should be floating point
- context.penWidth = 1; //FIXME hardcode
+ context.penWidth = painter->pen().width(); //floating point??
context.xLog = isXAxisLog();
context.yLog = isYAxisLog();
context.xLogBase = xLogBase();
context.yLogBase = yLogBase();
+ context.foregroundColor = painter->pen().color();
+ context.backgroundColor = painter->brush().color();
//FIXME rename these methods in kstvcurve
//FIXME Completely refactor KstCurveRenderContext now that we know what these are
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #721571:721572
@@ -52,6 +52,7 @@
View::~View() {
}
+
bool View::useOpenGL() const {
return _useOpenGL;
}
More information about the Kst
mailing list