3535from loopstructural .gui .loop_widget import LoopWidget
3636from loopstructural .main .data_manager import ModellingDataManager
3737from loopstructural .main .model_manager import GeologicalModelManager
38- from loopstructural .toolbelt import PlgLogger
38+ from loopstructural .toolbelt import PlgLogger , PlgOptionsManager
3939
4040# ############################################################################
4141# ########## Classes ###############
@@ -127,9 +127,13 @@ def initGui(self):
127127 self .tr ("LoopStructural Modelling" ),
128128 self .iface .mainWindow (),
129129 )
130+ self .action_visualisation = QAction (
131+ QIcon (os .path .dirname (__file__ ) + "/3D_icon.png" ),
132+ self .tr ("LoopStructural Visualisation" ),
133+ self .iface .mainWindow (),
134+ )
130135
131136 self .toolbar .addAction (self .action_modelling )
132-
133137 # -- Menu
134138 self .iface .addPluginToMenu (__title__ , self .action_settings )
135139 self .iface .addPluginToMenu (__title__ , self .action_help )
@@ -150,36 +154,102 @@ def initGui(self):
150154 self .iface .pluginHelpMenu ().addAction (self .action_help_plugin_menu_documentation )
151155
152156 ## --- dock widget
153- self .loop_dockwidget = QDockWidget (self .tr ("Loop" ), self .iface .mainWindow ())
154- self .loop_widget = LoopWidget (
155- self .iface .mainWindow (),
156- mapCanvas = self .iface .mapCanvas (),
157- logger = self .log ,
158- data_manager = self .data_manager ,
159- model_manager = self .model_manager ,
160- )
157+ # Get the setting for separate dock widgets
158+ settings = PlgOptionsManager .get_plg_settings ()
159+
160+ if settings .separate_dock_widgets :
161+ # Create separate dock widgets for modelling and visualisation
162+ self .loop_widget = LoopWidget (
163+ self .iface .mainWindow (),
164+ mapCanvas = self .iface .mapCanvas (),
165+ logger = self .log ,
166+ data_manager = self .data_manager ,
167+ model_manager = self .model_manager ,
168+ )
169+ self .toolbar .addAction (self .action_visualisation )
161170
162- self .loop_dockwidget .setWidget (self .loop_widget )
163- self .iface .addDockWidget (Qt .RightDockWidgetArea , self .loop_dockwidget )
164- right_docks = [
165- d
166- for d in self .iface .mainWindow ().findChildren (QDockWidget )
167- if self .iface .mainWindow ().dockWidgetArea (d ) == Qt .RightDockWidgetArea
168- ]
169- # If there are other dock widgets, tab this one with the first one found
170- if right_docks :
171- for dock in right_docks :
172- if dock != self .loop_dockwidget :
173- self .iface .mainWindow ().tabifyDockWidget (dock , self .loop_dockwidget )
174- # Optionally, bring your plugin tab to the front
175- self .loop_dockwidget .raise_ ()
176- break
177- self .loop_dockwidget .show ()
178-
179- self .loop_dockwidget .close ()
180-
181- # -- Connect actions
182- self .action_modelling .triggered .connect (self .loop_dockwidget .toggleViewAction ().trigger )
171+ # Create modelling dock
172+ self .modelling_dockwidget = QDockWidget (
173+ self .tr ("Loop - Modelling" ), self .iface .mainWindow ()
174+ )
175+ self .modelling_dockwidget .setWidget (self .loop_widget .get_modelling_widget ())
176+ self .iface .addDockWidget (Qt .RightDockWidgetArea , self .modelling_dockwidget )
177+
178+ # Create visualisation dock
179+ self .visualisation_dockwidget = QDockWidget (
180+ self .tr ("Loop - Visualisation" ), self .iface .mainWindow ()
181+ )
182+ self .visualisation_dockwidget .setWidget (self .loop_widget .get_visualisation_widget ())
183+ self .iface .addDockWidget (Qt .RightDockWidgetArea , self .visualisation_dockwidget )
184+
185+ # Tab them with other right docks if available
186+ right_docks = [
187+ d
188+ for d in self .iface .mainWindow ().findChildren (QDockWidget )
189+ if self .iface .mainWindow ().dockWidgetArea (d ) == Qt .RightDockWidgetArea
190+ ]
191+ if right_docks :
192+ for dock in right_docks :
193+ if dock != self .modelling_dockwidget and dock != self .visualisation_dockwidget :
194+ self .iface .mainWindow ().tabifyDockWidget (dock , self .modelling_dockwidget )
195+ self .modelling_dockwidget .raise_ ()
196+ break
197+
198+ # Tab visualisation with modelling
199+ self .iface .mainWindow ().tabifyDockWidget (
200+ self .modelling_dockwidget , self .visualisation_dockwidget
201+ )
202+
203+ self .modelling_dockwidget .show ()
204+ self .visualisation_dockwidget .show ()
205+ self .modelling_dockwidget .close ()
206+ self .visualisation_dockwidget .close ()
207+
208+ # Connect action to toggle modelling dock
209+ self .action_modelling .triggered .connect (
210+ self .modelling_dockwidget .toggleViewAction ().trigger
211+ )
212+ self .action_visualisation .triggered .connect (
213+ self .visualisation_dockwidget .toggleViewAction ().trigger
214+ )
215+ # Store reference to main dock as None for unload compatibility
216+ self .loop_dockwidget = None
217+ else :
218+ # Create single dock widget with tabs (default behavior)
219+ self .loop_dockwidget = QDockWidget (self .tr ("Loop" ), self .iface .mainWindow ())
220+ self .loop_widget = LoopWidget (
221+ self .iface .mainWindow (),
222+ mapCanvas = self .iface .mapCanvas (),
223+ logger = self .log ,
224+ data_manager = self .data_manager ,
225+ model_manager = self .model_manager ,
226+ )
227+
228+ self .loop_dockwidget .setWidget (self .loop_widget )
229+ self .iface .addDockWidget (Qt .RightDockWidgetArea , self .loop_dockwidget )
230+ right_docks = [
231+ d
232+ for d in self .iface .mainWindow ().findChildren (QDockWidget )
233+ if self .iface .mainWindow ().dockWidgetArea (d ) == Qt .RightDockWidgetArea
234+ ]
235+ # If there are other dock widgets, tab this one with the first one found
236+ if right_docks :
237+ for dock in right_docks :
238+ if dock != self .loop_dockwidget :
239+ self .iface .mainWindow ().tabifyDockWidget (dock , self .loop_dockwidget )
240+ # Optionally, bring your plugin tab to the front
241+ self .loop_dockwidget .raise_ ()
242+ break
243+ self .loop_dockwidget .show ()
244+
245+ self .loop_dockwidget .close ()
246+
247+ # -- Connect actions
248+ self .action_modelling .triggered .connect (self .loop_dockwidget .toggleViewAction ().trigger )
249+
250+ # Store references to separate docks as None for unload compatibility
251+ self .modelling_dockwidget = None
252+ self .visualisation_dockwidget = None
183253
184254 def tr (self , message : str ) -> str :
185255 """Translate a string using Qt translation API.
@@ -198,6 +268,17 @@ def tr(self, message: str) -> str:
198268
199269 def unload (self ):
200270 """Clean up when plugin is disabled or uninstalled."""
271+ # -- Clean up dock widgets
272+ if self .loop_dockwidget :
273+ self .iface .removeDockWidget (self .loop_dockwidget )
274+ del self .loop_dockwidget
275+ if self .modelling_dockwidget :
276+ self .iface .removeDockWidget (self .modelling_dockwidget )
277+ del self .modelling_dockwidget
278+ if self .visualisation_dockwidget :
279+ self .iface .removeDockWidget (self .visualisation_dockwidget )
280+ del self .visualisation_dockwidget
281+
201282 # -- Clean up menu
202283 self .iface .removePluginMenu (__title__ , self .action_help )
203284 self .iface .removePluginMenu (__title__ , self .action_settings )
0 commit comments