Solved

draw some building structures, Canvas in Delphi

Posted on 2009-05-19
14
899 Views
Last Modified: 2012-05-07
Dear all.
I've learned how use Canvas Object for creating basical shape like circle, square, arc and so on.
I am interested in creating 2D shape for drawing house project like this one:

http://www.eioba.pl/files/user598/dompastwakania2sj7.png

So I need to create simple Shape for "desk with chairs", chair, stairs, "L" and "U"walls ....

I could play with the canvas functions and do it by myself by the way i was thinking if
such library or procedure are already bee created by someone else in internet
so I would speed up with my project.

it does exsist a software that generate delphi code for a shape
to be used in my procedure? So i can create my TMyShapeDesk Class?

Thx a lot.
0
Comment
Question by:jaja2005
  • 7
  • 6
14 Comments
 
LVL 8

Assisted Solution

by:BdLm
BdLm earned 25 total points
ID: 24425715
this one helps :   http://www.flex-graphics.com/   ??
0
 

Author Comment

by:jaja2005
ID: 24426137
hmmm probably not because my goal is to find code to use.
I am using TeeTree:

http://www.steema.com/products/teetree/whatsnew.html

But here there are a only a few sample of Shape.

Here an example:

procedure TMyActorShape.DrawShapeCanvas(ACanvas: TCanvas3D; const R: TRect);
var tmpX : Integer;
    tmpY : Integer;
    tmpY2 : Integer;
    tmp : Integer;
begin
   inherited;
with R do
begin
tmpX:=(Right+Left) div 2;
tmpY:=(Bottom-Top) div 3;
tmpY2:=(Bottom-Top) div 9;
end;

with ACanvas do
begin
HorizLine3D(R.Left,R.Right,R.Top+tmpY,TeeTreeZ);
VertLine3D(tmpX,R.Top+tmpY-tmpY2,R.Bottom-tmpY,TeeTreeZ);
LineWithZ(tmpX,R.Bottom-tmpY,R.Left,R.Bottom,TeeTreeZ);
LineWithZ(tmpX,R.Bottom-tmpY,R.Right,R.Bottom,TeeTreeZ);
tmp:=(tmpY-tmpY2) div 2;
EllipseWithZ(tmpX-tmp,R.Top,tmpX+tmp,R.Top+tmp+tmp,TeeTreeZ);
 end;
end;


So in ACanvas I want to draw my own shape (clouds, desk, tree, gate, doors, windows..).


Thx






0
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 275 total points
ID: 24426453
You really should be using this:
http://www.codeaccelerate.com/drawing_engine.html
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:jaja2005
ID: 24426812
Hi. I have installed the package, I see all the components in palette but actually I don't
undestand how I could use them in the procedure I showed you before and what advantages
they offer compared with the standard canvas procedures. I need to draw the shape
via code...

Thx in advance
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 24428079
You need to create shape classes and program them to draw like you want.
0
 

Author Comment

by:jaja2005
ID: 24429182
do you have some example? I see that the documentation is quite poor.
0
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 275 total points
ID: 24431104
Well, I don't know the dimensions or shape that you want to draw. There are examples included of shape classes in the package, I believe, that you can see how to do it.
0
 

Author Comment

by:jaja2005
ID: 24431173
Oki. How you would compare it with this?

http://www.tmssoftware.com/site/diagram.asp?s=
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 24432478
That's all fine if you want the objects already created. Apparently, you want some things specially designed and you are going to have to do that yourself.
0
 

Author Comment

by:jaja2005
ID: 24441414
I do undestand. Thanks.

I've attached some picture of what I would like to achive.

1. Have seen the example of how create a mult-iline shape by clicking on the Diagram. Generally I would like to get
the same effect adding some code in my procedure DrawShapeCanvas for drawing a piece of wall as showed in my screenshot
and then fill it with my ow brush or simple color.

2. I would like to create a basical simple shape like TMychair and use them for a table in "conference room". You see
the second pic.  Here you see a red-square around the table which is a TRect type to draw in. (note TMyActorShape
is draggable on Diagram component so when I perform this action all the "shape" in ACanvas should move accordgly (charis, bottle of water :-) , table...)

How I can achive it?
Any code example?

Thx
1.jpg
2.jpg
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 24455782
There is a component on the Additional Tab called TShape. Make a copy of the code and modify the Paint to draw a chair, a table,and whatever, like it does with a Square, Rectangle, RoundRect, etc.
0
 

Author Comment

by:jaja2005
ID: 24457293
I know where Tshape is it. I was searching for other kind of information like How paint shapes, graphics algoritms...If someone else
have done it using pascal for exmaple drawing clouds I would look into his code ...




 

0
 

Author Comment

by:jaja2005
ID: 24457305
My previous question (1 and 2) are also very specific.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 275 total points
ID: 24458022
Looks like the chair is drawn with 3 ellipses and a round rect, all you need is to calculate the position and sizes.
Remember, TShape is a graphic control and does not respond to mouse messages so you really need to inherit from TComponent and build from there.

AFA No.1 is concerned, all you have to do is draw the two parallel lines at the same time
that is not hard to do. Take the position when the mouse button is pressed and set position 1 to the mouse position + 1/2 the width of the wall, set position 2 to the mouse position - 1/2 the width of the wall. then do the same thing when the button is released and draw lines from position1 to position 3 and position 2 to position 4.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question