Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

draw some building structures, Canvas in Delphi

Posted on 2009-05-19
14
Medium Priority
?
915 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 75 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:Eddie Shipman
Eddie Shipman earned 825 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:Eddie Shipman
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:Eddie Shipman
Eddie Shipman earned 825 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:Eddie Shipman
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:Eddie Shipman
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:
Eddie Shipman earned 825 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

564 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