Example #1
0
def start_fig_update(self):
    '''Mutates the matplotlib figure to show data. Takes data from 
    various input fields.'''

    self.status_text.SetLabel('Computing Field...')

    domain_x = (float(self.x1_input_field.GetValue()),float(self.x2_input_field.GetValue()))
    range_y = (float(self.y1_input_field.GetValue()),float(self.y2_input_field.GetValue()))
    plot_type= self.plot_type_selector.GetValue()
    vector_type = self.vector_drawing_selector.GetValue()
    field_type = self.field_type_selector.GetValue()

    xs, ys, cs = parse_dsl(self.input_text_ctrl.GetValue(),self.display_help_msg_callback)
    

    if xs == []:
        self.set_console_msg('Input cannot be empty!\
                             Update with "help" for commands')

    elif xs == None:
        pass

    elif GUI_CONSTANTS['Cache']==[domain_x,range_y,plot_type, field_type, self.input_text_ctrl.GetValue(),vector_type]:
        return

    elif GUI_CONSTANTS['Cache'][0:5]==[domain_x,range_y,plot_type, field_type, self.input_text_ctrl.GetValue()] and GUI_CONSTANTS['Cache'][5]!= vector_type:
        tmp = GUI_CONSTANTS['Field_Cache'][0:9]
        fig, X, Y, Xq, Yq, F, Fq, res, direc=\
        plot_on_fig(tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5],tmp[6],tmp[7],direc=vector_type)
        
        GUI_CONSTANTS['Cache'] = [domain_x,range_y,plot_type, field_type, self.input_text_ctrl.GetValue(), vector_type]
        GUI_CONSTANTS['Field_Cache'] = [fig, X, Y, Xq, Yq, F, Fq, res, direc]
        self.canvas.draw()
        return

    else:

        fig, X, Y, Xq, Yq, F, Fq, res, direc =\
        force_field(self.figure, plot_type, vector_type,
                    domain_x, range_y,xs,ys,cs,field_type, res = 100)

        self.canvas.draw()
        GUI_CONSTANTS['Cache'] = [domain_x,range_y,plot_type, field_type, self.input_text_ctrl.GetValue(), vector_type]
        GUI_CONSTANTS['Field_Cache'] = [fig, X, Y, Xq, Yq, F, Fq, res, direc]
        self.status_text.SetLabel('Render Finished')
Example #2
0
def save_charge_field(self,e):
    ''' Saves what's currently in the input box'''
    wildcard = "Files (*.figsave)|*.figsave"
    save_dlg = wx.FileDialog(
        self, message = 'Choose file',
        defaultDir=os.getcwd()+"/Saves",
        defaultFile="",
        wildcard=wildcard,
        style=wx.SAVE | wx.CHANGE_DIR
        )

    if save_dlg.ShowModal() == wx.ID_OK:
        path = save_dlg.GetPaths()[0]            
    save_dlg.Destroy()

    xs, ys, cs = parse_dsl(self.input_text_ctrl.GetValue(),
                            self.display_help_msg_callback)
    save_data(path,xs,ys,cs)