France
Joined: May 6, 2012
Post Count: 17
Status:
Offline
Attach View issue
Hello dear developpers,
I actually have an issue modifying the source code of Sweet Home. I want to create a new window with only the 3D view. I don't want to use the DetachView() function because I want to add other components in the window.
I then used the line view3D = (JComponent)homeController.getHomeController3D().getView();
to include the view in my window.
The problem is that the 3D view gets out of the main frame of sweetHome when I do that.
When I close the window, I want the 3D view to reattach into the SweetHome main window. I tried to put this line into a listener of the second window but it doesn't work : homeController.attachView(homeController.getHomeController3D().getView());
Firstly, I don't understand why it does not work.
My next idea is to make a .validate(); .repaint(); of the HomeFramePane so I would place a listener of the second window in the HomeFramePane or HomePane class. I don't know how to do this, as long as I have the error "cannot be resolved to a type" when I do in the second window class addListener(secondWindowListener);
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: Attach View issue
If you want two 3D views, you'll have to instantiate a second 3D view with its controller or program an other one, otherwise both 3D views will share the same exact viewpoint.
By the way, it would be nice to explain why you want to make such changes...
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
France
Joined: May 6, 2012
Post Count: 17
Status:
Offline
Re: Attach View issue
Thanks for your answer,
You are absolutely right, it's clearer in its context. The reasons why I want to do this : the SH3D application I have modified is in communication with some sensors (temperature, brigthness, electric consumption) through a database. For a project I have to achieve for school, I want to create what I called a "monitoring mode", where you cannot modify your house any more but you can just visualize it, with the sensors placed in the rooms, and graphs you get from your sensors.
It is not a problem for me if the two pages share the same viewpoint, as long as the "monitoring mode pannel" is big enough (to show all informations from sensors) to hide the main frame of SH3D. I just would like to reattach the view in the main frame when I close the monitoring mode (to continue editting the house for example).
Creating a new controller with its own viewFactory, contentManager... seems to me too complicated for what I need.
France
Joined: May 6, 2012
Post Count: 17
Status:
Offline
Re: Attach View issue
I've now succeeded in doing a homePane.validate() and homePane.repaint() after closing the second window using the observer design pattern, but this doesn't change anything (I precise again that this is after doing a homeController.attachView(homeController.getHomeController3D.getview());
Thank you for your interest, I just don't understand why it doesn't work.
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: Attach View issue
I think you're not on the easiest track. You don't need an other view factory, just use the one of Sweet Home 3D. Create a new HomeController3D instance, with home, preferences and viewFactory of Sweet Home 3D (I think you can set contentManager and undoSupport to null for your case), and call getView to get an other 3D view that you add to any window. If you don't need any mouse/keyboard interaction you can even instantiate HomeComponent3D class directly with a null controller, and add this component to a frame.
Will your project be distributed to the public?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
France
Joined: May 6, 2012
Post Count: 17
Status:
Offline
Re: Attach View issue
Thank you very much it works perfectly well !
It was so simple...!
I have not thought distributing it to the public because I am a beginner in Java and I've not made things very properly... I have modified methods without comments... And furthermore I have not followed the MVC architecture for my extension. I think my work cannot be distributed to the public. But if somebody contacts me by Private Message I would share my work with pleasure.
I really wonder how you can still be so active 7 years after the beginning ! Thank you for you investment in it M. Puybaret !