| #pragma once |
| |
| #ifndef GLAREA_INCLUDED |
| #define GLAREA_INCLUDED |
| |
| |
| #include "tw/tw.h" |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TWIN_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| class TStopWatch; |
| |
| class DVAPI TGLArea : public TWidget { |
| void swapBuffers(); |
| TStopWatch *m_stopwatch; |
| double m_framePerSecond; |
| |
| void computeOcclusingRegion(); |
| void deleteOcclusingRegion(); |
| |
| |
| std::vector<TRect> *m_arrayOfRectToRedraw; |
| |
| protected: |
| |
| |
| |
| |
| #define PEZZA_DISABLE_REDRAW |
| |
| #if defined(MACOSX) && defined(PEZZA_DISABLE_REDRAW) |
| bool m_disableRedraw; |
| #endif |
| |
| TPoint m_lastPos; |
| TPointD m_pan; |
| TPointD |
| m_zoomFactor; |
| TDimensionD m_pixelSize; |
| |
| double m_zoomLevel; |
| |
| |
| static bool m_bgraSupported; |
| |
| bool m_isInsideScreen; |
| void onGLContextCreated(); |
| |
| public: |
| class PickItem { |
| public: |
| UINT m_label; |
| UINT m_zMin; |
| UINT m_zMax; |
| |
| PickItem(UINT label, UINT zmin, UINT zmax) |
| : m_label(label), m_zMin(zmin), m_zMax(zmax) {} |
| |
| ~PickItem() {} |
| |
| private: |
| |
| PickItem(); |
| }; |
| |
| TGLArea(TWidget *parent, string name = "GLArea"); |
| ~TGLArea(); |
| |
| void repaint(); |
| void configureNotify(const TDimension &); |
| void create(); |
| |
| void paintIncrementally(); |
| |
| |
| void over(const TRaster32P &ras, const TPoint &p); |
| void over(const TRasterGR8P &ras, const TPoint &p); |
| |
| inline TPointD win2world(const TPointD &p) const; |
| inline TPointD world2win(const TPointD &p) const; |
| |
| inline TAffine getWin2WorldMatrix() const; |
| inline TAffine getWorld2WinMatrix() const; |
| |
| void scroll(const TPoint &d); |
| void lookAt( |
| const TPointD &d); |
| |
| |
| void setZoomLevel(double zlevel, const TPoint &zoomCenter); |
| void changeZoomLevel(double d, const TPoint ¢er); |
| virtual void onZoomChange() {} |
| |
| void fitToWindow(const TRectD &worldRect); |
| |
| void middleButtonDown(const TMouseEvent &e); |
| void middleButtonDrag(const TMouseEvent &e); |
| void middleButtonUp(const TMouseEvent &e); |
| |
| void draw(); |
| virtual void drawIncrementally(); |
| |
| virtual void drawForPick() { draw(); } |
| |
| void pick(const TPoint &point, vector<PickItem> &items); |
| |
| double getFramePerSecond() const { return m_framePerSecond; } |
| |
| static bool isBGRASupported() { return m_bgraSupported; } |
| |
| bool unProject(TPointD &output, |
| |
| const TPoint &mousePos, const T3DPointD &planeOrigin, |
| const T3DPointD &u, const T3DPointD &v) const; |
| |
| void makeCurrent(); |
| bool m_dontSwapBuffers; |
| }; |
| |
| inline TPointD TGLArea::win2world(const TPointD &p) const { |
| TPointD q = p - m_pan; |
| return TPointD(m_pixelSize.lx * q.x, m_pixelSize.ly * q.y); |
| } |
| |
| inline TPointD TGLArea::world2win(const TPointD &p) const { |
| return m_pan + TPointD(p.x * m_zoomFactor.x, p.y * m_zoomFactor.y); |
| } |
| |
| inline TAffine TGLArea::getWin2WorldMatrix() const { |
| return TScale(m_pixelSize.lx, m_pixelSize.ly) * TTranslation(-m_pan); |
| } |
| |
| inline TAffine TGLArea::getWorld2WinMatrix() const { |
| return TTranslation(m_pan) * TScale(m_zoomFactor.x, m_zoomFactor.y); |
| } |
| |
| #endif |