Solved

draw some building structures, Canvas in Delphi

Posted on 2009-05-19
14
897 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now