VCL——画一个房间

发布于 2024-08-21 06:09:37 字数 1182 浏览 10 评论 0原文

我仍在尝试绘制平面图(在 BCB 6 中)。

我已经问了几个问题。由于寻求布局设计VCL工具栏,我购买了TMC组件。

寻找非矩形面板 VCL 组件 让我很接近,但没有就在那里。

那么,让我们再试一次......


我猜是某种面板。边缘周围有漂亮的粗边框线(墙壁),可能有 5 甚至 10 像素,因此默认面板无法做到这一点。

我不能单独绘制线条,因为它们需要随表单调整大小。因此,要么我将线条连接到面板(所有者属性)并重新绘制它们...(何时?表单调整大小?面板调整大小?)

或者我可以制作自己的面板组件。

无论哪种情况,我都需要能够通过门开口中断线路 - 或者我是否需要添加门组件?但随后我需要将其绑定到面板上,以防表单大小调整。

如何最好地实施?它不必花哨,但像这样的东西......

=============================================
|              ||       ||                  |
|              ||       ||                  |
|              ||       ||                  |
|              ||       ||                  |
===   =============   =============    ======
|              ||                           |
|                                           |
|              ||                           |
=============================================

看到了吗?也有多个门;最好是非矩形的房间(至少是L形)并且可以根据形状调整大小。

有什么想法吗?

I am still trying to draw a floorplan (in BCB 6).

I already asked a few questions. As a result of Seeking floorplan design VCL toolbar I bought the TMC components.

Looking for non-rectangular panel VCL component got me close, but not quite there.

So, let's try again...


Some sort of panel, I guess. With nice thick border lines (walls) are around the edges, maybe 5 or even 10 pixels, so default panels won't do it.

I can't just draw lines separately, as they need to resize with the form. So, either I ties lines to panels (owner property) and redraw them ... (when? Form resize?, Panel resize?)

Or I can make my own panel component.

In either case, I need to be able to interrupt the lines with openings for doors - or do I add a door component? But then I need to tie that to the panel, in case of form resize.

How best to implement? It doesn't have to be too fancy, but something like this...

=============================================
|              ||       ||                  |
|              ||       ||                  |
|              ||       ||                  |
|              ||       ||                  |
===   =============   =============    ======
|              ||                           |
|                                           |
|              ||                           |
=============================================

See? multiple doors too; preferably non-rectangular rooms (at least L-shape) and resizable with the form.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝色星空 2024-08-28 06:09:38

我不知道这是否是一个适合您场景的解决方案,但如果我要设计一个类似的应用程序,我想我会利用 VCL 框架中新组件扩展的简单特性。我会为各种图形元素、门、墙等构建组件。我会创建一个它们可以继承的公共对象。

例如,我会创建一个 TFloorplanElement 组件,我的所有图形组件都可以继承该组件,我会让 TFloorplanElement 继承自 TGraphicControl 以获取利用TControl提供的Anchor属性和TGraphicControl提供的Canvas。我不会为此使用自定义的 TPanel,我认为这里不需要 TWinControl 提供的窗口句柄的开销。

对于墙壁,我将创建一个继承自 TFloorplanElement 的组件,该组件被赋予两个端点来连接墙壁,这可以是一侧的门和另一侧的另一堵墙,或者任何其他TFloorplanElement 后代的组合。当这些角中的任何一个移动时,您需要进行某种事件处理,在这种情况下您需要做的只是将墙的坐标重新调整为角元素的坐标。

解决表单大小调整问题的一种方法是使用 TFloorplanElement 组件的容器控件,我猜这就是图表工作室正在做的事情,但是如果您创建一个容器组件(TFloorplanContainer 例如)您可以以百分比指定元素的位置,或者在调整容器大小时调整缩放因子。容器当然会使用其锚属性将其绑定到其自己的容器(即表单)的边框。

每当调整容器大小时,您都会重新绘制包含的元素。正如我一开始所说的,我不确定这是否是适合您或您使用的图表工作室的解决方案,但如果我处于您的位置,这是我会考虑的一种方法。

I don't know if this is a solution that will fit your scenario, but if I were to design a similar application, I think I would take advantage of the easy nature of extending with new components in the VCL framework. I'd build components for the various graphical elements, door, wall, etc. I'd make a common object that they could inherit from.

For instance I'd make a TFloorplanElement component that all my graphical components could inherit from, I'd make the TFloorplanElement inherit from TGraphicControl to take advantage of the Anchor property given by TControl, and the Canvas provided by TGraphicControl. I wouldn't use a custom TPanel for this, I don't think the overhead of the windows handle provided by TWinControl is needed here.

For walls I'd make a component inheriting from my TFloorplanElement that is given two endpoints to connect the wall to, this could be either a door on one side and another wall on the other side, or any other combination of TFloorplanElement descendants. You need to have some sort of event handling for when either of these corners are moved, what you need to do in this case simply readjust the coordinates of your wall to the coordinates of the corner element.

One way you could solve the problem with form resizing, is by using a container control for your TFloorplanElement components, I guess that is what the Diagramming Studio is doing, but if you create a container component (TFloorplanContainer for instance) you could specify position of elements within in percentage, or have a scaling factor that was adjusted when the container was resized. The container ofcourse would be using its anchor properties binding it to the borders of its own container (ie. the form).

And whenever the container was resized you would redraw the containing elements. As I said to begin with, I'm not sure whether this is a solution that will work for you, or with the diagramming studio you use, but it is one approach I would consider, if I were in your place.

救赎№ 2024-08-28 06:09:38

看一下 TSimpleGraph,它可能会让您在这方面取得巨大的领先优势。它位于:
http://www.delphiarea.com/products/delphi-components/simplegraph/< /a>

这是一个免费组件,提供了一个面板,其中包含大量的方法、属性和事件处理程序的位置,而且效果非常华丽。他们提供了一个很好的 exe 演示,展示了一些可能性。他们为各种形状和线条定义了对象,但通过一些工作,我认为您可以添加自己的库存东西,例如墙壁等。

如果它适合您,TSimpleGraph 将提供一个很好的外壳,同时让您专注于您的内容应用程序。

Take a look at TSimpleGraph, which might get you a huge head start on this. It's at:
http://www.delphiarea.com/products/delphi-components/simplegraph/

It's a FREE component that provides a panel, with a huge assortment of methods, properties and places for event handlers, and the effect is pretty gorgeous. They provide a nice exe demo that shows of some of the possibilities. They have defined objects for various shapes and lines, but with some work I think you could add your own stock things like walls, etc.

If it works for you, TSimpleGraph would provide a nice housing, while letting you concentrate on the meat of your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文