I have been learning from this site for really long time, but this is actually my first appearance here, that is my first question, I am a civil Engineer and i am writing a software for the design of Retaining Walls, I need to draw figures like these shown below ,to be static or dynamic , (i mean by dynamic that i can change the dimensions of the graph via up-down numeric tool and the changes are visible at the graph,), these should be a ready forms to help the user entering the demotions.where i can find a source to learn this? i know i may be dealing with the smartest people in programing so please note that programing is not my major , i am not that good , consider me as a beginner ..thank you so much
-
1There is an old qustion in IT: Make or Buy? There are tools for this and learning to use them is daunting in itself. Writing them is not something for a single person, let alone a beginner. – TaW May 16 '14 at 17:26
-
TaW , first of all thank you for your attention and for replying ,so what do you advise me to do ? , what should i do ? to get these shapes and drawing into my software ? – Azzam Alrandi May 16 '14 at 17:30
-
Tell me a little what your program does so far! – TaW May 16 '14 at 21:08
-
And what are the steps that should be following in making any software , like i have heard about the display setting it should be adjusted, i think i am having a lack of information , i guess i need a guide to follow in order to know how to write a completely and effective software from A to Z , it's right i can declare values, use loops , use statements , and i have a deep thinking ability which gives me ability of coding any desired target even by using those basic steps , but the thing is i am looking for little bit guide to be organized or at least to have an effective software ,Thank you – Azzam Alrandi May 19 '14 at 22:32
-
1I see. Looking at the images, the first thing that comes to mind is how greatly they differ in detail and quality. Making illustrations in 3D with hidden line and plane detection, shading and whatnot is quite a task. OTOH, a drawing like the one at the middle bottom, showing just the side of the wall with a few labels, is really not that hard and I'll walk you through or give you enough hints to get you going..... – TaW May 19 '14 at 22:37
-
..... The second is this: The images have quite a few different wall types (needing various numbers of points to plot the wall.) How many wall types will you create? How many measurements/dimensions are input? Should this be flexible? Not that hard either, but it is always good to know this beforehand.. – TaW May 19 '14 at 22:38
-
Thank you so much for replying me, First of all , the software will deal with 4 types of retaining Walls , Gravity ,Cantilever,Counterfort And Rockery, i am not really concerned with 3D drawing , i only want to use them to help the user as another side of view , so i can use a static pictures , but for the main drawing with the soil slope and view , i think 2D could be enough, especially if 3D Drawing will be tough,for the 2D it;s okay if they will be static or dynamic,but i would rather if i could do them dynamic ,it gives more reality sense for the user,i can send you the photos of the Walls – Azzam Alrandi May 20 '14 at 12:04
-
Please note that this software well deal with optimization that based on algorithm , so i really need a powerful language, this optimization may take 3000 iteration, with really complicated equations, I have heard that Matlap is good choice ! but i am really confused , could matlap be c# and java , could it give me nice looking layout , and will it contain graphics and all what i need exactly as a normal program , I really want your advice in this ,i am really very grateful for your help – Azzam Alrandi May 20 '14 at 12:07
-
- C# is a very fast language today and will certainly be able to do the calculations fast enough, unless you write the code in an especially inefficient way ;-) - For four wall types the wall __type__ need not be made dynamic; just define each wall type, hard coding the calculation of the points. (Not sure what Rockery means here, though.) - A good book is a good friend and practice is a good teacher. There is a new platform here called [CodeReview](http://codereview.stackexchange.com/) where you can post things you write to get comments on. – TaW May 21 '14 at 10:02
-
BTW, I came across [this](http://www.excelcalcs.com/repository/strength/civil-engineering/retaining-wall-design/) site, which looks interesting.. – TaW May 21 '14 at 10:07
-
Thank you o much for you help , i do really appreciate this , i am now working on it , i will send you the feed back ,thank you so much again :), and you are right about the speed of the calculation that is because i used like 22 loops , with huge matrices , and lots of iterations , i am now trying to use matlab and connect between c# or java and matlab, but i will be using all what you told me about in the drawing , really hit the sense when you told me " A book is good friend , and exercise is a good teacher " and i will add , and you are a good library that full of books – Azzam Alrandi May 25 '14 at 14:39
-
"HighCore" Thank you for your time and attention :) – Azzam Alrandi May 25 '14 at 14:44
1 Answers
Here is a short introduction to the things you need to add drawings to your program:
0 - Decide on the platform: Winforms
or WPF
? For your kind of graphics WinForms
will do; for 3D and animation WFP
would be the better choice but at the cost of a steeper learning curve.
1 - Understand the basic graphics model in Winforms:
All things drawn onto a control must be drawn in the
paint event
or be triggered from thereWindows will take care of refreshing the drawing whenever outside events have e.g. covered it.
The user should be able to trigger the paint event by invalidating the control whenever he has changed the data. Add a refresh button with
sketchPanel.Invalidate();
as its code.
2 - Add a control to draw on to the form and anchor
or dock
it as you like. Use a panel
for drawing on, give it a nice name, say sketchPanel and create its Paint
event ( by doubleclicking it in the event properties pane)
3 - All drawing operations happen on a Graphics
object. In the Paint
event it is provided as e.Graphics
. If you would rather draw in a function of its own, say public drawMyWall(Graphics G) you can call it in the Paint event and pass in the e.Graphics object.
4 - The methods to use are
DrawLine
for creating linesDrawString
for writing the measurement labelsFillPolygon
for drawing a colored wall or the earth or water bodiesDrawPolygon
for drawing an outline of the wall
All will take coordinates in pixel units relative to the sketchPanel; as your user input will be in meters or millimeters you will have to convert the numbers. Calculate the outer wall dimensions and scale them to the panel's size!
The Draw-/FillPloygon methods also expect an array of Points
.
To create it you should first declare a List<Point> wallpoints = new List<Point>();
and then add each point you need: wallpoints.Add(new Point(someX, someY) );
Here both the order must be followed (CW or CCW) and the coordinates must each be calculated from the input measurements for each Point. A simple Gravity Wall will have only 4 points but the more complicated walls will have a dozen or more..
When your List is complete you can use in in e.g. the FillPolygon method like this:
e.Graphics.FillPolygon(Brushes.Orange, wallpoints.ToArray() );
Since you calculate all points from the input measurements the drawing will be completely dynamic.
You may want to leave out labels etc. at first. Also you may want to add an offset to the points you calculate to move the drawing to a more or less centered position on the panel.
I hope that helps..

- 53,122
- 8
- 69
- 111
-
Sorry, I disagree with all this. The image shown by the OP shows CAD-like 3D graphics and neither winforms (which is completely useless) nor WPF (which does not offer the high-performance 3D capabilities required for this) are suitable for this. This should really be done using pure hardcore C++ and either DirectX or OpenGL. – Federico Berasategui May 21 '14 at 15:23
-
This only because you did not read (all those) comments. Starting with my first (!) and also the one where the image at the middle bottom was agreed on as good enough. If you can't do this in WinForms, well, sorry for you. I can.. And even mentioning C++ is laughable. – TaW May 21 '14 at 15:27
-
"If you can't do this in WinForms" - winforms is incapable of even the most basic drawing without exhibiting a lot of horrible constant flicker due to lack of hardware acceleration. Let alone resolution independence and and auto-adjusting layout. I'd really like to see your winforms version of that. – Federico Berasategui May 21 '14 at 15:31
-
There is no animation involved in the problem nor any need for all those other things.. But as you obviously are just fanatic about winforms and chose to ignore the given problems, I see no use or reason to talk to you. – TaW May 21 '14 at 15:39