-
Notifications
You must be signed in to change notification settings - Fork 1
/
SectionCutDlg.cpp
executable file
·154 lines (127 loc) · 4.64 KB
/
SectionCutDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
///////////////////////////////////////////////////////////////////////
// XBeamRate - Cross Beam Load Rating
// Copyright © 1999-2024 Washington State Department of Transportation
// Bridge and Structures Office
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the Alternate Route Open Source License as
// published by the Washington State Department of Transportation,
// Bridge and Structures Office.
//
// This program is distributed in the hope that it will be useful, but
// distribution is AS IS, WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the Alternate Route Open Source License for more details.
//
// You should have received a copy of the Alternate Route Open Source
// License along with this program; if not, write to the Washington
// State Department of Transportation, Bridge and Structures Office,
// P.O. Box 47340, Olympia, WA 98503, USA or e-mail
// Bridge_Support@wsdot.wa.gov
///////////////////////////////////////////////////////////////////////
// SectionCutDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "SectionCutDlg.h"
#include <ostream>
#include <EAF\EAFDisplayUnits.h>
#include <EAF\EAFDocument.h>
#include <IFace\PointOfInterest.h>
#include <IFace\Pier.h>
#include <MFCTools\Format.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSectionCutDlg dialog
CSectionCutDlg::CSectionCutDlg(PierIDType pierID,const xbrPointOfInterest& initialPoi,CWnd* pParent)
: CDialog(CSectionCutDlg::IDD, pParent),
m_PierID(pierID),
m_SliderPos(0)
{
m_InitialPOI = initialPoi;
}
void CSectionCutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSectionCutDlgEx)
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_SLIDER, m_Slider);
DDX_Control(pDX, IDC_LOCATION, m_Label);
DDX_Slider(pDX, IDC_SLIDER, m_SliderPos);
}
BEGIN_MESSAGE_MAP(CSectionCutDlg, CDialog)
//{{AFX_MSG_MAP(CSectionCutDlg)
ON_WM_HSCROLL()
ON_COMMAND(ID_HELP, OnHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSectionCutDlg message handlers
BOOL CSectionCutDlg::OnInitDialog()
{
UpdatePOI();
CDialog::OnInitDialog();
// initial the slider range
m_Slider.SetRange(0,(int)(m_vPOI.size()-1)); // the range is number of spaces along slider...
// initial the slider position to the current poi location
IndexType pos = m_vPOI.size()/2; // default is mid-span
std::vector<xbrPointOfInterest>::iterator iter;
for ( iter = m_vPOI.begin(); iter != m_vPOI.end(); iter++ )
{
xbrPointOfInterest& poi = *iter;
if ( poi.GetID() == m_InitialPOI.GetID() )
{
pos = (iter - m_vPOI.begin());
}
}
m_Slider.SetPos((int)pos);
UpdateSliderLabel();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSectionCutDlg::OnHelp()
{
EAFHelp( EAFGetDocument()->GetDocumentationSetName(), IDH_SECTION_CUT );
}
xbrPointOfInterest CSectionCutDlg::GetPOI()
{
ASSERT((int)m_SliderPos < (int)m_vPOI.size());
xbrPointOfInterest poi = m_vPOI[m_SliderPos];
return poi;
}
void CSectionCutDlg::UpdatePOI()
{
CComPtr<IBroker> pBroker;
EAFGetBroker(&pBroker);
GET_IFACE2(pBroker,IXBRPointOfInterest,pPOI);
m_vPOI = pPOI->GetXBeamPointsOfInterest(m_PierID);
if (m_Slider.GetSafeHwnd() != nullptr )
{
m_Slider.SetRange(0,(int)(m_vPOI.size()-1)); // the range is number of spaces along slider...
// subtract one so we don't go past the end of the array
}
}
void CSectionCutDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
UpdateSliderLabel();
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CSectionCutDlg::UpdateSliderLabel()
{
CComPtr<IBroker> pBroker;
EAFGetBroker(&pBroker);
GET_IFACE2(pBroker,IEAFDisplayUnits,pDisplayUnits);
GET_IFACE2(pBroker,IXBRPointOfInterest,pPoi);
ASSERT((int)m_SliderPos < (int)m_vPOI.size());
xbrPointOfInterest poi = m_vPOI[m_Slider.GetPos()];
Float64 Xp = pPoi->ConvertPoiToPierCoordinate(m_PierID,poi);
GET_IFACE2(pBroker,IXBRPier,pPier);
Float64 Xxb = pPier->ConvertPierToCrossBeamCoordinate(m_PierID,Xp);
CString strLabel;
strLabel.Format(_T("Location from Left Side of Cross Beam, %s"),::FormatDimension(Xxb,pDisplayUnits->GetXSectionDimUnit()));
m_Label.SetWindowText(strLabel);
}