@@ -67,7 +67,7 @@ def __init__(self):
67
67
self .ui .plot_pushButton .clicked .connect (self .plot )
68
68
self .ui .fit_pushButton .clicked .connect (self .call_fit_and_plot )
69
69
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
71
71
self .ui .calculate_srv_pushButton .clicked .connect (self .calculate_srv )
72
72
73
73
self .ui .log_checkBox .stateChanged .connect (self .make_semilog )
@@ -518,6 +518,10 @@ def export_data(self):
518
518
519
519
def clear_export_data (self ):
520
520
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 )
521
525
522
526
def pub_ready_plot_export (self ):
523
527
try :
@@ -526,19 +530,27 @@ def pub_ready_plot_export(self):
526
530
plt .figure (figsize = (8 ,6 ))
527
531
plt .tick_params (direction = 'out' , length = 8 , width = 3.5 )
528
532
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 ()])
531
537
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 ()])
533
542
plt .yscale ('log' )
534
543
plt .xlabel ("Time (ns)" , fontsize = 20 , fontweight = 'bold' )
535
544
plt .ylabel ("Intensity (norm.)" , fontsize = 20 , fontweight = 'bold' )
536
545
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 ()])
537
548
538
549
plt .savefig (filename [0 ],bbox_inches = 'tight' , dpi = 300 )
539
550
plt .close ()
540
551
541
- except :
552
+ except Exception as e :
553
+ self .ui .Result_textBrowser .append (format (e ))
542
554
pass
543
555
544
556
def close_application (self ):
@@ -572,6 +584,38 @@ def done(self):
572
584
self .skip_rows_signal .emit ()
573
585
self .close ()
574
586
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
+
575
619
def run ():
576
620
win = MainWindow ()
577
621
QtGui .QApplication .instance ().exec_ ()
0 commit comments