Solved

draw some building structures, Canvas in Delphi

Posted on 2009-05-19
14
903 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

751 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