Ejemplo n.º 1
0
 def addRecentProject(self, project):
     #
     print '>> addRecentProject ', project
     if project is not None:
         if usePyQt4:
             recent_projects_max = getDefaultValue(app_settings, '',
                                                   'recent_projects_max')
             if project not in self.recentProjects:
                 self.recentProjects.prepend(QtCore.QString(project))
             while self.recentProjects.count() > recent_projects_max:
                 self.recentProjects.takeLast()
             recentProjects = QtCore.QVariant(
                 self.recentProjects
             ) if self.recentProjects else QtCore.QVariant()
             app_settings.setValue('RecentProjects', recentProjects)
         else:
             recent_projects_max = getDefaultValue(app_settings, '',
                                                   'recent_projects_max')
             if project not in self.recentProjects:
                 self.recentProjects.insert(0, project)
                 while len(self.recentProjects) > recent_projects_max:
                     self.recentProjects.pop()
                 app_settings.setValue('RecentProjects',
                                       self.recentProjects)
                 print '* project added recentProjects =', self.recentProjects
         print '* recentProjects =', self.recentProjects
Ejemplo n.º 2
0
 def itemChange ( self, change, value ) :
   #
   if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange:
     self.label_widget.setSelected ( value.toBool () )
     if value.toBool () :
       items = self.scene ().items ()
       for i in range ( len ( items ) - 1, -1, -1 ) :
         if items [ i ].parentItem() is None :
           if items [ i ] != self :
             items [ i ].stackBefore ( self )
       #scene.setFocusItem ( self )
   elif change == QtGui.QGraphicsItem.ItemPositionHasChanged:
     from meShaderEd import getDefaultValue
     grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' )
     grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )
     x = self.x ()
     y = self.y ()
     if grid_snap :
       #if DEBUG_MODE : print '* snap to grid  (size = %d)' % grid_size
       x -= ( x % grid_size )
       y -= ( y % grid_size )
       self.setPos ( x, y )
     #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y )
     self.node.offset = ( x, y )
     #self.adjustLinks ()
   return QtGui.QGraphicsItem.itemChange ( self, change, value )
Ejemplo n.º 3
0
	def itemChange ( self, change, value ) :
		#if DEBUG_MODE : print ">> itemChanged "
		if change == QtModule.QGraphicsItem.ItemSelectedHasChanged :
			#if DEBUG_MODE : print "* selection "
			self.isNodeSelected = ( value == 1 ) #value.toBool ()
			#if self.isNodeSelected :
			#  node = self.parentItem ().node
			#  if node is not None :
			#    if DEBUG_MODE : print ">> selected conector for node %s (id = %d)" % ( node.label, node.id )
		elif change == QtModule.QGraphicsItem.ItemPositionHasChanged :
			#if DEBUG_MODE : print "* position "
			if self.isNode () :
				#if DEBUG_MODE : print ">> ItemPositionHasChanged conector for node %s ( %d, %d )" % ( self.node.label, self.x(), self.y() )
				from meShaderEd import getDefaultValue
				grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' )
				grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )

				x = self.x()
				y = self.y()
				if grid_snap :
					#if DEBUG_MODE : print '* snap to grid  (size = %d)' % grid_size
					x -= ( x % grid_size )
					y -= ( y % grid_size )
					self.setPos ( x, y )

				#if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y )
				self.node.offset = ( x, y )
				self.adjustLinks ()
				#return QtCore.QPointF ( x, y )

		return QtModule.QGraphicsItem.itemChange ( self, change, value )
Ejemplo n.º 4
0
 def itemChange(self, change, value):
     #
     if change == QtModule.QGraphicsItem.ItemSelectedHasChanged:  #ItemSelectedChange:
         self.label_widget.setSelected(value == 1)
         if value == 1:
             items = self.scene().items()
             for i in range(len(items) - 1, -1, -1):
                 if items[i].parentItem() is None:
                     if items[i] != self:
                         items[i].stackBefore(self)
             #scene.setFocusItem ( self )
     elif change == QtModule.QGraphicsItem.ItemPositionHasChanged:
         from meShaderEd import getDefaultValue
         grid_snap = getDefaultValue(app_settings, 'WorkArea', 'grid_snap')
         grid_size = int(
             getDefaultValue(app_settings, 'WorkArea', 'grid_size'))
         x = self.x()
         y = self.y()
         if grid_snap:
             #if DEBUG_MODE : print '* snap to grid  (size = %d)' % grid_size
             x -= (x % grid_size)
             y -= (y % grid_size)
             self.setPos(x, y)
         #if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y )
         self.node.offset = (x, y)
         #self.adjustLinks ()
     return QtModule.QGraphicsItem.itemChange(self, change, value)
Ejemplo n.º 5
0
	def itemChange ( self, change, value ) :
		#
		if change == QtModule.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange: QGraphicsItem
			if self.node.type != 'variable' :
				# variable node has not header
				#if  not usePyQt5 :
				#	self.header [ 'label' ].setSelected ( value.toBool () )
				#else :
				self.header [ 'label' ].setSelected ( value )
				#self.header['swatch'].isNodeSelected = self.isNodeSelected
			if value == 1 :
				items = self.scene ().items ()
				for i in range ( len ( items ) - 1, -1, -1 ) :
					if items [ i ].parentItem() is None :
						if items [ i ] != self :
							items [ i ].stackBefore ( self )
				#scene.setFocusItem ( self )
		elif change == QtModule.QGraphicsItem.ItemPositionHasChanged :
			from meShaderEd import getDefaultValue
			grid_snap = bool ( getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' ) )
			grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )
			x = self.x ()
			y = self.y ()
			if grid_snap :
				#if DEBUG_MODE : print '* snap to grid  (size = %d)' % grid_size
				x -= ( x % grid_size )
				y -= ( y % grid_size )
				self.setPos ( x, y )
			#if DEBUG_MODE : print '* GfxNode.itemChange = ItemPositionHasChanged (%f, %f)' % ( x, y )
			self.node.offset = ( x, y )
			self.adjustLinks ()
			#return QtCore.QPointF ( x, y )
		#return super( GfxNode, self ).itemChange ( change, value )
		return QtModule.QGraphicsItem.itemChange ( self, change, value )
Ejemplo n.º 6
0
	def __init__ ( self, link = None, srcConnector = None, dstConnector = None ) :
		#
		QtModule.QGraphicsItem.__init__ ( self )

		from meShaderEd import getDefaultValue
		self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' )

		# qt graphics stuff
		self.brushSelected = QtGui.QBrush ( QtGui.QColor ( 250, 250, 250 ) )
		self.brushNormal = QtGui.QBrush ( QtGui.QColor ( 20, 20, 20 ) )
		self.setFlag ( QtModule.QGraphicsItem.ItemIsSelectable )
		self.setZValue( 0 )

		self.link = link

		self.rect = QtCore.QRectF ()
		self.points = []
		self.path = None
		self.isLinkSelected = False
		self.srcPoint = self.dstPoint = None
		self.srcConnector = self.dstConnector = None

		self.setSrcConnector ( srcConnector )
		self.setDstConnector ( dstConnector)

		if srcConnector != None :
			if srcConnector.isConnectedToInput () and not srcConnector.isConnectedToOutput (): 
				self.swapConnectors ()
Ejemplo n.º 7
0
	def onOpenRecentProject ( self ) :
		#
		action = self.sender ()
		if isinstance ( action, QtModule.QAction ):
			if usePyQt4 :
				project = unicode ( action.data ().toString () )
			else :
				project = action.data () 
			if project is not None :
				print '>> onOpenRecentProject : %s' % project
				project_filename = getDefaultValue ( app_settings, '', 'project_filename' )
				if openDefaultProject ( app_settings, app_global_vars, project, project_filename ) :
					# very strange... app_settings doesn't update inside meCommon.openDefaultProject...
					# though app_global_vars does
					# have to duplicate this action here...
					app_settings.setValue ( 'project', app_global_vars [ 'ProjectPath' ] )
					app_settings.setValue ( 'project_shaders', app_global_vars [ 'ProjectShaders' ] )
					app_settings.setValue ( 'project_textures', app_global_vars [ 'ProjectTextures' ] )
					app_settings.setValue ( 'shader_networks', app_global_vars [ 'ProjectNetworks' ] )
					app_settings.setValue ( 'shader_sources', app_global_vars [ 'ProjectSources' ] )

					self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] )
					self.setupWindowTitle ()
				else :
					print "ERROR! project %s doesn't exist" %  project
					if usePyQt4 : 
						self.recentProjects.removeAll ( network )
					else :
						self.recentProjects.remove ( network )
Ejemplo n.º 8
0
	def adjust ( self ) :
		#
		from meShaderEd import getDefaultValue
		self.isStraight = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' )

		if self.srcConnector is not None : self.srcPoint = self.srcConnector.getCenterPoint ()
		if self.dstConnector is not None : self.dstPoint = self.dstConnector.getCenterPoint ()

		self.prepareGeometryChange ()

		del self.points [ : ]  # clear bezier points
		self.path = None
		if self.srcPoint is not None and self.dstPoint is not None :
			self.path = QtGui.QPainterPath ()
			# first point
			self.points.append ( self.srcPoint )
			self.path.moveTo ( self.points [ 0 ] )

			# draw curved spline if isStraight is False
			if not self.isStraight :
				# hull spline
				hull = QtCore.QRectF ( self.srcPoint, self.dstPoint )
				centerX = hull.center ().x ()
				centerY = hull.center ().y ()
				# second point
				offsetVX = min ( abs ( hull.topRight ().x () - hull.topLeft ().x () ) * 0.1, 40 )
				offsetVY = 0.0

				p1 = self.srcPoint + QtCore.QPointF ( offsetVX, offsetVY )
				self.points.append ( p1 )
				# third point
				p2 =   QtCore.QPointF ( centerX, self.srcPoint.y() )
				self.points.append ( p2 )
				# fourth point
				p3 = QtCore.QPointF ( centerX, centerY )
				self.points.append ( p3 )
				# fifth point (bezier tangent)
				p4 = QtCore.QPointF ( centerX, centerY )
				self.points.append ( p4 )
				# sixth point
				p5 = QtCore.QPointF ( centerX, self.dstPoint.y() )
				self.points.append ( p5 )
				# seventh point
				p6 = self.dstPoint - QtCore.QPointF ( offsetVX, offsetVY )
				self.points.append ( p6 )
			# last point
			self.points.append ( self.dstPoint )
			if self.isStraight :
				#if DEBUG_MODE : print '* GfxLink: Straight mode'
				self.path.lineTo ( self.dstPoint )
			else:
				#if DEBUG_MODE : print '* GfxLink: Curved mode'
				#self.path.cubicTo ( self.points[1], self.points[2], self.points[3] )
				#self.path.cubicTo ( self.points[5], self.points[6], self.points[7] )
				self.path.cubicTo ( p1, p1, p3 )
				self.path.cubicTo ( p6, p6, self.dstPoint )
			self.rect = self.path.boundingRect ()
Ejemplo n.º 9
0
	def addRecentNetwork ( self, network ) :
		#
		if network is not None :
			if usePyQt4 :
				recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' )
				if network not in self.recentNetworks :
					self.recentNetworks.prepend ( QtCore.QString ( network ) )
				while self.recentNetworks.count () > recent_networks_max :
					self.recentNetworks.takeLast ()
				recentNetworks = QtCore.QVariant ( self.recentNetworks ) if self.recentNetworks else QtCore.QVariant ()
				app_settings.setValue ( 'RecentNetworks', recentNetworks )
			else :
				recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' )
				if network not in self.recentNetworks :
					self.recentNetworks.insert ( 0, network )
				while len ( self.recentNetworks ) > recent_networks_max :
					self.recentNetworks.pop ()
				app_settings.setValue ( 'RecentNetworks', self.recentNetworks )
Ejemplo n.º 10
0
 def __init__ ( self ) : 
   #
   QtGui.QMainWindow.__init__ ( self )
   
   # This is always the same
   self.ui = Ui_MainWindow ()
   self.ui.setupUi ( self )
   self.setupMenuBar ()
   self.setupPanels ()
   
   self.setWindowTitle ( "meShaderEd (" + app_renderer.getCurrentPresetName() + ")")
   
   self.activeNodeList = None
   self.workArea = None # current work area
   self.onNew () # create new document 
   
   grid_enabled = getDefaultValue( app_settings, 'WorkArea', 'grid_enabled' )
   grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' )
   grid_size = int( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )
   reverse_flow = getDefaultValue ( app_settings, 'WorkArea', 'reverse_flow' )
   straight_links = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' )
 
   #self.ui.workArea.gridSize = grid_size
   #self.ui.workArea.gridSnap = grid_snap
   self.workArea.drawGrid = grid_enabled
   #self.ui.workArea.reverseFlow = reverse_flow 
   #self.ui.workArea.straightLinks = straight_links
   
   self.ui.actionShowGrid.setChecked( grid_enabled )
   self.ui.actionSnapGrid.setChecked( grid_snap )
   self.ui.actionReverseFlow.setChecked( reverse_flow )
   self.ui.actionStraightLinks.setChecked( straight_links )
  
   self.ui.nodeList_ctl.setLibrary ( app_global_vars[ 'NodesPath' ] )
   self.ui.project_ctl.setLibrary ( app_global_vars[ 'ProjectNetworks' ] )
   
   QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL( "setActiveNodeList" ), self.setActiveNodeList )
   QtCore.QObject.connect ( self.ui.project_ctl.ui.nodeList, QtCore.SIGNAL( "setActiveNodeList" ), self.setActiveNodeList )
   
   QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL( "currentChanged(int)" ), self.onTabSelected )
   QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL( "tabCloseRequested(int)" ), self.onTabCloseRequested )
   
   QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL( "nodeLabelChanged" ), self.onNodeLabelChanged  )
Ejemplo n.º 11
0
	def addRecentProject ( self, project ) :
		#
		print '>> addRecentProject ', project
		if project is not None :
			if usePyQt4 :
				recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' )
				if project not in self.recentProjects :
					self.recentProjects.prepend ( QtCore.QString ( project ) )
				while self.recentProjects.count () > recent_projects_max :
					self.recentProjects.takeLast ()
				recentProjects = QtCore.QVariant ( self.recentProjects ) if self.recentProjects else QtCore.QVariant ()
				app_settings.setValue ( 'RecentProjects', recentProjects )
			else :
				recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' )
				if project not in self.recentProjects :
					self.recentProjects.insert ( 0, project )
					while len ( self.recentProjects ) > recent_projects_max :
						self.recentProjects.pop ()
					app_settings.setValue ( 'RecentProjects', self.recentProjects )
					print '* project added recentProjects =', self.recentProjects
			print '* recentProjects =', self.recentProjects
Ejemplo n.º 12
0
  def addRecentNetwork ( self, network ) :
    #
    if network is not None :
      recent_networks_max = getDefaultValue ( app_settings, '', 'recent_networks_max' )

      if not self.recentNetworks.contains ( network ) :
        self.recentNetworks.prepend ( QtCore.QString ( network ) )

      while self.recentNetworks.count () > recent_networks_max :
        self.recentNetworks.takeLast ()

      recentNetworks = QtCore.QVariant ( self.recentNetworks ) if self.recentNetworks else QtCore.QVariant ()
      app_settings.setValue ( 'RecentNetworks', recentNetworks )
Ejemplo n.º 13
0
  def addRecentProject ( self, project ) :
    #
    if project is not None :
      recent_projects_max = getDefaultValue ( app_settings, '', 'recent_projects_max' )

      if not self.recentProjects.contains ( project ) :
        self.recentProjects.prepend ( QtCore.QString ( project ) )

      while self.recentProjects.count () > recent_projects_max :
        self.recentProjects.takeLast ()

      recentProjects = QtCore.QVariant ( self.recentProjects ) if self.recentProjects else QtCore.QVariant ()
      app_settings.setValue ( 'RecentProjects', recentProjects )
Ejemplo n.º 14
0
 def itemChange ( self, change, value ) :
   #
   if change == QtGui.QGraphicsItem.ItemSelectedHasChanged : #ItemSelectedChange:
     if value.toBool () :
       items = self.scene ().items ()
       for i in range ( len ( items ) - 1, -1, -1 ) :
         if items [ i ].parentItem() is None :
           if items [ i ] != self :
             items [ i ].stackBefore ( self )
   elif change == QtGui.QGraphicsItem.ItemPositionHasChanged :
     from meShaderEd import getDefaultValue
     grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' )
     grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )
     x = self.x ()
     y = self.y ()
     if grid_snap :
       x -= ( x % grid_size )
       y -= ( y % grid_size )
       self.setPos ( x, y )
     self.node.offset = ( x, y )
     self.adjustLinks ()
   return QtGui.QGraphicsItem.itemChange ( self, change, value )
Ejemplo n.º 15
0
 def addRecentNetwork(self, network):
     #
     if network is not None:
         if usePyQt4:
             recent_networks_max = getDefaultValue(app_settings, '',
                                                   'recent_networks_max')
             if network not in self.recentNetworks:
                 self.recentNetworks.prepend(QtCore.QString(network))
             while self.recentNetworks.count() > recent_networks_max:
                 self.recentNetworks.takeLast()
             recentNetworks = QtCore.QVariant(
                 self.recentNetworks
             ) if self.recentNetworks else QtCore.QVariant()
             app_settings.setValue('RecentNetworks', recentNetworks)
         else:
             recent_networks_max = getDefaultValue(app_settings, '',
                                                   'recent_networks_max')
             if network not in self.recentNetworks:
                 self.recentNetworks.insert(0, network)
             while len(self.recentNetworks) > recent_networks_max:
                 self.recentNetworks.pop()
             app_settings.setValue('RecentNetworks', self.recentNetworks)
Ejemplo n.º 16
0
 def itemChange(self, change, value):
     #
     if change == QtModule.QGraphicsItem.ItemSelectedHasChanged:  #ItemSelectedChange:
         if value == 1:
             items = self.scene().items()
             for i in range(len(items) - 1, -1, -1):
                 if items[i].parentItem() is None:
                     if items[i] != self:
                         items[i].stackBefore(self)
     elif change == QtModule.QGraphicsItem.ItemPositionHasChanged:
         from meShaderEd import getDefaultValue
         grid_snap = getDefaultValue(app_settings, 'WorkArea', 'grid_snap')
         grid_size = int(
             getDefaultValue(app_settings, 'WorkArea', 'grid_size'))
         x = self.x()
         y = self.y()
         if grid_snap:
             x -= (x % grid_size)
             y -= (y % grid_size)
             self.setPos(x, y)
         self.node.offset = (x, y)
         self.adjustLinks()
     return QtModule.QGraphicsItem.itemChange(self, change, value)
Ejemplo n.º 17
0
    def onOpenRecentProject(self):
        #
        action = self.sender()
        if isinstance(action, QtModule.QAction):
            if usePyQt4:
                project = unicode(action.data().toString())
            else:
                project = action.data()
            if project is not None:
                print '>> onOpenRecentProject : %s' % project
                project_filename = getDefaultValue(app_settings, '',
                                                   'project_filename')
                if openDefaultProject(app_settings, app_global_vars, project,
                                      project_filename):
                    # very strange... app_settings doesn't update inside meCommon.openDefaultProject...
                    # though app_global_vars does
                    # have to duplicate this action here...
                    app_settings.setValue('project',
                                          app_global_vars['ProjectPath'])
                    app_settings.setValue('project_shaders',
                                          app_global_vars['ProjectShaders'])
                    app_settings.setValue('project_textures',
                                          app_global_vars['ProjectTextures'])
                    app_settings.setValue('shader_networks',
                                          app_global_vars['ProjectNetworks'])
                    app_settings.setValue('shader_sources',
                                          app_global_vars['ProjectSources'])

                    self.ui.project_ctl.setLibrary(
                        app_global_vars['ProjectNetworks'])
                    self.setupWindowTitle()
                else:
                    print "ERROR! project %s doesn't exist" % project
                    if usePyQt4:
                        self.recentProjects.removeAll(network)
                    else:
                        self.recentProjects.remove(network)
Ejemplo n.º 18
0
	def __init__ ( self ) :
		#
		QtModule.QMainWindow.__init__ ( self )

		self.ui = Ui_MainWindow ()
		self.ui.setupUi ( self )
		#
		# setup WhatsThis help action
		#
		self.ui.actionHelpMode = QtModule.QWhatsThis.createAction ( )
		self.ui.actionHelpMode.setToolTip ( 'Enter "WhatsThis" help mode' )
		self.ui.menuHelp.addAction ( self.ui.actionHelpMode )
		self.ui.toolBar.addSeparator()
		self.ui.toolBar.addAction ( self.ui.actionHelpMode )
		
		self.clipboard = QtModule.QApplication.clipboard ()

		if usePyQt4 :
			self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList ()
			self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList ()
		else :
			self.recentProjects = []
			self.recentNetworks = []
			
			recentProjects = app_settings.value ( 'RecentProjects' )
			if recentProjects is not None :
				if isinstance ( recentProjects, list ) :
					for proj in recentProjects :
						self.recentProjects.append ( proj )	
				else :
					self.recentProjects.append ( recentProjects )
			
			recentNetworks = app_settings.value ( 'RecentNetworks' )
			if recentNetworks is not None :
				if isinstance ( recentNetworks, list ) :
					for network in recentNetworks :
						self.recentNetworks.append ( network )	
				else :
					self.recentNetworks.append ( recentNetworks )
			
		print '* recentProjects =', self.recentProjects
		print '* recentNetworks =', self.recentNetworks
		
		print '* ProjectPath =', app_global_vars [ 'ProjectPath' ]
			
		self.addRecentProject ( app_global_vars [ 'ProjectPath' ] )

		self.setupMenuBar ()
		self.setupPanels ()

		self.activeNodeList = None
		self.workArea = None # current work area
		self.onNew () # create new document

		grid_enabled = getDefaultValue ( app_settings, 'WorkArea', 'grid_enabled' )
		grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' )
		grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )
		reverse_flow = getDefaultValue ( app_settings, 'WorkArea', 'reverse_flow' )
		straight_links = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' )

		#self.ui.workArea.gridSize = grid_size
		#self.ui.workArea.gridSnap = grid_snap
		self.workArea.drawGrid = grid_enabled
		#self.ui.workArea.reverseFlow = reverse_flow
		#self.ui.workArea.straightLinks = straight_links

		self.ui.actionShowGrid.setChecked ( grid_enabled )
		self.ui.actionSnapGrid.setChecked ( grid_snap )
		self.ui.actionReverseFlow.setChecked ( reverse_flow )
		self.ui.actionStraightLinks.setChecked ( straight_links )

		self.ui.nodeList_ctl.setLibrary ( app_global_vars [ 'NodesPath' ] )
		self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] )

		#self.ui.dockNodes.setWindowTitle ( 'Library: %s' % app_global_vars [ 'NodesPath' ] )
		#self.ui.dockProject.setWindowTitle ( 'Project: %s' % app_global_vars [ 'ProjectNetworks' ] )

		self.connectSignals ()
		
		self.setupActions ()
		self.setupWindowTitle ()
Ejemplo n.º 19
0
  def __init__ ( self ) :
    #
    QtGui.QMainWindow.__init__ ( self )

    self.ui = Ui_MainWindow ()
    self.ui.setupUi ( self )
    #
    # setup WhatsThis help action
    #
    self.ui.actionHelpMode = QtGui.QWhatsThis.createAction ( )
    self.ui.actionHelpMode.setToolTip ( 'Enter "WhatsThis" help mode' )
    self.ui.menuHelp.addAction ( self.ui.actionHelpMode )
    self.ui.toolBar.addSeparator()
    self.ui.toolBar.addAction ( self.ui.actionHelpMode )
    QtCore.QObject.connect ( self.ui.actionHelpMode, QtCore.SIGNAL ( 'toggled(bool)' ), self.onHelpMode )
    
    self.clipboard = QtGui.QApplication.clipboard ()

    self.recentProjects = app_settings.value ( 'RecentProjects' ).toStringList ()
    self.recentNetworks = app_settings.value ( 'RecentNetworks' ).toStringList ()

    self.addRecentProject ( app_global_vars [ 'ProjectPath' ] )

    self.setupMenuBar ()
    self.setupPanels ()

    self.activeNodeList = None
    self.workArea = None # current work area
    self.onNew () # create new document

    grid_enabled = getDefaultValue ( app_settings, 'WorkArea', 'grid_enabled' )
    grid_snap = getDefaultValue ( app_settings, 'WorkArea', 'grid_snap' )
    grid_size = int ( getDefaultValue ( app_settings, 'WorkArea', 'grid_size' )  )
    reverse_flow = getDefaultValue ( app_settings, 'WorkArea', 'reverse_flow' )
    straight_links = getDefaultValue ( app_settings, 'WorkArea', 'straight_links' )

    #self.ui.workArea.gridSize = grid_size
    #self.ui.workArea.gridSnap = grid_snap
    self.workArea.drawGrid = grid_enabled
    #self.ui.workArea.reverseFlow = reverse_flow
    #self.ui.workArea.straightLinks = straight_links

    self.ui.actionShowGrid.setChecked ( grid_enabled )
    self.ui.actionSnapGrid.setChecked ( grid_snap )
    self.ui.actionReverseFlow.setChecked ( reverse_flow )
    self.ui.actionStraightLinks.setChecked ( straight_links )

    self.ui.nodeList_ctl.setLibrary ( app_global_vars [ 'NodesPath' ] )
    self.ui.project_ctl.setLibrary ( app_global_vars [ 'ProjectNetworks' ] )

    #self.ui.dockNodes.setWindowTitle ( 'Library: %s' % app_global_vars [ 'NodesPath' ] )
    #self.ui.dockProject.setWindowTitle ( 'Project: %s' % app_global_vars [ 'ProjectNetworks' ] )

    QtCore.QObject.connect ( self.ui.nodeList_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList )
    QtCore.QObject.connect ( self.ui.project_ctl.ui.nodeList, QtCore.SIGNAL ( 'setActiveNodeList' ), self.setActiveNodeList )

    QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'currentChanged(int)' ), self.onTabSelected )
    QtCore.QObject.connect ( self.ui.tabs, QtCore.SIGNAL ( 'tabCloseRequested(int)' ), self.onTabCloseRequested )

    QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeLabelChanged' ), self.onNodeLabelChanged  )
    QtCore.QObject.connect ( self.ui.nodeParam_ctl, QtCore.SIGNAL ( 'nodeParamChanged' ), self.onNodeParamChanged  )

    self.setupActions ()
    self.setupWindowTitle ()
Ejemplo n.º 20
0
    def __init__(self):
        #
        QtModule.QMainWindow.__init__(self)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        #
        # setup WhatsThis help action
        #
        self.ui.actionHelpMode = QtModule.QWhatsThis.createAction()
        self.ui.actionHelpMode.setToolTip('Enter "WhatsThis" help mode')
        self.ui.menuHelp.addAction(self.ui.actionHelpMode)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addAction(self.ui.actionHelpMode)

        self.clipboard = QtModule.QApplication.clipboard()

        if usePyQt4:
            self.recentProjects = app_settings.value(
                'RecentProjects').toStringList()
            self.recentNetworks = app_settings.value(
                'RecentNetworks').toStringList()
        else:
            self.recentProjects = []
            self.recentNetworks = []

            recentProjects = app_settings.value('RecentProjects')
            if recentProjects is not None:
                if isinstance(recentProjects, list):
                    for proj in recentProjects:
                        self.recentProjects.append(proj)
                else:
                    self.recentProjects.append(recentProjects)

            recentNetworks = app_settings.value('RecentNetworks')
            if recentNetworks is not None:
                if isinstance(recentNetworks, list):
                    for network in recentNetworks:
                        self.recentNetworks.append(network)
                else:
                    self.recentNetworks.append(recentNetworks)

        print '* recentProjects =', self.recentProjects
        print '* recentNetworks =', self.recentNetworks

        print '* ProjectPath =', app_global_vars['ProjectPath']

        self.addRecentProject(app_global_vars['ProjectPath'])

        self.setupMenuBar()
        self.setupPanels()

        self.activeNodeList = None
        self.workArea = None  # current work area
        self.onNew()  # create new document

        grid_enabled = getDefaultValue(app_settings, 'WorkArea',
                                       'grid_enabled')
        grid_snap = getDefaultValue(app_settings, 'WorkArea', 'grid_snap')
        grid_size = int(getDefaultValue(app_settings, 'WorkArea', 'grid_size'))
        reverse_flow = getDefaultValue(app_settings, 'WorkArea',
                                       'reverse_flow')
        straight_links = getDefaultValue(app_settings, 'WorkArea',
                                         'straight_links')

        #self.ui.workArea.gridSize = grid_size
        #self.ui.workArea.gridSnap = grid_snap
        self.workArea.drawGrid = grid_enabled
        #self.ui.workArea.reverseFlow = reverse_flow
        #self.ui.workArea.straightLinks = straight_links

        self.ui.actionShowGrid.setChecked(grid_enabled)
        self.ui.actionSnapGrid.setChecked(grid_snap)
        self.ui.actionReverseFlow.setChecked(reverse_flow)
        self.ui.actionStraightLinks.setChecked(straight_links)

        self.ui.nodeList_ctl.setLibrary(app_global_vars['NodesPath'])
        self.ui.project_ctl.setLibrary(app_global_vars['ProjectNetworks'])

        #self.ui.dockNodes.setWindowTitle ( 'Library: %s' % app_global_vars [ 'NodesPath' ] )
        #self.ui.dockProject.setWindowTitle ( 'Project: %s' % app_global_vars [ 'ProjectNetworks' ] )

        self.connectSignals()

        self.setupActions()
        self.setupWindowTitle()