1 #pragma once 2 3 /* GLView: A basic OpenGL rectangle for rendering images. 4 5 This class is inherited by: 6 7 *QGLview - for Qt GUI 8 *OffscreenView - for offscreen rendering, in tests and from command-line 9 (This class is also overridden by NULLGL.cc for special experiments) 10 11 The view assumes either a Gimbal Camera (rotation,translation,distance) 12 or Vector Camera (eye,center/target) is being used. See Camera.h. The 13 cameras are not kept in sync. 14 15 QGLView only uses GimbalCamera while OffscreenView can use either one. 16 Some actions (showCrossHairs) only work properly on Gimbal Camera. 17 18 */ 19 20 #include <Eigen/Core> 21 #include <Eigen/Geometry> 22 #include <string> 23 #include "system-gl.h" 24 #include <iostream> 25 #include "Camera.h" 26 #include "colormap.h" 27 28 class GLView 29 { 30 public: 31 GLView(); 32 void setRenderer(class Renderer* r); getRenderer()33 Renderer *getRenderer() const { return this->renderer; } 34 35 void initializeGL(); 36 void resizeGL(int w, int h); 37 virtual void paintGL(); 38 39 void setCamera(const Camera &cam); 40 void setupCamera() const; 41 42 void setColorScheme(const ColorScheme &cs); 43 void setColorScheme(const std::string &cs); 44 void updateColorScheme(); 45 showAxes()46 bool showAxes() const { return this->showaxes; } setShowAxes(bool enabled)47 void setShowAxes(bool enabled) { this->showaxes = enabled; } showScaleProportional()48 bool showScaleProportional() const { return this->showscale; } setShowScaleProportional(bool enabled)49 void setShowScaleProportional(bool enabled) { this->showscale = enabled; } showEdges()50 bool showEdges() const { return this->showedges; } setShowEdges(bool enabled)51 void setShowEdges(bool enabled) { this->showedges = enabled; } showFaces()52 bool showFaces() const { return this->showfaces; } setShowFaces(bool enabled)53 void setShowFaces(bool enabled) { this->showfaces = enabled; } showCrosshairs()54 bool showCrosshairs() const { return this->showcrosshairs; } setShowCrosshairs(bool enabled)55 void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; } 56 57 virtual bool save(const char *filename) const = 0; 58 virtual std::string getRendererInfo() const = 0; getDPI()59 virtual float getDPI() { return 1.0f; } 60 ~GLView()61 virtual ~GLView(){}; 62 63 Renderer *renderer; 64 const ColorScheme *colorscheme; 65 Camera cam; 66 double far_far_away; 67 double aspectratio; 68 bool showaxes; 69 bool showfaces; 70 bool showedges; 71 bool showcrosshairs; 72 bool showscale; 73 74 #ifdef ENABLE_OPENCSG 75 /// Shader attribute identifiers 76 struct shaderinfo_t { 77 enum shader_type_t { 78 NONE, 79 CSG_RENDERING, 80 SELECT_RENDERING, 81 }; 82 int progid = 0; 83 shader_type_t type; 84 union { 85 struct { 86 int color_area; 87 int color_edge; 88 // barycentric coordinates of the current vertex 89 int barycentric; 90 } csg_rendering; 91 struct { 92 int identifier; 93 } select_rendering; 94 } data; 95 96 }; 97 98 shaderinfo_t shaderinfo; 99 bool is_opencsg_capable; 100 bool has_shaders; 101 void enable_opencsg_shaders(); 102 virtual void display_opencsg_warning() = 0; 103 bool opencsg_support; 104 int opencsg_id; 105 106 #endif 107 private: 108 void showCrosshairs(const Color4f &col); 109 void showAxes(const Color4f &col); 110 void showSmallaxes(const Color4f &col); 111 void showScalemarkers(const Color4f &col); 112 void decodeMarkerValue(double i, double l, int size_div_sm); 113 }; 114