Commit 5be366fc authored by David Saxton's avatar David Saxton

- Use antialiasing for drawing plots now (except when translating view).

- Removed a couple of unnecessary calls to render the view.

svn path=/trunk/KDE/kdeedu/kmplot/; revision=524551
parent a472a1e1
......@@ -242,11 +242,11 @@ void View::draw(QPaintDevice *dev, int form)
updateCursor();
stop_calculating = false;
// Antialiasing is *not* used for drawing the plots, as lines (of a shallow gradient)
// drawn one pixel at a time with antialiasing turned on do not look smooth -
// instead, they look like a pixelated line that has been blurred.
// (plus, it makes drawing a *lot* slower).
DC.setRenderHint( QPainter::Antialiasing, false );
// Antialiasing slows down rendering a lot, so turn it off if we are
// sliding the view about
DC.setRenderHint( QPainter::Antialiasing, m_zoomMode != Translating );
// if ( m_zoomMode != Translating )
// kDebug() << "##############################\n";
DC.setClipping( true );
DC.setClipRect( PlotArea );
foreach ( Ufkt * ufkt, m_parser->m_ufkt )
......@@ -982,9 +982,9 @@ void View::mousePressEvent(QMouseEvent *e)
while(++k<ke);
}
// user didn't click on a plot; so we now enter translation mode
// user didn't click on a plot; so we prepare to enter translation mode
csmode=-1;
m_zoomMode = Translating;
m_zoomMode = AboutToTranslate;
m_prevDragMousePos = e->pos();
}
......@@ -1023,8 +1023,10 @@ void View::mouseMoveEvent(QMouseEvent *e)
m_zoomMode = ZoomOutDrawing;
m_zoomRectangleStart = e->pos();
}
else if ( m_zoomMode == Translating )
else if ( ((m_zoomMode == AboutToTranslate) || (m_zoomMode == Translating)) &&
(e->pos() != m_prevDragMousePos) )
{
m_zoomMode = Translating;
QPoint d = m_prevDragMousePos - e->pos();
m_prevDragMousePos = e->pos();
translateView( d.x(), d.y() );
......@@ -1123,14 +1125,17 @@ bool View::updateCrosshairPosition()
void View::mouseReleaseEvent ( QMouseEvent * e )
{
update();
updateCursor();
bool doDrawPlot = false;
switch ( m_zoomMode )
{
case Normal:
case AnimatingZoom:
case AboutToTranslate:
break;
case Translating:
doDrawPlot = true;
break;
case ZoomIn:
......@@ -1151,6 +1156,11 @@ void View::mouseReleaseEvent ( QMouseEvent * e )
}
m_zoomMode = Normal;
if ( doDrawPlot )
drawPlot();
updateCursor();
}
......@@ -1384,7 +1394,6 @@ void View::setScaling()
void View::getSettings()
{
m_parser->setAngleMode( Settings::anglemode() );
m_parser->linewidth0 = Settings::gridLineWidth();
backgroundcolor = Settings::backgroundcolor();
invertColor(backgroundcolor,inverted_backgroundcolor);
......@@ -2239,6 +2248,7 @@ void View::updateCursor()
newCursor = CursorLessen;
break;
case AboutToTranslate:
case Translating:
newCursor = CursorMove;
break;
......
......@@ -285,13 +285,14 @@ private:
enum ZoomMode
{
Normal, ///< no zooming
AnimatingZoom, ///< animating a current zooming
ZoomIn, ///< zoom in
ZoomOut, ///< zoom out
ZoomInDrawing, ///< drawing a rectangle for zooming in
ZoomOutDrawing, ///< drawing a rectangle for zooming out
Translating, ///< dragging the view with the mouse
Normal, ///< no zooming
AnimatingZoom, ///< animating a current zooming
ZoomIn, ///< zoom in
ZoomOut, ///< zoom out
ZoomInDrawing, ///< drawing a rectangle for zooming in
ZoomOutDrawing, ///< drawing a rectangle for zooming out
AboutToTranslate, ///< user has clicked on an empty spot, but hasn't moved the mouse yet
Translating, ///< dragging the view with the mouse
};
/// The current editing status
......
......@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>603</height>
<height>719</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -437,19 +437,6 @@ Example: f(x)=x^2</string>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3" >
......@@ -1369,28 +1356,41 @@ Example: loop(angle)=ln(angle)</string>
<widget class="QWidget" name="page_2" />
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<class>KColorButton</class>
<extends></extends>
<header>klineedit.h</header>
<header>kcolorbutton.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>KDoubleNumInput</class>
<class>KLineEdit</class>
<extends></extends>
<header>knuminput.h</header>
<header>klineedit.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>KColorButton</class>
<class>KDoubleNumInput</class>
<extends></extends>
<header>kcolorbutton.h</header>
<header>knuminput.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
......
......@@ -54,7 +54,6 @@ public:
double euler_method(const double, const QVector<Ufkt>::iterator);
/// Line width default
double linewidth0;
QColor defaultColor(int function);
virtual int addfkt(QString);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment