Example #1
0
    def __init__(self):
        super(MeshViewController, self).__init__('Mesh')
        self.layout = QVBoxLayout()
        self.buttons = QHBoxLayout()
        self.stack = QStackedLayout()

        # Add child container to parent container
        self.layout.addLayout(self.buttons)
        self.layout.addLayout(self.stack)

        # Plotter for Pressure Head
        self.frame1 = QFrame()
        self.frame1.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        self.plotter1 = pv.QtInteractor(self.frame1)
        self.plotter1.show_bounds(grid=True, location='back')
        self.stack.addWidget(self.plotter1)

        # Plotter for Concentration
        self.frame2 = QFrame()
        self.frame2.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        self.plotter2 = pv.QtInteractor(self.frame2)
        self.plotter2.show_bounds(grid=True, location='back')
        self.stack.addWidget(self.plotter2)

        # Set up navigation buttons
        self.setMeshPageButtons()
        self.buttons.setAlignment(Qt.AlignLeft)
        self.buttons.setContentsMargins(0, 0, 0, 0)
        self.buttons.setSpacing(20)

        self.setLayout(self.layout)
Example #2
0
    def __init__(self, geo_model, parent=None):
        super(MainWidget, self).__init__(parent)
        self.model = geo_model

        # init base ui
        hbox = QHBoxLayout(self)
        splitter = QSplitter(Qt.Horizontal)

        self.init_tree()
        splitter.addWidget(self.tree)

        plot = QFrame()
        self.Vista = Vista(geo_model,
                           plotter_type="basic")  # init Vista plotter
        self.vtk_widget = pv.QtInteractor(plot)
        self.Vista.p = self.vtk_widget  # set Plotter to the vtk widget Plotter

        splitter.addWidget(self.vtk_widget)
        hbox.addWidget(splitter)
        self.setLayout(hbox)
Example #3
0
    def __init__(self, parent=None, show=True):
        Qt.QMainWindow.__init__(self, parent)
        self.setWindowTitle('DoseMap trajectory calculator')
        self.statusBar().showMessage(
                'Welcome to DoseMap trajectory calculator.')

        # Attributes not related to the GUI
        self.trajectories = {}  # keys=csv filename  values=trajectory class
        self.vtk_files = {}  # keys=vtk filename  values=vtk_file class
        self.bounds = [5, 5, 5]  # boundaries of the moving prism
        self.step = 1  # Maximum distance between computed points
        self.sargs = dict(interactive=True,  # Log bar for plots
                          title_font_size=20,
                          label_font_size=16,
                          shadow=True,
                          n_labels=11,  # Because n_colors of the plot is 10
                          italic=True,
                          fmt="%.e",
                          font_family="arial")

        # create the frame
        self.frame = Qt.QFrame()
        vlayout = Qt.QVBoxLayout()
        hlayout1 = Qt.QHBoxLayout()  # ComboBox labels
        hlayout2 = Qt.QHBoxLayout()  # ComboBox selections
        vlayout.addLayout(hlayout1)
        vlayout.addLayout(hlayout2)

        # add the pyvista interactor object
        self.plotter = pv.QtInteractor(self.frame)
        vlayout.addWidget(self.plotter.interactor)

        # Populate the window with the vlayout
        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        # MENU TO LOAD FILES
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('File')

        opencsvButton = Qt.QAction('Load a trajectory csv file', self)
        opencsvButton.triggered.connect(self.opencsv)
        fileMenu.addAction(opencsvButton)

        openVTKbutton = Qt.QAction('Load a VTK file', self)
        openVTKbutton.triggered.connect(self.openVTK)
        fileMenu.addAction(openVTKbutton)

        exitButton = Qt.QAction('Exit', self)
        exitButton.setShortcut('Ctrl+Q')
        exitButton.triggered.connect(self.close)
        fileMenu.addAction(exitButton)

        # PLOTTING MENU
        plotMenu = mainMenu.addMenu('Plot')
        # plot selected mesh
        plotmesh_action = Qt.QAction('Plot mesh', self)
        plotmesh_action.triggered.connect(self.plotmesh)
        plotMenu.addAction(plotmesh_action)
        # plot selected trajectory
        plottraj_action = Qt.QAction('Plot trajectory', self)
        plottraj_action.triggered.connect(self.plottraj)
        plotMenu.addAction(plottraj_action)
        # show prism
        showprism_action = Qt.QAction('Show prism', self)
        showprism_action.triggered.connect(self.show_prism)
        plotMenu.addAction(showprism_action)
        # plot sampled trajectory over mesh and data array
        plotsampledtraj_action = Qt.QAction('Plot sampled trajectory', self)
        plotsampledtraj_action.triggered.connect(self.sample_over_traj)
        plotMenu.addAction(plotsampledtraj_action)
        # clear slicing planes
        clearplanes_action = Qt.QAction('Clear slicing planes', self)
        clearplanes_action.triggered.connect(self.clear_planes)
        plotMenu.addAction(clearplanes_action)
        # clear plots
        clearplots_action = Qt.QAction('Clear plots', self)
        clearplots_action.setShortcut('Ctrl+C')
        clearplots_action.triggered.connect(self.clear_plots)
        plotMenu.addAction(clearplots_action)

        # PARAMETERS MENU
        paramMenu = mainMenu.addMenu('Parameters')
        # input XYZ bounds
        xyzbounds_action = Qt.QAction('Input XYZ bounds', self)
        xyzbounds_action.triggered.connect(self.xyzbounds)
        paramMenu.addAction(xyzbounds_action)
        # input step
        set_step_action = Qt.QAction('Set step distance', self)
        set_step_action.triggered.connect(self.set_step)
        paramMenu.addAction(set_step_action)
        # csv traj
        csv_traj_action = Qt.QAction('Display trajectory table', self)
        csv_traj_action.triggered.connect(self.csv_traj)
        paramMenu.addAction(csv_traj_action)

        # CALCULATE MENU
        calculateMenu = mainMenu.addMenu('Calculate')
        # dose calculation
        dose_calculation_action = Qt.QAction('Calculate doses', self)
        dose_calculation_action.triggered.connect(self.dose_calculation)
        calculateMenu.addAction(dose_calculation_action)

        # About us menu
        plotMenu = mainMenu.addMenu('About us')
        # about F4E
        aboutf4e_action = Qt.QAction('Fusion for Energy', self)
        aboutf4e_action.triggered.connect(self.aboutf4e)
        plotMenu.addAction(aboutf4e_action)
        # about rpn
        aboutRPN_action = Qt.QAction('Raul Pampin', self)
        aboutRPN_action.triggered.connect(self.aboutRPN)
        plotMenu.addAction(aboutRPN_action)
        # about mfi
        aboutMFI_action = Qt.QAction('Marco Fabbri', self)
        aboutMFI_action.triggered.connect(self.aboutMFI)
        plotMenu.addAction(aboutMFI_action)
        # about aci
        aboutACI_action = Qt.QAction('Alvaro Cubi', self)
        aboutACI_action.triggered.connect(self.aboutACI)
        plotMenu.addAction(aboutACI_action)
        # about hcn
        aboutHCN_action = Qt.QAction('Haridev Chohan', self)
        aboutHCN_action.triggered.connect(self.aboutHCN)
        plotMenu.addAction(aboutHCN_action)

        # comboBox to select trajectory
        self.cbTrajectory = QComboBox()
        self.cbTrajectory.currentIndexChanged.connect(
                                                self.selectionchangeTrajectory)
        hlayout1.addWidget(QLabel(self, text="Trajectory"))
        hlayout2.addWidget(self.cbTrajectory)

        # comboBox to select vtk file
        self.cbVTK = QComboBox()
        self.cbVTK.currentIndexChanged.connect(self.selectionchangeVTK)
        hlayout1.addWidget(QLabel(self, text="VTK file"))
        hlayout2.addWidget(self.cbVTK)

        # comboBox to select vtk array
        self.cbArray = QComboBox()
        self.cbArray.activated.connect(self.selectionchangeArray)
        hlayout1.addWidget(QLabel(self, text="Data Array"))
        hlayout2.addWidget(self.cbArray)

        if show:
            self.show()
Example #4
0
    def __init__(self, parent=None, show=True):
        self.time_speed = 1
        self.earth_av = 7.2921150*360.0*1e-5/(2*np.pi)
        self.run_flag = False
        self.pause_flag = False
        self.stop_flag = False
        self.thread = None
        self.countTime = 0
        self.screen = None
        self.simulation_index = -1

        QMainWindow.__init__(self, parent)
        self.window = Ui_MainWindow()
        self.window.setupUi(self)

        # Set-up signals and slots
        # self.window.actionGeneratePlot.triggered.connect(self.plot_slot)
        # self.window.control_spinbox.valueChanged.connect(self.window.control_slider.setValue)
        # self.window.control_slider.valueChanged.connect(self.window.control_spinbox.setValue)

        #########################################

        vlayout = QVBoxLayout()
        self.window.view_frame.setLayout(vlayout)

        self.vtk_widget = pv.QtInteractor(self.window.view_frame, shape=(1, 2))
        self.vtk_widget.set_background([0.25, 0.25, 0.25])
        vlayout.addWidget(self.vtk_widget)

        GeoDef.__init__(self, self.vtk_widget)

        self.add_bar()
        self.add_i_frame_attitude()

        # --------------------------------------------------------------------------------------------------------------
        # simple menu to functions
        main_menu = self.menuBar()
        # --------------------------------------------------------------------------------------------------------------
        # File option
        self.window.actionLoadCsv.triggered.connect(self.load_csv_file)
        # --------------------------------------------------------------------------------------------------------------
        # Path Orbit option
        # aries_action = QAction('Add vector to Vernal Equinox', self)

        # orb_menu.addAction(orbit_action)
        # orb_menu.addAction(cad_action)
        # orb_menu.addAction(aries_action)
        # --------------------------------------------------------------------------------------------------------------
        # Attitude
        # AttMenu         = main_menu.addMenu('Attitude')
        # sat_action      = QAction('Add satellite', self)
        # frame_action    = QAction('Add Body reference frame', self)

        # sat_action.triggered.connect(self.add_spacecraft_2_attitude)
        # frame_action.triggered.connect(self.add_b_frame_attitude)
        # AttMenu.addAction(sat_action)
        # AttMenu.addAction(frame_action)
        # --------------------------------------------------------------------------------------------------------------
        # Simulation option
        # sim_menu = main_menu.addMenu('Simulation')
        # run_action = QAction('Run', self)
        # pause_action = QAction('Pause', self)
        # stop_action = QAction('Stop', self)

        self.window.actionRun.triggered.connect(self.run_simulation)
        self.window.actionPause.triggered.connect(self.pause_simulation)
        self.window.actionStop.triggered.connect(self.stop_simulation)

        # sim_menu.addAction(run_action)
        # sim_menu.addAction(pause_action)
        # sim_menu.addAction(stop_action)
        # --------------------------------------------------------------------------------------------------------------
        self.window.actionGeneratePlot.triggered.connect(self.add_graph2d)
Example #5
0
    def __init__(self, files, parent=None):
        super(ModelWindow, self).__init__()
        self.setupUi(self)

        # Add the model
        self.dataset = WSDS.Dataset(modelfile=files['model'],
                                    datafile=files['dat'])
        self.model = self.dataset.model
        self.clip_model = deepcopy(self.model)

        # self.dataset.data.locations /= 1000
        self.dataset.spatial_units = 'km'
        self.model.spatial_units = 'km'
        self.clip_model.spatial_units = 'km'
        # Make sure the frame fills the tab
        vlayout3D = Qt.QVBoxLayout()
        # add the pyvista interactor object
        self.vtk_widget = pv.QtInteractor(self.frame3D)
        vlayout3D.addWidget(self.vtk_widget)
        self.frame3D.setLayout(vlayout3D)

        # simple menu to demo functions
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('File')
        self.colourMenu = classes.ColourMenu(self)
        mainMenu.addMenu(self.colourMenu)
        exitButton = Qt.QAction('Exit', self)
        exitButton.setShortcut('Ctrl+Q')
        exitButton.triggered.connect(self.close)
        fileMenu.addAction(exitButton)

        self.plot_data = {'stations': []}
        if files['dat']:
            self.plot_locations = True
            self.locs_3D = np.zeros((len(self.dataset.data.locations), 3))
            self.plot_data['stations'] = pv.PolyData(self.locs_3D)
            self.locs_3D[:, 0] = self.dataset.data.locations[:, 1]
            self.locs_3D[:, 1] = self.dataset.data.locations[:, 0]
        else:
            self.locs_3D = np.zeros((1, 3))
            self.plot_locations = False
        self.rect_grid = model_to_rectgrid(self.clip_model)
        self.colourmap = 'jet_plus'
        self.cmap = cm.jet_plus(64)
        self.cax = [1, 5]
        self.actors = {'X': [], 'Y': [], 'Z': [], 'transect': []}
        self.slices = {'X': [], 'Y': [], 'Z': [], 'transect': []}
        self.transect_plot = {'easting': [], 'northing': []}
        self.transect_picking = False
        self.n_interp = 200
        self.show_transect_markers = True
        self.show_transect_line = True
        self.transect_artists = {'line': [], 'markers': []}
        self.faces = []
        self.init_widgets()
        # self.clip_volume()
        self.connect_widgets()
        self.render_3D()
        self.view_xy()
        # self.vtk_widget.view_isometric()
        # self.vtk_widget.view_xy()

        # Set up 2-D views
        self.canvas = {'2D': [], 'transect': []}
        self.toolbar = {'2D': [], 'transect': []}
        self.fig_2D = Figure()
        self.spec = {'X': [], 'Y': [], 'Z': []}
        self.spec['Y'] = GridSpec(3, 3).new_subplotspec((0, 2),
                                                        colspan=1,
                                                        rowspan=2)
        self.spec['X'] = GridSpec(3, 3).new_subplotspec((2, 0),
                                                        colspan=2,
                                                        rowspan=1)
        self.spec['Z'] = GridSpec(3, 3).new_subplotspec((0, 0),
                                                        colspan=2,
                                                        rowspan=2)
        self.fig_2D.add_subplot(self.spec['Z'])
        self.fig_2D.add_subplot(self.spec['Y'])
        self.fig_2D.add_subplot(self.spec['X'])
        self.fig_2D.subplots_adjust(top=1,
                                    bottom=0.05,
                                    left=0.06,
                                    right=0.94,
                                    hspace=0.05,
                                    wspace=0.05)
        self.map = gplot.MapView(figure=self.fig_2D)
        self.init_map(self.dataset)
        self.add_mpl(self.map.window['figure'], '2D')
        self.fig_transect = Figure()
        self.add_mpl(self.fig_transect, 'transect')
        self.fig_transect.add_subplot(111)
        # Click event hooks
        self.cid = {'transect_2D': []}

        self.update_plan_view()
        self.update_2D_X()
        self.update_2D_Y()
Example #6
0
    def __init__(self, parent=None, show=True):
        self.time_speed = 1
        self.earth_av = 7.2921150 * 360.0 * 1e-5 / (2 * np.pi)
        self.run_flag = False
        self.pause_flag = False
        self.stop_flag = False
        self.thread = None
        self.countTime = 0

        Qt.QMainWindow.__init__(self, parent)
        # create the frame
        self.frame = Qt.QFrame()
        vlayout = Qt.QVBoxLayout()

        # add the pyvista interactor object
        self.vtk_widget = pv.QtInteractor(self.frame, shape=(1, 2))
        self.vtk_widget.set_background([0.25, 0.25, 0.25])
        self.vtk_widget.setFixedWidth(1000)
        self.vtk_widget.setFixedHeight(500)
        vlayout.addWidget(self.vtk_widget)
        GeoDef.__init__(self, self.vtk_widget)

        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        self.add_bar()
        self.add_i_frame_attitude()

        #--------------------------------------------------------------------------------------------------------------
        # simple menu to functions
        mainMenu = self.menuBar()
        #--------------------------------------------------------------------------------------------------------------
        # File option
        fileMenu = mainMenu.addMenu('File')
        loadcsvData = Qt.QAction('Load csv data', self)
        exitButton = Qt.QAction('Exit', self)

        exitButton.setShortcut('Ctrl+Q')
        loadcsvData.triggered.connect(self.load_csv_file)
        exitButton.triggered.connect(self.close)
        fileMenu.addAction(loadcsvData)
        fileMenu.addAction(exitButton)
        #--------------------------------------------------------------------------------------------------------------
        # Path Orbit option
        OrbMenu = mainMenu.addMenu('Orbit')
        orbit_action = Qt.QAction('Show Orbit', self)
        cad_action = Qt.QAction('Add satellite', self)
        aries_action = Qt.QAction('Add vector to Vernal Equinox', self)

        orbit_action.triggered.connect(self.add_orbit)
        cad_action.triggered.connect(self.add_spacecraft_2_orbit)
        aries_action.triggered.connect(self.add_aries_arrow)

        OrbMenu.addAction(orbit_action)
        OrbMenu.addAction(cad_action)
        OrbMenu.addAction(aries_action)
        #--------------------------------------------------------------------------------------------------------------
        # Attitude
        AttMenu = mainMenu.addMenu('Attitude')
        sat_action = Qt.QAction('Add satellite', self)
        frame_action = Qt.QAction('Add Body reference frame', self)

        sat_action.triggered.connect(self.add_spacecraft_2_attitude)
        AttMenu.addAction(sat_action)
        frame_action.triggered.connect(self.add_b_frame_attitude)
        AttMenu.addAction(frame_action)
        #--------------------------------------------------------------------------------------------------------------
        # Simulation option
        SimMenu = mainMenu.addMenu('Simulation')
        run_action = Qt.QAction('Run', self)
        pause_action = Qt.QAction('Pause', self)
        stop_action = Qt.QAction('Stop', self)

        run_action.triggered.connect(self.run_simulation)
        pause_action.triggered.connect(self.pause_simulation)
        stop_action.triggered.connect(self.stop_simulation)

        SimMenu.addAction(run_action)
        SimMenu.addAction(pause_action)
        SimMenu.addAction(stop_action)
        #--------------------------------------------------------------------------------------------------------------
        graph2dMenu = mainMenu.addMenu('Data')
        plot_action = Qt.QAction('Generate graph', self)

        plot_action.triggered.connect(self.add_graph2d)

        graph2dMenu.addAction(plot_action)
        #--------------------------------------------------------------------------------------------------------------

        if show:
            self.show()
    def __init__(self, parent=None, show=True):

        QtWidgets.QMainWindow.__init__(self, parent)
        self.frame = QtWidgets.QFrame()  # create the frame
        vlayout = QtWidgets.QVBoxLayout()
        # add the pyvista interactor object
        self.vtk_widget = pv.QtInteractor(self.frame)
        vlayout.addWidget(self.vtk_widget)
        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        # set hot keys
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('File')
        exitButton = QtWidgets.QAction('Exit', self)
        exitButton.setShortcut('Ctrl+Q')
        exitButton.triggered.connect(self.close)
        fileMenu.addAction(exitButton)

        # draw all the polyhedrons
        self.add_polyhedron()

        # menu button for screenshots
        scrshots_menu = mainMenu.addMenu('Screenshots')
        self.add_screenshots_action = QtWidgets.QAction('Print screen', self)
        self.add_screenshots_action.triggered.connect(self.print_screen)
        scrshots_menu.addAction(self.add_screenshots_action)

        # menu button for hide/show zones
        layer_menu = mainMenu.addMenu('Brillouin Zone')
        zone_switch_action = QtWidgets.QAction('Zone Switch',
                                               self,
                                               checkable=True,
                                               checked=True)
        layer_menu.addAction(zone_switch_action)
        zone_switch_action.triggered.connect(self.zone_switch_is_clicked)

        # menu button for save orbiting gif
        gif_menu = mainMenu.addMenu('Orbit GIF')
        gif_action_x = QtWidgets.QAction('Around X-Axis', self)
        gif_action_y = QtWidgets.QAction('Around Y-Axis', self)
        gif_action_z = QtWidgets.QAction('Around Z-Axis', self)
        gif_menu.addAction(gif_action_x)
        gif_menu.addAction(gif_action_y)
        gif_menu.addAction(gif_action_z)
        gif_action_x.triggered.connect(self.orbit_gif_is_clicked)
        gif_action_y.triggered.connect(self.orbit_gif_is_clicked)
        gif_action_z.triggered.connect(self.orbit_gif_is_clicked)

        # menu button for save growing ball gif
        growing_ball_menu = mainMenu.addMenu('Growing Ball GIF')
        growing_action = QtWidgets.QAction('Start recording', self)
        growing_ball_menu.addAction(growing_action)
        growing_action.triggered.connect(self.growing_action_is_clicked)

        # menu button for camera to return to a specific position
        axis_view_menu = mainMenu.addMenu('Axis View')
        axis_view_action_x = QtWidgets.QAction('X-Axis', self)
        axis_view_action_y = QtWidgets.QAction('Y-Axis', self)
        axis_view_action_z = QtWidgets.QAction('Z-Axis', self)
        axis_view_menu.addAction(axis_view_action_x)
        axis_view_menu.addAction(axis_view_action_y)
        axis_view_menu.addAction(axis_view_action_z)
        axis_view_action_x.triggered.connect(self.axis_view_is_clicked)
        axis_view_action_y.triggered.connect(self.axis_view_is_clicked)
        axis_view_action_z.triggered.connect(self.axis_view_is_clicked)

        self.zone_switch = ZoneSwitch(self)

        self.vtk_widget.background_color = "white"

        self.radius_recorder = 0  # to stop ball growing

        if show:
            self.show()
            self.zone_switch.show()