Logo Search packages:      
Sourcecode: udav version File versions  Download package


 *   Copyright (C) 2008 by Alexey Balakin                                  *
 *   mathgl.abalakin@gmail.com                                             *
 *                                                                         *
 *   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        *
 *   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.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
#include <qwidget.h>
#include <QPixmap>
#include <QThread>
#include <mgl/mgl_zb.h>
class QTextEdit;
class QMenu;
class QMGLCanvas;
/// Class for making picture in separate thread
00031 class MGLThread : public QThread
friend class QMGLCanvas;
      QMGLCanvas *cnv;
      mglGraph *gr;
00037       QString mes;      ///< gr->Message after execution
00038       QString text;     ///< text for parsing
      QString warn;
      void run();
/// Class for displaying the result of MGL script parsing
00044 class QMGLCanvas : public QWidget
friend class MGLThread;
00049       bool autoResize;        ///< Allow auto resizing (default is false)
00050       QString appName;        ///< Application name for message boxes
00051       QTextEdit *textMGL;           ///< Editor with MGL script body
00052       QTextEdit *warnMGL;           ///< Buffer for messages and warnings
00053       QString scriptName;           ///< Default script name which used for exporting
00054       mglGraphAB *graph;            ///< Built-in mglGraph-er instance (used by default)

      QMGLCanvas(QWidget *parent = 0, Qt::WindowFlags f = 0);
      double getRatio() {     return double(graph->GetWidth())/graph->GetHeight();  };
      void setPopup(QMenu *p) {     popup = p;  };
      void setSize(int w, int h);
      QString run(const QString &text, bool showm=true, mglGraph *gr=0);      ///< Execute script from string
//    void showMess(const QString &mes);
      void refreshData();
public slots:
      void execute(mglGraph *gr=0); ///< Execute script (and update picture)
      void copy();                  ///< copy graphics to clipboard
      void stop();                  ///< Stop execution
      void setPer(int p);           ///< Set perspective value
      void setPhi(int p);           ///< Set Phi-angle value
      void setTet(int t);           ///< Set Theta-angle value
      void setAlpha(bool a);  ///< Switch on/off transparency
      void setLight(bool l);  ///< Switch on/off lightning
      void setZoom(bool z);   ///< Switch on/off mouse zooming
      void setRotate(bool r); ///< Switch on/off mouse rotation
      void zoomIn();                ///< Zoom in graphics
      void zoomOut();               ///< Zoom out graphics
      void restore();               ///< Restore zoom and rotation to default values
      void reload();                ///< Reload data and execute script
      void shiftLeft();       ///< Shift graphics to left direction
      void shiftRight();            ///< Shift graphics to right direction
      void shiftUp();               ///< Shift graphics to up direction
      void shiftDown();       ///< Shift graphics to down direction
      void exportPNG(QString fname="");   ///< export to PNG file
      void exportPNGs(QString fname="");  ///< export to PNG file (no transparency)
      void exportJPG(QString fname="");   ///< export to JPEG file
      void exportGIF(QString fname="");   ///< export to GIF file
      void exportBPS(QString fname="");   ///< export to bitmap EPS file
      void exportEPS(QString fname="");   ///< export to vector EPS file
      void exportSVG(QString fname="");   ///< export to SVG file
      void exportCPP(QString fname="");   ///< export to CPP file
      void exportIDTF(QString fname="");  ///< export to IDTF file
      void setMGLFont(QString path);            ///< restore/load font for graphics
      void phiChanged(int);
      void tetChanged(int);
      void perChanged(int);
      void alphaChanged(bool);
      void lightChanged(bool);
      void zoomChanged(bool);
      void rotateChanged(bool);
      void posChanged(QString message);   ///< user click to show mouse position
      void paintEvent(QPaintEvent *);
      void resizeEvent(QResizeEvent *);
      void mousePressEvent(QMouseEvent *);
      void mouseReleaseEvent(QMouseEvent *);
      void mouseMoveEvent(QMouseEvent *);

00110       MGLThread *thr;         ///< Thread for making picture
00111       QPixmap pic;            ///< Pixmap for drawing (changed by update)
00112       double tet, phi;  ///< Rotation angles
00113       double per;             ///< Value of perspective ( must be in [0,1) )
00114       bool alpha;             ///< Transparency state
00115       bool light;             ///< Lightning state
00116       bool zoom;              ///< Mouse zoom state
00117       bool rotate;            ///< Mouse rotation state
00118       float x1,x2,y1,y2;      ///< Zoom in region
00119       bool showMessage; ///< Flag for showing messages (enabled by each execute())
00120       QMenu *popup;     ///< Pointer to pop-up menu
00122       int x0, y0, xe, ye;           ///< Temporary variables for mouse
      uchar *grBuf;
00124       QString defText;        ///< Default text for execution
/// Convert bitmap from mglGraphAB to QPixmap
void convertFromGraph(QPixmap &pic, mglGraphAB *gr, uchar **buf);

Generated by  Doxygen 1.6.0   Back to index