\doxysection{Camera.\+hpp}
\hypertarget{Camera_8hpp_source}{}\label{Camera_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/UI/Camera.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/UI/Camera.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_UI\_CAMERA\_H}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_UI\_CAMERA\_H}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}Py.hpp"{}}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ "{}Math/Mat4.hpp"{}}}
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#include\ "{}Math/Misc.hpp"{}}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ <QOpenGLFunctions\_4\_3\_Core>}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <QPointF>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00014\ \textcolor{keyword}{class\ }Camera}
\DoxyCodeLine{00015\ \{}
\DoxyCodeLine{00016\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00017\ \ \ \ \ Camera();}
\DoxyCodeLine{00018\ \ \ \ \ \string~Camera();}
\DoxyCodeLine{00019\ }
\DoxyCodeLine{00021\ \ \ \ \ QPointF\ \mbox{\hyperlink{classCamera_a6af7580ad67cf9b55fa44298bb05dd7b}{worldPosToNormalizedPos}}(\textcolor{keyword}{const}\ Point\_2\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00022\ \ \ \ \ Point\_2\ normalizedPosToWorldPos(\textcolor{keyword}{const}\ QPointF\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ \ \ \ \ \textcolor{keywordtype}{bool}\ isVisible(\textcolor{keyword}{const}\ Bbox\_2\ \&bbox)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ CGAL::do\_overlap(mBbox,\ bbox);\ \}}
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ \ \ \ \ \textcolor{keywordtype}{void}\ loadUniforms();}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \ \ \ \ \textcolor{keywordtype}{float}\ adjustLineWidth(\textcolor{keywordtype}{float})\ \textcolor{keyword}{const};}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keywordtype}{void}\ setBaseDimensions(uint\ w,\ uint\ h,\ \textcolor{keywordtype}{double}\ unitsPerNanoMeter);}
\DoxyCodeLine{00031\ \ \ \ \ \textcolor{keywordtype}{void}\ setZoom(\textcolor{keywordtype}{float},\ QPointF\ anchor\ =\ QPointF(0.5,\ 0.5));}
\DoxyCodeLine{00032\ \ \ \ \ \textcolor{keywordtype}{void}\ setOrigin(\textcolor{keyword}{const}\ Point\_2\&);}
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keywordtype}{void}\ setOriginRelative(\textcolor{keyword}{const}\ Vector\_2\&);}
\DoxyCodeLine{00034\ \ \ \ \ \textcolor{keywordtype}{void}\ setCenter(\textcolor{keyword}{const}\ Point\_2\&);}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keywordtype}{void}\ setView(\textcolor{keyword}{const}\ Point\_2\ \&origin,\ \textcolor{keyword}{const}\ Vector\_2\ \&size);}
\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keywordtype}{void}\ setZNear(\textcolor{keywordtype}{float}\ z);}
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{keywordtype}{void}\ setZFar(\textcolor{keywordtype}{float}\ z);}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordtype}{void}\ setZRange(\textcolor{keywordtype}{float}\ near,\ \textcolor{keywordtype}{float}\ far);}
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00040\ \ \ \ \ \textcolor{keywordtype}{void}\ moveBy(\textcolor{keyword}{const}\ Vector\_2\ \&v)\ \{\ setCenter(mCenter\ +\ v);\ \}}
\DoxyCodeLine{00041\ }
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keyword}{const}\ Bbox\_2\ getBbox()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mBbox;\ \}}
\DoxyCodeLine{00043\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{float}\ getZoom()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mZoom;\ \}}
\DoxyCodeLine{00044\ \ \ \ \ \textcolor{keyword}{const}\ Vector\_2\&\ getDims()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mDims;\ \}}
\DoxyCodeLine{00045\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ getCornerMin()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mCornerBL;\ \}}
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ getCornerMax()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mCornerTR;\ \}}
\DoxyCodeLine{00047\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ getOrigin()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mCornerBL;\ \}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \ \ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{classmath_1_1Mat4}{math::Mat4}}\&\ getMVP()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mMVP;\ \}}
\DoxyCodeLine{00050\ }
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{float}\ *getFloatMVP()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \&mUniforms.MVP[0];\ \}}
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keyword}{struct\ }\{}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ GLfloat\ MVP[16];}
\DoxyCodeLine{00054\ \ \ \ \ \}\ mUniforms;}
\DoxyCodeLine{00055\ }
\DoxyCodeLine{00056\ \ \ \ \ GLuint\ getUBO()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mUBO;\ \}}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00058\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00059\ \ \ \ \ \mbox{\hyperlink{classmath_1_1Mat4}{math::Mat4}}\ mMVP;}
\DoxyCodeLine{00060\ \ \ \ \ \textcolor{keywordtype}{float}\ mZoom\{1.0f\};}
\DoxyCodeLine{00061\ \ \ \ \ Vector\_2\ mBaseDims;}
\DoxyCodeLine{00062\ \ \ \ \ Vector\_2\ mDims;}
\DoxyCodeLine{00063\ \ \ \ \ Bbox\_2\ mBbox;}
\DoxyCodeLine{00064\ \ \ \ \ Point\_2\ mCornerBL\{0,0\};}
\DoxyCodeLine{00065\ \ \ \ \ Point\_2\ mCornerTR;}
\DoxyCodeLine{00066\ \ \ \ \ Point\_2\ mCenter;}
\DoxyCodeLine{00067\ \ \ \ \ \textcolor{keywordtype}{float}\ mZNear\{-\/1.0f\};}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keywordtype}{float}\ mZFar\{1.0f\};}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{comment}{//float\ mAspectRatio\{1.0f\};}}
\DoxyCodeLine{00070\ \ \ \ \ GLuint\ mUBO\{0\};}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00072\ \ \ \ \ \textcolor{keywordtype}{void}\ update();}
\DoxyCodeLine{00073\ \};}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ Camera::setZNear(\textcolor{keywordtype}{float}\ z)}
\DoxyCodeLine{00076\ \{}
\DoxyCodeLine{00077\ \ \ \ \ setZRange(z,\ mZFar);}
\DoxyCodeLine{00078\ \}}
\DoxyCodeLine{00079\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ Camera::setZFar(\textcolor{keywordtype}{float}\ z)}
\DoxyCodeLine{00080\ \{}
\DoxyCodeLine{00081\ \ \ \ \ setZRange(mZNear,\ z);}
\DoxyCodeLine{00082\ \}}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00084\ \textcolor{keyword}{inline}\ Point\_2\ Camera::normalizedPosToWorldPos(\textcolor{keyword}{const}\ QPointF\ \&v)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00085\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordflow}{return}\ mCornerBL\ +\ Vector\_2(mDims.x()\ *\ v.x(),\ mDims.y()\ *\ v.y());}
\DoxyCodeLine{00087\ \}}
\DoxyCodeLine{00088\ \textcolor{keyword}{inline}\ QPointF\ \mbox{\hyperlink{classCamera_a6af7580ad67cf9b55fa44298bb05dd7b}{Camera::worldPosToNormalizedPos}}(\textcolor{keyword}{const}\ Point\_2\ \&v)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00089\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00090\ \ \ \ \ \textcolor{keyword}{auto}\ dv\ =\ v\ -\/\ mCornerBL;}
\DoxyCodeLine{00091\ \ \ \ \ \textcolor{keywordflow}{return}\ QPointF(\textcolor{keywordtype}{float}(dv.x())\ /\ mDims.x(),\ 1.0f\ -\/\ \textcolor{keywordtype}{float}(dv.y())\ /\ mDims.y());}
\DoxyCodeLine{00092\ \}}
\DoxyCodeLine{00093\ }
\DoxyCodeLine{00094\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ Camera::adjustLineWidth(\textcolor{keywordtype}{float}\ lw)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00095\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00096\ \ \ \ \ \textcolor{keywordflow}{return}\ lw\ *\ math::approx::rsqrt(mZoom);}
\DoxyCodeLine{00097\ \}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ \ GYM\_PCB\_UI\_CAMERA\_H}}

\end{DoxyCode}
