0029367: Visualization - simplify interface of V3d_View and V3d_Viewer
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / ScaleDlg.cpp
CommitLineData
7fd59977 1// ScaleDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "ScaleDlg.h"
6
7#ifdef _DEBUG
8#define new DEBUG_NEW
9#undef THIS_FILE
10static char THIS_FILE[] = __FILE__;
11#endif
12
13/////////////////////////////////////////////////////////////////////////////
14// ScaleDlg dialog
15
16
92efcf78 17ScaleDlg::ScaleDlg(Handle(V3d_View) Current_V3d_View, CViewer3dView* pView, CWnd* pParent /*=NULL*/)
7fd59977 18 : CDialog(ScaleDlg::IDD, pParent)
19{
20 //{{AFX_DATA_INIT(ScaleDlg)
21 myCurrent_V3d_View = Current_V3d_View;
22 myView=pView;
23 m_ScaleX = 0;
24 m_ScaleY = 0;
25 m_ScaleZ = 0;
26 //}}AFX_DATA_INIT
27}
28
29
30void ScaleDlg::DoDataExchange(CDataExchange* pDX)
31{
32 CDialog::DoDataExchange(pDX);
33 //{{AFX_DATA_MAP(ScaleDlg)
34 DDX_Control(pDX, IDC_SLIDER_SCALEX, m_ScaleXSlidCtrl);
35 DDX_Control(pDX, IDC_SLIDER_SCALEY, m_ScaleYSlidCtrl);
36 DDX_Control(pDX, IDC_SLIDER_SCALEZ, m_ScaleZSlidCtrl);
37 DDX_Text(pDX, IDC_EDIT_SCALEX, m_ScaleX);
38 DDV_MinMaxInt(pDX, m_ScaleX, 1, 100);
39 DDX_Text(pDX, IDC_EDIT_SCALEY, m_ScaleY);
40 DDV_MinMaxInt(pDX, m_ScaleY, 1, 100);
41 DDX_Text(pDX, IDC_EDIT_SCALEZ, m_ScaleZ);
42 DDV_MinMaxInt(pDX, m_ScaleZ, 1, 100);
43 //}}AFX_DATA_MAP
44}
45
46
47BEGIN_MESSAGE_MAP(ScaleDlg, CDialog)
48 //{{AFX_MSG_MAP(ScaleDlg)
49 ON_EN_CHANGE(IDC_EDIT_SCALEX, OnChangeEditScaleX)
50 ON_EN_CHANGE(IDC_EDIT_SCALEY, OnChangeEditScaleY)
51 ON_EN_CHANGE(IDC_EDIT_SCALEZ, OnChangeEditScaleZ)
52 ON_WM_HSCROLL()
53 //}}AFX_MSG_MAP
54END_MESSAGE_MAP()
55
56/////////////////////////////////////////////////////////////////////////////
57// ScaleDlg message handlers
58BOOL ScaleDlg::OnInitDialog()
59{
60 CDialog::OnInitDialog();
61
62 int ScaleX = myView->scaleX;
63 int ScaleY = myView->scaleY;
64 int ScaleZ = myView->scaleZ;
65
66 m_ScaleX=ScaleX;
67 m_ScaleXSlidCtrl.SetRange(0, 100, TRUE);
68 m_ScaleXSlidCtrl.SetPos( ScaleX );
69
70 m_ScaleY=ScaleY;
71 m_ScaleYSlidCtrl.SetRange(0, 100, TRUE);
72 m_ScaleYSlidCtrl.SetPos( ScaleY );
73
74 m_ScaleZ=ScaleZ;
75 m_ScaleZSlidCtrl.SetRange(0, 100, TRUE);
76 m_ScaleZSlidCtrl.SetPos( ScaleZ );
77
78 UpdateData(FALSE);
79
80 return TRUE; // return TRUE unless you set the focus to a control
81 // EXCEPTION: OCX Property Pages should return FALSE
82}
83
84void ScaleDlg::OnChangeEditScaleX()
85{
86 UpdateData(TRUE);
87
88 m_ScaleXSlidCtrl.SetPos( m_ScaleX );
89 myView->scaleX = m_ScaleX;
90
91 myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ );
92 myCurrent_V3d_View->Update();
93
94 TCollection_AsciiString Message("\
95myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ);\n\
96\n\
97myCurrent_V3d_View->Update();\n\
98 ");
99
100 // Update The Result Message Dialog
101 myView->GetDocument()->UpdateResultMessageDlg("SetAxialScale",Message);
102}
103
104void ScaleDlg::OnChangeEditScaleY()
105{
106 UpdateData(TRUE);
107
108 m_ScaleYSlidCtrl.SetPos( m_ScaleY );
109 myView->scaleY = m_ScaleY;
110
111 myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ );
112 myCurrent_V3d_View->Update();
113
114 TCollection_AsciiString Message("\
115myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ);\n\
116\n\
117myCurrent_V3d_View->Update();\n\
118 ");
119
120 // Update The Result Message Dialog
121 myView->GetDocument()->UpdateResultMessageDlg("SetAxialScale",Message);
122}
123
124void ScaleDlg::OnChangeEditScaleZ()
125{
126 UpdateData(TRUE);
127
128 m_ScaleZSlidCtrl.SetPos( m_ScaleZ );
129 myView->scaleZ = m_ScaleZ;
130
131 myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ );
132 myCurrent_V3d_View->Update();
133
134 TCollection_AsciiString Message("\
135myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ);\n\
136\n\
137myCurrent_V3d_View->Update();\n\
138 ");
139
140 // Update The Result Message Dialog
141 myView->GetDocument()->UpdateResultMessageDlg("SetAxialScale",Message);
142}
143
144void ScaleDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
145{
146 m_ScaleX = m_ScaleXSlidCtrl.GetPos();
147 m_ScaleY = m_ScaleYSlidCtrl.GetPos();
148 m_ScaleZ = m_ScaleZSlidCtrl.GetPos();
149
150 if(m_ScaleX<=0)
151 {
152 m_ScaleX=1;
153 m_ScaleXSlidCtrl.SetPos( 1 );
154 }
155
156 if(m_ScaleY<=0)
157 {
158 m_ScaleY=1;
159 m_ScaleYSlidCtrl.SetPos( 1 );
160 }
161
162 if(m_ScaleZ<=0)
163 {
164 m_ScaleZ=1;
165 m_ScaleZSlidCtrl.SetPos( 1 );
166 }
167
168 UpdateData(FALSE);
169
170 myView->scaleX = m_ScaleX;
171 myView->scaleY = m_ScaleY;
172 myView->scaleZ = m_ScaleZ;
173
174 myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ );
175 myCurrent_V3d_View->Update();
176
177 TCollection_AsciiString Message("\
178myCurrent_V3d_View->SetAxialScale( m_ScaleX, m_ScaleY, m_ScaleZ);\n\
179\n\
180myCurrent_V3d_View->Update();\n\
181 ");
182
183 // Update The Result Message Dialog
184 myView->GetDocument()->UpdateResultMessageDlg("SetAxialScale",Message);
185
186 CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
187}
188