def setModel(self, model, alias=None, delayed=False, trace=False): self.modelName = str(model) self._currF = str(model) if alias is not None: self.setAlias(alias) ll = taurus.getLogLevel() if trace: taurus.setLogLevel(taurus.Debug) # self.debug('setModel("%s")'%model) if self._currF: #filename = str(self._currFile.absoluteFilePath()) filename = self._currF filename = os.path.realpath(filename) if os.path.isfile(filename): self.debug("Starting to parse %s" % filename) self.path = os.path.dirname(filename) factory = self.getGraphicsFactory(delayed=delayed) scene = jdraw_parser.parse(filename, factory) scene.setSelectionStyle(self._selectionStyle) self.debug("Obtained %s(%s)", type(scene).__name__, filename) if not scene: self.warning( "TaurusJDrawSynopticsView.setModel(%s): Unable to parse %s!!!" % (model, filename)) elif self.w_scene is None and scene.sceneRect(): self.w_scene = scene.sceneRect().width() self.h_scene = scene.sceneRect().height() else: self.debug('JDrawView.sceneRect() is NONE!!!') self.setScene(scene) self.scene().graphicItemSelected.connect( self._graphicItemSelected) self.scene().graphicSceneClicked.connect( self._graphicSceneClicked) # Qt.QApplication.instance().lastWindowClosed.connect(self.close) #It caused a # segfault! self.__modelsChanged() self.setWindowTitle(self.modelName) # The emitted signal contains the filename and a dictionary # with the name of items and its color self.emitColors() # get_item_colors(emit=True) self.fitting(True) else: self.setScene(None) #self.debug('out of setModel()') taurus.setLogLevel(ll)
def setModel(self, model, alias=None, delayed=False, trace=False): self.modelName = str(model) self._currF = str(model) if alias is not None: self.setAlias(alias) ll = taurus.getLogLevel() if trace: taurus.setLogLevel(taurus.Debug) # self.debug('setModel("%s")'%model) if self._currF: #filename = str(self._currFile.absoluteFilePath()) filename = self._currF filename = os.path.realpath(filename) if os.path.isfile(filename): self.debug("Starting to parse %s" % filename) self.path = os.path.dirname(filename) factory = self.getGraphicsFactory(delayed=delayed) scene = jdraw_parser.parse(filename, factory) scene.setSelectionStyle(self._selectionStyle) self.debug("Obtained %s(%s)", type(scene).__name__, filename) if not scene: self.warning("TaurusJDrawSynopticsView.setModel(%s): Unable to parse %s!!!" % ( model, filename)) elif self.w_scene is None and scene.sceneRect(): self.w_scene = scene.sceneRect().width() self.h_scene = scene.sceneRect().height() else: self.debug('JDrawView.sceneRect() is NONE!!!') self.setScene(scene) self.scene().graphicItemSelected.connect(self._graphicItemSelected) self.scene().graphicSceneClicked.connect(self._graphicSceneClicked) # Qt.QApplication.instance().lastWindowClosed.connect(self.close) #It caused a # segfault! self.__modelsChanged() self.setWindowTitle(self.modelName) # The emitted signal contains the filename and a dictionary # with the name of items and its color self.emitColors() # get_item_colors(emit=True) self.fitting(True) else: self.setScene(None) #self.debug('out of setModel()') taurus.setLogLevel(ll)
def setModel(self, model, alias=None, delayed=False, trace=False): #print "\n\n\n before set Model: \n\n" self.modelName = str(model) #print "\n Model: ", self.modelName self._currF = str(model) #print "\n\n Alias: ", alias if alias is not None: self.setAlias(alias) ll = taurus.getLogLevel() #print "\n\n LL:", ll, "\n\n" #print "\n\n TRACE: ", trace if trace: taurus.setLogLevel(taurus.Debug) #self.debug('setModel("%s")'%model) if self._currF: #filename = str(self._currFile.absoluteFilePath()) filename = self._currF #print "\n", filename filename = os.path.realpath(filename) #print "real path filename: ", filename if os.path.isfile(filename): #print "\n\n Jestem plikiem: ", filename self.debug("Starting to parse %s" % filename) #print "\n\nSPARSOWALEM\n\n" self.path = os.path.dirname(filename) #print "\n\n KATALOG: ", self.path factory = self.getGraphicsFactory(delayed=delayed) print "\n\n Zrobione factory ;)" scene = jdraw_parser.parse(filename, factory) print "\n\n filename and factory parsed" scene.setSelectionStyle(self._selectionStyle) self.debug("Obtained %s(%s)", type(scene).__name__, filename) if not scene: self.warning( "TaurusJDrawSynopticsView.setModel(%s): Unable to parse %s!!!" % (model, filename)) elif self.w_scene is None and scene.sceneRect(): self.w_scene = scene.sceneRect().width() self.h_scene = scene.sceneRect().height() else: self.debug('JDrawView.sceneRect() is NONE!!!') self.setScene(scene) for i in self.scene().items(): print "\n element: ", i #i.connect(i, Qt.SIGNAL('clicked()'), self.onClicked) #i.mousePressEvent(i, event) try: Qt.QObject.connect( i, Qt.SIGNAL("activated(const QString&)"), self._test) print "\n connected" except: print "exeption" Qt.QObject.connect(self.scene(), Qt.SIGNAL("graphicItemSelected(QString)"), self._graphicItemSelected) Qt.QObject.connect(self.scene(), Qt.SIGNAL("graphicSceneClicked(QPoint)"), self._graphicSceneClicked) #Qt.QObject.connect(Qt.QApplication.instance(), Qt.SIGNAL("lastWindowClosed()"), self.close) #It caused a segfault! self.modelsChanged() self.setWindowTitle(self.modelName) #The emitted signal contains the filename and a dictionary with the name of items and its color self.emitColors() #get_item_colors(emit=True) self.fitting(True) else: self.setScene(None) #self.debug('out of setModel()') taurus.setLogLevel(ll)