1 //#**************************************************************
2 //# filename:             WCDriver3DDlg.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 #if !defined(AFX_WCDriver3DDLG_H__270A972D_93F5_46BD_8737_55C336E60107__INCLUDED_)
24 #define AFX_WCDriver3DDLG_H__270A972D_93F5_46BD_8737_55C336E60107__INCLUDED_
25 
26 #if _MSC_VER > 1000
27 #pragma once
28 #endif // _MSC_VER > 1000
29 
30 /////////////////////////////////////////////////////////////////////////////
31 // CWCDriver3DDlg dialog
32 
33 #include "mbs_interface.h"
34 #include "..\WorkingModule\WinCompDriverInterface.h"
35 #include "gldrawwnd.h"
36 #include "DialogDataManager.h"
37 #include "FEdrawingOptions.h"
38 #include "OutputDialog.h"
39 #include "DialogViewingOptions.h"
40 //#include "DialogComputationSettings.h" //$ DR 2013-10-16 removed
41 #include "DlgBodyJointOpt.h"
42 #include "OpenGLDlg.h"
43 #include "DlgOneEditCtrl.h"
44 #include "ComputeEigenmodes.h"
45 //#include "DialogComputationSettings.h" //$ DR 2013-10-16 removed
46 #include "DialogProgressBar.h"
47 #include "PlotToolDlg.h"
48 #include "DrawWindow2D.h"
49 #include "afxwin.h"
50 
51 const int MAX_SENSOR_WATCH = 20;
52 const int MAX_AUTOSAVE_MODELS = 3;	//$ DR 2013-05-21
53 #define WM_CLOSE_EV_WINDOW (WM_USER + 3)
54 
55 class CWCDriver3DDlg : public CDialog, public WCDInterface::UserInterface, public WCDInterface::ComputationFeedBack
56 {
57 	//variables:
58 	CRect PictureRect;
59 	int enableOutputText;
60 
61 	typedef WCDInterface * (*PExpFn)();		// exported-from-dll function type
62 	HINSTANCE hWorkingDll;
63 	// pointer to a function exported from the dll
64 	PExpFn pExpFn;
65 	WCDInterface * pWCDI;
66 
67 	CGLDrawWnd GLDrawWnd;
68 
69 	HCURSOR hCursDragHor, hCursCross;
70 
71 	void PositionButtons();
72 
73 	CDialogDataManager DialogDataManager;
74 	FEDrawingOptions DialogFEDrawingOptions;
75 	COutputDialog dialogComputationOutput;
76 	DialogViewingOptions dialogViewingOptions;
77 	//DialogComputationSettings dialogComputationSettings;	//$ DR 2013-10-16 removed
78 
79 	DialogBodyJointOptions dialogBodyJointOptions;
80 	DialogOpenGLOptions dialogOpenGLOptions;
81 	ComputeEigenmodes computeEigenmodes;
82 	CDialogProgressBar dialogProgressbar;
83 
84 	CDrawWindow2DDlg Dialog2DView;
85 	TArray<CPlotToolDlg*> PlotToolArray;
86 
87 	CDialogOneEditControl* sensorwatchctrl[MAX_SENSOR_WATCH];
88 
89 	int fileopened;
90 	int model_modified;
91 
92 	//TArray<int> asv_models; //$ DR 2013-05-21
93 	mystr asv_models;//$ DR 2013-05-21
94 
95 	void ReadConfigFile();
96 
97 // Construction
98 public:
99 	CWCDriver3DDlg(CWnd* pParent = NULL);	// standard constructor
100 	~CWCDriver3DDlg();
101 
GetWCDInterface()102 	WCDInterface * GetWCDInterface() { return pWCDI; }
103 
104 	virtual void SetModelModified(int mod=1) {model_modified = mod;}
GetModelModified()105 	virtual int GetModelModified() const {return model_modified;}
106 
107 	CString m_ConsoleText_buffer;				// contains short string to append ( buffer for
108 	CString m_ConsoleText_append;				// contains short string to append ( this is the stacked text
109 	int update_text_action_flag;				// choses routine to call in OutputDlg: 0 = full update, 1 = append, 2 = replace
110 	CRITICAL_SECTION uses_append_text;  // ensure that appendstring is not changed by AddText while processed by OnUpdateText
111 
GetOutputDialogText()112 	virtual const CString& GetOutputDialogText() const {return m_ConsoleText;}
113 
114 	//convert some internal settings (window position, open dialog windows, etc.) to EDC
115 	virtual void Configuration2EDC(ElementDataContainer& edc);
116 	//convert EDC to some internal settings (window position, open dialog windows, etc.)
117 	virtual void EDC2Configuration(const ElementDataContainer& edc);
118 
119 // Dialog Data
120 	//{{AFX_DATA(CWCDriver3DDlg)
121 	enum { IDD = IDD_WCDRIVER3D_DIALOG };
122 	CString	m_ConsoleText;						// full output string
123 	//}}AFX_DATA
124 
125 	// ClassWizard generated virtual function overrides
126 	//{{AFX_VIRTUAL(CWCDriver3DDlg)
127 	protected:
128 	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
129 	//}}AFX_VIRTUAL
130 
131 public: //AD 2013-07-08: functions should be public so other Dialogs can use them (via pWCDI pointer)
132 // implementation of WCDInterface::UserInterface
133 	virtual void InstantMessageText(const char * );
134 	virtual void StatusText(const char * );
135 	virtual void AddText(const char * );
136 	virtual int CreateMissingDirectory(const char * );
137 	virtual void SleepX(int xMilliseconds);
138 	virtual void SetPlotToolRedrawTimer(int flag_onoff, int delay_ms = 1000);		//$ AD 2011-02 new timer: PlotToolRefreshTimer
139 //	virtual void OnTimer(UINT_PTR nIDEvent);
140 	//TODO
AssureTextIsVisible()141 	virtual void AssureTextIsVisible() {}
142 
143 // implementation of WCDInterface::ComputationFeedBack
144 	void ResultsUpdated(int flag);
145 	void FinishedComputation();
146 	void PausedComputation();
RedrawNewResults()147 	bool RedrawNewResults() { return DialogDataManager.RedrawNewResults(); }
148 
149 	virtual int CallWCDriverFunction(int action, int option = 0, int value = 0, ElementDataContainer* edc = NULL);
150 
151 	//add element; if option&1 -> element is added; returns 0 if dialog is canceled
152 	virtual int EditElementProperties(int nelem, int option = 0);
153 
154 	virtual void GetSensorWatchDialog(CDialogOneEditControl*& watch, int& dialognum);
155 
156 	// select (autocreate) a PlotToolDialog
157 	virtual int GetPlotToolDlg(CPlotToolDlg*& plottool, int number = 0);
158 
159 	// create a new PlotToolDialog
160 	virtual int CreatePlotToolDlg(CPlotToolDlg*& plottool);
161 
162 	// remove the PlotToolDlg from the list
163 	virtual int DeletePlotToolDlg(CPlotToolDlg* plottool);
164 
165 protected:
166   // display Rect for i-th PlotTool (Sensor Watch)
167 	CRect ComputeDisplayRectForSensorWatch(int i);
168 
169 	//virtual void AddConstraint(int mode);
170 	virtual void RemoveExperimentalMenuItems();
171 	virtual void ModelChanged();
172 	virtual void DisplaySelectedModelName();
173 	virtual void AddRecentFile(const char * filename); 	//$ DR 2012-12-06 add "filename" to list of recent files and resort this list
174 	virtual void AutoSavembs();	//$ DR 2013-03-19
175 
176 // Implementation
177 protected:
178 	HICON m_hIcon;
179 
180 	// Generated message map functions
181 	//{{AFX_MSG(CWCDriver3DDlg)
182 	virtual void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu);
183 	virtual BOOL OnInitDialog();
184 	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
185 	afx_msg HCURSOR OnQueryDragIcon();
186 	afx_msg void OnSize(UINT nType, int cx, int cy);
187 	afx_msg void OnButtonGo();
188 	afx_msg void OnButtonPause();
189 	afx_msg void OnPaint();
190 	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
191 	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
192 	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
193 	afx_msg void OnClose();
194 	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
195 	afx_msg void OnTimer(UINT_PTR nIDEvent);
196 
197 	//}}AFX_MSG
198 	afx_msg LRESULT OnUpdateText(WPARAM, LPARAM);
199 	afx_msg LRESULT OnButtonGoMessage(WPARAM, LPARAM);
200   DECLARE_MESSAGE_MAP()
201 
202 
203 	bool bClosingDialog;
204 	void OnCancel();
205 public:
206 	afx_msg void OnBnClickedButton1();
207 	afx_msg void OnBnClickedButtonDrawres();
208 	afx_msg void OnBnClickedButtonDrawres2();
209 	afx_msg void OnBnClickedButtonTexres();
210 	afx_msg void OnBnClickedButtonTexres2();
211 	afx_msg void OnBnClickedButtonGeneraloptions();
212 	afx_msg void OnResultsDatamanager();
213 	afx_msg void OnResultsViewoutput();
214 	afx_msg void OnComputationReset();
215 	afx_msg void OnComputationPrinttimings();
216 	afx_msg void OnResultsShowoutputstatictext();
217 	afx_msg void OnOptionsSaveconfiguration();
218 	afx_msg void OnOptionsSaveSolverOptions();
219 	afx_msg void OnOptionsSaveHotintOptions();
220 	afx_msg void OnResultsEnableoutput();
221 	afx_msg void OnMove(int x, int y);
222 	afx_msg void OnViewFeDrawingoptions();
223 	afx_msg void OnViewViewingoptions();
224 //	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
225 	//afx_msg void OnComputationComputationoptions();	//$ DR 2013-10-16 removed
226 	afx_msg void OnComputationComputeEigenmodes();
227 	afx_msg void OnViewRigidbodyJointOptions();
228 	afx_msg void OnEditEditbody();
229 	//afx_msg void OnComputationAssemblesystem();
230 	afx_msg void OnViewOpengloptions();
231 	//afx_msg void OnComputationAssigninitialvector();
232 	afx_msg void OnFileExit();
233 	afx_msg void OnFileNewmbs();
234 	afx_msg void OnFileSavembs();
235 	afx_msg void OnEditEditsensor();
236 	afx_msg void OnFileOpenmbs();
237 	afx_msg void OnFileSavembsas();
238 	afx_msg void OnSpecialAddsensor();
239 	afx_msg void OnResultsPlotsensor();
240 	afx_msg void OnSpecialAddbody();
241 	afx_msg void OnResultsSensorwatch();
242 	afx_msg void OnFileRecentfile1();
243 	afx_msg void OnBnClickedButtonRecentFile();
244 	afx_msg void OnSpecialAddgeomelement();
245 	afx_msg void OnEditEditgeomelement();
246 	afx_msg void OnSystemShowsystemproperties();
247 	afx_msg void OnAddobjectAddnode();
248 	afx_msg void OnEditEditnode();
249 	afx_msg void OnSystemChecksystem();
250 	afx_msg void OnHelpAbout();
251 	afx_msg void OnViewDefaultview1();
252 	afx_msg void OnViewXY();
253 	afx_msg void OnViewXZ();
254 	afx_msg void OnViewYZ();
255 	afx_msg void OnComputationLoadinitialvector();
256 	afx_msg void OnComputationStoresolutionvector();
257 	afx_msg void OnMenuHelp();
258 	afx_msg void OnViewRobotoptions();
259 	afx_msg void OnEditEditmaterial();
260 public:
261 	afx_msg void OnSystemEditmodelparameters();
262 public:
263 	afx_msg void OnSystemLoadmodelparameter();
264 public:
265 	afx_msg void OnSystemSavemodeldata();
266 public:
267 	afx_msg void OnViewEditalloptions();
268 public:
269 	afx_msg void OnResultsPlot2sensorsxy();
270 public:
271 	afx_msg void OnResultsPlotnsensors();
272 public:
273 	afx_msg void OnViewShowprogressbar();
274 public:
275 	afx_msg void OnResultsPlottooldialog();
276 	afx_msg void OnBnClickedOptionsSaveconfiguration();
277 	afx_msg void OnFileSelectmodel();
278 	afx_msg void OnEditEditsolveroptions();
279 	afx_msg void OnEditEdithotintoptions();
280 	afx_msg void OnEditComputationSteps();
281 	afx_msg void OnEditEditLoad();
282 	afx_msg void OnAddload();
283 	afx_msg void OnViewShowContolWindow();
284 	afx_msg void OnAddobjectAddmaterial();
285 	afx_msg void OnAddbeam3dproperties();
286 	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
287 	afx_msg void OnAddconnectorKinematicpairs();
288 	afx_msg void OnAddconnectorControlelement();
289 	afx_msg void OnBnClickedButtonSaveMbs();
290 	afx_msg void OnEditDeleteLoad();
291 	afx_msg void OnEditDeleteGeomelement();
292 	afx_msg void OnEditDeleteSensor();
293 	afx_msg void OnEditDeleteNode();
294 	afx_msg void OnEditDeleteMaterial();
295 	afx_msg void OnEditDeleteElement();
296 	afx_msg void OnEditUndo();
297 	afx_msg void OnSystemRunmacro();
298 };
299 
300 //{{AFX_INSERT_LOCATION}}
301 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
302 
303 #endif // !defined(AFX_WCDriver3DDLG_H__270A972D_93F5_46BD_8737_55C336E60107__INCLUDED_)
304