|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef GLAREA_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define GLAREA_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/tw.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TWIN_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TStopWatch;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TGLArea : public TWidget {
|
|
Shinya Kitaoka |
120a6e |
void swapBuffers();
|
|
Shinya Kitaoka |
120a6e |
TStopWatch *m_stopwatch;
|
|
Shinya Kitaoka |
120a6e |
double m_framePerSecond;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void computeOcclusingRegion();
|
|
Shinya Kitaoka |
120a6e |
void deleteOcclusingRegion();
|
|
Shinya Kitaoka |
120a6e |
// void redrawUncoveredArea(const TPoint &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<trect> *m_arrayOfRectToRedraw;</trect>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
// int m_lx, m_ly;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// double m_angle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define PEZZA_DISABLE_REDRAW
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX) && defined(PEZZA_DISABLE_REDRAW)
|
|
Shinya Kitaoka |
120a6e |
bool m_disableRedraw;
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint m_lastPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pan; // world origin (win coords) (n. m_pan*2 are integer)
|
|
Shinya Kitaoka |
120a6e |
TPointD
|
|
Shinya Kitaoka |
120a6e |
m_zoomFactor; // "world pixel" dimension (win coords) (integer if >=1)
|
|
Shinya Kitaoka |
120a6e |
TDimensionD m_pixelSize; // 1/zoomFactor; win pixel dimension (world coords)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double m_zoomLevel; // m_zoomFactor = e^m_zoomLevel
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// supported extensions
|
|
Shinya Kitaoka |
120a6e |
static bool m_bgraSupported;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_isInsideScreen;
|
|
Shinya Kitaoka |
120a6e |
void onGLContextCreated();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
class PickItem {
|
|
Shinya Kitaoka |
120a6e |
public:
|
|
Shinya Kitaoka |
120a6e |
UINT m_label;
|
|
Shinya Kitaoka |
120a6e |
UINT m_zMin;
|
|
Shinya Kitaoka |
120a6e |
UINT m_zMax;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
PickItem(UINT label, UINT zmin, UINT zmax)
|
|
Shinya Kitaoka |
120a6e |
: m_label(label), m_zMin(zmin), m_zMax(zmax) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
~PickItem() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
private:
|
|
Shinya Kitaoka |
120a6e |
// not implemented
|
|
Shinya Kitaoka |
120a6e |
PickItem();
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TGLArea(TWidget *parent, string name = "GLArea");
|
|
Shinya Kitaoka |
120a6e |
~TGLArea();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void repaint();
|
|
Shinya Kitaoka |
120a6e |
void configureNotify(const TDimension &);
|
|
Shinya Kitaoka |
120a6e |
void create();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void paintIncrementally();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// void rectwrite(const TRaster32P &ras, const TPoint &p);
|
|
Shinya Kitaoka |
120a6e |
void over(const TRaster32P &ras, const TPoint &p);
|
|
Shinya Kitaoka |
120a6e |
void over(const TRasterGR8P &ras, const TPoint &p);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TPointD win2world(const TPointD &p) const;
|
|
Shinya Kitaoka |
120a6e |
inline TPointD world2win(const TPointD &p) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TAffine getWin2WorldMatrix() const;
|
|
Shinya Kitaoka |
120a6e |
inline TAffine getWorld2WinMatrix() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void scroll(const TPoint &d); // viewport coordinates
|
|
Shinya Kitaoka |
120a6e |
void lookAt(
|
|
Shinya Kitaoka |
120a6e |
const TPointD &d); // world coordinates of the desired window center
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// n. zoomCenter : viewport coords
|
|
Shinya Kitaoka |
120a6e |
void setZoomLevel(double zlevel, const TPoint &zoomCenter);
|
|
Shinya Kitaoka |
120a6e |
void changeZoomLevel(double d, const TPoint ¢er);
|
|
Shinya Kitaoka |
120a6e |
virtual void onZoomChange() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void fitToWindow(const TRectD &worldRect);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void middleButtonDown(const TMouseEvent &e);
|
|
Shinya Kitaoka |
120a6e |
void middleButtonDrag(const TMouseEvent &e);
|
|
Shinya Kitaoka |
120a6e |
void middleButtonUp(const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void draw();
|
|
Shinya Kitaoka |
120a6e |
virtual void drawIncrementally();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void drawForPick() { draw(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pick(const TPoint &point, vector<pickitem> &items);</pickitem>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double getFramePerSecond() const { return m_framePerSecond; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static bool isBGRASupported() { return m_bgraSupported; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool unProject(TPointD &output,
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const TPoint &mousePos, const T3DPointD &planeOrigin,
|
|
Shinya Kitaoka |
120a6e |
const T3DPointD &u, const T3DPointD &v) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void makeCurrent(); // Gl context
|
|
Shinya Kitaoka |
120a6e |
bool m_dontSwapBuffers;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TPointD TGLArea::win2world(const TPointD &p) const {
|
|
Shinya Kitaoka |
120a6e |
TPointD q = p - m_pan;
|
|
Shinya Kitaoka |
120a6e |
return TPointD(m_pixelSize.lx * q.x, m_pixelSize.ly * q.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TPointD TGLArea::world2win(const TPointD &p) const {
|
|
Shinya Kitaoka |
120a6e |
return m_pan + TPointD(p.x * m_zoomFactor.x, p.y * m_zoomFactor.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TAffine TGLArea::getWin2WorldMatrix() const {
|
|
Shinya Kitaoka |
120a6e |
return TScale(m_pixelSize.lx, m_pixelSize.ly) * TTranslation(-m_pan);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TAffine TGLArea::getWorld2WinMatrix() const {
|
|
Shinya Kitaoka |
120a6e |
return TTranslation(m_pan) * TScale(m_zoomFactor.x, m_zoomFactor.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|