1 //#************************************************************** 2 //# filename: GLDrawWnd.h 3 //# 4 //# author: Gerstmayr, Vetyukov 5 //# 6 //# generated: 7 //# description: 8 //# comments: 9 //# 10 //# Copyright (c) 2003-2013 Johannes Gerstmayr, Linz Center of Mechatronics GmbH, Austrian 11 //# Center of Competence in Mechatronics GmbH, Institute of Technical Mechanics at the 12 //# Johannes Kepler Universitaet Linz, Austria. All rights reserved. 13 //# 14 //# This file is part of HotInt. 15 //# HotInt is free software: you can redistribute it and/or modify it under the terms of 16 //# the HOTINT license. See folder 'licenses' for more details. 17 //# 18 //# bug reports are welcome!!! 19 //# WWW: www.hotint.org 20 //# email: bug_reports@hotint.org or support@hotint.org 21 //#*************************************************************************************** 22 23 24 25 #if !defined(AFX_GLDRAWWND_H__C4A1F1E3_E308_11D4_BA16_000021038B9A__INCLUDED_) 26 #define AFX_GLDRAWWND_H__C4A1F1E3_E308_11D4_BA16_000021038B9A__INCLUDED_ 27 28 #if _MSC_VER > 1000 29 #pragma once 30 #endif // _MSC_VER > 1000 31 // GLDrawWnd.h : header file 32 // 33 34 #include <afxtempl.h> 35 36 #include "rendercontext.h" 37 #include "dialogframesrecording.h" 38 39 #include "extgl.h" 40 //#include "gl/gl.h" 41 #include "gl/glu.h" 42 43 #define WM_REDRAW (WM_USER + 1) 44 45 ///////////////////////////////////////////////////////////////////////////// 46 // CGLDrawWnd window 47 48 class CGLDrawWnd : public CWnd, RenderContext_ 49 { 50 float saved_modelview_matrix[16]; 51 52 // flag: no rotation 53 bool bNoRotationState; 54 55 void MakeZoom(const CPoint & p1, const CPoint & p2); 56 57 struct TextPortion 58 { 59 enum {Text3D, Text2D, TextStruct} type; 60 float x,y,z; 61 int nLineNo; 62 int nXPos; 63 CString text; 64 }; 65 // in this list the texts are being stored 66 CList<TextPortion,TextPortion&> Texts; 67 float GetStructTextVertPos(int nLineNo); 68 float GetStructTextHorPos(int nXPos,const CString & text); 69 70 static CToolBar ToolBar; 71 72 GLuint GL_SCENE_LIST; 73 74 75 void Init(); 76 77 BOOL SetupPixelFormat(); 78 void StopOpenGL(); 79 void SetPerspective(); 80 81 CDC * m_pDC; 82 HGLRC hrc; 83 84 /* 85 static GLsizei SelBufSize; 86 void SelectRegion(const CPoint & p1, const CPoint & p2, bool bShift, bool bCtrl); 87 CList<unsigned int,unsigned int&> Selection; 88 */ 89 90 // Viewing parameters 91 float TranslationStepCoeff; // how quick is the view pan 92 float RotationStep; // how quick is rotation 93 float DetailLevelStepCoeff; // how quick is zoom 94 float PerspectiveStepCoeff; // how quick is perspective 95 GLdouble AspectRatio; // currect aspect ratio 96 97 enum 98 { 99 ActionNone, 100 ActionSelect, 101 ActionMove, 102 ActionRotate, 103 ActionZoom, 104 ActionPerspective 105 } Action; 106 CPoint CurrentPoint; // here is the mouse 107 CPoint StartingPoint; // here it was as the operation started 108 109 Vertex CenterPoint; // here is the actual center of the construction 110 Vertex CenterOffset; // offset to the center of the construction (camera moving with object) 111 float SCENE_OFFSET_COEFF; // see SetPerspective() 112 113 114 void DrawScene(); 115 116 int AxesPosition; // 5 -- no axes 117 bool bFittingTheView; // is used in OnButtonFit(), 118 // so that some details would not affect the scene 119 120 bool bRotationTimerRunning; 121 122 WCDInterface * pWCDI; 123 124 int bShowLegend; 125 126 CDialogFramesRecording DialogFramesRecording; 127 void PerformVideoFramesRecord(); 128 129 130 // implementing the rest of the interface 131 virtual void PrintText2D(float x, float y, const char * text); 132 virtual void PrintText3D(float x, float y, float z, const char * text); 133 virtual void PrintTextStruct(int nLineNo, int nXPos, const char * text); GetDetailLevel()134 virtual int GetDetailLevel() { return 1; } ShowLegend()135 virtual int ShowLegend() { return bShowLegend; } GetConfigurationNumber()136 virtual int GetConfigurationNumber() { return 1; } 137 138 float BackgroundR,BackgroundG,BackgroundB; SetBackgroundColor(float r,float g,float b)139 virtual void SetBackgroundColor(float r, float g, float b) 140 { 141 BackgroundR = r; 142 BackgroundG = g; 143 BackgroundB = b; 144 } 145 146 float ScrTextR,ScrTextG,ScrTextB; SetTextColor(float r,float g,float b)147 virtual void SetTextColor(float r, float g, float b) 148 { 149 ScrTextR = r; 150 ScrTextG = g; 151 ScrTextB = b; 152 } SetCenterOffset(float x,float y,float z)153 virtual void SetCenterOffset(float x, float y, float z) 154 { 155 CenterOffset.x = x; 156 CenterOffset.y = y; 157 CenterOffset.z = z; 158 } 159 GetWindowSize(int & width,int & height)160 virtual void GetWindowSize(int& width, int& height) 161 { 162 CRect r; 163 GetWindowRect(r); 164 width = r.Width(); 165 height = r.Height(); 166 } 167 168 virtual void SetSceneOffsetCoeff(float x); 169 170 171 void PrintTextsFixed(); 172 173 // chooses the color for the axes to be painted 174 void ChooseAxesColor(); 175 176 // these functions can be used in order to move the clipping plane, before 177 // painting the lines or points that can appear in a surface of a solid 178 virtual void BeginLinesOnSolid(); 179 virtual void EndLinesOnSolid(); 180 181 void CreateFEColorTexture(int ncols, int texnum, int grey); //create 1D texture for FE-color drawing 182 183 CString ProgramDirectory; // directory where the program is running 184 185 // Construction 186 public: 187 CGLDrawWnd(); 188 189 void SetAnimateScalingTimer(int flag); 190 bool prohibit_redraw; 191 192 double old_scaling_factor; 193 double virtual_animate_time; 194 195 // the class should be not constructed without setting this pointer 196 void SetWCDI(WCDInterface * p_wcdi); 197 198 void Redraw(); 199 void ButtonFit(); 200 void ResetOpenGLParam(); //call if global light or material has changed 201 void ContentsChanged(int forcefit=0); //Redraw and recompute scene size 202 203 void SaveConfig(CArchive & ar); 204 void LoadConfig(CArchive & ar); 205 206 //convert some internal settings (window position, open dialog windows, etc.) to EDC 207 virtual void Configuration2EDC(ElementDataContainer& edc); 208 //convert EDC to some internal settings (window position, open dialog windows, etc.) 209 virtual void EDC2Configuration(const ElementDataContainer& edc); 210 SetProgramDirectoryAsCurrent()211 void SetProgramDirectoryAsCurrent() { SetCurrentDirectory(ProgramDirectory); } GetProgramDirectory()212 const CString& GetProgramDirectory() { return ProgramDirectory; } 213 Lighting()214 BOOL & Lighting() { return pWCDI->GetIOption(206)/*bLighting*/; } //gl_lighting 215 216 void OnMouseWheelGLDW(UINT nFlags, short zDelta, CPoint pt); 217 218 // Attributes 219 public: 220 //HENHMETAFILE hEnhMetaFile; 221 222 // Operations 223 public: 224 225 // Overrides 226 // ClassWizard generated virtual function overrides 227 //{{AFX_VIRTUAL(CGLDrawWnd) 228 public: 229 //}}AFX_VIRTUAL 230 231 // Implementation 232 public: 233 virtual ~CGLDrawWnd(); 234 235 // Generated message map functions 236 //protected: 237 public: 238 //{{AFX_MSG(CGLDrawWnd) 239 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 240 afx_msg void OnPaint(); 241 afx_msg void OnSize(UINT nType, int cx, int cy); 242 afx_msg BOOL OnEraseBkgnd(CDC* pDC); 243 afx_msg void OnDestroy(); 244 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); 245 afx_msg void OnLButtonDown(UINT nFlags, CPoint point); 246 afx_msg void OnLButtonUp(UINT nFlags, CPoint point); 247 afx_msg void OnMouseMove(UINT nFlags, CPoint point); 248 afx_msg void OnRButtonDown(UINT nFlags, CPoint point); 249 afx_msg void OnRButtonUp(UINT nFlags, CPoint point); 250 afx_msg void OnButtonNoRotation(); 251 afx_msg void OnButtonStandardViewXy(); 252 afx_msg void OnButtonStandardViewXyz(); 253 afx_msg void OnButtonStandardViewXz(); 254 afx_msg void OnButtonStandardViewYz(); 255 afx_msg void OnButtonStandardViewRotate(); 256 afx_msg void OnButtonFit(); 257 afx_msg void OnButtonMoveAxes(); 258 afx_msg void OnTimer(UINT_PTR nIDEvent); 259 afx_msg void OnButtonSaveImage(); 260 afx_msg void OnButtonFramesRecording(); 261 //}}AFX_MSG 262 afx_msg LRESULT OnRedraw(WPARAM, LPARAM); 263 BOOL ToolBarToolTipsSupport( UINT id, NMHDR * pTTTStruct, LRESULT * pResult ); 264 DECLARE_MESSAGE_MAP() 265 public: 266 // afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); 267 }; 268 269 ///////////////////////////////////////////////////////////////////////////// 270 271 //{{AFX_INSERT_LOCATION}} 272 // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 273 274 #endif // !defined(AFX_GLDRAWWND_H__C4A1F1E3_E308_11D4_BA16_000021038B9A__INCLUDED_) 275