10
10
from plot_script import measurement_data_plotting
11
11
from plot_script .config import gnuplot_preferences , user_config
12
12
from dialogs import LabelArrowDialog , StyleLine , SimpleEntryDialog , \
13
- PreviewDialog
13
+ PreviewDialog , VListEntry
14
14
from diverse_classes import PlotProfile
15
15
16
16
errorbars = False
@@ -357,6 +357,7 @@ def replot(self, echo=True):
357
357
# make sure hugeMD objects are removed from memory after plotting
358
358
if hasattr (self .active_dataset , 'tmp_export_file' ):
359
359
self .active_dataset .store_data ()
360
+ self .emit ('plot-drawn' )
360
361
361
362
def open_plot_options_window (self , action ):
362
363
'''
@@ -616,43 +617,73 @@ def show_last_plot_params(self, action):
616
617
param_dialog = gtk .Dialog (title = 'Last plot parameters:' )
617
618
param_dialog .set_default_size (600 , 600 )
618
619
# alignment table
619
- table = gtk .Table ( 1 , 2 , False )
620
+ vbox1 = gtk .VBox ( )
620
621
paned = gtk .VPaned ()
621
622
622
623
# Label
623
624
label = gtk .Label ('Gnuplot input for the last plot:' )
624
- table . attach (label , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 );
625
+ vbox1 . pack_start (label , expand = False )
625
626
626
627
# plot options
627
628
sw = gtk .ScrolledWindow ()
628
629
# Set the adjustments for horizontal and vertical scroll bars.
629
630
# POLICY_AUTOMATIC will automatically decide whether you need
630
631
# scrollbars.
631
632
sw .set_policy (gtk .POLICY_AUTOMATIC , gtk .POLICY_AUTOMATIC )
632
- text_field = gtk .Label (plot_text )
633
+ text_field1 = gtk .Label (plot_text )
633
634
#text_filed.set_markup(plot_text.replace('<', '[').replace('>', ']'))
634
- sw .add_with_viewport (text_field ) # add textbuffer view widget
635
- table . attach (sw , 0 , 1 , 1 , 2 , gtk . EXPAND | gtk . FILL , gtk . EXPAND | gtk . FILL , 0 , 0 )
636
- paned .add ( table )
635
+ sw .add_with_viewport (text_field1 ) # add textbuffer view widget
636
+ vbox1 . add (sw )
637
+ paned .add1 ( vbox1 )
637
638
# errors of the last plot
638
- if self .last_plot_text != '' :
639
- table = gtk .Table (1 , 2 , False )
640
- # Label
641
- label = gtk .Label ('Error during execution:' )
642
- table .attach (label , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 );
643
- sw = gtk .ScrolledWindow ()
644
- # Set the adjustments for horizontal and vertical scroll bars.
645
- # POLICY_AUTOMATIC will automatically decide whether you need
646
- # scrollbars.
647
- sw .set_policy (gtk .POLICY_AUTOMATIC , gtk .POLICY_AUTOMATIC )
648
- text_field = gtk .Label (self .last_plot_text )
649
- #text_field.set_markup()
650
- sw .add_with_viewport (text_field ) # add textbuffer view widget
651
- table .attach (sw , 0 , 1 , 1 , 2 , gtk .EXPAND | gtk .FILL , gtk .EXPAND | gtk .FILL , 0 , 0 )
652
- paned .add (table )
653
- paned .set_position (400 )
639
+ vbox2 = gtk .VBox ()
640
+ # Label
641
+ label = gtk .Label ('Error during execution:' )
642
+ vbox2 .pack_start (label , expand = False )
643
+ sw = gtk .ScrolledWindow ()
644
+ # Set the adjustments for horizontal and vertical scroll bars.
645
+ # POLICY_AUTOMATIC will automatically decide whether you need
646
+ # scrollbars.
647
+ sw .set_policy (gtk .POLICY_AUTOMATIC , gtk .POLICY_AUTOMATIC )
648
+ text_field2 = gtk .Label (self .last_plot_text )
649
+ #text_field.set_markup()
650
+ sw .add_with_viewport (text_field2 ) # add textbuffer view widget
651
+ vbox2 .add (sw )
652
+ paned .add2 (vbox2 )
653
+ paned .set_position (400 )
654
654
param_dialog .vbox .add (paned )
655
655
param_dialog .show_all ()
656
+ if self .last_plot_text == '' :
657
+ paned .set_position (580 )
658
+ def update_text (ignore ):
659
+ # recreate string after replot command
660
+ if self .active_multiplot :
661
+ itemlist = [item [0 ] for item in self .multiplot ]
662
+ if self .active_dataset in itemlist :
663
+ new_plot_text = measurement_data_plotting .create_plot_script (
664
+ self .active_session ,
665
+ [item [0 ] for item in self .multiplot ],
666
+ self .active_session .active_file_name ,
667
+ '' ,
668
+ self .multiplot [0 ][0 ].short_info ,
669
+ [item [0 ].short_info for item in self .multiplot ],
670
+ errorbars ,
671
+ self .active_session .TEMP_DIR + 'plot_temp.png' ,
672
+ fit_lorentz = False )
673
+ else :
674
+ new_plot_text = measurement_data_plotting .create_plot_script (
675
+ self .active_session ,
676
+ [self .active_dataset ],
677
+ self .active_session .active_file_name ,
678
+ '' ,
679
+ self .active_dataset .short_info ,
680
+ [ds .short_info for ds in self .active_dataset .plot_together ],
681
+ errorbars ,
682
+ output_file = self .active_session .TEMP_DIR + 'plot_temp.png' ,
683
+ fit_lorentz = False )
684
+ text_field1 .set_text (new_plot_text )
685
+ text_field2 .set_text (self .last_plot_text )
686
+ self .connect ('plot-drawn' , update_text )
656
687
# connect dialog to main window
657
688
self .open_windows .append (param_dialog )
658
689
param_dialog .connect ("destroy" , lambda * w : self .open_windows .remove (param_dialog ))
@@ -750,6 +781,7 @@ def change_plot_style(self, action):
750
781
Open a Dialog to chang the style of the current plot.
751
782
'''
752
783
dialog = gtk .Dialog (title = 'Plot style settings...' , parent = self )
784
+ dialog .set_default_size (600 , 300 )
753
785
nb = gtk .Notebook ()
754
786
nb .show ()
755
787
dialog .vbox .add (nb )
@@ -768,11 +800,11 @@ def change_plot_style(self, action):
768
800
tentry .show ()
769
801
title .add (entry )
770
802
title .add (tentry )
771
- dialog .vbox .add (title )
803
+ dialog .vbox .pack_start (title , expand = False )
772
804
tentry .connect ('activate' , self .change_plot_shortinfo , dataset )
773
805
line = StyleLine (dataset .plot_options , self .replot )
774
806
line .show ()
775
- main_items .add (line )
807
+ main_items .pack_start (line , expand = False )
776
808
i += 1
777
809
else :
778
810
datasets = self .active_dataset .plot_together
@@ -787,10 +819,10 @@ def change_plot_style(self, action):
787
819
tentry .connect ('activate' , self .change_plot_shortinfo , dataset )
788
820
title .add (entry )
789
821
title .add (tentry )
790
- main_items .add (title )
822
+ main_items .pack_start (title , expand = False )
791
823
line = StyleLine (dataset .plot_options , self .replot )
792
824
line .show ()
793
- main_items .add (line )
825
+ main_items .pack_start (line , expand = False )
794
826
sw = gtk .ScrolledWindow ()
795
827
sw .add_with_viewport (main_items )
796
828
sw .set_policy (gtk .POLICY_NEVER , gtk .POLICY_AUTOMATIC )
@@ -799,7 +831,22 @@ def change_plot_style(self, action):
799
831
# Create entries for the advanced options of the PlotOptions class
800
832
advanced_items = gtk .VBox ()
801
833
#
834
+ pre_entry = VListEntry (self .active_dataset .plot_options .free_input ,
835
+ title = 'Custom commands before script' )
836
+ pre_entry .show ()
837
+ advanced_items .pack_start (pre_entry , expand = False )
838
+ advanced_items .show_all ()
839
+ pre_entry .connect ('activate' , lambda * ignore : self .replot ())
840
+ post_entry = VListEntry (self .active_dataset .plot_options .free_input_after ,
841
+ title = 'Custom commands after settings' )
842
+ post_entry .show ()
843
+ advanced_items .pack_start (post_entry , expand = False )
844
+ button = gtk .Button ('Show gnuplot script' )
845
+ button .connect ('clicked' , self .show_last_plot_params )
846
+ advanced_items .pack_end (button , expand = False )
802
847
advanced_items .show_all ()
848
+ post_entry .connect ('activate' , lambda * ignore : self .replot ())
849
+ #
803
850
nb .append_page (advanced_items , gtk .Label ('Advanced Gnuplot Settings' ))
804
851
dialog .show ()
805
852
self .open_windows .append (dialog )
0 commit comments