An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ......

38
AN APPLICATION FOR RETAINING WALL ANALYSIS UNDERGRADUATE COMPUTER SCIENE PROJECT 415.385AT Guanglun Yu February 2000

Transcript of An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ......

Page 1: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

AN APPLICATION FOR RETAINING WALL ANALYSIS

UNDERGRADUATE COMPUTER SCIENE PROJECT

415.385AT

Guanglun Yu

February 2000

Page 2: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 1

ABSTRACTRetaining Walls are used for providing slope stability. The calculation of thewall dimensions of a particular earth-retaining problem requires several runs ofanalyses and thus assistance of a computer application is naturally desirable.To this end, a user-friendly application is required to carry out analysis ofretaining wall structures. The application needs to check on the stability of thewall for the user-defined data and soil properties. Subsequently, results fromthe analysis should be displayed on screen so that the user can either acceptthe parameters or invoke a re-analysis session.

With this in view, an application has been developed to provide an interactive-interface to analyse and design retaining wall structures.

This application is written in C++ programming language. Microsoft Visual C++and Borland C++ Builder are compared in the light of developing thisapplication.

Page 3: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 2

1. Introduction

Retaining wall is one of the solutions for preventing a slope or an unstableearth from moving or collapsing. Design Engineers normally carry outseveral analyses to find the most cost-effective dimensions for retainingwalls. Since it is a repetitive and time-consuming task it can be automatedto speed up the process. Therefore, an application has been developed toperform the analysis and design of earth retaining structures.

Analysis and design of retaining walls involve stability checks and walldetailing. Thus the application needs to cater for both requirements. Toachieve an optimized, wall parameters, civil engineers normally assume aset of data based on experience. The assumed data is then checked for thestability of the wall. If the checks fail, the corresponding data need to bechanged and checked again, until the stability checks are satisfied.

For the ease of use, this application requires a user-friendly interface. Likenormal windows application, with the GUI feature, this application should bedriven by menus, toolbar buttons, and command buttons. The data, eitheroptimized or not, must be saved for future use. If a user double-clicks adata file of this type, the application will be launched with this data fileloaded, so the user can immediately perform analysis and design.

This project implements the application by means of two C++ IntegratedDevelopment Environments (IDE), Microsoft Visual C++ (VC++) andBorland C++ Builder (BCB). Therefore, there are two editions of theapplication created using two different OO programming structures.

The VC++ edition uses MFC classes while BCB edition uses VCL classes. Thedesign ideas for these two editions for the implementation are nearly thesame, but the programming structures are different. Discussion on thedifferences and similarities between these structures are made for the twoeditions of the application.

This application was first implemented in VC++ and then in BCB. The timetaken to complete the application using BCB is less than the time taken todevelop the application using VC++.

Some technical problems were encountered during the implementation ofthis application, mainly with the VC++ edition. The reason is due to thecomplicated programming structure and poor documentation of VC++.

Summary of points for using the two IDEs are listed at the end of thisreport.

Page 4: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 3

Fig 1

2. Retaining Wall Model

Figure 1 illustrates a typical retainingwall. The required data for analysis anddesign of the wall are listed below(prefixed with * are the target data):

Wall properties:

Retaining Height – HrWall Density -- DwPassive Earth Height – HpBase Thickness – TbKey Thickness – TkStem Thickness – TsToe Length – LtHeel Length – LhKey Length – Lk

Soil properties:

Angle of Backfill – AbDry Density of Soil – DsEffective Angle of Shearing Resistance – AeFriction Angle (Concrete and Foundation material) – AfAdhesion – Cb

Loads:

Surcharge - Ws

In the application and report the engineering notations are used forsimplicity, eg. Hr stands for Retaining Height.

All these data are needed for carrying out the stability check and designingthe retaining walls. The data prefixed with * sign are the target data thatneed to be optimized.

The stability check covers three sub-checks plus pre-calculations. So thetask can be categorized as:• Pre-calculations (also called Earth Pressure Calculation)• The check of Factor of Safety Against Overturning - Stability Check 1• The check of Factor of Safety Against Sliding- Stability Check 2• The check of Factor of Safety Against Bearing Failure (also including the

check of Distance from the Tow to the Point Where Reaction ForceIntersects the Base) - Stability Check 3

Page 5: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 4

The factor of safety (FS) against overturning must be greater than 2, whilstFS for sliding must be greater than 1.5, and for bearing failure is 3.

Also the distance from the tow to the point where reaction force intersectsthe base should not be less than one third and not greater than two third ofthe total Base Length (B). If any of these criteria are not met, then the dataneed to be revised and re-analysed until all these three sub-checks aresatisfied.

These formulas are listed here by the order of calculation:

Pre-calculations (Earth Pressure Calculation – based on RankineTheory):

Description Notation and Formula Formula Index

Earth Pressure Height(m) He= Hr + Hp + Tb + Tk (1)

WsEquivalent Height of Surcharge Hs = ----- (2)

(kN/m2) Ds

Total Height (m) H = He + Hs (3)

If Cb equals to zero, then carry out formulas 4,5,6,7 (or 8).

cos(Ab) - cos2(Ab)-cos2(Ae)Active Earth Pressure Ka = cos(Ab) (4)

Coefficient cos(Ab) + cos2(Ab)-cos2(Ae)

H2

Active Earth pressure Pa = Ka Ds ------ (5)Per Meter Wall 2

cos(Ab) + cos2(Ab)-cos2(Ae)Passive Earth Pressure Kp = cos(Ab) (6)

Coefficient cos(Ab) - cos2(Ab)-cos2(Ae)

If Passive Earth Pressure is taken into account, then (Hp + Tb – 1.5)2

Passive Earth Pressure Pp = Kp Ds ------------------ (7)Per Meter Wall 2

Else then Pp = 0 (8)

Stability Check 1 -- Overturning:H

Overturning Moment Mo = Pa cos(Ab) --- - Tk (9)3

Base Length B = Lt + Ts + Lh (10)

Retaining Moments Mwall = Dw (Hr+Hp)Ts(Lt+Ts/2)+(B2/2)Tb+Lk Tk(B-Lk/2) (11)

Page 6: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 5

Lh Lh2 tan(Ab) 2Msoil=Ds Lh(Hr+Hp)(Lt+Ts+---)+ ------------(Lt+Ts+---Lh) (12)

2 2 3

If Surcharge is not zero thenMaep = Pa sin(Ab) B (13)

ElseMaep = ( Ka Ds He2 /2 ) sin(Ab) B (14)

Mpep = Pp ( Hp + Tb – 1.5) /3 (15)

Retaining Moment Mr = Mwall + Msoil + Maep + Mpep (16)

Factor of Safety Against Overturning = Mr / Mo (17)

Stability Check 2 – Sliding:

Sliding Force Fs = Pa cos(Ab)

Vertical ForceIf Surcharge is greater than zero, then

Fv = (Hr+Hp)Ts + B Tb + Lk Tk Dw + (18)

(Lt+Hp)Lh + Lh2 tan(Ab)/2 + (B – Lk)Tk Ds +

Pa sin(Ab)Else

Fv = (Hr+Hp)Ts + B Tb + Lk Tk Dw + (19)

(Lt+Hp)Lh + Lh2 tan(Ab)/2 + (B – Lk)Tk Ds +

Ka Ds He2

------------ sin(Ab) 2

Restraining ForceIf Tk is not zero, then

Fr = Cb B + Fv tan(Ab) Ae + Pp (20)Else

Fr = Cb B + Fv tan(Ab) Af + Pp (21)

Factor of Safety against Sliding = Fr / Fs (22)

Stability Check 3 – Bearing:

Distance from the tow to the point where reaction force intersects the baseMr – Mo

d = ----------- (23)Fv

BLoad eccentricity e = --- - d (24)

2

Page 7: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 6

Effective Width of the Base B’ = B – 2e (25)

Pressure on Base q = Fv / B (26)

Calculation of the ultimate bearing capacity of the soilNq = tan2(45o+Ae /2) epi tan(Ae) (27)

( pi = 3.1415926)Nc = ( Nq – 1 ) cot(Ae) (28)Nr = 1.5(Nq – 1)tan(Ae) (29)

Ultimate bearing capacity of soilqult = Cb Nc + Ds(Hp + Tb)Nq + Ds b Nr / 2 (30)

Factor of Safety Against Bearing Failure = qult / q (31)

3. Application Designing:

3.1 User Interface (UI) Layout

Considering how a user willinteract with the application,first step is to show the inputdata which are either enteredby the user or loaded from adata file. Then data can beprocessed and results can bepresented to the user. Soseveral panels (areas) areneeded in this application; theData Entry panel on the leftfor data input; loading; andthe result panel on the right.

There is a diagram (as illustrated in Fig 1) on the right for helping theuser to understand the notation and symbols. The Data Entry Panelcovers three parts of data: Wall Properties, Soil Properties and Loads.The layout of this user interface is shown in Fig 2.

In the design layout, the Menu and Toolbar Buttons are for application’sWindows’ style commands like “File New”, “Open File”, “Save” and “Exit”.Wall Properties, Soil Properties and Loads hold the data. CommandButtons are for the command Analyse, Design and Done. The top rightpanel holds the illustration picture for references to the data. On thebottom right is the result showing panel.

3.2 Use Case of the Application3.2.1 User inputs new data into the DataEntry pane. If all data entered, button

Analyse enabled. Goto 3.2.33.2.2 Or user can load data from previously stored data file as:

§ Choose menu command “Open” or press toolbar button “Open”.

Fig 2. User Interface layout design

Menu

Data Entry Panel Illustration Graph

Result Panel

Wall Properties

Soil Properties

Loads

Command Buttons

Toolbar Buttons

Page 8: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 7

Fig 3. Application DesigningStructure in VC++

RetainingWall : CDocument

NewFile()OpenFile()SaveFile()SaveAs()DataTransferUI() DataView : CFormView

ValidateInput()DataTransferRtWall()StabilityCheck()EnableAnalyse()EnableDesign()EnableDone()

ResultShow:CEditViewInitiate()SetFont()ShowResult()

IllustrationGraph:CViewResize()

MainFrame : CframeWnd

CSplitterWnd mSpliter2CSplitterWnd mSpliter3

§ Select a data file and load it3.2.3 Press “Analyse” button. First check entry data validity. If not reasonable

data entered, then show invalid data, goto 3.2.1. If all data is valid,continue.

3.2.4 Show the calculation result of stability. If all ok, enable button “Design”,if not, show warning notes, goto 3.2.1 but keep button “Analyse”enabled.

3.2.5 User can save data at any time whenever data is valid or not. When dropdown menu “Save” or toolbar “Save”. If it hasn’t had a file name, thenshow “Save As” dialog box for saving data. If it already has a file name,then just save the data to that file. If user choose “Save As”, there isalways a chance to choose a new file name to save the data.

3.2.6 When point to any items on the data entry pane, there are tooltipsappearing for each item.

3.3 Application Designing Structure

Application Designing Structure for VC++There must be a RetainingWall class for handling the data and aninterface DataView class to interact with the users. Because the existenceof the Result Panel, the ResultShow class also needs to be created andIllustrationGraph class as well.

Why need ResultShow and IllustrationGraph classes instead of included in

the interface class DataView? The result showing panel may need tochange its size frequently to meet the need of showing most resultcontents to the user at one time. So Result Panel is an extra panel. Atthe same time, the DataView Panel may involve more data in the future,thus give the sizable flexibility to users: making all three panels’boundaries adjustable.

This application structure is showed in Fig 3. In this class schema, all thecommunications with files are handled in class RetainingWall, which is the

Page 9: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 8

Fig 4. Application Designing Structure in BCB

RetainingWall

NewFile()OpenFile()SaveFile()SaveAs()DataTransferUI()

TmainForm : TForm

ValidateInput()DataTransferRtWall()StabilityCheck()EnableAnalyse()EnableDesign()EnableDone()

data handling class. It also needs to transfer the loaded data intoDataView class (the user interface). This task is committed byDataTransferUI function. RetainingWall is a root class, it does not derivefrom any others.

MainFrame derives from CframeWnd. It gives a whole frame window forthe user interface. In this class, two important members mSplitter2 andmSplitter3 respond to create three split panes which are holdingDataView, ResultShow and IllustrationGraph user interface classes.

DataView is the main working place which derives from CformView. Itholds and shows the data that are inputted by the users or receives thedata from the transfer of the RetainingWall. It has three main tasks.ValidateInput acts as a input filter, preventing invalid characters enteredinto the application; DataTransferRtWall fulfils the task of transferring theset of whole data to RetainingWall class ( normally for storing into datafiles) at any time once the users choose to save data or any othernecessities. Three functions EnableAnalyse, EnableDesign andEnableDone are for application running cycle state setting. EnableAnalysedetects conditions and then disables or enables Analyse commandbutton, EnableDesign does to Design button and EnableDone does toDone button.

StabilityCheck is the main working function in this application. It firstcheck validity of all data ( Please note that this validity check is differentfrom the one of ValidateInput function ) to see all data is reasonable andin a valid scope, then processes three checks as mentioned in Section 2:Stability Check 1, 2 and 3. Whether or not the checks for validity, andthe three stability checks are satisfied, the result will be showed inResultShow user interface class by calling its ShowResult function.

The IllustrationGraphclass is for a illustrationpurpose of giving usersthe engineeringmeanings of thenotations used inDataView class for thedata. It has a functioncalled Resize to committhe repositioning of the graph every time the size of its holder, createddynamically by mSplitter3 in class MainFrame, changes.

Application Designing Structure for BCBThis edition of structure is designed simpler than in VC++, but the idea issame. There is a RetainingWall class and a MainForm class. But theMainForm class covers all the user interface functions, so the DataView,IllustrationGraph and ResultShow classes in VC++ edition are allintegrated into the MainForm class. Thus, it is lack of the flexibility for

Page 10: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 9

State 3: DesignData lockedAnalyse, Design disabledDone enabled

State 2: AnalyzingData modifiableAnalyse still enabledDesign may enabledDone disabled

State 1: Initiate / DoneExpecting data entry/loadingData modifiableAnalyse may enabledDesign and Done disabled

Click Analyse btn

ClickAnalyse

Click DesignClick Done

Fig 5. Running Cycle

users to drag the borders of DataView and ResultShow panels to meettheir specific view need. This structure is showed in Fig 4.

3.4 State TransitionsThere are three states in this application: Initiate/Done state – state 1,Analyzing state – state 2 and Design state – state 3, which are illustratedin Fig 5.

When application launched, whatever there is a data file loaded or not, atthis moment it is in State 1. In this state, all data are modifiable. Userscan input data by entry or load data from file. Design and Done aredisabled. If all data field are filled, then command button Analyseenabled. If user click on the Analyse, application changes to State 2. Atthis stage, all data are still modifiable. The data validity check andstability checks have been processed and result has been showed. If allthe checks passed, then Design button enabled, otherwise, the Designbutton keep disabled, requiring users re-setup the data again. In thisstage, users can click Analyse button to re-calculate whatever the checkshave been passed or not. If clicking Design button, then users enterState 3. This state is actually the finished state: all checks and designhave been done. This state is used for giving the users a chance to view,store data with the safety of not being allowed to change the finisheddata. In this state, Done button is enabled and Analyse, Design aredisabled. Also, all data fields are not allowed to be modified. If users clickthe Done button, that means the user has saved or processed the designresult. This application shifts to State 1 again. At this moment, the datain all data fields are still the last designing data.

Page 11: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 10

Fig 5. UI of VC++ edition

Fig 6. UI of BCB edition

4. Implementation4.1 User Interface Implementation and Application Functions

Two editions of user interfaces are implemented here. Fig 5 shows the UIVC++ edition and Fig 6 the BCB edition.

The main differencefrom the users point ofview is that in VC++edition the three panelsare resizable – theirborders can be draggedto achieve bigger viewsfor the left data paneland result showingpanel.

They are both menus,toolbar buttons andcommand buttonsdriven. The menus andtoolbar buttons areused for standardWindows applications’operations like dataNew, data Open anddata Save. The leftbottom three commandbuttons are for thespecific functions of thisapplication:Button “Analyse” is forStability Check.“Design” is for materialchoosing, which is notrequired theimplementation at thismoment; so this buttonis only enabled ordisabled. Thus button“Done” is always not reached by the program.

Because most of the data have long names or descriptions, it is quitespace wasteful if put the full names or descriptions directly on theinterface for users’ reference. The application takes the solution of usingengineering notation (like “Hr” stands for “Retaining Height”) plus usingTooltips for showing the full names or descriptions of these data. Everyillustratable data has a corresponding position in the graph on the rightfor users to refer their physical meanings.

Page 12: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 11

The tooltips showing in this UI is a friendly feature. The data filter alsogives the users a good safety tool for data entry. This feature enablesany data field (Edit control) always contains a valid float value. This datafilter refuses data like “56-4”, “dog”, “3D”, “23.56.21” and “-43+3” to beentered into data fields.

This interface implements the running cycle mentioned in Section 3.4.Once all data fields are filled with data, the button Analyse is enabled,the application is at state 1. If the users click on Analyse, it shifts to state2. The users can either change any data if they are not satisfied with thedata already entered or can do the designing process by click on Design ifthe data validity check and stability check are passed. When designingprocess finishes, the application is at state 3. The data fields are locked,preventing the data being changed. The Analyse and Design button aredisabled, but Done button is enabled. If users click on the Done button,this running cycle finishes, a new running cycle begins.

4.2 Application Features and Their Implementation Details

4.2.1 Programming Implementation Structure

In the past, when there were no application wizard, any applications aprogrammer needed to begin at its original start point. So every thingin the application needed be built by the programmer. Theprogrammer might feel boring, because every time he must repeatsome codes in every application. That itself is a programmingstructure.

Today, VC++ Provides programmers with MFC and Application Wizard;BCB with VCL and also Application Wizard for creating or programmingapplications. These utilities may do more and more things for theprogrammers, but thus require the programmer do their application asper the way specified by these utilities. That is that both the two mainC++ programming IDEs provide their own programming structuresand suggest them to be used by the programmers when theyimplement applications. The point is somehow that in the past theprogramming structure was more likely designed and created byprogrammers, but today it seems to has been designed and created bythe IDEs while the programmers just need to follow these structuresto complete their applications.

It is very important today for a programmer to understand theprogramming structures provided by these IDEs.

The programming structures provided by the two IDEs are totallydifferent even at the first glance we would think they are all based onC++ language and all in the Windows operating system. VC++provides a more complicated structure that can associate with or

Page 13: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 12

handle more Windows resources and utilities. BCB provides somesimples solutions for application under Windows operating system andalso provides with their own resources and utilities in a quite clearlogic which makes programmers feel easy to understand and usethese resources and utilities for creating applications.

VC++ Programming StructureThe central point of VC++ programming structure is the concept ofDocument Template which is manipulated as CDocTemplate class inMFC. The idea is quite simple. Every application today needs at leastone user interface (UI) which is called by VC++ the “View”(s), onedata set and the corresponding operations and associations which areall put together as a whole called by VC++ the “Document”(s). TheDocument has a position in MFC called CDocument and the View has aposition in MFC called Cview. View is used to present Documents, soone Document may need more than one Views to make a Documenthave more than one specific presentations[2]. That is why dividing thedata and the presentation into two things, i.e. the Document—Viewmechanism. This is the only best way to implement an application withMDI features.

But there is a requirement for holding the several views and arrangethem shown on the screen. VC++ uses CFrameWnd object to act as ageneral window for the application.

Now we can see what is a Document Template now. The DocumentTemplate is a compound product of association of Document, View andthe general window. So every time when we create an application forWindows system, if we want work best with the MFC and wantframework do as more things as possible, then we should use thisDocument—View architecture for our applications.

To achieve that, create a CDocument derived class, a CView derivedclass and a CFrameWnd derived class, then in the application’s mainroutine CWinApp derived class’s override function InitInstance, createa CDocTemplate object with this set of CDocument, Cview andCFrameWnd added.

We can understand this structure this way: CDocTemplate must workson its contents CDocument, CView and CFrameWnd.

Let’s see what it can do for us. For file operations, if we create fileservices like “Open”, “Save” by using Application Wizard. The VC++IDE will create the code for us (actually hidden to programmers). Asthe programmers, we do not need to care about where to open, howto open and where to write, how to write. All these things will be doneby the framework, and we only need to implement how we transferthe contents of a CArchive variable to or from our application. That isquite easy to do it (also see section 4.2.9).

Page 14: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 13

If we want the feature of the ability of launching the application bydouble-clicking its data file in Windows Explorer, just make aregistration and call the parsing commandline function, framework willregister the file type retrieved from that CDocTemplate object (alsosee section 4.2.10).

Now we investigate the main route of this mechanism – how tointeract with each other and how to transfer data. For transferringdata from Document to View(s), VC++ uses event created byUpdateAllViews function to notify all Views to retrieve the data. On theView’s side, it has a OnUpdate message handler function to receivethis notification and the processing code can be put in there. Fortransferring data from a View to Document, use the View’s methodGetDocument to define a variable to refer to the associated Document,then directly transfer the data to the Document. Because oftransferring data that way, if one Document has more than one Views,then one specific View can use that variable to refer to the Document,next it can use the Document’s method UpdateAllView to notify allother Views which are associated with that Document. That is thepower of Document—View structure.

In this application, this Document—View structure is used. When datais loaded from file, then The function UpdateAllViews is used totransfer the data to View—DataView object. See section 4.2.9 ‘sSolution (22) for where to place the function UpdateAllViews. Fortransferring data from DataView object to the DocumentRetainingWall, see section 4.2.4 ‘s Solution (9).

BCB programming StructureBCB does not provide special mechanism like VC++. Every thing needto be done by programmers. But its VCL structure is quite logical andit provides many convenient components. The programmer would feelquite easy to create the routines for implementing the application.

VCL focuses on how to implement a user problem instead of mustpaying lot of attention on the operating system. It hides the details ofoperating system and Its class structure – properties, methods andevents are quite easy to understand and easy to use. Thus, theprogramming structure for the application is much simpler.

In this application, reference variables are used to refer to each otherbetween RetainingWall and TMainForm for transferring the data.

4.2.2 Resizable Panels (only in edition of VC++)In the application edition of VC++, the resizable panel feature isimplemented for giving users the ability to view each panel – datapanel and result panel more flexibly.

Page 15: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 14

In this application, there are actually three panels. First, divides theMainFrame object window’s client into two child windows(panels) byusing the member variable mSplitter2 in MainFrame object. ThusmSplitter2 has two panels, the left one will hold the DataView object,but the right panel will further be divided, by using mSplitter3 inMainFrame object, into two panels – one top and one bottom forholding IllustrationGraph class object and ResultShow objectrepectively.

Creating first two panels is quite easy by using the followingstatements( putting them in OnCreateClient message handler ofCmainFrame):

--- Solution (1)// create a splitter with 1 row, 2 columns!mSplitter2.CreateStatic(this, 1, 2);//Put the DataView object on left pane – first two parameters row 0,col 0!mSplitter2.CreateView(0,0,

RUNTIME_CLASS(DataView), CSize(0,0), pContext);

In above routine, “this” refers to the CmainFrame object pointer;“pContext” is a pointer to CcreateContext structure which is passed inby VC++ framework in the OnCreateClient message handler. The firststatement uses CreateStatic method of CsplitterWnd to create aCsplitterWnd object window with one row and two columns. Thesecond statement puts the DataView class Object on the row 0, col 0pane (left side pane) to act as an visible interface to users.

The next step is that we want further create two panels on the leftside pane of mSplitter2, but this time, things are not so direct. Look atthe CreateStatic method of CsplitterWnd:

BOOL CsplitterWnd::CreateStatic( CWnd* pParentWnd,int nRows,int nCols,DWORD dwStyle = WS_CHILD | WS_VISIBLE,UINT nID = AFX_IDW_PANE_FIRST );

Note that in routine Solution (1), the fourth and fifth parameters ofusing CreateStatic method are missed out, therefore, default valuesare used. This time, the default nID can not be used, so the fourthparameter dwStyle needs to be set to WS_CHILD | WS_VISIBLE |WS_BORDER. Before setting the fifth parameter nID, we mustunderstand how the nID works on creating splitter windows (panes).When framework creates a splitter window, it needs a unique id to beassigned to that splitter window. VC++ allows up to 256 splitterwindows for one CsplitterWnd object. The scope of id is fromAFX_IDW_PANE_FIRST (0xE900) to AFX_IDW_PANE_LAST (0xE9ff).Thus the number 0xE900 has been used for left pane of mSplitter2object, so this time for the next two splitter windows we will useothers. To do that, we need to use another CsplitterWnd’s methodIdFromRowCol to get the id assigned by the framework to the rightside pane of the mSplitter2 object. The implementation statementslisted as below:

Page 16: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 15

---Solution (2)(Put below in OnCreate or OnCreateClient message handler rountine ofMainFrame )

// create mSplitter3, on the right pane of mSplitter2, with 2 rows, 1 colmSplitter3.CreateStatic(

&mSplitter2, // mSplitter3 is created on mSplitter22, 1, // the new splitter is 2 rows, 1 columnWS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is neededmSplitter2.IdFromRowCol(0, 1) // the id for parent splitter window);

// create IllustrationGraph object on pane row 0, col 0mSplitter3.CreateView(0, 0,

RUNTIME_CLASS(IllustrationGraph), CSize(0,0), pContext);// create ResultShow object on pane row 1, col 0mSplitter3.CreateView(1, 0,

RUNTIME_CLASS(ResultShow), CSize(0,0), pContext);

After the above Solution (1) and (2), the application will have threeresizable panes with the independent behavior of each class object ofthe three – DataView, ResultShow and IllustrationGraph.

4.2.3 TooltipsWhen programming in BCB IDE, it is quite easy to set the controls toshow tooltips. We just need to set the some words as tooltip contentto the Hint property of the control, then set the ShowHint property tovalue True. Then at run time, this control would show tooltip (in BCB,tooltip is called hint) when the user put the mouse on the control.

Using tooltips in VC++ is not simple as in BCB, and more, if the tooltipwe need to show is not for the classes derived from CframeWnd, wemust use message handlers to process showing tooltips. That means,in BCB, the BCB kernel will handle the message handlers internally. Itlets programmer set the tooltip without dealing detail of some complexmechanism; on the other hand, in VC++, creating the tooltip for acontrol needs: first create a CtoolTip object on the control’s containerobject (the control’s parent), then add tooltip words to that control. Sofor tooltips for all controls, the CtoolTip object needs add one tooltipfor each control.

---Solution (3)// m_pToolTip is a member variable in DataView objectm_pToolTip = new CtoolTip;// this pointer refers to DataView objectm_pToolTip->Create(this); // create a CtoolTip control on DataView

// set tooltip words “Retaining Height: Hr” to Cstatic control (Label)// with the id IDC_WALLPROP_HRLBLm_pToolTip->AddTool(GetDlgItem(IDC_WALLPROP_HRLBL),"Retaining Height: Hr");// set tooltip words “Retaining Height: Hr” to CEdit control (Text field)// with the id IDC_WALLPROP_HRm_pToolTip->AddTool(GetDlgItem(IDC_WALLPROP_HR), "Retaining Height: Hr");

………

// do until all required controls have been set with tooltips

Page 17: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 16

Note: This solution is not VC++ suggested, for more information, seechapter 5.4 “Problem with tooltips”.

4.2.4 Reacts to users action – message driven for data inputFor data input by the user, every key-stroke must be detected toprevent non digit characters or other invalid characters entered.Second, there is also a need to detect if all data fields (CEdit controls)have not empty, then button Analyse needs to be enabled.

BCB EditionIn BCB, it is also quite simple: set the OnChange event function foreach data field (in BCB, called TEdit control), then put the processingsubroutine in them. Note in this way, fifteen TEdit control need fifteenOnChange event functions.

---Solution (4)

void __fastcall TForm1::edtWallHrChange(TObject *Sender){

if (!(checkDataEntryStokeValid((TEdit*) Sender)>-1)) enableAnalyse();

}Function “edtWallHrChange” is the default OnChange event handlerfunction name for TEdit control object “edtWallHr”. The parameterSender is actually referred to the “edtWallHr” object itself. Thesubroutine

int checkDataEntryStokeValid (TEdit *)is the data filter discussed in next section, Section 4.2.4 “Data filters”.Function

void enableAnalyse()detects if all data fields have values, then enables button Analyse.

VC++ EditionIn VC++, there are two ways to achieve this by using messageON_CONTROL and message ON_CONTROL_RANGE. We must addthese message handlers by hand into the message map, because theClassWizard does not have these two message handlers. The syntaxfor these two message map are:

ON_CONTROL ( wNotifyCode, id, memberFxn )ON_CONTROL_RANGE ( wNotifyCode, id1, id2, memberFxn )(The wNotifyCode here is EN_CHANGE, the id is the control’s id,id1 is the control range starting id, id2 is the control rangeending id)

For using ON_CONTROL message, follow the steps below:-- For each CEdit control, add one ON_CONTROL message map

macro into class DataView’s message map structure (eg. forCEdit control used for Key Thickness value (see chapter 2), its idis IDC_WALLPROP_TK)

--- Solution (5)

Page 18: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 17

ON_CONTROL ( EN_CHANGE, IDC_WALLPROP_TK, OnChangeTk)OnChangeTk is the message handler function that processes theEN_CHANGE message for the CEdit control IDC_WALLPROP_TKand will be defined at second step

-- Define the “memberFxn” in message map, using the exampleOnChangeTkAdd the declaration of OnChangeTk in VC++ message handlerdeclaration area (just before then end of whole DataView classdeclaration and the macro DECLARE_MESSAGE_MAP( ),actually in

--- Solution (6)//{{AFX_MSG(DataView)

....afx_msg void OnChangeTk( NMHDR * pNotifyStruct, LRESULT * result );

....//}}AFX_MSG

block.

Then create the definition of this EN_CHANGE message handlerfunction as

--- Solution (7)void DataView::OnChangeTk( NMHDR * pNotifyStruct, LRESULT * result ){

//call general processing routineOnChangeEdits(IDC_WALLPROP_TK, pNotifyStruct, result );

}

Note that with ON_CONTROL message map, like in BCB, we willstill need fifteen message handlers for all fifteen CEdit controls.

Here is a efficient way of doing that, only need one message handlerfor all fifteen controls, that is ON_CONTROL_RANGE message.

-- Add ON_CONTROL_RANGE message map macro into classDataView’s message map structure, for all data fields (CEditcontrols)

--- Solution (8)ON_CONTROL_RANGE( EN_CHANGE,

IDC_WALLPROP_HR,IDC_LOAD_WSLBL,OnChangeEdits )

EN_CHANGE is message code for CEdit change event,IDC_WALLPROP_HR is the first id of the control range,IDC_LOAD_WSLBL the last id of the control range,OnChangeEdits is the message handler function.

-- Define the OnChangeEdits function---Solution (9)

//{{AFX_MSG(DataView)....

afx_msg void OnChangeEdits (UINT id,NMHDR * pNotifyStruct,LRESULT * result );

....//}}AFX_MSG

// the definition

Page 19: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 18

void CvwDataEntry::OnChangeEdits( UINT id,NMHDR * pNotifyStruct,LRESULT * result )

{// Data Filter

....// transfer updated data to RetainingWall

// docu points to the RetainingWallswitch (id) { // which data field changedcase IDC_WALLPROP_HR:

docu->Hr= m_RtnHeight;case IDC_WALLPROP_HP:

docu->Hp=m_PsvEarthHeight;....}....

}

By using this solution, when ever a data field control (CEditcontrol) ‘s value gets changed, the message EN_CHANGE is sentand then the function is called. So, parameter id is the messagesender’s id.

By now, we have seen the power of using ON_CONTROL_RANGEmessage. Note the documentation of VC++ does not suggest tohandle controls’ message this way, it suggest use ON_NOTIFYmessage. For more information about this, see section 5.8.

4.2.5 Data filter

The data filter guarantees all key-strokes, entered in data fields, to bevalid number format. So non-digit characters will be prevented frombeing entered, except minus sign “-“ and point sign “.” with correctformat can be entered.

The data filter is placed in OnChangeEdits function (VC++ edition)which is the EN_CHANGE message handler, discussed in section 4.2.3,or function checkDataEntryStokeValid (BCB edition) which is called inthe OnChange message handlers.

Eg. Acceptable character set Unacceptable characterset

“45”, “2.345”, “-50.20”, “dog”, “3D”, “We4”,“12.10.9”,

“-0.34”, “-.456”, “98-”, “.-”, “--”, “+-”, “-+”

“.”, “-”, “-.”

VC++ EditionSolution (10) gives the way implemented in this application. First itcalls “checkEditString” function, if tmp_str includes invalid character,then checkEditString returns that invalid character’s position index(starting from 0). If all characters are valid, it returns –1. If faultIndex

Page 20: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 19

is greater than –1, then the routine takes off the invalid charter andchanges the corresponding control to the valid value.

Note that in VC++ MFC OOP style, direct access to control is notrecommended. VC++ provides a function called UpdateData(BOOLbSaveAndValidate = TRUE) for any CWnd classes to use. IfbSaveAndValidate =TRUE, data will transferred from controls tovariables; if FALSE, data transferred from variables to controls.UpdateData stores or retrieves all data at one time when call it once.

--- Solution (10)// tmp_str (Cstring*), stores the current control’s text valueint faultIndex=checkEditString(tmp_str);if (faultIndex>-1) {

CString s1,s2;if (faultIndex==0) {

s1="";if (tmp_str->GetLength()>1)

s2=tmp_str->Mid(1);else

s2="";}else {

s1=tmp_str->Left(faultIndex);if (tmp_str->GetLength()>faultIndex+1)

s2=tmp_str->Mid(faultIndex+1);else

s2="";

}*tmp_str=(s1+s2);UpdateData(FALSE);tmp_ctrl->SetSel(faultIndex,faultIndex,FALSE);

}else { // if it's a valid input data character

// transfer data to RetainingWall object}

But how checkEditString function decides which character is valid ornot, look at the function’s implementation. In this routine, we can seethat checkEditString will reckon that the parameter string containsinvalid character if “-” is not at first position or more than one “-”symbols appear, or if more than two “.” signs appear or any other nondigit characters appear, thus returns the position index of that invalidcharacter, otherwise returns –1.

--- Solution (11)int DataView::checkEditString(CString* string){

int reslt=-1;if (*string=="") return reslt; //empty string is okint validSign=0; //=0,(no sign),1(one sign at head) or -1 invalid signint validPoint=0;//=0(no point),1(1 point),

//or others (means more than one point--invalid)int validChar=0; //=0, valid character, or

// others (invalid character, other than 0--9,- and.)int start=0;const char* s= LPCTSTR( *string);if (s[0] =='-') {

validSign++;start++;

Page 21: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 20

};for (UINT ii=start;ii<strlen(*string);ii++) {

switch (s[ii]) {case '-':

validSign++;validSign++;break;

case '.':validPoint++;break;

case '0':case '1': case '2':case '3': case '4':case '5':case '6': case '7':case '8': case '9':

break;default:

validChar++;break;

} // end of switch (s[ii])if (validSign>1||validPoint>1||validChar!=0){

// then this char is unvalid charreslt=ii;break;// break from for

}} // end of forreturn reslt;

}

BCB EditionNearly the same as VC++ edition, except that it lets programmer theability to directly use these control variables. So the UpdateDatafunction is not needed.

4.2.6 Controlling the running cycle

Three running states mentioned in section 3.4 are detected andchanged by three functions, enableAnalyse, enableDesign andenableDone. There are three interior flag variables isValidData (true ifapplication has passed the data validity check mentioned in section4.2.6), isValidDesign (true if the application has passed the stabilitycheck) and stageFlag(equals to 0 if new data, to 1 if analysed, to 2 ifdesigned, to 3 or 0 if done) in class DataView.

The enableAnalyse function detects all data fields to see if all of themhave values (At this moment, the values to be detected have passedthe data filter). If so, then button Analyse enabled, otherwise disabled.This function is called when each key stroke happens provided this keystroke pass the data filter. So in VC++ edition, it is placed inOnChangeEdits function which handles the EN_CHANGE message asmentioned in section 4.2.3. In BCB edition, this function is placed inevery TEdit control’s OnChange message handler. The enableDesignfunction detects the interior flag variables isValidDesign and stageFlag.If isValidDesign is true and stageFlag equals 1, then button Designenabled, otherwise, disabled. The enableDesign function is called inStabilityCheck function of DataView class. The enableDone functionenables the button Done only stageFlag equals 2.

Page 22: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 21

IDC_CMDBTN_ANALYSE is the id number of button Analyse,IDC_CMDBTN_DESIGN for button Design and IDC_CMDBTN_DONE forbutton Done. Class Cbutton’s method EnableWindow is used to enableor disable the buttons.

--- Solution (12)void DataView::enableAnalyse(){if ((m_RtnHeight!="") && (m_PsvEarthHeight!="")&&

(m_BaseThick!="") && (m_KeyThick!="") &&(m_StemThick!="") && (m_ToeLength!="") &&(m_HeelLength!="") && (m_KeyLength!="") &&(m_WallDensity!="") && (m_DrySoilDensity!="") &&(m_EfctAngle!="") && (m_FricAngle!="") &&(m_BkfAngle!="") && (m_Adhesion!="") &&(m_Surcharge!="")&& (mn_stageFlag==0||mn_stageFlag==1))((CButton*)(this->GetDlgItem(IDC_CMDBTN_ANALYSE)))->EnableWindow(TRUE);

else((CButton*)(this->GetDlgItem(IDC_CMDBTN_ANALYSE)))->EnableWindow(FALSE);

}

--- Solution (13)// to enable Design buttonvoid DataView::enableDesign(){if (isValidData /*is inputted data initially valid */

&& stageFlag==1) /*is at stage 1 (has analysed) */((CButton*)(this->GetDlgItem(IDC_CMDBTN_DESIGN)))->EnableWindow(TRUE);

else((CButton*)(this->GetDlgItem(IDC_CMDBTN_DESIGN)))->EnableWindow(FALSE);

}

--- Solution (14)/ to enable Done buttonvoid DataView::enableDone(){

if (stageFlag==2) /*is at stage 2 (after Designing */((CButton*)(this->GetDlgItem(IDC_CMDBTN_DONE)))->EnableWindow(TRUE);

else((CButton*)(this->GetDlgItem(IDC_CMDBTN_DONE)))->EnableWindow(FALSE);

}

4.2.7 Data validity check

The Data validity check task is part of whole stability check, and isprocessed by the function doDataValidityCheck in DataView class. Datavalidity check is actually checking the scope validity of all data fields,each of them has their specific scope requirement.

These scope requirements for these 15 data fields are:

Requirements Data Fields for Check> 0 Retaining Height (Hr), Passive Earth Height (Hp),

Base Thickness (Tb), Stem Thickness (Ts), ToeLength (Lt),

Heel Length (Lh), Wall Density (Dw), Dry SoilDensity (Ds),

Page 23: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 22

Friction Angle between concrete base and foundation material (Af),

>=0 Key Thickness (Tk), Key Length (Lk), Adhesion(Cb),

Angle of Backfill (Ab), m_Surcharge

Ab < Ae Angle of Backfill (Ab)

There are also warning check for the data:

Warning Requirement Data Fields for Check20<= AND =<30 Effective Angle of Shearing Resistance (Ae)

The doDataValidityCheck uses a function called dataCheck to makeindividual check. This dataCheck ‘s declaration is

void dataCheck( CString &varStr, CString & varDesc, int mode,CString &note, int &errCnt,double lowLimit=0, double highLimit=0);

Parameter note is of in and out, errCnt is of in and out, others are ofin. The dataCheck convert the string stored in variable varStr todouble, then checks if the value is in the required scope specified byparameters lowLimit and highLimit according to the checking modespecified by parameter mode. If the check is ok, the parameter noteand parameter errCnt will keep unchanged. But if dataCheck hasdetected out of scope to the data, the error message will be addedinto the string of parameter note, also errCnt will be added 1.

--- Solution (15)void DataView::dataCheck(CString &varStr, CString & varDesc, int mode,

CString &note, int &errCnt,double lowLimit, double highLimit)

{// mode =0, errCnt if <=lowLimit; =1 errCnt if >=highLimit;// =2, errCnt if not in (lowLimit,highLimit);// mode =10, errCnt if <lowLimit; =11, errorCnt if >highLimit;// =12, errCnt if not in [lowLimit,highLimit]// mode =100, warn if <=lowLimit; =101 warn if >=highLimit;// =102, warn if not in (lowLimit,highLimit);// mode =110, warn if <lowLimit; =111, warn if >highLimit;// =112, warn if not in [lowLimit,highLimit]char lowstr[32],highstr[32];_gcvt(lowLimit,14,lowstr);_gcvt(highLimit,14,highstr);switch (mode) {

case 0: // error if <=lowLimit;if (!(atof(varStr)>lowLimit)) {

note +="\r\n\tError:\t"+varDesc+"\r\n\t\t must not less than or equal to "+lowstr;

errCnt ++;}break;

case 1: //error if >=highLimit;if (!(atof(varStr)<highLimit)) {

note +="\r\n\tError:\t"+varDesc+"\r\n\t\t must not greater than or equal to "+highstr;

errCnt ++;}break;

case 2: // error if not in (lowLimit,highLimit);

Page 24: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 23

if (!(atof(varStr)<highLimit) || !(atof(varStr)>lowLimit)) {note +="\r\n\tError:\t"+varDesc+"\r\n\t\t must greater than "+

lowstr+" and must less than "+highstr;errCnt ++;

}break;

case 10: // error if <lowLimit;if (atof(varStr)<lowLimit) {

....}break;

case 11: // error if >highLimit;if (atof(varStr)>highLimit) {

....}break;

case 12: //error if not in [lowLimit,highLimit]if (atof(varStr)>highLimit || atof(varStr)<lowLimit) {

....}break;

case 100: // warn if <=lowLimit;if (!(atof(varStr)>lowLimit)) {

....}break;

case 101: //warn if >=highLimit;if (!(atof(varStr)<highLimit)) {

....}break;

case 102: // warn if not in (lowLimit,highLimit);if (!(atof(varStr)<highLimit) || !(atof(varStr)>lowLimit)) {

....}break;

case 110: // warn if <lowLimit;if (atof(varStr)<lowLimit) {

....}break;

case 111: // warn if >highLimit;if (atof(varStr)>highLimit) {

....}break;

case 112: //warn if not in [lowLimit,highLimit]if (atof(varStr)>highLimit || atof(varStr)<lowLimit) {

....}break;

} // end of switch (mode)} // end of function dataCheck

Let us see how doDataValidityCheck calls dataCheck and works.DoDataValidityCheck uses four modes of checks provided bydataCheck, mode 0, 1, 10 and 112. For Hr,Hp,Tb,Ts,Lt,Lh,Dw,Ds andAe, use mode 0 for greter-than-0-check. For Tk, Lk, Cb, Af, Ab andWs, use mode 10 for not-less-than-0-check. Af also need a mode 1check for less-than-Ae-check. Ae also need a mode 112 warning checkfor in-scope-[20,30]-check. If all compulsory check (mode <100) arepassed, then return TRUE, otherwise return FALSE. Check resultincluding error messages is always returned.

--- Solution (16)BOOL DataView::doDataValidityCheck(CString & rsltNote)

Page 25: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 24

{int psudoErri=0,psudoWarni=0;int& errCount=psudoErri;int & warnCount=psudoWarni;char buferr[32];char bufwarn[32];rsltNote=" 1.\tEntry Data Check:";int errFlag =0;double tp1=0,tp2=0;// for checking Hr,Hp, .... , requirement is >0// uses default lowLimit=0, mode =0dataCheck(m_RtnHeight,

CString("Retaining Wall Height (Hr) "), 0,rsltNote,errCount,0);dataCheck(m_PsvEarthHeight,

CString("Passive Earth Height (Hp) "),0, rsltNote, errCount,0); .... // others are same

// for check Tk, Lk, .... , requirement is >=0// uses default lowLimit=0, mode =10dataCheck(m_KeyThick,

Cstring("Key Thickness (Tk) "),10,rsltNote,errCount,0);// Tk=0 is allowed .... // others are same

// check if Ae is in [20,30], if not, gives warning message// lowLimit=20, highLimit =30, mode =112dataCheck(m_EfctAngle,

CString("Effective Angle of Shearing Resistance (degree) (Ae) "),112,rsltNote,warnCount,20,30);

// check if Ab < Ae, if not, gives error message// lowLimit is Ae’s valuedataCheck(m_BkfAngle,

CString("Angle of Backfill (degree) (Ab) must <= Effective Angle (Ae)"),1,rsltNote,errCount,0,atof(m_EfctAngle)); // Ab must < Ae

int errC=errCount;int warnC=warnCount;rsltNote +=itoa(errCount,buferr,10);rsltNote +="\r\n\t Warnings:\t";rsltNote +=itoa(warnCount,bufwarn,10);if (errCount>0)

return FALSE;else {

return TRUE;}

} // end of doDataValidityCheck

4.2.8 Stability check

The whole Stability Check includes Data Validity Check, which isdiscussed in section 4.2.6, the Overturning Check, the Sliding Checkand the Bearing Check. Stability Check is achieved when buttonAnalyse is enabled and has been pressed by the users. It is the maintask of this application. Overturning Check is actually to calculate thevalue of the Factor of Safety Against Overturning, Sliding Check theFactor of Safety Against Sliding and Bearing Check the Factor ofSafety Against Bearing Failure.

When button Analyse is pressed, its ON_BN_CLICKED messagehandler OnCmdbtnAnalyse calls the stability check processing functiondoAnalysis. This doAnalysis function executes the following things:

--- Solution (17)BOOL CvwDataEntry::doAnalysis(){ // Five things done in

// this function

Page 26: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 25

CString strResult;BOOL isOk=TRUE;strResult="";// FOR entry data checkif (!doDataValidityCheck(strResult)) // 1) Data Validity Check

isOk=FALSE;if (resultEdit!=NULL) {

resultEdit->SetWindowText(strResult.GetBuffer(strResult.GetLength()+1));

strResult.ReleaseBuffer();}if (!isOk) return isOk;strResult +="\r\n\r\n 2.\tStability Check:";// FOR check Factor of Safety against overtuningdoEarthPressCal(); // 2) Pre-calculationif (!doStabCheck_FactSafeOvert(strResult)) // 3) Overturning Check

isOk=FALSE;if (!doStabCheck_FactSafeSlide(strResult)) // 4) Sliding Check

isOk=FALSE;if (!doStabCheck_FactSafeBear(strResult)) // 5) Bearing Check

isOk=FALSE;if (resultEdit!=NULL) {resultEdit->SetWindowText // 6) Show Result

(strResult.GetBuffer(strResult.GetLength()+1));strResult.ReleaseBuffer();

}return isOk;

}

All the data and their calculation models are discussed in chapter 2.Because all the data are held in string format, they all need to beconverted to data type double before doing all calculations.

The Data Validity Check has already been discussed in section 4.2.6.The second task is the Pre-calculation, which is completed by

--- Solution (18)void DataView::doEarthPressCal(){

double d1,d2;Hr = atof(LPCTSTR(m_RtnHeight)); // convert to doubleHp= atof(LPCTSTR(m_PsvEarthHeight));Tb = atof(LPCTSTR(m_BaseThick));Tk = atof(LPCTSTR(m_KeyThick));Ts = atof (LPCTSTR( m_StemThick));Lt = atof ( LPCTSTR( m_ToeLength));Lh = atof (LPCTSTR( m_HeelLength));Lk = atof (LPCTSTR(m_KeyLength));Dw = atof ( LPCTSTR(m_WallDensity));Ds_d= atof(LPCTSTR(m_DrySoilDensity));Ae = atof (LPCTSTR(m_EfctAngle));Af = atof (LPCTSTR(m_FricAngle));Cb = atof (LPCTSTR(m_Adhesion));Ab = atof (LPCTSTR(m_BkfAngle));Ws = atof (LPCTSTR(m_Surcharge));htEarthPress=Hr+Hp+Tb+Tk; // Earth Pressure HeighthtSurchargeEquiv=Ws/Ds_d; //Equivalent Height of SurchargehtTotal=htEarthPress + htSurchargeEquiv; //Total Heightif (!(Cb>0)) { // if Cb(Cohesion)=0

d1=cos(pi*Ab/180);d2=cos(pi*Ae/180);AEPcoeff= d1 * //Active Earth Pressure Coefficient

(d1 - sqrt( d1*d1- d2*d2))/(d1+ sqrt ( d1*d1- d2*d2));

AEPmeterWall= AEPcoeff * Ds_d * //Active Earth pressure per meter WallhtTotal *htTotal /2;

Page 27: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 26

PEPcoeff= d1 * //passive Earth Pressure Coefficient( d1 + sqrt (d1*d1 - d2 *d2))/ (d1 - sqrt(d1*d1-d2*d2));

if ( m_optPEP) // if taking account of PEPPEPmeterWall = PEPcoeff * //PassiveEarth Pressure per meter wall

Ds_d * ( Hp + Tb -1.5)*(Hp +Tb -1.5) /2;else

PEPmeterWall = 0;}else {// if Cb<>0

} // end of if Cb=0}

Then the next task is the Overturning Check: to calculate the value ofFactor of Safety Against Overturning which is implemented bydoStabCheck_FactSafeOvert. This function return FALSE if the value ofFactor of Safety Against Overturning is less than 2, and the errormessage or being passed message (if the value not less than 2) isadded into the parameter note.

--- Solution (19)BOOL CvwDataEntry::doStabCheck_FactSafeOvert(CString & note){

char buf[32];BOOL rslt =FALSE;mmntOvert=AEPmeterWall * cos(pi * Ab / 180) * ( htTotal /3 - Tk );lenBase = Lt + Ts + Lh;mmntWall =((Hr+Hp)*Ts*(Lt+Ts/2) +

lenBase*lenBase* Tb/2 + Lk*Tk*(lenBase - Lk/2)) * Dw;mmntSoil =((Hr+Hp)*Lh*(Lt+Ts+Lh/2) +

Lh*Lh*tan((Ab / 180)*pi)*(Lt+Ts+Lh*2/3)/2 ) * Ds_d;if (Ws>0) { // if taking account of Surcharge, --- Surcharge Ws >0

mmntAEP = AEPmeterWall * sin((Ab /180) *pi) * lenBase;}else {

mmntAEP = (AEPcoeff * Ds_d * htEarthPress * htEarthPress /2 ) * lenBase * sin((Ab/180)*pi);

}mmntPEP = PEPmeterWall * ( Hp+Tb - 1.5) /3;mmntRetain = mmntWall + mmntSoil + mmntAEP + mmntPEP;factSafeOvert = mmntRetain / mmntOvert;

//factor of safety against overturningnote +="\r\n\t\tSafety Factor Against Overturning\r\n\t\t\t= ";sprintf(buf,"%.2f",factSafeOvert);note +=buf;//note +=_gcvt(factSafeOvert,14,buf);if (factSafeOvert <2) { // result failure, warn

note +="\r\n\t\t\tWarning:\tNeed Redesign ! (Required not less than 2)";

rslt = FALSE;}else { //check result OK

note +="\r\n\t\t\tOK";rslt =TRUE;

}return rslt;

}

The next is the Sliding Check: to calculate the value of Factor ofSafety Against Sliding which is implemented bydoStabCheck_FactSafeSlide. This function returns FALSE if the valueof Factor of Safety Against Sliding is less than 1.5, and the errormessage or being passed message (if the value not less than 1.5) is

Page 28: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 27

added into the parameter note.

--- Solution (20)BOOL DataView::doStabCheck_FactSafeSlide(CString & note){

BOOL rslt=FALSE;char buf[32];// Sliding Force --- HsforceSlide= AEPmeterWall * cos((Ab /180)*pi);// Vertical Forces ---FvforceVert = ((Hr+Hp)*Ts + lenBase*Tb + Lk*Tk) * Dw

+((Hr+Hp)*Lh + Lh*Lh*tan((Ab/180)*pi)/2 +(lenBase-Lk)*Tk) *Ds_d;

if (Ws>0) { // Surcharge is taken into accountforceVert += AEPmeterWall * sin((Ab/180)*pi);

}else { // if Surcharge is Zero

forceVert+=AEPcoeff*Ds_d*htEarthPress*htEarthPress/2*sin((Ab/180)*pi);}//Restraining Force // FrforceRestr = Cb*lenBase + PEPmeterWall;if (Tk>0)

forceRestr +=forceVert * tan((Ae/180)*pi);else

forceRestr +=forceVert * tan((Af/180)*pi);

// Safety Factor Against Sliding = Hr / HefactSafeSlide = forceRestr / forceSlide;

note +="\r\n\t\tSafety Factor Against Sliding\r\n\t\t\t= ";sprintf(buf,"%.2f",factSafeSlide);note +=buf;//note += _gcvt(factSafeSlide,14,buf);if (factSafeOvert <1.5) { // result failure, warn

note +="\r\n\t\t\tWarning:\tNeed Redesign ! (Required not less than1.5)";

rslt = FALSE;}else { //check result OK

note +="\r\n\t\t\tOK";rslt =TRUE;

}return rslt;

}

The last check is the Bearing Check: to calculate the value of Factor ofSafety Against Sliding which is implemented bydoStabCheck_FactSafeSlide. Before doing that check, it needs first tocheck the “distance from the tow to the point where reaction forceintersects the base” (d, also can be referred as the d Check) to see ifthe value is between third of and tow of three of the Base Length (B).This function returns FALSE if either the d Check fails to pass or thevalue of Factor of Safety Against Bearing Failure is less than 3, andthe error message or being passed messages (if the d Check passedand the value not less than 3) are added into the parameter note.

--- Solution (21)BOOL DataView::doStabCheck_FactSafeBear(CString & note){

BOOL rslt=TRUE;char buf[32];//distance from the tow to the point// where reaction force intersects the basedistTowBase = (mmntRetain - mmntOvert ) / forceVert;note +="\r\n\t\tdistance from the tow to the

Page 29: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 28

point where reaction force intersects the base ";note +="\r\n\t\t\t=";sprintf(buf,"%.2f",distTowBase);note +=buf;if (distTowBase <(lenBase/3) || distTowBase >(lenBase *2/3)) {

note +="\r\n\t\t\tWARN:\tNeed Redesign ! ";note +="\r\n\t\t\t(Requires >= ";sprintf(buf,".2f",(lenBase/3));note +=buf;note +=" (1/3 Base Length) and <= ";sprintf(buf,".2f",(lenBase*2/3));note +=buf;note +=" (2/3 Base Length)";rslt = FALSE;

}else {

note +="\r\n\t\t\tOK";}// Load Eccentricity e=|(B/2-d)|eccentricityLoad = lenBase/2.0 - distTowBase;if (eccentricityLoad<0 ) eccentricityLoad *=-1;//Effective width of the vase Be = B - 2 *ewdEfctBase = lenBase - 2 * eccentricityLoad;// Pressure on Base q= Fv / BepressBase = forceVert / wdEfctBase;// Calculation of ultimate bearing capacity of the soil

// Nq=(tan(45+Af/2)^2 + e^(pi * tan (Af))double Nq = pow (tan (((45+Ae/2)/180)*pi),2) * exp(pi*tan((Ae/180)*pi));// Nc = (Nq-1) * cot(Af)double Nc = (Nq - 1) / tan((Ae/180)*pi);// Nr = 1.5 * ( Nq -1 ) * tan(Af)double Nr = 1.5 * (Nq-1)*tan((Ae/180)*pi);// Ultimate berating capacity of soil// --- Qult = cb * Nc + Ds_d*(Hp+Tb)*Nq + Ds_d*lenBase*Nr/2capUltBearingSoil = Cb*Nc + Ds_d*(Hp+Tb)*Nq + Ds_d*lenBase*Nr/2;

// Safety Factor Against Bearing Failure --- Qult /qfactSafeBearing = capUltBearingSoil / pressBase;note +="\r\n\t\tSafety Factor Against Bearing Failure\r\n\t\t\t= ";sprintf(buf,"%.2f",factSafeBearing);note +=buf;if (factSafeBearing <3) { // result failure, warn

note +="\r\n\t\t\tWarning:\tNeed Redesign ! (Required not less than 3)";rslt = FALSE;

}else { //check result OK

note +="\r\n\t\t\tOK";}return rslt;

}

4.2.9 Data saving and loading

It is very essential for nearly every application, that there are theneeds of storing data to file and retrieving data from file. Using C++OO programming, the style for doing so is somehow different from theC of using FILE stream class. In this application, the functions like“fopen” are not going to be used, instead, the relevant classes in MFC(for VC++ edition) or classes in VCL (for BCB edition).

This project covers two editions of the application. Theimplementations of saving data to file and loading data from file parts

Page 30: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 29

are tightly associated with the programming structure provided bythese two IDEs (For discussion about these two programmingstructures, see section 3.3 and 4.2.1). Implementations about datasaving and data loading of VC++ edition and BCB edition are totallydifferent.

VC++ EditionAfter the creation of this application structure, for supporting fileaccess by using Serialization we must change the RetainingWall class’slevel of functionality to highest level by using DECLARE_SERIALmacro[1]. Because RetainingWall derives from CDocument and hasbeen added into the template together with the MainFrame class, sonow whenever “File Open”, “File Save” or “File SaveAs” menus ortoolbar buttons pressed, the framework will call the Serialize functionin RetainingWall class if RetainingWall has created its own andoverridden the CDocument class’s virtual function Serialize. In fact,VC++ framework does the standard things for “File Open”, “File Save”and “File SaveAs” commands and let the programmer to do howhe/she retrieve or save data in the message handler Serialize functionwhich looks very simple to programmer.

In this way, we can now use the automatically provided parameterCArchive object to store or extract the data to file or from file. Byusing the isStoring method of CArchive class, we can get theinformation that the current operation is to store data to file or extractdata from file. CArchive class actually is an intermediary between theoperator and CFile object and uses stream to work. CArchive can usesymbols “<<” for storing and “>>” for extracting from a file. Thismechanism is quite easy and powerful for us to handle file operationsonce we have understood how it works.

Here is how we define the Serialize function in RetainingWall class.---Solution (22)

void CTest3Doc::Serialize(CArchive& ar){

UINT nullFlag=0;if (ar.IsStoring()){ // store data to file

ar<<mp_docData.Hr<<mp_docData.Hp<<mp_docData.Tb<<mp_docData.Tk<<mp_docData.Ts<<mp_docData.Lt<<mp_docData.Lh<<mp_docData.Lk<<mp_docData.Dw<<mp_docData.Ds_d<<mp_docData.Ae<<mp_docData.Af<<mp_docData.Cb<<mp_docData.Ab<<mp_docData.Ws<<mp_docData.optPEP;

}else{ //retrieve / extract data from file

ar>>mp_docData.Hr>>mp_docData.Hp>>mp_docData.Tb>>mp_docData.Tk>>mp_docData.Ts>>mp_docData.Lt>>mp_docData.Lh>>mp_docData.Lk>>mp_docData.Dw>>mp_docData.Ds_d>>mp_docData.Ae>>mp_docData.Af>>mp_docData.Cb>>mp_docData.Ab>>mp_docData.Ws>>mp_docData.optPEP ;

this->UpdateAllViews(NULL,0L,this);}

}

Page 31: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 30

VC++ IDE hides the codes for prompting dialog forms to get file namefrom a user for either “File Open” or “File SaveAs” commands. If wewant, we can get file name from GetFile method to first get thecorresponding CFile object, then get the file name from the CFileobject. The working procedure is that, when a user launches a “FileSave” command from menu or toolbar button, if there has alreadybeen a file name for this application, there is no dialog prompting forfile name and Serialize function would execute directly; if there is nofile name for this application yet or “File Open” or “File SaveAs”commands launched, the framework first prompts a dialog for gettingthe file name from the user and then calls Serialize function.

Why use UpdateAllViews function when retrieving data from a file?Because VC++ uses document—view mechanism. Every time data areextracted from a file, then they need to be sent to correspondingview(s). This UpdateAllViews function sends a message and tells allviews that “I have new data now, who is interested? Come and pickthem”. In any CView classes, there always a m_Document membervariable (pointer) to refer to its corresponding CDocument object. Soin our DataView object, we can use that variable to get new data fromRetainingWall, show them on the form and calculate them for design.

BCB EditionBCB does not use that complicated mechanism for file saving andloading from a file. When design an application that needs fileoperation, we must first add these menus or toolbar buttons, thencreate the command handler function for these menu item or toolbarbuttons. There is no automatically created functions for file operations.This way is quite simple, and the logic is straight forward tounderstand. But one little thing is that we need to find a suitable classto take charge of file reading and writing.

In this application, we use string to store data, and also want data filebe stored in string format, so the TStringList class is used to retrievedata from file and store data to file. The two methods LoadFromFileand SaveToFile in TStringList can be used to do the works. But beforedoing that, we need to set up a TOpenDialog control objectOpenDialog1 and one TSaveDialog control object SaveDialog1. Hereare the routines to implement file operation jobs.

---Solution(23)void __fastcall TForm1::mnuOpenClick(TObject *Sender) { if ( OpenDialog1->Execute() ) { if (!(FileExists(OpenDialog1->FileName))) { Application->MessageBoxA("File does not exist","Error Message",IDOK); return; } calledLoadData(OpenDialog1->FileName);

....}

}

Page 32: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 31

The above routine mnuOpenClick is the menu Open’s Click eventmessage handler. mnuOpenClick uses the Execute method of theOpenDialog1 to prompt a dialog for the user to select a file whichname then be stored in the member variable FileName, then calls theopening process routine calledLoadData to load data in. ---Solution(24)BOOL __fastcall TForm1::calledLoadData(AnsiString & fileName){ TStringList* strIn = new TStringList; try { strIn->LoadFromFile(fileName); edtWallHr->Text=strIn->Strings[0]; edtWallHp->Text=strIn->Strings[1]; edtWallTb->Text=strIn->Strings[2]; edtWallTk->Text=strIn->Strings[3]; edtWallTs->Text=strIn->Strings[4]; edtWallLt->Text=strIn->Strings[5]; edtWallLh->Text=strIn->Strings[6]; edtWallLk->Text=strIn->Strings[7]; edtWallDw->Text=strIn->Strings[8]; edtSoilDs->Text=strIn->Strings[9]; edtSoilAe->Text=strIn->Strings[10]; edtSoilAf->Text=strIn->Strings[11]; edtSoilCb->Text=strIn->Strings[12]; edtSoilAb->Text=strIn->Strings[13]; edtLoadWs->Text=strIn->Strings[14]; s_optPEP=strIn->Strings[15]; s_isValidData=strIn->Strings[16]; s_isValidDesign=strIn->Strings[17]; } catch (Exception & e) { Application->MessageBoxA( e.Message.c_str(),"Error Message",IDOK); if (strIn !=NULL) { delete strIn; strIn=NULL; } return FALSE; } if (strIn !=NULL) { delete strIn; strIn=NULL; } isDirty=FALSE; return TRUE;}

In this calledLoadData function, the TStringList class is used to processfile access for the string data in this application. If it is needed, theCount property can be used to get total string numbers in the justloaded TStringList object, but here we don’t use it because we mustput each value into different individual data field (TEdit control). So inthat case, the total number of data is hard coded.

Note that because it is a file operation, we should catch the possiblefile exceptions by using “try— catch” syntax.

The second is the “File SaveAs” command. Like the “File Open”, thisone also need to use SaveDialog1’s function Execute to prompt adialog for the user to setup or select a file name. There is one extrastep in which the application first detects if the file name by theFileName property of SaveDialog1 exists, then asks user to decide to

Page 33: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 32

override or not. If true, then processes the saving action with the filename specified by SaveDialog1’s FileName property.

---Solution(25)void __fastcall TForm1::mnuSaveAsClick(TObject *Sender){ BOOL needsave=FALSE; if ( SaveDialog1->Execute() ) { if (FileExists(SaveDialog1->FileName)) { if (Application->MessageBoxA ("File already exists. Do want to replace it ?", "",MB_YESNO|MB_ICONQUESTION )==IDYES) needsave=TRUE; else needsave=FALSE; } else { // if that's a new filename, then need save needsave=TRUE; } if (needsave) { assitDataTransSave(); calledSaveData(SaveDialog1->FileName); int ind=SaveDialog1->FileName.LastDelimiter("\\"); s_dataFileNameOnly = SaveDialog1->FileName.SubString

(ind+1,SaveDialog1->FileName.Length()); s_dataFilePath=SaveDialog1->FileName.SubString(0,ind); } }}

The main saving task is completed by the calledSaveData routinewhich is defined as below. It also uses TStringList object to save thedata to file. But before do that, the data need to be put into thisTStringList object by using its method Add.

---Solution(26)BOOL __fastcall TForm1::calledSaveData(AnsiString & filename){

TStringList* strOut=new TStringList; try { strOut->Add(edtWallHr->Text); strOut->Add(edtWallHp->Text); strOut->Add(edtWallTb->Text); strOut->Add(edtWallTk->Text); strOut->Add(edtWallTs->Text); strOut->Add(edtWallLt->Text); strOut->Add(edtWallLh->Text); strOut->Add(edtWallLk->Text); strOut->Add(edtWallDw->Text); strOut->Add(edtSoilDs->Text); strOut->Add(edtSoilAe->Text); strOut->Add(edtSoilAf->Text); strOut->Add(edtSoilCb->Text); strOut->Add(edtSoilAb->Text); strOut->Add(edtLoadWs->Text); strOut->Add(s_optPEP); strOut->Add(s_isValidData); strOut->Add(s_isValidDesign); strOut->SaveToFile(filename);

} catch (Exception & e){ if (strOut!=NULL) { delete strOut; strOut=NULL; } return FALSE;

Page 34: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 33

//throw e; } if (strOut!=NULL) { delete strOut; strOut=NULL; } isDirty=FALSE; return TRUE;}

The last task deals with the “File Save” command. The extra work isthat it first detects if current application has already had a file name, ifnot then execute “File SaveAs” command, otherwise just save thedata.

---Solution(27)void __fastcall TForm1::mnuSaveClick(TObject *Sender){ if (s_dataFilePath=="") mnuSaveAsClick(Sender); else { assitDataTransSave(); calledSaveData(s_dataFilePath+s_dataFileNameOnly); }}

4.2.10 Launching the application by double clicking on a data file

It is very important feature for an windows application to be the useris that the user can launch this application with loaded data just bydouble clicking on a data file. This feature enables users to quicklynavigate data by just double clicking on the data files in a filenavigating application like MS Windows Explorer.

The working principles for VC++ and BCB edition are same, butdifferent on how to achieve it. The idea is that, first register the datafile type for this retaining wall application(using *.rwd for VC++edition and *.rwb for BCB edition) in the initiation at the running time;then parse if there are parameters passed in when launching, if so,take the first parameter as the data file name.

VC++ EditionFor MFC application, VC++ suggests use Document-Templatemechanism for applications. The file name type is stored in theCdocTemplate class . We can register the data file type and parse theapplication launching parameter by using

--- Solution (28)// register the data file typeEnableShellOpen();RegisterShellFileTypes(TRUE);

// Parse command line for standard shell commands, DDE, file openCCommandLineInfo cmdInfo;ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command lineif (!ProcessShellCommand(cmdInfo))

return FALSE;

Page 35: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 34

Actually, VC++ Application Wizard will create the above statements forus if we use Advanced settings for specifying a file type extensionwhen using Application Wizard to create an application. FunctionEnableShellOpen enables users to open data files when they double-click the files from within the Windows File Manager like WindowsExplorer. It should be associated with the use of functionRegisterShellFileType which register the data file types specified in theapplication’s CTemplate object. The use the ParseCommandLine to getthe command parameters and processed by usingProcessShellCommand function.

After first run the application, then at any time, when a user double-click the retaining wall data file (with the extension .rwd) theapplication will be launched with that data file loaded.

BCB EditionBCB does not automatically provides file type registration function, wemust manually create this kind of a function here we call itmakeSureInitFile and call it in the main form’s constructor. In thisedition, automatic file type registration is not implemented, so usersmust manually register file type to this application when first timedouble-click the data file in Windows Explorer. The reason for that isstated in section 5.2. Please note, the data file type of this retainingwall application, the file name is hard coded the name with theextension type “rwb”.

--- Solution (28)// Check if command line parameter 1 as a file exists, if so then load it inBOOL __fastcall TForm1::makeSureInitFile(){ AnsiString initFileName=ParamStr(1); if (initFileName=="") { // empty string, means no parameters return FALSE; } else { // has some parameter file if (!FileExists(initFileName)) { // file not exists return FALSE; } else { // the data file exists calledLoadData(initFileName); assitDataTransLoad(); int ind=initFileName.LastDelimiter("\\");

s_dataFileNameOnly=initFileName.SubString(ind+1,initFileName.Length());

s_dataFilePath=initFileName.SubString(0,ind); } } return TRUE;}

Using function ParamStr(index) can get the first command lineparameter. Take it as a data file name, then check it exists or not, ifso then load it in. Use function FileExists to detect if the file exists ornot.

Page 36: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 35

4.3 Program Routine Lists

See Appendix A for VC++ edition, Appendix B for BCB edition.

5. Problems during the Implementation of the Application

Before doing this project, I had never touched programming for Windowsapplication using C++. But I did have some knowledge on C and C++language. This is the first time that I use MFC of VC++ and VCL of BCB toimplement a windows application.

When I started the implementation by using VC++, I found its structure isquite complicated and spent a quite high ratio of time to learn it. I felt thatthe MFC model is not easy to understand because, I think, MFC preferablyfocuses on controlling and associating with the windows system resources,instead, BCB’s VCL pay more attention to solutions of users’ problems. SoVC++ provides more services and utilities for controlling and using windowsresources than BCB does, but its structure is also complicated. The two IDEsdiffer from each other quite far away.

For implementing the application in two editions, I met much moreproblems with VC++ than BCB. Even I implemented the VC++ edition first,but I still think I spent much more time on learning the VC++.

5.1 Problems with VC++

The Documentation of VC++I learnt the VC++ from its documentation – MSDN, for “Visual C++Documentation”, “Platform SDK”, “Visual C++” part of “Knowledge Base”,“The Windows Interface Guidelines for Software Design” in its attached“Books” and “Periodicals”. MSDN is quite a big repository and nearly coversall information required for programming in windows system. But it is like aforever-added repository that makes me confused sometime.

Problem with TooltipsBesides on the toolbars, tooltips are needed for the data fields and theirdescription labels for a clear interface and give the users some informationfor the data they are currently pointing to.

Because the tooltips are required on DataView window that is a classderiving from CView and is not a class from CFrameWnd. According to thedocumentation, I should do this way:

a) Using function EnableToolTips to first allow showing tooltips on theDataView object as

this->EnableToolTips(TRUE); // “this” refers to DataView

Page 37: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 36

b) Add a message map for handling TTN_NEEDTEXT message codeand provide a handling function as

ON_NOTIFY_EX( TTN_NEEDTEXT, 0, memberFxn ) // the message mapBOOL DataView::memberFxn( UINT id, // handling function

NMHDR * pTTTStruct,LRESULT * pResult );

But I do not know why it did not work. So I went back to the referencedocument to CToolTipCtrl control, tried several times, then succeeded bythe solution mentioned in section 4.2.3, the Solution (3).

Problem with TEdit Control Change EventAs stated in section 4.2.5, every key stroke need to be detected when usersfocus on any data field. So the TEdit control—data field need to sendmessage notification and a message handling function needs to be defined.In the TEdit class reference there is only one sentence for how to usemessage:

ON_Notification( id, memberFxn )I do not know on which “Notification” for what “id” in this message entry forthe TEdit’s Text content change event, so I checked this document[6] andseemed to have found a solution by using the following

ON_NOTIFY( wNotifyCode, id, memberFxn ) orON_NOTIFY_RANGE( wNotifyCode, id, idLast, memberFxn )

The handler function is memberFxn, and defined asafx_msg void memberFxn( NMHDR * pNotifyStruct, // for ON_NOTIFY

LRESULT * result );afx_msg void memberFxn( UINT id, // for ON_NOTIFY_RANGE

NMHDR * pNotifyStruct,LRESULT * result );

The id is for message sending control’s id. I had found that the Textchanged event code is EN_CHANGE.

But it did not work. So I used the VC++ IDE’s one powerful tool – thecontext menu command to find the definition of ON_NOTIFY, and then Icalled out one MFC’s header file Afxmsg_.h. I found just beside thedefinition of the macro ON_NOTIFY, there are macros called ON_CONTROLand ON_CONTROL_RANGE. I tried these two, and surprisingly, succeeded. Ichoose ON_CONTROL_RANGE because it can handle range. See 4.2.4 forthis solution.

Problem with Accessing Object in its Initializing TimeI spent a quite long time wondering why the codes I added for initialing thesplit window’s size, initialing ResultShow’s font, first transferring the data tothe DataView form from RetainingWall etc, I always got an exception. Ifinally found the reason is that, before the finishing of DataViewconstruction, I can not use the pointer “this”; I can not use any childcontrol. Till now, I still do not know, what is the exact good moment I canuse to access a CWnd classes just before it shows on the screen, EvenVC++ gives us many chances like in the constructors, OnInitialUpdate,OnUpdate, PreCreateWindow, OnCreate, OnCreateClient etc.

In this application, I used the strategy that I first defined some publicfunction do these jobs mentioned above, then call them outside their own

Page 38: An Application for Retaining Wall Analysis - · PDF fileRetaining wall is one of the ... Analysis and design of retaining walls involve stability checks and wall detailing. ... Retaining

Page 37

classes— in the main window class CmainFrame—at the end of initiation ofCMainFrame.

The BCB VCL does not have this problem.

5.2 Problems with BCBBCB has fewer problems but this only one problem is very fatal: the a littlepoor documentation’s organization. Today’s technique grows very fast, themain resource of knowledge would comes from the online helpdocumentation. VC++ does it good, but for BCB, I feel it’s hard to find thetopics that I need to refer to, and I do not have the idea of whole frame ofthe VCL; also, they did not provide a class hierarchy chart for a quickreference. If I have a problem, it is not easy to get a solution from theirdocumentation – it is hard to find the proper topic. BCB’s helpdocumentation is scattered, not fully indexed, so some times I waswondering which topic I should choose to search for the help.

An instance is I wanted to register the data file type in the application, but Ican not find the help text for the solution. Because no much more time Ican spent on it, I had only to leave this question. Fortunately, the users canmanually register the file type in the Windows Explorer.

The good thing is that because the clearness and simplicity of VCL, in mostcase, it is enough to check VCL classes by only index.

6. Summary

The whole project took me about 180 hours, including about 80 hours forlearning, 70 hours for implementation, and 30 hours for this report.

The implementations in the two editions of the project are simple windowsapplication, but I gathered knowledge in this project and have alreadyobtained the main idea for programming in OO C++ language and inwindows platform by using two different IDEs with two different models—MFC and VCL.

I also have gained the knowledge of Retaining Wall and its models forfulfilling the design.

Thanks to Dr. Manoharan and Dr. Shanmuganathan who helped me duringthe project.

7. Reference

[1] MSDN, Visual C++ Documentation, Using Visual C++,Visual C++ Programmer’s Guide.

[2] Visual Component Library. Inprise Corporation.