@@ -459,6 +459,23 @@ def run(self, fixed_params, params, inspect=None):
459459 self .__emitter .status ('Started simulation/trace in background shell...' )
460460 subprocess .Popen (runstr , shell = True )
461461
462+ def vis_run (self , tool = '' ):
463+
464+ runstr = tool + ' ' + os .path .basename (self .__instrFile ) + ' -n100 -y'
465+
466+ # Add & for backgrounding on Unix systems
467+ if not os .name == 'nt' :
468+ runstr = runstr + ' &'
469+ else :
470+ runstr = 'start ' + runstr
471+
472+ # Ensure assembled runstr is a string, not a QString
473+ runstr = str (runstr )
474+
475+ self .__emitter .status ('Starting visualisation in background shell...' )
476+ self .__emitter .message (runstr , gui = False )
477+ subprocess .Popen (runstr , shell = True )
478+
462479 def __runFinished (self , process_returncode ):
463480 self .__fireSimStateUpdate ()
464481 if process_returncode == 0 :
@@ -741,35 +758,22 @@ def handleMcDisplayWeb(self):
741758 DISPLAY = "mcdisplay"
742759 else :
743760 DISPLAY = "mxdisplay"
744- self .emitter .status ('Running ' + DISPLAY + '-webgl...' )
745- try :
746- cmd = DISPLAY + '-webgl --default -n100 ' + os .path .basename (self .state .getInstrumentFile ()) + '&'
747- self .emitter .message (cmd , gui = True )
748- self .emitter .message ('' , gui = True )
749-
750- def messg (s ): self .emitter .message (s )
751- def messg_err (s ): self .emitter .message (s , err_msg = True )
752- utils .run_subtool_to_completion (cmd , stdout_cb = messg , stderr_cb = messg_err )
753- finally :
754- self .emitter .status ('' )
755-
761+ tool = DISPLAY + "-webgl-classic"
762+
763+ self .emitter .status ('Running ' + tool )
764+ self .state .vis_run (tool = tool )
765+
756766 def handleMcDisplay2D (self ):
757767 if mccode_config .configuration ["MCCODE" ]== "mcstas" :
758768 DISPLAY = "mcdisplay"
759769 else :
760770 DISPLAY = "mxdisplay"
761- self .emitter .status ('Running ' + DISPLAY + '-pyqtgraph...' )
762- try :
763- cmd = DISPLAY + '-pyqtgraph --default -n100 ' + os .path .basename (self .state .getInstrumentFile ()) + '&'
764- self .emitter .message (cmd , gui = True )
765- self .emitter .message ('' , gui = True )
766-
767- def messg (s ): self .emitter .message (s )
768- def messg_err (s ): self .emitter .message (s , err_msg = True )
769- utils .run_subtool_to_completion (cmd , stdout_cb = messg , stderr_cb = messg_err )
770- finally :
771- self .emitter .status ('' )
772-
771+ tool = DISPLAY + "-pyqtgraph"
772+
773+ self .emitter .status ('Running ' + tool )
774+ self .state .vis_run (tool = tool )
775+
776+
773777 def handleHelpWeb (self ):
774778 # open the mcstas homepage
775779 mcurl = 'http://www.' + mccode_config .configuration ["MCCODE" ]+ '.org'
0 commit comments