Gl Graph

Gl Graph Source of mapquad.h


#ifndef MAPQUAD_H
#define MAPQUAD_H
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
 
#include <drawabledatareader.h>
#include <globjectdata.h>
 
class MapQuad : public DrawableDataReader {
public:
    MapQuad();
    MapQuad(std::string * filename, std::string * format, int maxline,std::unordered_map<std::string, std::string> * args);
 
    void addData(std::vector<float> line);
    void draw();
    virtual void init();
    void print();
 
 
 
    int getElementNb() const;
 
    void updateMinMax() {
        float minz=data[0][0];
        float maxz=data[0][0];
        unsigned int maxj = 0;
        unsigned int sizei = data.size();
        for (unsigned int i = 0; i < sizei; i++)
        {
            unsigned int sizej = data[i].size();
            maxj=max<unsigned int>(maxj,sizej);
            for (unsigned int j = 0; j < sizej; j++)
            {
                minz=min<float>(minz,data[i][j]);
                maxz=max<float>(maxz,data[i][j]);
            }
        }
 
        vmin = Vec3f(0,0,minz);
        vmax = Vec3f(sizei,maxj+1,maxz);
    }
 
    float getMinX() {
 
        return vmin.getX();
    };
 
    float getMaxX() {
 
        return vmax.getX();
    };
 
    float getMinY() {
 
        return vmin.getY();
    };
 
    float getMaxY() {
 
        return vmax.getY();
    };
 
    float getMinZ() {
 
        return vmin.getZ();
    };
 
    float getMaxZ() {
 
        return vmax.getZ();
    };
 
    std::vector<std::vector<float>> getData() const {
        return data;
    };
 
 
 
    void onFileOpen();
    bool onLineRead(std::string line);
    void onFileClose();
 
protected:
 
    Vec3f vmin;
    Vec3f vmax;
 
    GlQuadData glquaddata;
    std::vector<std::vector<float>> data;
 
 
 
    float getVertexColor(Vec3f &vec);
    void pushQuad(Vec3f &pts,float sizex,float sizey);
    void buildMap();
};
 
#endif