Bug found in HomefurniturePanel.java

This topic has been viewed 3508 times and has 8 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
Walter125
Posts: 25
Joined: Mon Sep 11, 2023 12:04 pm

Bug found in HomefurniturePanel.java

Post by Walter125 »

Hi,

I'm using linux version of SweetHome3D.

When I try to modify a furniture, for example open the door of a kitchen cabinet, the most of time, the 3D view of the cabinet isn't shown, and so, I can't open the door.

After several clicks on the button to reloads of the ModelTransformationsPanel, the 3D view of the model is finally shown.

The bug doesn't appear when I compile SweetHome3D with the following modification, arround line 2111 in HomefurniturePanel.java:

Code: Select all

    private void layoutComponents() {
      int standardGap = Math.round(5 * SwingTools.getResolutionScale());
      // Preview
      
      // BUG Here ?
      /*
      add(this.transformationsLabel, new GridBagConstraints(
          0, 0, 2, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.NONE, new Insets(0, 0, standardGap, 10), 0, 0));
      */
      
      this.previewComponent.setPreferredSize(new Dimension(400, 400));
      add(this.previewComponent, new GridBagConstraints(
          0, 1, 1, 10, 0, 0, GridBagConstraints.NORTH,
          GridBagConstraints.NONE, new Insets(0, 2, 0, 15), 0, 0));
      add(this.resetTransformationsButton, new GridBagConstraints(
          1, 1, 1, 1, 0, 0, GridBagConstraints.NORTH,
          GridBagConstraints.BOTH, new Insets(0, 2, standardGap, 0), 0, 0));
I have commented the lines adding a label to the grid. With this modification, the 3D view of the model is shown each time I open the transformations panel.

But I'm not used to program grid layouts, so I don't know how to correct this bug.

At a first look, the grid layouts of all the objects seem to me to be correct.
User avatar
Keet
Posts: 1807
Joined: Fri Apr 08, 2022 7:13 am
Country: Netherlands

Re: Bug found in HomefurniturePanel.java

Post by Keet »

I've had the same but always thought is was the momentary lack of resources on my system. If it's really this bug I'm sure Emmanuel will have it solved pretty fast.
Dodecagon.nl
1300+ 3D models, manuals, and projects
User avatar
Daniels118
Posts: 503
Joined: Wed Nov 17, 2021 9:04 pm
Country: Italy

Re: Bug found in HomefurniturePanel.java

Post by Daniels118 »

You may report the bug here:
https://sourceforge.net/p/sweethome3d/bugs/

It will help the developer to keep track of problems that must be solved (the forum post could be forgotten after a while).
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Bug found in HomefurniturePanel.java

Post by Puybaret »

This looks like the bug #1184.
Emmanuel Puybaret, Sweet Home 3D creator
User avatar
Keet
Posts: 1807
Joined: Fri Apr 08, 2022 7:13 am
Country: Netherlands

Re: Bug found in HomefurniturePanel.java

Post by Keet »

It does look like bug #1184. But I doubt it's a system update problem. I run into it every now and then on three different systems. Although all three are Debian (one host, two VM) they are different versions. The same problem persists on all three before and after system updates. Sometimes it helps to close Sweet Home 3D and restart it, other times I just keep on trying and after multiple tries it suddenly works.
It's as if the 3D view to display the model can't be painted. In rare cases just modifying a color and then trying the deformations works, as if the model wasn't fully loaded before and changing a color loaded it correctly for 3D display.
The main problem is that it isn't consistent, not even with the exact same model. This makes it very hard to determine what exactly is causing this. As far as I remember this happens with all versions of Sweet Home 3D, at least for the last 1-2 years.
Dodecagon.nl
1300+ 3D models, manuals, and projects
Walter125
Posts: 25
Joined: Mon Sep 11, 2023 12:04 pm

Re: Bug found in HomefurniturePanel.java

Post by Walter125 »

I think it is a bug internal to the java linux implementation.

It seems I have found a workarround, adding the following line before to add the Label to the grid at line 2111:

Code: Select all

this.transformationsLabel.setPreferredSize(this.transformationsLabel.getPreferredSize());
I haven't a good knowledge of the program, but I also wonder if the size of the previewComponent should be scaled by in order to be adapted to the screen resolution, at line 2114 ?

Example of scaling:

Code: Select all

float scale = SwingTools.getResolutionScale();

this.previewComponent.setPreferredSize(new Dimension((int)(400*scale), (int)(400*scale)));
instead of actually:

Code: Select all

this.previewComponent.setPreferredSize(new Dimension(400, 400));
Walter125
Posts: 25
Joined: Mon Sep 11, 2023 12:04 pm

Re: Bug found in HomefurniturePanel.java

Post by Walter125 »

I just noticed the previewComponent is already scaled in the function createComponents, so the line 2114 that rescale it, should be removed ?
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Bug found in HomefurniturePanel.java

Post by Puybaret »

Adding the line

Code: Select all

this.transformationsLabel.setPreferredSize(this.transformationsLabel.getPreferredSize());
should have no effect, since without this line the layout will try to set the label to its preferred size.
The problem looks like the preferred size is actually different when the container is laid out and when it's displayed.
Maybe forcing the preferred size to a larger size could fix the problem (a few pixels along width or height) without breaking container layout in Java implementations where it works now. Can you try?
Emmanuel Puybaret, Sweet Home 3D creator
Walter125
Posts: 25
Joined: Mon Sep 11, 2023 12:04 pm

Re: Bug found in HomefurniturePanel.java

Post by Walter125 »

Following your suggestion, I tried to add 1 pixel only to the height, it also works. With the following code:

Code: Select all

Dimension size = this.transformationsLabel.getPreferredSize();
size.height = size.height + 1;
this.transformationsLabel.setPreferredSize(size);
I tried to add 1 pixel only to the width, and 1 pixel both to the width and the height. It worked in all these cases.

About the line I suggested, I don't know why but it works on my system.

I precise that like Keet, I'm using Debian.
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest