def displayLine(): global __data_model__ if sg.SelectedCount() != 1: return entry = sg.getSelected(0) obj = ctx.DM.getObject(entry) if obj is None: QMessageBox.information(sgPyQt.getDesktop(), 'Info', 'Please, select line!') return text = obj.getText() if text == "\n": return renderer = libSalomePy.getRenderer() actor = getActor(entry) if actor is None: actor = vtk.vtkTextActor() dict_actors[entry] = actor pass center = renderer.GetCenter() actor.SetInput(str(text)) actor.SetPosition(center[0], center[1]) txtPr = vtk.vtkTextProperty() txtPr.SetFontSize(30) actor.SetTextProperty(txtPr) for act in list(dict_actors.values()): renderer.RemoveActor(act) renderer.AddActor(actor) pass
def removeLine(): global __data_model__ selcount = sg.SelectedCount() onlyLines = True lines = [] while selcount != 0: entry = sg.getSelected(selcount - 1) #Check what only lines selected obj = __data_model__.getObject(entry) if obj is None: continue if obj.getText() == "\n": onlyLines = False break lines.append(entry) selcount = selcount - 1 pass if not onlyLines: return else: renderer = libSalomePy.getRenderer() for ln in lines: actor = getActor(ln) if actor is not None: renderer.RemoveActor(actor) pass pass __data_model__.removeObjects(lines) sg.updateObjBrowser() pass pass
def __init__(self): """ http://www.google.com/codesearch/p?hl=fr#a-DtlzUst6U/Examples/Annotation/Python/textOrigin.py&q=annotatePick&d=3 """ #super(Actors, self).__init__() self.render = libSalomePy.getRenderer() self.__interactor = libSalomePy.getRenderWindowInteractor() self.picker = self.__interactor.GetPicker() self.__interactor.AddObserver("LeftButtonPressEvent", self.leftButtonPressEvent) self.radius = 0.025 self.p = []
def clearAll(): global __data_model__ paragraphs = __data_model__.getParagraphs() for paragr in paragraphs: lines = sgPyQt.getChildren(paragr) __data_model__.removeObjects(lines) renderer = libSalomePy.getRenderer() for l in lines: actor = getActor(l) if actor is not None: renderer.RemoveActor(actor) pass pass sg.updateObjBrowser() pass
def eraseLine(): global __data_model__ if sg.SelectedCount() != 1: return entry = sg.getSelected(0) obj = __data_model__.getObject(entry) if obj is None: QMessageBox.information(sgPyQt.getDesktop(), 'Info', 'Please, select line!') return text = obj.getText() if text == "\n": return renderer = libSalomePy.getRenderer() actor = getActor(entry) if actor is not None: renderer.RemoveActor(actor) pass pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : [email protected] # # File : examplevtk1.py # Module : SALOME # import os import libSalomePy from vtk import * from vtkRenderingCorePython import * from vtkFiltersSourcesPython import * # get the "vtkRenderer": an OpenGL rendering context ren = libSalomePy.getRenderer() # create an actor and give it cone geometry cone = vtkConeSource() cone.SetResolution(8) coneMapper = vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort(0)) coneActor = vtkActor() coneActor.SetMapper(coneMapper) # assign our actor to the renderer ren.AddActor(coneActor) libSalomePy.fitAll()