|
Sweet Home 3D Forum » List all forums » » Forum: Developers » » » Thread: New feature: Caption |
|
| Print at Jan 21, 2026, 4:22:54 AM | |
| Posted by keymusicman at Oct 23, 2022, 10:22:37 PM |
New feature: CaptionHi everyone, I would like to present you a new feature for Sweet Home 3D called "Caption". I use the Sweet Home 3D while building my own house. One of the next steps in my house is the mounting of electrical equipment. For the electrical equipment like switches it's important to see an elevation on the 2D sheet but I've found no easy way to place it to the plan. So I have added this feature myself. I've added the ability to add any caption to any furniture. It also supports a templated text, for example, you can use $ELEVATION to place to target furniture elevation or $NAME to place the name. You can find a record of how it works here: https://youtu.be/VpYJFZLGZ1Q I will be glad to answer any questions you have about it. I would also like to contribute the Sweet Home 3D if you find this feature useful. Please give some contribution guides. Thank you for your attention ;)) |
| Posted by hansmex at Oct 24, 2022, 12:23:39 AM |
|
Re: New feature: Caption Very nice work!! Where can we download the plugin? Hans ---------------------------------------- Hans new website - under constuction hansdirkse.info |
| Posted by keymusicman at Oct 24, 2022, 9:05:40 AM |
|
Re: New feature: Caption Hans, Thank you for the appreciation! Actually, I decided to make this feature a core one. So there is no a plugin, I've added it directly to the Sweet Home source code. How can I share it with everyone? Should I upload the source or make a Sweet Home installer? Regards, Vasilij Maleev |
| Posted by hansmex at Oct 24, 2022, 11:18:21 AM |
|
Re: New feature: Caption Sorry to say, Vasilij, but that way I can't update SH3D without losing the functionality of your feature. Could you re-write it as a plugin, so that it can be used alongside the main program? Hans ---------------------------------------- Hans new website - under constuction hansdirkse.info |
| Posted by Puybaret at Oct 24, 2022, 11:56:06 AM |
|
Re: New feature: Caption Nice proposal Vasilij. You can post a source code patch in a feature request ticket if you want. Hans, I fear this can't be transformed as a plug-in because it changes the behavior of the plan and how it's drawn. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by hansmex at Oct 24, 2022, 2:02:11 PM |
|
Re: New feature: Caption Emmanuel, thats too bad :-( Any chance it gets a place in SH3D v8 ?? ---------------------------------------- Hans new website - under constuction hansdirkse.info |
| Posted by keymusicman at Oct 24, 2022, 2:02:14 PM |
|
Re: New feature: Caption Writing a plugin was my first thought. But Emmanuel is right, the plugins API seems not enough to implement this as a plugin. Thank you for the feature requests link. I would definitely like to post a patch. Emmanuel, can I message you directly in the case of questions about a feature request? |
| Posted by Puybaret at Oct 24, 2022, 2:28:27 PM |
|
Re: New feature: Caption Any chance it gets a place in SH3D v8 ?? That would imply quite a lot of changes because changing how user interface components are displayed and behave should be feasible from more than a plug-in. And I'm not sure it would be such a good idea, because such plug-ins would have to always interact nicely with the default behavior of the program and other plug-ins.Vasilij, don't hesitate to write me directly and sorry if I didn't answer faster to your last mail. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by Daniels118 at Oct 25, 2022, 8:12:07 PM |
|
Re: New feature: Caption I think this could be programmed as a plugin using the standard API. I'm not saying this would be easy, but I'm sure it can be done. Here some tips: a) The monitoring of furniture properties like name and elevation can be monitored by attaching listeners. b) From a graphical point of view you need only basic elements, i.e. the polyline and the label. c) The label and polyline can be logically linked to a furniture using the custom properties. d) The label position relative to the furniture can be saved using custom properties. e) as a furniture moves the polyline and label position can be changed accordingly using a listener (as at point A). If you look at the "Link selected furniture" feature from the Wirings plugin you can get an idea of how it cloud be done in a plugin. Watch the last part of the following video, you will see polylines that follow a furniture: https://youtu.be/Z_XFq4QaD8E |
| Posted by keymusicman at Nov 5, 2022, 12:02:38 PM |
|
Re: New feature: Caption Hello Daniels, Thank you for the reply. I made one more try with a plugin. I've downloaded the Wirings plugin and explored this a little bit. I still have some questions, can you please help with this? - If I understand correctly, the Wirings plugin is built upon the "polyline" feature so the core part of SH3D knows how to handle it. The new feature requires new drawings and I've found no API to do this. Have I missed something? How can I draw a 2D graphics I need? - The saving and reading home elements is also hard for a new types of elements, I've also found no API to do this. If you have ideas on how I can implement this in a plugin, please share 🙂 I would be glad to make a plugin Regards, Vasilij Maleev |
| Posted by Daniels118 at Nov 5, 2022, 9:39:50 PM |
|
Re: New feature: Caption Hi Vasilij, you're right, the wirings are just [enhanced] polylines. To understand what it can be done and what cannot, we have to look at how SH3D works. Each class of object is stored in a distinct list member of the Home class: private List<HomePieceOfFurniture> furniture;The drawing is implemented in PlanComponent.paintHomeItems(...) by drawing each item of these lists: paintRooms(g2D, selectedItems, ...);Although the items in each list can be added or removed, there is no chance to add a new list to draw another class of objects. This means you have to resort to the current object classes. The Wirings and 3D dimension lines plugins work by extending one of the existing object classes (i.e. the polyline), by overriding the actual drawing code for the 3D view. This required some hack thich I'm not going to explain here. For your project I wouldn't use this approach, because basically you can use the current object classes without changing the drawing code. Let's call your new object "Caption", and let's see the difference with Wirings. The Wiring extends the polyline by adding a 3rd dimension to each point and changing the drawing code to handle 3 dimensions. The Caption is a collection of 2 objects: a standard Polyline and a standard Label. The caption doesn't need to draw a new type of object. It should only place a standard Polyline and a standard Label, and use event handling to enforce some rules, i.e. the polyline must always have exaclty 3 points, one attached to the furniture, and the other 2 attached to the bottom left and bottom right corners of the label; if the user moves the furniture, then the polyline and the label must translate with the furniture; if the user moves the label, then the 2 polyline points must move with the label. The offsets of the polyline and the label relative to the furniture must be saved in a custom property, so that you can keep it constant when translating. If the user tries to move a point of the polyline you should block it by forcing its position to the expected value. So the question is: how to know which furniture the polyline and the label belong to? It's easy: when you create the polyline and the label through the plugin, you also set a custom property on both objects, which is set to the id of the selected furniture. The text template can be stored in a custom property of the label, while the actual text of the label is computed by your plugin and updated from the template each time a change is detected in the properties of the attached furniture. This is how the "Link selected furniture" feature is capable of updating wirings position when the linked furnitures are moved around. You don't need to implement saving and reading of a new type, everythng you need are the custom properties which are already persisted. If you would follow this road, I would be happy to help you. But please be aware that I would only give hints and some code snippets, I'm not going to write whole pages of code for you (that would be matter for a paid work). You are free to copy as much code you need from the Wirings plugin as long as you respect the GPL license. Best regards, Daniele |
| Posted by keymusicman at Nov 6, 2022, 5:49:48 AM |
|
Re: New feature: Caption Thank you for the so much details. I missed the custom properties, it seems to be very flexible! There will be another difficulties. For example: while editing a Caption I need to edit not the Text itself but its Template. If I use a Label, it will edit a Text by default. And this is not the only problem I see. While I can heroically find some workarounds for this, I would prefer to have a clear feature in the core part of SH3D. I believe that such a feature should be important for a modeling software. Ideally, there could be an API that allows to extend the SH3D with a new elements without modifying the core part. Daniele, I appreciate your help very much. I will follow your advices if Emmanuel declines my changes |
|
|
Current timezone is GMT Jan 21, 2026, 4:22:54 AM |