Hello community, here is the log from the commit of package kalgebra for openSUSE:Factory checked in at 2013-12-02 12:32:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kalgebra (Old) and /work/SRC/openSUSE:Factory/.kalgebra.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kalgebra" Changes: -------- --- /work/SRC/openSUSE:Factory/kalgebra/kalgebra.changes 2013-10-03 15:49:58.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.kalgebra.new/kalgebra.changes 2013-12-02 12:32:16.000000000 +0100 @@ -1,0 +2,21 @@ +Sat Nov 16 17:53:49 UTC 2013 - [email protected] + +- Update to 4.11.90 + * KDE 4.12 Beta 2 release + * See http://www.kde.org/announcements/announce-4.12-beta2.php + +------------------------------------------------------------------- +Sat Nov 9 22:55:04 UTC 2013 - [email protected] + +- Update to 4.11.80 + * KDE 4.12 Beta 1 release + * See http://www.kde.org/announcements/announce-4.12-beta1.php + +------------------------------------------------------------------- +Sat Nov 2 15:08:49 UTC 2013 - [email protected] + +- Update to 4.11.3 + * KDE 4.11.3 bugfix release + * See http://www.kde.org/announcements/announce-4.11.3.php + +------------------------------------------------------------------- Old: ---- kalgebra-4.11.2.tar.xz New: ---- kalgebra-4.11.90.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kalgebra.spec ++++++ --- /var/tmp/diff_new_pack.wxz0mi/_old 2013-12-02 12:32:17.000000000 +0100 +++ /var/tmp/diff_new_pack.wxz0mi/_new 2013-12-02 12:32:17.000000000 +0100 @@ -21,7 +21,7 @@ License: GPL-2.0+ Group: Productivity/Scientific/Math Url: http://edu.kde.org -Version: 4.11.2 +Version: 4.11.90 Release: 0 Source0: %{name}-%{version}.tar.xz BuildRequires: analitza-devel ++++++ kalgebra-4.11.2.tar.xz -> kalgebra-4.11.90.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/doc/index.docbook new/kalgebra-4.11.90/doc/index.docbook --- old/kalgebra-4.11.2/doc/index.docbook 2013-08-28 19:02:05.000000000 +0200 +++ new/kalgebra-4.11.90/doc/index.docbook 2013-10-28 20:29:09.000000000 +0100 @@ -416,9 +416,8 @@ <para>The view can be zoomed and moved with the mouse. Using the wheel you can zoom in and out. Hold the &LMB; and move the mouse to rotate the graph.</para> -<!--FIXME BUG:321686 it is not possible to do use keys -<para>The left and right arrow keys rotate the graph around the z axis, the up and down arrow keys rotate around the horizontal axis of the view.</para> - --> + <para>The left and right arrow keys rotate the graph around the z axis, the up and down arrow keys rotate around the horizontal axis of the view. Press <keycap>W</keycap> to zoom in the plot and <keycap>S</keycap> to zoom it out.</para> + <para>In the <guimenu>3D Graph</guimenu> menu you find these options:</para> <itemizedlist> <!-- not in master for 4.11 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/CMakeLists.txt new/kalgebra-4.11.90/src/CMakeLists.txt --- old/kalgebra-4.11.2/src/CMakeLists.txt 2013-06-28 19:16:58.000000000 +0200 +++ new/kalgebra-4.11.90/src/CMakeLists.txt 2013-10-28 20:29:09.000000000 +0100 @@ -14,19 +14,17 @@ functionedit.cpp ) -if(OPENGL_FOUND) - set(kalgebra_SRCS - ${kalgebra_SRCS} - graph3d.cpp - ) -endif(OPENGL_FOUND) - #uncomment this if oxygen icons for kalgebra are available #kde4_add_app_icon(kalgebra_SRCS "${CMAKE_INSTALL_PREFIX}/share/icons/oxygen/*/apps/kalgebra.png") kde4_add_app_icon(kalgebra_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-app-kalgebra.png") kde4_add_executable(kalgebra ${kalgebra_SRCS}) -target_link_libraries(kalgebra ${KDE4_KHTML_LIBS} ${QTMML_LIBRARY} ${ANALITZA_LIBRARY} ${ANALITZAGUI_LIBRARY} ${ANALITZAPLOT_LIBRARY}) +target_link_libraries(kalgebra + ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTWEBKIT_LIBRARY} + ${KDE4_KPARTS_LIBS} + ${ANALITZA_LIBRARY} ${ANALITZAGUI_LIBRARY} ${ANALITZAPLOT_LIBRARY} + ${QTMML_LIBRARY} +) if(OPENGL_FOUND) target_link_libraries(kalgebra ${QT_QTOPENGL_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/consolehtml.cpp new/kalgebra-4.11.90/src/consolehtml.cpp --- old/kalgebra-4.11.2/src/consolehtml.cpp 2013-06-28 19:16:58.000000000 +0200 +++ new/kalgebra-4.11.90/src/consolehtml.cpp 2013-10-28 20:29:09.000000000 +0100 @@ -25,7 +25,9 @@ #include <QTemporaryFile> #include <QTimer> #include <QTextDocument> +#include <qevent.h> #include <QDir> +#include <QWebFrame> #include <KLocale> #include <KStandardAction> @@ -39,19 +41,13 @@ #include <analitza/variables.h> #include <analitza/expression.h> -ConsoleHtml::ConsoleHtml(QWidget *parent) : KHTMLPart(parent), m_mode(Evaluation) +ConsoleHtml::ConsoleHtml(QWidget *parent) + : QWebView(parent), m_mode(Evaluation) { - setJScriptEnabled(false); - setJavaEnabled(false); - setMetaRefreshEnabled(false); - setPluginsEnabled(false); - setOnlyLocalReferences(true); - - view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - - connect(this, SIGNAL(popupMenu(QString,QPoint)), this, SLOT(context(QString,QPoint))); - connect(browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), SLOT(openClickedUrl(KUrl))); - connect(view()->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), SLOT(scrollDown(int,int))); + page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); + setRenderHint(QPainter::TextAntialiasing); + + connect(this, SIGNAL(linkClicked(QUrl)), SLOT(openClickedUrl(QUrl))); QMetaObject::invokeMethod(this, "initialize", Qt::QueuedConnection); } @@ -84,16 +80,12 @@ m_css +="\t.string { color: #bb0000 }\n"; m_css +="\tli { padding-left: 12px; padding-bottom: 4px; list-style-position: inside; }"; m_css +="</style>\n"; - -// begin(); -// write("<html>\n<head>"+m_css+"</head></html>"); -// end(); } -void ConsoleHtml::openClickedUrl(const KUrl& url) +void ConsoleHtml::openClickedUrl(const QUrl& url) { - QString id =url.queryItem("id"); - QString exp=url.queryItem("func"); + QString id =url.queryItemValue("id"); + QString exp=url.queryItemValue("func"); foreach(InlineOptions* opt, m_options) { if(opt->id() == id) { @@ -248,29 +240,27 @@ void ConsoleHtml::updateView(const QString& newEntry, const QString& options) { - //FIXME: Check that the output html is not correct - begin(); - write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); - write("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<title> :) </title>\n"); - write(m_css); - write("</head>\n<body>"); + QByteArray code; + code += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; + code += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<title> :) </title>\n"; + code += m_css; + code += "</head>\n<body>"; foreach(const QString &entry, m_htmlLog) - write("<p class='normal'>"+entry+"</p>"); - + code += "<p class='normal'>"+entry+"</p>"; + if(!newEntry.isEmpty()) { m_htmlLog += newEntry; - write(options); - write("<p class='last'>"+newEntry+"</p>"); + code += options; + code += "<p class='last'>"+newEntry+"</p>"; } - write("</body></html>"); - end(); + code += "</body></html>"; + + setContent(code); emit changed(); -} -void ConsoleHtml::scrollDown(int min, int max) -{ - view()->verticalScrollBar()->setValue(max); + QWebFrame* mf = page()->mainFrame(); + mf->setScrollBarValue(Qt::Vertical, mf->scrollBarMaximum(Qt::Vertical)); } void ConsoleHtml::copy() const @@ -278,7 +268,7 @@ QApplication::clipboard()->setText(selectedText()); } -void ConsoleHtml::context(const QString & /*url*/, const QPoint & p) +void ConsoleHtml::contextMenuEvent(QContextMenuEvent* ev) { KMenu popup; if(hasSelection()) { @@ -290,7 +280,7 @@ } popup.addAction(KStandardAction::clear(this, SLOT(clear()), &popup)); - popup.exec(p); + popup.exec(ev->pos()); } void ConsoleHtml::clear() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/consolehtml.h new/kalgebra-4.11.90/src/consolehtml.h --- old/kalgebra-4.11.2/src/consolehtml.h 2013-06-28 19:16:58.000000000 +0200 +++ new/kalgebra-4.11.90/src/consolehtml.h 2013-10-28 20:29:09.000000000 +0100 @@ -20,10 +20,11 @@ #define CONSOLE_H #include <QWidget> -#include <khtml_part.h> +#include <QWebView> #include <analitza/analyzer.h> +class KUrl; class InlineOptions { public: @@ -41,7 +42,7 @@ * @author Aleix Pol Gonzalez */ -class ConsoleHtml : public KHTMLPart +class ConsoleHtml : public QWebView { Q_OBJECT public: @@ -67,6 +68,9 @@ ConsoleMode mode() const { return m_mode; } void addOptionsObserver(InlineOptions* opt) { m_options += opt; } + + virtual void contextMenuEvent(QContextMenuEvent* ev); + public slots: /** Adds the operation defined by the expression @p e. */ bool addOperation(const Analitza::Expression& e, const QString& input); @@ -86,7 +90,7 @@ /** Copies the selected text to the clipboard */ void copy() const; - void openClickedUrl(const KUrl& url); + void openClickedUrl(const QUrl& url); signals: /** Emits a notification that tells that the widget status. */ @@ -100,12 +104,10 @@ private slots: void initialize(); - void context(const QString&, const QPoint& p); void modifyVariable(const QString& name, const Analitza::Expression& exp); void removeVariable(const QString& name); void paste(); - void scrollDown(int min, int max); private: QString retrieve(const KUrl& remoteUrl); @@ -118,7 +120,7 @@ void updateView(const QString& newEntry, const QString& options); - QString m_css; + QByteArray m_css; QList<InlineOptions*> m_options; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/functionedit.cpp new/kalgebra-4.11.90/src/functionedit.cpp --- old/kalgebra-4.11.2/src/functionedit.cpp 2013-08-28 19:02:05.000000000 +0200 +++ new/kalgebra-4.11.90/src/functionedit.cpp 2013-10-28 20:29:09.000000000 +0100 @@ -112,10 +112,10 @@ QHBoxLayout *m_butts = new QHBoxLayout; m_ok = new QPushButton(i18n("OK"), this); m_ok->setIcon(QIcon::fromTheme("dialog-ok")); - QPushButton *m_clear = new QPushButton(i18nc("@action:button", "Clear"), this); - m_clear->setIcon(QIcon::fromTheme("dialog-cancel")); + m_remove = new QPushButton(i18nc("@action:button", "Remove"), this); + m_remove->setIcon(QIcon::fromTheme("list-remove")); connect(m_ok, SIGNAL(clicked()), this, SLOT(ok())); - connect(m_clear, SIGNAL(clicked()), this, SLOT(clear())); + connect(m_remove, SIGNAL(clicked()), this, SIGNAL(removeEditingPlot())); topLayout->addWidget(m_name); topLayout->addWidget(m_func); @@ -127,7 +127,7 @@ m_name->hide(); //FIXME: Remove this when the name has any sense m_butts->addWidget(m_ok); - m_butts->addWidget(m_clear); + m_butts->addWidget(m_remove); m_func->setFocus(); m_ok->setEnabled(false); @@ -138,9 +138,7 @@ } FunctionEdit::~FunctionEdit() -{ - delete m_vars; -} +{} void FunctionEdit::clear() { @@ -252,15 +250,15 @@ bool added = false; PlaneCurve* f = 0; - PlotBuilder req = PlotsFactory::self()->requestPlot(expression(), Dim2D); + PlotBuilder req = PlotsFactory::self()->requestPlot(expression(), Dim2D, m_vars); if(req.canDraw()) f = createFunction(); if(f && f->isCorrect()) f->update(QRect(-10, 10, 20, -20)); + m_funcsModel->clear(); if(f && f->isCorrect()) { - m_funcsModel->clear(); m_funcsModel->addPlot(f); added=true; setState(QString("%1:=%2") @@ -271,7 +269,6 @@ errors = f->errors(); Q_ASSERT(!errors.isEmpty()); - m_funcsModel->clear(); setState(errors.first(), true); m_valid->setToolTip(errors.join("<br />")); delete f; @@ -308,11 +305,6 @@ return m_func->expression(); } -bool FunctionEdit::isMathML() const -{ - return m_func->isMathML(); -} - void FunctionEdit::setOptionsShown(bool shown) { m_viewTabs->setVisible(shown); @@ -323,3 +315,9 @@ QFontMetrics fm(m_valid->font()); m_valid->setText(fm.elidedText(m_valid->toolTip(), Qt::ElideRight, m_valid->width())); } + +void FunctionEdit::setEditing(bool m) +{ + m_modmode=m; + m_remove->setVisible(m); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/functionedit.h new/kalgebra-4.11.90/src/functionedit.h --- old/kalgebra-4.11.2/src/functionedit.h 2013-08-28 19:02:05.000000000 +0200 +++ new/kalgebra-4.11.90/src/functionedit.h 2013-10-28 20:29:09.000000000 +0100 @@ -67,14 +67,11 @@ /** Sets the selected color for the function.*/ void setColor(const QColor &newColor); - /** Returns whether it is a MathML function. */ - bool isMathML() const; - /** Returns whether we are editing or adding a function. */ bool editing() const { return m_modmode; } /** Sets whether we are editing or adding a function. */ - void setEditing(bool m) { m_modmode=m; } + void setEditing(bool m); /** Sets a name to the function. (Not used YET) */ void setName(const QString& name) { m_name->setText(name); } @@ -99,6 +96,9 @@ /** Tells that the result has been accepted. */ void accept(); + /** asks the currently edited plot to be removed. */ + void removeEditingPlot(); + private slots: void edit(); void ok(); @@ -124,6 +124,7 @@ bool m_modmode; KTabWidget* m_viewTabs; + QPushButton* m_remove; }; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/graph3d.cpp new/kalgebra-4.11.90/src/graph3d.cpp --- old/kalgebra-4.11.2/src/graph3d.cpp 2013-06-28 19:16:58.000000000 +0200 +++ new/kalgebra-4.11.90/src/graph3d.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,535 +0,0 @@ -/************************************************************************************* - * Copyright (C) 2007 by Aleix Pol <[email protected]> * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * - *************************************************************************************/ - -#include "graph3d.h" - -#if defined(Q_WS_MAC) - #include <OpenGL/glu.h> -#else - #include <GL/glu.h> -#endif - -#include <KLocale> - -#include <QImage> -#include <QMouseEvent> -#include <QKeyEvent> -#include <QPixmap> -#include <QTime> - -#include <analitza/analyzer.h> -#include <analitza/value.h> -#include <analitza/variable.h> - -using std::fabs; -using std::log10; - -using namespace Analitza; - -enum ActionsEnum { - KEYRIGHT=1<<0, KEYLEFT=1<<1, KEYUP=1<<2, KEYDOWN=1<<3, KEYAVPAG=1<<4, KEYREPAG=1<<5, KEYS=1<<6, KEYW=1<<7, - KEYQ=1<<8, KEYE=1<<9, LCLICK=1<<10, RCLICK=1<<11, MCLICK=1<<12 }; - -Graph3D::Graph3D(QWidget *parent) : QGLWidget(parent), - default_step(0.15f), default_size(10.0f), zoom(1.0f), points(0), alpha(60.), - method(Solid), trans(false), keyspressed(0), m_n(4) -{ - setFocusPolicy(Qt::ClickFocus); - rotation[0] = 90.0; - rotation[1] = 0.0; - rotation[2] = 0.0; -} - - -Graph3D::~Graph3D() -{ - if(points) { - const int j= 2*static_cast<int>(default_size/default_step); - - for(int i=0; i<j; i++) - delete [] points[i]; - delete [] points; - } -} - -void Graph3D::initializeGL() -{ - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClearDepth(1.0f); -// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glShadeModel(GL_SMOOTH); - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - - QImage t, b; - GLuint texture[1]; - b = QImage(8, 8, QImage::Format_Mono); - b.fill(QColor(0xff, 0xff, 0xff).rgb()); - for(int i=0; i<b.height(); i++) - b.setPixel(4, i, 0); - - for(int i=0; i<b.width(); i++) - b.setPixel(i, 4, 0); - - t = QGLWidget::convertToGLFormat( b ); - glGenTextures( 1, &texture[0] ); - glBindTexture( GL_TEXTURE_2D, texture[0] ); - glTexImage2D( GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits() ); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); -} - -void Graph3D::resizeGL( int width, int height ) -{ - height = height ? height : 1; - - glViewport( 0, 0, width, height ); -} - -void Graph3D::mousePressEvent(QMouseEvent *e) -{ - if(e->button() == Qt::LeftButton) { - press = e->pos(); - keyspressed |= LCLICK; - } -} - -void Graph3D::mouseReleaseEvent(QMouseEvent *e) -{ - if(e->button() == Qt::LeftButton) - keyspressed &= ~LCLICK; -} - -void Graph3D::mouseMoveEvent(QMouseEvent *e) -{ - if(keyspressed & LCLICK){ - QPoint rel = e->pos() - press; - rotation[0] += rel.y(); - rotation[2] -= rel.x(); - - press = e->pos(); - repaint(); - } -} - -void Graph3D::drawAxes() -{ - glColor3f(0.8, 0.8, 0.4); - renderText(11.0, 0.0, 0.0, "Y"); - renderText(0.0, 11.0, 0.0, "X"); - renderText(0.0, 0.0,-11.0, "Z"); - - glBegin(GL_LINES); - glColor3f(1.0f, 0.0f, 0.0f); - glVertex3f(-10.0f, 0.0f, 0.0f); - glVertex3f( 10.0f, 0.0f, 0.0f); - glColor3f(0.0f, 1.0f, 0.0f); - glVertex3f( 0.0f, 10.0f, 0.0f); - glVertex3f( 0.0f,-10.0f, 0.0f); - glColor3f(0.0f, 0.0f, 1.0f); - glVertex3f( 0.0f, 0.0f, 10.0f); - glVertex3f( 0.0f, 0.0f,-10.0f); - glEnd(); -} - -void Graph3D::paintGL() -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if(keyspressed & KEYDOWN) rotation[0]+=3.f; - if(keyspressed & KEYUP) rotation[0]-=3.f; - if(keyspressed & KEYAVPAG) rotation[1]+=3.f; - if(keyspressed & KEYREPAG) rotation[1]-=3.f; - if(keyspressed & KEYLEFT) rotation[2]+=3.f; - if(keyspressed & KEYRIGHT) rotation[2]-=3.f; - if(keyspressed & KEYW) alpha/=2.f; - if(keyspressed & KEYS && alpha<=90.f) alpha*=2.f; - if(keyspressed & KEYQ) { zoom/=2.0f; create(a.expression()); } - if(keyspressed & KEYE) { zoom*=2.0f; create(a.expression()); } - - if(rotation[0]>=360.f) rotation[0]-=360.f; - if(rotation[1]>=360.f) rotation[1]-=360.f; - if(rotation[2]>=360.f) rotation[2]-=360.f; - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(alpha,(GLfloat)width()/(GLfloat)height(),0.1f,100.0f); - - float z=25.f; - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0,0,-z); - glRotatef(rotation[0], 1.0, 0.0, 0.0); - glRotatef(rotation[1], 0.0, 1.0, 0.0); - glRotatef(rotation[2], 0.0, 0.0, 1.0); - - const double mida=default_size*zoom, step=default_step*zoom; - uint bound=(2*mida/step)-1; - drawAxes(); - - if(!points) - return; - - if(method==Dots) { - glBegin(GL_POINTS); - for(uint i=0; i<bound; i++) { - double red=i*step/mida; - double x=i*step-mida; - for(uint j=0; j<bound; j++) { - double curr=points[i][j]; - glColor3d(red, j*step/mida, curr/5); - glVertex3d(x, j*step-mida, curr); - } - } - glEnd(); - } else if(method == Lines) { - glBegin(GL_LINES); - - for(uint i=0; i<bound; i++) { - double x=i*step-mida; - double red=i*step/mida; - int ii=i?i-1:i; - - for(uint j=0; j<bound; j++) { - double y=j*step - mida; - double curr=points[i][j]; - glColor3d( red, j*step/mida, curr/5); - - glVertex3d( x, y, curr); - glVertex3d( ii*step-mida, y, points[ii][j]); - - int jj=j?j-1:j; - glVertex3d( x, y, curr); - glVertex3d( x, jj*step-mida, points[i][jj]); - } - } - glEnd(); - } else if(method == Solid) { - if(trans){ - glEnable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glBlendFunc(GL_SRC_ALPHA,GL_ONE); - } else { - glDisable(GL_BLEND); - glEnable(GL_DEPTH_TEST); - } - - glEnable(GL_TEXTURE_2D); - double transf=0.8; - - glPushMatrix(); - for(uint i=0; i<bound-1; i++) { - glPopMatrix(); - - glPushMatrix(); - glTranslatef(i*step-mida, -mida, 0); - glBegin(GL_TRIANGLE_STRIP); - - double red=fabs((i*step-mida)/mida); - double nextRed=fabs(((i+1)*step-mida)/mida); - for(uint j=0; j<bound; j++) { - float s=j%2 ? .0f : 1.f; - double green=fabs((j*step-mida)/mida); - - double z=points[i][j]; - double blue=1./fabs(log10(10.+fabs(z))); - - glTexCoord2f(s, 0.f); - glColor4d(red, green, blue, transf); - glVertex3d(0., j*step, z); - - z=points[i+1][j]; - glTexCoord2f(s, 1.f); - glColor4d(nextRed, green, blue, transf); - glVertex3d(step, j*step, z); - } - glEnd(); - } - glDisable(GL_TEXTURE_2D); - } - glPopMatrix(); - glFlush(); -} - -bool Graph3D::create(const Expression& func3d) -{ - double mida=default_size*zoom, step=default_step*zoom; - const int k=static_cast<int>(mida/step)*2; - - int part = k/m_n; - QList<Calculate3D*> threads; - - a.setExpression(func3d); - - QTime t; - t.restart(); - - for(int i=0; i<m_n; ++i) { - Calculate3D *r = new Calculate3D(this, a, points, part*i, part*(i+1), mida, step); - if(i+1==m_n) - r->setTo(2*static_cast<int>(default_size/default_step)); - - threads << r; - r->start(); - } - - bool ret=true; - QList<Calculate3D*>::const_iterator it = threads.constBegin(); - for(; it!=threads.constEnd(); ++it) { - if(!(*it)->wait(1000)) { - ret=false; - (*it)->terminate(); - } - } - -// qDebug() << "Elapsed time" << t.elapsed(); - - qDeleteAll(threads); - return ret; -} - -void Calculate3D::run() -{ - Q_ASSERT(a.isCorrect()); - Q_ASSERT(points); - - const int k= static_cast<int>(size/step)*2; - - Cn *x=new Cn; - Cn *y=new Cn; - - QVector<Analitza::Object*> runStack; - runStack.append(x); - runStack.append(y); - a.setStack(runStack); - - for(int j=from; j<to; j++) { - y->setValue(j*step-size); - for(int i=0; i<k; i++) { - x->setValue(i*step-size); - points[j][i] = -a.calculateLambda().toReal().value(); - } - } - qDeleteAll(runStack); -} - -void Graph3D::wheelEvent(QWheelEvent * e) -{ - if(e->delta()>0) - alpha/=2.f; - else if(alpha<=90.f) - alpha*=2.f; - repaint(); -} - -void Graph3D::keyPressEvent( QKeyEvent *e ) -{ - switch(e->key()) { - case Qt::Key_Up: - keyspressed |= KEYUP; - break; - case Qt::Key_Down: - keyspressed |= KEYDOWN; - break; - case Qt::Key_Left: - keyspressed |= KEYLEFT; - break; - case Qt::Key_Right: - keyspressed |= KEYRIGHT; - break; - case Qt::Key_PageUp: - keyspressed |= KEYREPAG; - break; - case Qt::Key_PageDown: - keyspressed |= KEYAVPAG; - break; - case Qt::Key_W: - keyspressed |= KEYW; - break; - case Qt::Key_S: - keyspressed |= KEYS; - break; - case Qt::Key_Q: //Be careful - keyspressed |= KEYQ; - break; - case Qt::Key_E: //Be careful - keyspressed |= KEYE; - break; - } -// sendStatus(QString("-%1-").arg(keyspressed, 16)); - repaint(); -} - -void Graph3D::keyReleaseEvent( QKeyEvent *e ) -{ - switch(e->key()) { - case Qt::Key_Up: - keyspressed &= ~KEYUP; - break; - case Qt::Key_Down: - keyspressed &= ~KEYDOWN; - break; - case Qt::Key_Left: - keyspressed &= ~KEYLEFT; - break; - case Qt::Key_Right: - keyspressed &= ~KEYRIGHT; - break; - case Qt::Key_PageUp: - keyspressed &= ~KEYREPAG; - break; - case Qt::Key_PageDown: - keyspressed &= ~KEYAVPAG; - break; - case Qt::Key_W: - keyspressed &= ~KEYW; - break; - case Qt::Key_S: - keyspressed &= ~KEYS; - break; - case Qt::Key_Q: //Be careful - keyspressed &= ~KEYQ; - break; - case Qt::Key_E: //Be careful - keyspressed &= ~KEYE; - break; - - } -// sendStatus(QString(".%1.").arg(keyspressed, 16)); - repaint(); -} - -void Graph3D::timeOut() -{ - rotation[0] += 20.0; - rotation[1] += 20.0; - rotation[2] += 20.0; - repaint(); -} - -bool Graph3D::checkExpression(const QStringList& bvars, const Analitza::ExpressionType& actual) -{ - if(bvars!=(QStringList("x") << "y")) { - return false; - } - - static ExpressionType expected=ExpressionType(ExpressionType::Lambda) - .addParameter(ExpressionType::Value) - .addParameter(ExpressionType::Value) - .addParameter(ExpressionType::Value); - - return actual.canReduceTo(expected); -} - -void Graph3D::setFunc(const Expression& exp) -{ - if(exp.isCorrect()) { - Analitza::Analyzer f3d; - f3d.setExpression(exp); - f3d.setExpression(f3d.dependenciesToLambda()); - f3d.simplify(); - - if(!checkExpression(f3d.expression().bvarList(), f3d.type())) { - sendStatus(i18n("Error: Wrong type of function")); - return; - } - - if(f3d.isCorrect()) { - QTime t; - t.restart(); - mem(); - create(f3d.expression()); - // xgettext: no-c-format - sendStatus(i18nc("3D graph done in x milliseconds", "Done: %1ms", t.elapsed())); - } - else - sendStatus(i18n("Error: %1", f3d.errors().join(", "))); - } else - sendStatus(i18n("Error: %1", exp.error().join(", "))); -} - -void Graph3D::mem() -{ - const int j= 2*static_cast<int>(default_size/default_step); - if(points!=0){ - for(int i=0; i<j; i++) - delete [] points[i]; - delete [] points; - } - - - points = new double* [j]; - Q_CHECK_PTR(points); - for(int i=0; i<j; i++){ - points[i] = new double[j]; - Q_CHECK_PTR(points[i]); - } - - qDebug() << "Size: " << sizeof(double)*j*j; -} - -void Graph3D::setSize(double newSize) -{ - default_size = newSize; - repaint(); -} - -void Graph3D::setStep(double newRes) -{ - default_step = newRes; - repaint(); -} - -void Graph3D::setZoom(float a) -{ - alpha = a; - repaint(); -} - -void Graph3D::setMethod(enum Type m) -{ - method = m; - repaint(); -} - -QPixmap Graph3D::toPixmap() -{ - return renderPixmap(); -} - -void Graph3D::resetView() -{ - default_step=0.15f; - default_size=8.0f; - if(zoom!=1.0f) { - zoom=1.0f; - } - alpha=60.; - - rotation[0] = 90.0; - rotation[1] = 0.0; - rotation[2] = 0.0; - updateGL(); -} - -#include "graph3d.moc" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/graph3d.h new/kalgebra-4.11.90/src/graph3d.h --- old/kalgebra-4.11.2/src/graph3d.h 2013-06-28 19:16:58.000000000 +0200 +++ new/kalgebra-4.11.90/src/graph3d.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,151 +0,0 @@ -/************************************************************************************* - * Copyright (C) 2007 by Aleix Pol <[email protected]> * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * - *************************************************************************************/ - -#ifndef GRAPH3D_H -#define GRAPH3D_H - -#include <QGLWidget> -#include <QtCore/QThread> - -#include "analitza/analyzer.h" - -/** - * Used to calculate 3D Graphs in parallel. - * @author Aleix Pol i Gonzalez <[email protected]> - */ - -class Calculate3D : public QThread -{ -public: - /** Constructor. Creates a Calculate3D thread. - @param p parent object. - @param na Analitza module used fot the calculations. - @param poi memory space where the results will be located. - @param fr Beginning of the calculated values. - @param to End of the calculated values. - @param m Distance of each dimension from the (0, 0) to be calculated. - @param s Step between each 2 values. - */ - Calculate3D(QObject *p, const Analitza::Analyzer &na, double** poi, int fr, int to, double m, double s) : - QThread(p), a(na), points(poi), from(fr), to(to), size(m), step(s) {} - - /** Runs the thread. */ - void run(); - - /** Sets the end of the segment to calculate. */ - void setTo(int nto) { to = nto; } -private: - Analitza::Analyzer a; - double **points; - int from; - int to; - - double size; - double step; -}; - -/** - * The Graph3D provides a 3D OpenGL graph representation. - * @author Aleix Pol i Gonzalez - */ - -class Graph3D : public QGLWidget -{ - Q_OBJECT - public: - /** Defines how will be the graph representated. */ - enum Type { - Dots=0, ///< Dots will be drawn. - Lines=1, ///< Lines will be drawn. - Solid=2 ///< A solid graph will be drawn with a line texture. - }; - - /** Constructor. Creates a new Graph3D widget. */ - Graph3D(QWidget *parent = 0); - - /** Destructor. */ - ~Graph3D(); - - /** Sets @p exp as the function's expression. */ - void setFunc(const Analitza::Expression& exp); - - /** Toggles the transparency for Solid graphs. */ - void setTransparency(bool tr) { trans = tr; glDraw(); } - - /** Returns whether there is transparency. */ - bool transparency() const { return trans; } - - /** Returns the pixmap painting. */ - QPixmap toPixmap(); - - /** Sets the @p max maximum size. */ - void setSize(double max); - - /** Sets the interval between two points. */ - void setStep(double res); - - /** Sets the Z coordinate. */ - void setZoom(float alpha); - - /** Sets the showed method. */ - void setMethod(Type m); - - void wheelEvent(QWheelEvent *e); - - static bool checkExpression(const QStringList& bvars, const Analitza::ExpressionType& actual); - - public slots: - /** Resets the view coordinates. */ - void resetView(); - - signals: - /** Emits a status message. */ - void status(const QString &msg); - - private: - void drawAxes(); - - virtual void initializeGL() ; - virtual void resizeGL( int width, int height ) ; - virtual void paintGL() ; - - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); - void timeOut(); - void mousePressEvent(QMouseEvent *e); QPoint press; - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void mem(); - bool create(const Analitza::Expression& func3d); - void sendStatus(const QString& msg) { emit status(msg); } - - Analitza::Analyzer a; - double default_step; - double default_size; - double zoom; - double **points; - float rotation[3]; - float alpha; - Type method; - bool trans; - unsigned short keyspressed; - - int m_n; -}; - -#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/kalgebra.cpp new/kalgebra-4.11.90/src/kalgebra.cpp --- old/kalgebra-4.11.2/src/kalgebra.cpp 2013-08-28 19:02:05.000000000 +0200 +++ new/kalgebra-4.11.90/src/kalgebra.cpp 2013-10-28 20:29:09.000000000 +0100 @@ -42,6 +42,7 @@ #include <QHeaderView> #include <QDockWidget> #include <QTableView> +#include <QPrinter> #include <KAction> #include <KHTMLView> #include <KHelpMenu> @@ -132,7 +133,7 @@ QWidget *console = new QWidget(m_tabs); QVBoxLayout *c_layo = new QVBoxLayout(console); c_results = new ConsoleHtml(console); - c_results->view()->setFocusPolicy(Qt::NoFocus); + c_results->setFocusPolicy(Qt::NoFocus); c_dock_vars = new QDockWidget(i18n("Variables"), this); c_dock_vars->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable); addDockWidget(Qt::RightDockWidgetArea, c_dock_vars); @@ -154,7 +155,7 @@ m_tabs->addTab(console, i18n("&Console")); console->setLayout(c_layo); - c_layo->addWidget(c_results->view()); + c_layo->addWidget(c_results); c_layo->addWidget(c_exp); connect(c_exp, SIGNAL(returnPressed()), this, SLOT(operate())); @@ -214,8 +215,9 @@ b_tools->addTab(b_funcs, i18n("List")); b_funced = new FunctionEdit(b_tools); - b_funced->setVariables(new Analitza::Variables); + b_funced->setVariables(c_varsModel->variables()); connect(b_funced, SIGNAL(accept()), this, SLOT(new_func())); + connect(b_funced, SIGNAL(removeEditingPlot()), this, SLOT(remove_func())); b_tools->addTab(b_funced, KIcon("list-add"), i18n("&Add")); QTableView* b_varsView=new QTableView(b_tools); @@ -425,6 +427,18 @@ m_graph2d->setFocus(); } +void KAlgebra::remove_func() +{ + Q_ASSERT(b_funced->editing()); + b_funcsModel->removeRow(b_funcs->currentIndex().row()); + + b_funced->setEditing(false); + b_funced->clear(); + b_tools->setCurrentIndex(0); + b_funcs->setCurrentIndex(QModelIndex()); + m_graph2d->setFocus(); +} + void KAlgebra::edit_func(const QModelIndex &idx) { b_tools->setTabText(1, i18n("&Editing")); @@ -558,10 +572,22 @@ void KAlgebra::save3DGraph() { #ifdef HAVE_OPENGL - QString path = KFileDialog::getSaveFileName(KUrl(), i18n("*.png|PNG File"), this, QString(), KFileDialog::ConfirmOverwrite); + QString path = KFileDialog::getSaveFileName(KUrl(), i18n("*.png|PNG File\n*.pdf|PDF Document"), this, QString(), KFileDialog::ConfirmOverwrite); if(!path.isEmpty()) { QPixmap px = m_graph3d->renderPixmap(); - px.save(path); + if(path.endsWith(".pdf")) { + QPrinter printer; + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOutputFileName(path); + printer.setPaperSize(px.size(), QPrinter::DevicePixel); + printer.setPageMargins(0,0,0,0, QPrinter::DevicePixel); + QPainter painter; + painter.begin(&printer); + painter.drawPixmap(QPoint(0,0), px); + painter.end(); + } else { + px.save(path); + } } #endif } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kalgebra-4.11.2/src/kalgebra.h new/kalgebra-4.11.90/src/kalgebra.h --- old/kalgebra-4.11.2/src/kalgebra.h 2013-08-28 19:02:05.000000000 +0200 +++ new/kalgebra-4.11.90/src/kalgebra.h 2013-10-28 20:29:09.000000000 +0100 @@ -102,6 +102,7 @@ void select(const QModelIndex& idx); void new_func(); + void remove_func(); void edit_func ( const QModelIndex & ); void edit_var ( const QModelIndex & ); void toggleSquares(); -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
