def duplicate_alternate_vtk_grid(self, name, name_duplicate_from, color=None, line_width=5, opacity=1.0, point_size=1, bar_scale=0.0, is_visible=True, follower_nodes=None, is_pickable=False): """Fake copies the VTK actor""" if name_duplicate_from == 'main': grid_copy_from = self.grid representation = 'toggle' else: grid_copy_from = self.alt_grids[name_duplicate_from] props = self.geometry_properties[name_duplicate_from] representation = props.representation self.alt_grids[name] = MockGrid() geom = AltGeometry(self, name, color=color, line_width=line_width, point_size=point_size, bar_scale=bar_scale, opacity=opacity, representation=representation, is_visible=is_visible, is_pickable=is_pickable) self.geometry_properties[name] = geom if follower_nodes is not None: self.follower_nodes[name] = follower_nodes
def create_alternate_vtk_grid(self, name, color=None, line_width=None, opacity=None, point_size=None, bar_scale=None, representation=None, is_visible=True, follower_nodes=None, follower_function=None, is_pickable=False, ugrid=None): """Fake creates an AltGeometry object""" self.alt_grids[name] = MockGrid() geom = AltGeometry(self, name, color=color, line_width=line_width, point_size=point_size, bar_scale=bar_scale, opacity=opacity, representation=representation, is_visible=is_visible, is_pickable=is_pickable) self.geometry_properties[name] = geom if follower_nodes is not None: self.follower_nodes[name] = follower_nodes if follower_function is not None: self.follower_functions[name] = follower_function
def main(): # kills the program when you hit Cntl+C from the command line # doesn't save the current state as presumably there's been an error import signal signal.signal(signal.SIGINT, signal.SIG_DFL) import sys from qtpy.QtWidgets import QApplication # Someone is launching this directly # Create the QApplication app = QApplication(sys.argv) #The Main window #g = GeometryHandle() #g.add('main', color=(0, 0, 0), line_thickness=0.0) #g.get_grid('name') #g.set_color('name') #g.set_grid('name') #g.set_grid('name') parent = app green = (0, 255, 0) point_properties = AltGeometry(parent, 'point_properties', color=green, point_size=5, opacity=1.0) points = { 1: ['LERoot', 0, 'R', 1.0, 2.0, 3.0], 2: ['LETip', 42, 'S', 2.0, 3.0, 4.0], } coords = { 0: ['R'], 2: ['C'], 42: ['S'], } data = { 'point_properties': point_properties, 'points': points, 'active_point': 2, 'coords': coords, } main_window = BreakSurfaceMenu(data, win_parent=None) main_window.show() # Enter the main loop app.exec_()
def main(): # pragma: no cover """gui independent way to test the program""" # kills the program when you hit Cntl+C from the command line # doesn't save the current state as presumably there's been an error import signal signal.signal(signal.SIGINT, signal.SIG_DFL) import sys # Someone is launching this directly # Create the QApplication app = QApplication(sys.argv) parent = app red = (255, 0, 0) blue = (0, 0, 255) green = (0, 255, 0) purple = (255, 0, 255) # representation # * main - main mesh # * toggle - change with main mesh # * wire - always wireframe # * point - always points # * wire+point - point (vertex) and wireframe allowed # * surface - always surface # * bar - this can use bar scale data = { 'font_size' : 8, 'toggle' : AltGeometry(parent, 'toggle', color=green, line_width=3, opacity=0.2, representation='toggle'), 'wire' : AltGeometry(parent, 'wire', color=purple, line_width=4, opacity=0.3, representation='wire'), 'wire+point' : AltGeometry(parent, 'wire+point', color=blue, line_width=2, opacity=0.1, bar_scale=1.0, representation='wire+point'), 'main' : AltGeometry(parent, 'main', color=red, line_width=1, opacity=0.0, representation='main'), 'point' : AltGeometry(parent, 'point', color=blue, opacity=0.1, representation='point'), 'surface' : AltGeometry(parent, 'surface', color=blue, opacity=0.1, representation='surface'), } main_window = EditGeometryProperties(data, win_parent=None) main_window.show() # Enter the main loop app.exec_()
def _add_alt_geometry(self, grid, name: str, color=None, line_width=None, opacity=None, representation=None): """NOTE: color, line_width, opacity are ignored if name already exists""" has_geometry_actor = name in self.gui.geometry_actors is_pickable = self.gui.geometry_properties[name].is_pickable quad_mapper = vtk.vtkDataSetMapper() if has_geometry_actor: alt_geometry_actor = self.gui.geometry_actors[name] alt_geometry_actor.GetMapper().SetInputData(grid) else: quad_mapper.SetInputData(grid) alt_geometry_actor = vtk.vtkActor() if not is_pickable: alt_geometry_actor.PickableOff() alt_geometry_actor.DragableOff() alt_geometry_actor.SetMapper(quad_mapper) self.gui.geometry_actors[name] = alt_geometry_actor #geometryActor.AddPosition(2, 0, 2) if name in self.gui.geometry_properties: geom = self.gui.geometry_properties[name] else: geom = AltGeometry(self, name, color=color, line_width=line_width, opacity=opacity, representation=representation) self.gui.geometry_properties[name] = geom color = geom.color_float opacity = geom.opacity point_size = geom.point_size representation = geom.representation line_width = geom.line_width #print('color_2014[%s] = %s' % (name, str(color))) assert isinstance(color[0], float), color assert color[0] <= 1.0, color prop = alt_geometry_actor.GetProperty() #prop.SetInterpolationToFlat() # 0 #prop.SetInterpolationToGouraud() # 1 #prop.SetInterpolationToPhong() # 2 prop.SetDiffuseColor(color) prop.SetOpacity(opacity) #prop.Update() #print('prop.GetInterpolation()', prop.GetInterpolation()) # 1 if representation == 'point': prop.SetRepresentationToPoints() prop.SetPointSize(point_size) elif representation in ['surface', 'toggle']: prop.SetRepresentationToSurface() prop.SetLineWidth(line_width) elif representation == 'wire': prop.SetRepresentationToWireframe() prop.SetLineWidth(line_width) if not has_geometry_actor: self.rend.AddActor(alt_geometry_actor) vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset() if geom.is_visible: alt_geometry_actor.VisibilityOn() else: alt_geometry_actor.VisibilityOff() #print('current_actors = ', self.geometry_actors.keys()) alt_geometry_actor.Modified()