"Fossies" - the Fresh Open Source Software Archive

Member "mathmod-branches-r508-trunk/ui_modules/mathmod.h" (8 Mar 2021, 13312 Bytes) of package /linux/misc/mathmod-11.0-source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mathmod.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 10.1_vs_11.0.

    1 /***************************************************************************
    2  *   Copyright (C) 2021 by Abderrahman Taha                                *
    3  *                                                                         *
    4  *                                                                         *
    5  *   This program is free software; you can redistribute it and/or modify  *
    6  *   it under the terms of the GNU General Public License as published by  *
    7  *   the Free Software Foundation; either version 2 of the License, or     *
    8  *   (at your option) any later version.                                   *
    9  *                                                                         *
   10  *   This program is distributed in the hope that it will be useful,       *
   11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   13  *   GNU General Public License for more details.                          *
   14  *                                                                         *
   15  *   You should have received a copy of the GNU General Public License     *
   16  *   along with this program; if not, write to the                         *
   17  *   Free Software Foundation, Inc.,                                       *
   18  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
   19  ***************************************************************************/
   20 
   21 #ifndef mathmod_H
   22 #define mathmod_H
   23 #include "../pariso/isosurface/Iso3D.h"
   24 #include "../pariso/parametric/Model3D.h"
   25 #include <QFileDialog>
   26 #include <QOpenGLWidget>
   27 #include <QMessageBox>
   28 #include <QMouseEvent>
   29 #include <QResizeEvent>
   30 #include <QTextStream>
   31 #include <QTimer>
   32 #include <iostream>
   33 #include <math.h>
   34 #include <qpixmap.h>
   35 #include <qthread.h>
   36 #include <stdlib.h>
   37 #include <string>
   38 #include "../json_parser/parisodef.h"
   39 #include "../ui_modules/ParisoMathObject.h"
   40 #include <QMessageBox>
   41 #include <QOpenGLWidget>
   42 #include <QOpenGLFunctions>
   43 #include <QLabel>
   44 #include <QVector3D>
   45 #include <QQuaternion>
   46 #include <QMatrix4x4>
   47 #include <QPainter>
   48 
   49 class MathMod : public QOpenGLWidget, protected QOpenGLFunctions
   50 {
   51     Q_OBJECT
   52 public:
   53     uint Ugrid, Vgrid, CutV, CutU;
   54     int btgauche, btdroit, btmilieu, latence;
   55     int Xgrid, Ygrid, Zgrid, CutX, CutY, CutZ, TypeTriangle;
   56     QBasicTimer *timer;
   57     double factx=1.0, facty=1.0, factz=1.0;
   58     ObjectProperties LocalScene;
   59     QString FramesDir;
   60     Iso3D *IsoObjet;
   61     Par3D *ParObjet;
   62     int TypeFormule;
   63     QMessageBox message;
   64     ErrorMessage stError;
   65     ImprovedNoise *PerlinNoise;
   66     int xyzactivated, isomesh, uvactivated, uvactivated4D;
   67     ParisoMathObject RootObjet;
   68     jcollection collection;
   69     QWidget *Parent;
   70     QLabel LabelInfos;
   71     QString labelinfos;
   72     int FistTimecalibrate = -1;
   73     double hauteur_fenetre,difMaximum,decalage_xo,decalage_yo,decalage_zo;
   74     GLfloat minx, miny, minz,maxx, maxy, maxz;
   75     GLfloat oldminx, oldminy, oldminz,oldmaxx,oldmaxy,oldmaxz;
   76     GLfloat difX, difY, difZ;
   77     uint CubeStartIndex=0, PlanStartIndex=0, AxesStartIndex=0;
   78     uint XStartIndex=0, YStartIndex=0, ZStartIndex=0,
   79     XletterIndex=0,YletterIndex=0,ZletterIndex=0;
   80     float wh=0.57;
   81     GLfloat AxeArray[3*36]={5.0f*wh/4.0f, 0.0, 0.0,0.0, 0.0, 0.0,
   82                                   0.0, 5.0f*wh/4.0f, 0.0,0.0, 0.0, 0.0,
   83                                   0.0, 0.0, 5.0f*wh/4.0f,0.0, 0.0, 0.0,
   84                                   5.0f*wh/4.0f, 0.0, 0.0, 95.0f*wh/80.0f, 95.0f*wh/4000.0f, 0.0,
   85                                   95.0f*wh/80.0f, 0.0,  95.0f*wh/4000.0f,95.0f*wh/80.0f, -95.0f*wh/4000.0f, 0.0,
   86                                   95.0f*wh/80.0f, 0.0,  -95.0f*wh/4000.0f,95.0f*wh/80.0f, 95.0f*wh/4000.0f, 0.0,
   87                                    0.0, 5.0f*wh/4.0f, 0.0,95.0f*wh/4000.0f, 95.0f*wh/80.0f, 0.0,
   88                                    0.0, 95.0f*wh/80.0f, 95.0f*wh/4000.0f,-95.0f*wh/4000.0f, 95.0f*wh/80.0f, 0.0,
   89                                    0.0, 95.0f*wh/80.0f, -95.0f*wh/4000.0f,95.0f*wh/4000.0f, 95.0f*wh/80.0f, 0.0,
   90                                    0.0, 0.0, 5.0f*wh/4.0f,95.0f*wh/4000.0f, 0.0, 95.0f*wh/80.0f,
   91                                    0.0, 95.0f*wh/4000.0f, 95.0f*wh/80.0f,-95.0f*wh/4000.0f, 0.0, 95.0f*wh/80.0f,
   92                                    0.0, -95.0f*wh/4000.0f, 95.0f*wh/80.0f,95.0f*wh/4000.0f, 0.0, 95.0f*wh/80.0f,
   93                                    5.0f*wh/4.0f + (2.5f)*95.0f*wh/4000.0f, 0.0f, -95.0f*wh/4000.0f, 5.0f*wh/4.0f + (1.5f)*95.0f*wh/4000.0f, 0.0f, 95.0f*wh/4000.0f,
   94                                    5.0f*wh/4.0f + (2.5f)*95.0f*wh/4000.0f, 0.0f, 95.0f*wh/4000.0f, 5.0f*wh/4.0f + (1.5f)*95.0f*wh/4000.0f, 0.0f, -95.0f*wh/4000.0f,
   95                                    0.0f, 5.0f*wh/4.0f + (2.5f)*95.0f*wh/4000.0f, 95.0f*wh/4000.0f, 0.0f, 5.0f*wh/4.0f + (1.5f)*95.0f*wh/4000.0f, -95.0f*wh/4000.0f,
   96                                    0.0f, 5.0f*wh/4.0f + (2.0f)*95.0f*wh/4000.0f, 0.0f, 0.0f, 5.0f*wh/4.0f + (1.5f)*95.0f*wh/4000.0f, 95.0f*wh/4000.0f,
   97                                    60.0f*wh/4000.0f, -60.0f*wh/4000.0f, 5.0f*wh/4.0f + (2.5f)*95.0f*wh/4000.0f, -60.0f*wh/4000.0f, 60.0f*wh/4000.0f, 5.0f*wh/4.0f + (2.5f)*95.0f*wh/4000.0f,
   98                                    60.0f*wh/4000.0f, -60.0f*wh/4000.0f, 5.0f*wh/4.0f + (1.5f)*95.0f*wh/4000.0f, -60.0f*wh/4000.0f, 60.0f*wh/4000.0f, 5.0f*wh/4.0f + (1.5f)*95.0f*wh/4000.0f
   99                                   };
  100     GLfloat PlanArray[3*60]=
  101     {
  102         -(4*wh/3)/4, (4*wh/3), -(5*wh/4),
  103         -(4*wh/3)/4, -(4*wh/3), -(5*wh/4),
  104         0.0, (4*wh/3), -(5*wh/4),
  105         0.0, -(4*wh/3), -(5*wh/4),
  106         (4*wh/3)/4, (4*wh/3), -(5*wh/4),
  107         (4*wh/3)/4, -(4*wh/3), -(5*wh/4),
  108         (4*wh/3), -(4*wh/3)/4, -(5*wh/4),
  109         -(4*wh/3), -(4*wh/3)/4, -(5*wh/4),
  110         (4*wh/3), 0.0, -(5*wh/4),
  111         -(4*wh/3), 0.0, -(5*wh/4),
  112         (4*wh/3), (4*wh/3)/4, -(5*wh/4),
  113         -(4*wh/3), (4*wh/3)/4, -(5*wh/4),
  114         -(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  115         -(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  116         -3*(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  117         -3*(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  118         -(4*wh/3)/2, (4*wh/3), -(5*wh/4),
  119         -(4*wh/3)/2, -(4*wh/3), -(5*wh/4),
  120         -5*(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  121         -5*(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  122         -3*(4*wh/3)/4, (4*wh/3), -(5*wh/4),
  123         -3*(4*wh/3)/4, -(4*wh/3), -(5*wh/4),
  124         -7*(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  125         -7*(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  126         (4*wh/3)/8, (4*wh/3), -(5*wh/4),
  127         (4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  128         3*(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  129         3*(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  130         (4*wh/3)/2, (4*wh/3), -(5*wh/4),
  131         (4*wh/3)/2, -(4*wh/3), -(5*wh/4),
  132         5*(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  133         5*(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  134         3*(4*wh/3)/4, (4*wh/3), -(5*wh/4),
  135         3*(4*wh/3)/4, -(4*wh/3), -(5*wh/4),
  136         7*(4*wh/3)/8, (4*wh/3), -(5*wh/4),
  137         7*(4*wh/3)/8, -(4*wh/3), -(5*wh/4),
  138         (4*wh/3), -(4*wh/3)/8, -(5*wh/4),
  139         -(4*wh/3), -(4*wh/3)/8, -(5*wh/4),
  140         (4*wh/3), -3*(4*wh/3)/8, -(5*wh/4),
  141         -(4*wh/3), -3*(4*wh/3)/8, -(5*wh/4),
  142         (4*wh/3), -(4*wh/3)/2, -(5*wh/4),
  143         -(4*wh/3), -(4*wh/3)/2, -(5*wh/4),
  144         (4*wh/3), -5*(4*wh/3)/8, -(5*wh/4),
  145         -(4*wh/3), -5*(4*wh/3)/8, -(5*wh/4),
  146         (4*wh/3), -3*(4*wh/3)/4, -(5*wh/4),
  147         -(4*wh/3), -3*(4*wh/3)/4, -(5*wh/4),
  148         (4*wh/3), -7*(4*wh/3)/8, -(5*wh/4),
  149         -(4*wh/3), -7*(4*wh/3)/8, -(5*wh/4),
  150         (4*wh/3), (4*wh/3)/8, -(5*wh/4),
  151         -(4*wh/3), (4*wh/3)/8, -(5*wh/4),
  152         (4*wh/3), 3*(4*wh/3)/8, -(5*wh/4),
  153         -(4*wh/3), 3*(4*wh/3)/8, -(5*wh/4),
  154         (4*wh/3), (4*wh/3)/2, -(5*wh/4),
  155         -(4*wh/3), (4*wh/3)/2, -(5*wh/4),
  156         (4*wh/3), 5*(4*wh/3)/8, -(5*wh/4),
  157         -(4*wh/3), 5*(4*wh/3)/8, -(5*wh/4),
  158         (4*wh/3), 3*(4*wh/3)/4, -(5*wh/4),
  159         -(4*wh/3), 3*(4*wh/3)/4, -(5*wh/4),
  160         (4*wh/3), 7*(4*wh/3)/8, -(5*wh/4),
  161         -(4*wh/3), 7*(4*wh/3)/8, -(5*wh/4)
  162     };
  163     bool PutObjectInsideCubeOk=false;
  164     GLuint vbo[2];
  165     float gridcol[4]  ={0.4f, 0.4f, 0.4f, 0.9f};
  166     float lightPosition[4] = {0, 0, 10, 0};
  167     float lightAmbient[4]  = {0.5f, 0.5f, 0.5f, 1.0f};//{0.4f, 0.4f, 0.4f, 0.1};
  168     float lightDiffuse[4]  = {0.8f, 0.8f, 0.8f, 1.0};
  169     float lightSpecular[4] = {0.5f, 0.5f, 0.5f, 0.1f};//{0.4f, 0.4f, 0.4f, 0.1};
  170     float frontColor[4] = {0.72f, 0.5f, 0.1, 1};
  171     float backColor[4]  = {0.1f, 0.7f, 0.2f, 1};
  172     int shininessVal=20;
  173     int screenWidth=100;
  174     int screenHeight=100;
  175     bool mouseLeftDown=false;
  176     bool mouseRightDown=false;
  177     float mouseY=0;
  178     float cameraDistance=1.4f;
  179     bool vboSupported, vboUsed;
  180     QMatrix4x4 matrixProjectionx;
  181     GLuint shaderprogramId = 0;
  182     bool glslSupported;
  183     GLint uniformFrontColor;
  184     GLint uniformBackColor;
  185     GLint uniformGridColor;
  186     GLint uniformThereisRGBA;
  187     GLfloat uniformShininess;
  188     GLint uniformdrawgridColor;
  189     GLint uniformMatrixModelView;
  190     GLint uniformMatrixModelViewProjection;
  191     GLint uniformMatrixNormal;
  192     GLint uniformLightPosition;
  193     GLint uniformLightAmbient;
  194     GLint uniformLightDiffuse;
  195     GLint uniformLightSpecular;
  196     GLint attribVertexPosition;
  197     GLint attribVertexNormal;
  198     GLint attribVertexColor;
  199     GLint attribVertexTexCoord;
  200     QVector2D mousePressPosition;
  201     qreal angularSpeed = 0;
  202     QMatrix4x4 matrixViewx;
  203     QQuaternion rotation= QQuaternion::fromAxisAndAngle(QVector3D(1.0,0.0,0.0), 270)*
  204             QQuaternion::fromAxisAndAngle(QVector3D(0.0,0.0,1.0), 225)*
  205             QQuaternion::fromAxisAndAngle(QVector3D(1.0,-1.0,0.0), -29);
  206     QQuaternion rotationx;
  207     QQuaternion rotationy;
  208     QQuaternion rotationz;
  209     QQuaternion oldRotation= rotation;
  210     QMatrix4x4 matrixModelViewProjectionx;
  211     QMatrix4x4 matrixNormalx;
  212     qreal acc;
  213     QVector3D n;
  214 public:
  215     MathMod(QWidget *, uint, uint initpargrid = 50, uint initisogrid = 40,
  216             uint factx = 4, uint facty = 4, uint factz = 4);
  217     ~MathMod();
  218     void ParametricSurfaceProcess(int type = 1);
  219     void ParisoObjectProcess();
  220     void Initparametricpage();
  221     void updateGL();
  222 public slots:
  223     void fill();
  224     void iso_infos();
  225     void attachinfos();
  226     void draw_norm_clicked();
  227     void linecolumn_valueChanged(int, ModelType type=PAR_TYPE);
  228     void line_valueChanged(int);
  229     void column_valueChanged(int);
  230     void linecolumn_valueChanged_2(int);
  231     void linecolumn_valueupdate(int);
  232     void line_valueupdate(int);
  233     void column_valueupdate(int);
  234     void ProcessNewIsoSurface();
  235     void xyzg_valueChanged(int, ModelType);
  236     void xyzg_valueupdate(int);
  237     void slot_checkBox73_clicked(ModelType type=ISO_TYPE);
  238     void slot_uv_clicked(ModelType type=PAR_TYPE);
  239     void slot_uv4D_clicked();
  240     void Mesh();
  241     void slot_triangles_clicked();
  242     int ParseIso();
  243     int ParsePar();
  244     void ShowErrormessage();
  245     void frames_clicked();
  246     void CreateShaderProgram();
  247     void draw(ObjectProperties *);
  248     void plan();
  249     void CopyData(ObjectProperties *);
  250     void DrawMinimalTopology(ObjectProperties *);
  251     void DrawMeshIso(ObjectProperties *);
  252     void DrawParisoCND(ObjectProperties *, uint);
  253     void DrawNormals(ObjectProperties *);
  254     void DrawAxe();
  255     void proj();
  256     void DrawPariso(ObjectProperties *, uint);
  257     void drawCube();
  258     void initializeGL() override;
  259     void Winitialize_GL();
  260     void resizeGL(int, int) override;
  261     void paintGL()  override;
  262     void timerEvent(QTimerEvent *)  override;
  263     void mousePressEvent(QMouseEvent *)  override;
  264     void mouseMoveEvent(QMouseEvent *)  override;
  265     void mouseReleaseEvent(QMouseEvent *)  override;
  266     void keyPressEvent(QKeyEvent *)  override;
  267     virtual void run();
  268     void InitSpecularParameters();
  269     void Shininess(int);
  270     int memoryallocation(uint, uint initpargrid = 50, uint initgrid = 40,
  271                          uint factx = 4, uint facty = 4, uint factz = 4);
  272     void PutObjectInsideCube();
  273     void screenshot();
  274     void FramesShot();
  275     void FramesSave();
  276     QImage Copyscreenshot();
  277     void moveEvent(QMoveEvent *) override;
  278     void closeEvent(QCloseEvent *) override;
  279 public slots:
  280     void anim();
  281     void morph();
  282     void starttimer();
  283     void stoptimer();
  284     bool timeractif();
  285     void restarttimer(int);
  286     void FillOk();
  287     void normOk();
  288     void boundingboxOk();
  289     void transparency(int, int currentposition = 0);
  290     void red(int, int currentposition = 0);
  291     void green(int, int currentposition = 0);
  292     void blue(int, int currentposition = 0);
  293     void redSpec(int);
  294     void greenSpec(int);
  295     void blueSpec(int);
  296     void transSpec(int);
  297     void redAmb(int);
  298     void greenAmb(int);
  299     void blueAmb(int);
  300     void transAmb(int);
  301     void redDiff(int);
  302     void greenDiff(int);
  303     void blueDiff(int);
  304     void transDiff(int);
  305     void quality(int);
  306     void bmp();
  307     void jpg();
  308     void png();
  309     void colorstype(int);
  310     void colorstypeParIso(int);
  311     void colorstypeParam(int);
  312     void SaveSceneAsObjPoly(int n = 0);
  313     void SaveSceneAsObjTrian(int n = 0);
  314     void CalculateTexturePoints(int type);
  315     void CalculatePigmentPoints(int type);
  316     void LoadShadersFiles();
  317     void UpdateGL();
  318 };
  319 #endif