@@ -67,7 +67,7 @@ def __init__(self):
6767 self .ui .plot_pushButton .clicked .connect (self .plot )
6868 self .ui .fit_pushButton .clicked .connect (self .call_fit_and_plot )
6969 self .ui .clear_pushButton .clicked .connect (self .clear_plot )
70- self .ui .export_plot_pushButton .clicked .connect (self .pub_ready_plot_export )
70+ self .ui .export_plot_pushButton .clicked .connect (self .export_window ) #pub_ready_plot_export
7171 self .ui .calculate_srv_pushButton .clicked .connect (self .calculate_srv )
7272
7373 self .ui .log_checkBox .stateChanged .connect (self .make_semilog )
@@ -518,6 +518,10 @@ def export_data(self):
518518
519519 def clear_export_data (self ):
520520 self .data_list = []
521+
522+ def export_window (self ):
523+ self .exportplotwindow = ExportPlotWindow ()
524+ self .exportplotwindow .export_fig_signal .connect (self .pub_ready_plot_export )
521525
522526 def pub_ready_plot_export (self ):
523527 try :
@@ -526,19 +530,27 @@ def pub_ready_plot_export(self):
526530 plt .figure (figsize = (8 ,6 ))
527531 plt .tick_params (direction = 'out' , length = 8 , width = 3.5 )
528532 if self .ui .save_w_fit_checkBox .isChecked ():
529- plt .plot (self .out [:,0 ],self .out [:,1 ]/ np .max (self .out [:,1 ]))
530- plt .plot (self .out [:,0 ],self .out [:,2 ]/ np .max (self .out [:,1 ]),'k' )
533+ plt .plot (self .out [:,0 ],self .out [:,1 ]/ np .max (self .out [:,1 ]),self .exportplotwindow .ui .traceColor_comboBox .currentText ())
534+ plt .plot (self .out [:,0 ],self .out [:,2 ]/ np .max (self .out [:,1 ]),self .exportplotwindow .ui .fitColor_comboBox .currentText ())
535+ if self .exportplotwindow .ui .legend_checkBox .isChecked ():
536+ plt .legend ([self .exportplotwindow .ui .legend1_lineEdit .text (),self .exportplotwindow .ui .legend2_lineEdit .text ()])
531537 else :
532- plt .plot (self .acquire_settings ()[0 ],self .acquire_settings ()[1 ]/ np .max (self .acquire_settings ()[1 ]))
538+ plt .plot (self .acquire_settings ()[0 ],self .acquire_settings ()[1 ]/ np .max (self .acquire_settings ()[1 ]),
539+ self .exportplotwindow .ui .traceColor_comboBox .currentText ())
540+ if self .exportplotwindow .ui .legend_checkBox .isChecked ():
541+ plt .legend ([self .exportplotwindow .ui .legend1_lineEdit .text ()])
533542 plt .yscale ('log' )
534543 plt .xlabel ("Time (ns)" , fontsize = 20 , fontweight = 'bold' )
535544 plt .ylabel ("Intensity (norm.)" , fontsize = 20 , fontweight = 'bold' )
536545 plt .tight_layout ()
546+ plt .xlim ([self .exportplotwindow .ui .lowerX_spinBox .value (),self .exportplotwindow .ui .upperX_spinBox .value ()])
547+ plt .ylim ([10 ** (self .exportplotwindow .ui .lowerY_spinBox .value ()),self .exportplotwindow .ui .upperY_doubleSpinBox .value ()])
537548
538549 plt .savefig (filename [0 ],bbox_inches = 'tight' , dpi = 300 )
539550 plt .close ()
540551
541- except :
552+ except Exception as e :
553+ self .ui .Result_textBrowser .append (format (e ))
542554 pass
543555
544556 def close_application (self ):
@@ -572,6 +584,38 @@ def done(self):
572584 self .skip_rows_signal .emit ()
573585 self .close ()
574586
587+ """Export plot GUI"""
588+ ui_file_path = (base_path / "export_plot.ui" ).resolve ()
589+ export_WindowTemplate , export_TemplateBaseClass = pg .Qt .loadUiType (ui_file_path )
590+
591+ class ExportPlotWindow (export_TemplateBaseClass ):
592+
593+ export_fig_signal = QtCore .pyqtSignal ()
594+
595+ def __init__ (self ):
596+ export_TemplateBaseClass .__init__ (self )
597+
598+ self .ui = export_WindowTemplate ()
599+ self .ui .setupUi (self )
600+ self .ui .traceColor_comboBox .addItems (["C0" ,"C1" ,"C2" ,"C3" ,"C4" ,"C5" ,"C6" ,"C7" , "r" , "g" , "b" , "y" , "k" ])
601+ self .ui .fitColor_comboBox .addItems (["k" , "r" , "b" , "y" , "g" ,"C0" ,"C1" ,"C2" ,"C3" ,"C4" ,"C5" ,"C6" ,"C7" ])
602+ self .ui .export_pushButton .clicked .connect (self .export )
603+ self .ui .legend_checkBox .stateChanged .connect (self .legend_title )
604+ self .show ()
605+
606+ def legend_title (self ):
607+ if self .ui .legend_checkBox .isChecked ():
608+ self .ui .legend1_lineEdit .setEnabled (True )
609+ self .ui .legend2_lineEdit .setEnabled (True )
610+ else :
611+ self .ui .legend1_lineEdit .setEnabled (False )
612+ self .ui .legend2_lineEdit .setEnabled (False )
613+
614+ def export (self ):
615+ self .export_fig_signal .emit ()
616+ self .close ()
617+
618+
575619def run ():
576620 win = MainWindow ()
577621 QtGui .QApplication .instance ().exec_ ()
0 commit comments