Example #1
0
    def __init__(self, *args, **kwargs):
        RanaModule.__init__(self, *args, **kwargs)
        self.tt = 0
        self.connected = False
        self.set('speed', None)
        self.set('metersPerSecSpeed', None)
        self.set('bearing', None)
        self.set('elevation', None)
        self.status = "Unknown"
        self._enabled = False
        self.provider = None
        self.startSignal = Signal()
        self.stopSignal = Signal()
        self.positionUpdate = Signal()

        # check if the device handles location by itself
        if not self.modrana.dmod.handles_location:
            method = self.modrana.dmod.location_type
            if method == "qt_mobility":
                self.log.info("using Qt Mobility")
                from . import qt_mobility

                self.provider = qt_mobility.QtMobility(self)
            elif method == "gpsd":  # GPSD
                self.log.info("using GPSD")
                from . import gps_daemon

                self.provider = gps_daemon.GPSD(self)

        # watch if debugging needs to be enabled
        self.modrana.watch("gpsDebugEnabled", self._debugCB, runNow=True)
Example #2
0
 def __init__(self, view):
     #
     QtModule.QGraphicsScene.__init__(self)
     #
     # Define signals for PyQt5
     #
     if usePySide or usePyQt5:
         #
         self.startNodeConnector = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF )
         self.traceNodeConnector = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF )
         self.endNodeConnector = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF )
         self.startNodeLink = Signal(
         )  #( QtModule.QGraphicsObject ) # QtModule.QGraphicsItem
         self.traceNodeLink = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF )
         self.endNodeLink = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject, QtCore.QPointF )
         self.onGfxNodeRemoved = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject )
         self.onGfxLinkRemoved = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsObject )
         self.nodeUpdated = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsItem )
         self.gfxNodeParamChanged = Signal(
         )  #QtCore.pyqtSignal ( QtModule.QGraphicsItem, QtCore.QObject )
         #
     self.view = view
     self.connectSignals()
Example #3
0
 def __init__(self):
     self._objs = {}
     self._objs_lock = threading.RLock()
     self._global_index = 0
     self._errors = {}
     self._main_thread = threading.currentThread()
     # signals
     self.thread_status_changed = Signal()
     self.thread_progress_changed = Signal()
     self.thread_removed = Signal()
Example #4
0
 def __init__(self):
     self._objs = {}
     self._objs_lock = threading.RLock()
     self._globalIndex = 0
     self._errors = {}
     self._main_thread = threading.currentThread()
     # signals
     self.threadStatusChanged = Signal()
     self.threadProgressChanged = Signal()
     self.threadRemoved = Signal()
 def __init__(self, rendererPreset):
     #
     QtModule.QDialog.__init__(self)
     #
     # Define signals for PyQt5
     #
     if usePySide or usePyQt5:
         #
         self.presetChanged = Signal()
         self.savePreset = Signal()
         #
     self.rendererPreset = rendererPreset
     self.labelsReady = False
     self.buildGui()
Example #6
0
    def __init__(self,
                 parent,
                 gfxNode=None,
                 isInput=True,
                 showConnected=False):
        #
        QtModule.QWidget.__init__(self, parent)
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.sectionResized = Signal()
            #
        self.nodeParamView = parent
        self.gfxNode = gfxNode
        self.isInput = isInput

        self.showConnected = showConnected

        self.labelWidth = UI.CHECK_WIDTH + UI.LABEL_WIDTH + 6 + 20
        self.stackedWidget = None
        self.nodeParamList = None

        self.buildGui()
        self.updateGui()
        self.connectSignals()
Example #7
0
    def __init__(self, parent):
        #
        QtModule.QGraphicsView.__init__(self, parent)
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.mouseDoubleClickSignal = Signal()
            #
        self.state = 'idle'
        self.panStartPos = None

        self.pixmap = None

        # set scene
        scene = QtModule.QGraphicsScene(self)

        scene.setSceneRect(0, 0, 256, 256)
        #scene.setItemIndexMethod ( QtGui.QGraphicsScene.NoIndex )
        self.setScene(scene)

        # qt graphics stuff
        #self.setCacheMode ( QtGui.QGraphicsView.CacheBackground )
        self.setRenderHint(QtGui.QPainter.Antialiasing)

        self.setTransformationAnchor(QtModule.QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QtModule.QGraphicsView.AnchorViewCenter)
        self.setDragMode(QtModule.QGraphicsView.RubberBandDrag)

        self.setMouseTracking(False)

        self.BgBrush = QtGui.QBrush(QtGui.QColor(128, 128, 128))
Example #8
0
    def __init__(self, db, data):
        super(MessageStream, self).__init__(db, data)
        self._messages = []
        self._input_group = None
        self._filter_group = None

        if self.data.input_group:
            self._input_group = InputGroup(self.db, self.data.input_group)
        else:  # create a new input group
            self._input_group = InputGroup.new(self.db)
            self.data.input_group = self._input_group.data

        if self.data.filter_group:
            self._filter_group = group.FilterGroup(self.db,
                                                   self.data.filter_group)
        else:  # create a new filter group
            self._filter_group = group.FilterGroup.new(self.db)
            self.data.filter_group = self._filter_group.data

        # get initial messages
        initial_messages = self.inputs.messages

        self._messages = self.filters.filter_messages(initial_messages)

        self.refresh_done = Signal()
Example #9
0
    def __init__(self, *args, **kwargs):
        RanaModule.__init__(self, *args, **kwargs)
        self._go_to_initial_state()
        # how long the last routing lookup took in seconds
        self._route_lookup_duration = 0
        self._once = True
        self._entry = None

        # tracks the state of the onscreen routing menu
        self._osd_menu_state = None

        self.set('startPos', None)
        self.set('endPos', None)

        self._directions_filter_rules = []
        self._directions_filter_rules_loaded = False

        self._addressLookupLock = threading.Lock()
        self._startLookup = False
        self._destinationLookup = False

        # offline routing provider
        self._offline_routing_provider = None

        # signals
        self.routing_done = Signal()
Example #10
0
 def __init__(self, parent):
     #
     QtModule.QWidget.__init__(self, parent)
     #
     # Define signals for PyQt5
     #
     if usePySide or usePyQt5:
         #
         self.selectionChangedSignal = Signal()
         self.addItem = Signal()
         self.removeItem = Signal()
         self.renameItem = Signal()
     #
     self.saved_text = ''
     self.approvedNewName = ''
     self.buildGui()
Example #11
0
    def __init__(self, parent):
        #
        QtModule.QWidget.__init__(self, parent)
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.changeParamName = Signal()
            self.changeParamLabel = Signal()
            self.changeParamIsShader = Signal()
            self.changeParamType = Signal()
            self.changeParamDetail = Signal()
            self.changeParamProvider = Signal()
            self.changeParamSubtype = Signal()
            self.changeParamRange = Signal()

            self.changeParamValue = Signal()
            self.changeParamDefValue = Signal()
        #
        self.param = None
        self.param_default = None
        self.paramWidgets = {
            'string': StringWidget,
            'image': StringWidget,
            'rib': StringWidget,
            'surface': StringWidget,
            'displacement': StringWidget,
            'light': StringWidget,
            'volume': StringWidget,
            'float': FloatWidget,
            'int': IntWidget,
            'color': ColorWidget,
            'normal': NormalWidget,
            'transform': PointWidget,
            'point': PointWidget,
            'vector': VectorWidget,
            'matrix': MatrixWidget,
            'text': TextWidget,
            'control': ControlWidget,
            'shader': StringWidget,
            'geom': StringWidget
        }

        self.buildGui()
Example #12
0
 def __init__(self, db, data):
     super(StreamManager, self).__init__(db, data)
     self._lock = RLock()
     self._streams_loaded = False
     self._stream_list = []
     self._stream_dict = {}
     self.stream_list_changed = Signal()
     account_module.account_manager.account_added.connect(
         self._new_account_added_cb)
Example #13
0
 def __init__(self, *args, **kwargs):
     RanaModule.__init__(self, *args, **kwargs)
     # initial colors
     self.navigationBoxBackground = (0, 0, 1, 0.3)  # very transparent blue
     self.navigationBoxText = (1, 1, 1, 1)  # non-transparent white
     self._tbt_worker_lock = RLock()
     self._tbt_worker_enabled = False
     self._go_to_initial_state()
     self._automatic_reroute_counter = 0  # counts consecutive automatic reroutes
     self._last_automatic_reroute_timestamp = time.time()
     # reroute even though the route was not yet reached (for special cases)
     self._override_route_reached = False
     # signals
     self.navigation_started = Signal()
     self.navigation_stopped = Signal()
     self.destination_reached = Signal()
     self.rerouting_triggered = Signal()
     self.current_step_changed = Signal()
Example #14
0
 def __init__(self, *args, **kwargs):
     RanaModule.__init__(self, *args, **kwargs)
     self._layers = {}
     self._groups = {}
     self._tree = {}
     # TODO: actually support runtime layer reconfiguration
     # and use this signal
     self.layersChanged = Signal()
     # parse the config file
     self._parseConfig()
Example #15
0
    def buildGui(self):
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.clicked = Signal()

        self.ui = Ui_ColorWidget_field()
        self.ui.setupUi(self)
Example #16
0
    def __init__(self, *args, **kwargs):
        RanaModule.__init__(self, *args, **kwargs)
        self.notificationText = ""
        self.timeout = 5000
        self.position = 'middle'
        self.expirationTimestamp = time.time()
        self.draw = False
        self.redrawn = None
        self.wipOverlayEnabled = Signal()
        self._showWorkInProgressOverlay = False
        self.workStartTimestamp = None
        self._wipOverlayText = ""
        # this indicates if the notification about
        # background processing should be shown
        self._tasks = {}
        self._tasksLock = threading.RLock()

        ## for WiP overlay testing
        #self._tasks = {
        #  "foo" : ("foo", None),
        #  "bar" : ("bar", None),
        #  "baz" : ("baz", None)
        #}

        # key is an unique task name (unique for each instance of a task)
        # and value is a (status, progress) tuple
        self.tasksChanged = Signal()

        # connect thread manager signals to task status changes
        threadMgr.threadStatusChanged.connect(self.setTaskStatus)
        threadMgr.threadProgressChanged.connect(self.setTaskProgress)
        threadMgr.threadRemoved.connect(self.removeTask)

        # also with GTK GUI, assure screen is redrawn properly
        # when WiP overlay changes
        if gs.GUIString == "GTK":
            self.wipOverlayEnabled.connect(self._doRefresh)
            self.tasksChanged.connect(self._doRefresh)
            # we handle notification only with the GTK GUI and when the device module does not
            # support showing them
            if not self.modrana.dmod.hasNotificationSupport():
                self.modrana.notificationTriggered.connect(self._startCustomNotificationCB)
Example #17
0
 def __init__(self, parent):
     #
     QtModule.QWidget.__init__(self, parent)
     #
     # Define signals for PyQt5
     #
     if usePySide or usePyQt5:
         #
         self.setActiveNodeList = Signal()
         self.addNode = Signal()
         #
     self.nodesLib = ''
     self.nodesDir = ''
     # This is always the same
     self.ui = Ui_nodeList()
     self.ui.setupUi(self)
     self.ui.treeView.setDragEnabled(True)
     #self.ui.treeView.setRootIsDecorated( True )
     self.connectSignals()
     self.updateGui()
Example #18
0
    def __init__(self):
        #
        QtModule.QWidget.__init__(self)
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.nodeParamChangedSignal = Signal()
            self.nodeLabelChangedSignal = Signal()
            #
        self.gfxNode = None

        self.inputParamListTab = None
        self.outputParamListTab = None

        self.showConnected = False
        self.buildGui()
        self.updateGui()
        self.connectSignals()
Example #19
0
    def __init__(self, main_db):
        super(AccountManager, self).__init__()
        self._accounts = {}
        self._main_db = main_db
        self.account_added = Signal()

        # load stored accounts (if any)
        account_data = self._main_db.filter(TwitterAccountData, {})

        for data in account_data:
            self._accounts[data.username] = TwitterAccount(main_db, data)
Example #20
0
 def buildGui(self):
     #
     # Define signals for PyQt5
     #
     if usePySide or usePyQt5:
         #
         self.clicked = Signal()
         #
     if self.param.isArray():
         self.ui = Ui_ColorWidget_array()
     else:
         self.ui = Ui_ColorWidget_field()
     self.ui.setupUi(self)
Example #21
0
 def __init__(self, name=None):
     if name is None:
         self._name = _getBatchPoolName()
     else:
         self._name = name
     self._batch = set()
     self._doneCount = 0
     self._running = False
     self._shutdown = False
     self._mutex = threading.RLock()
     self._loaderName = None
     self._pool = None
     self.batchDone = Signal()
Example #22
0
 def __init__(self, parent, value=None, idx=None):
     #
     QtModule.QWidget.__init__(self, parent)
     #
     # Define signals for PyQt5
     #
     if usePySide or usePyQt5:
         #
         self.clicked = Signal()
         #
     #print ( '>>> ColorField.init' )
     self.value = value
     self.idx = idx
     self.buildGui()
    def __init__(self, parent, editNode=None):
        #
        QtModule.QWidget.__init__(self, parent)
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.changeNodeLabel = Signal()
            #
        self.editNode = editNode

        #self.debugPrint()
        self.buildGui()
        self.setNode(editNode)
Example #24
0
    def __init__(self, param, gfxNode, ignoreSubtype=False):
        #
        QtModule.QWidget.__init__(self)
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.nodeParamRemoved = Signal()
            #
        self.param = param
        self.gfxNode = gfxNode
        self.ignoreSubtype = ignoreSubtype  # if widget is used in NodeEditor, then ignoreSubtype = True

        self.buildGeneralGui()
        self.buildGui()
        self.ui.updateGui(self.param.value)
Example #25
0
    def __init__(self, *args, **kwargs):
        RanaModule.__init__(self, *args, **kwargs)
        self.images = [{}, {}] # the first dict contains normal image data, the second contains special tiles
        self.imagesLock = threading.RLock()
        # we need to limit the size of the tile cache to avoid a memory leak
        memoryTileCacheSize = int(self.get("memoryTileCacheSize", constants.DEFAULT_MEMORY_TILE_CACHE_SIZE))
        self.log.info("in memory tile cache size: %d", memoryTileCacheSize)
        self.maxImagesInMemory = memoryTileCacheSize
        self.imagesTrimmingAmount = constants.DEFAULT_MEMORY_TILE_CACHE_TRIM_SIZE
        # how many tiles to remove once the maximum is reached
        # so that trim does not run always run after adding a tile
        # TODO: analyse memory usage,
        #       set appropriate value,
        #       platform dependent value,
        #       user configurable
        self.tileSide = 256 # by default, the tiles are squares, side=256
        self.scalingInfo = (1, 15, 256)
        self.downloadRequestTimeout = 30 # in seconds

        specialTiles = [
            ('tileDownloading', 'themes/default/tile_downloading.png'),
            ('tileDownloadFailed', 'themes/default/tile_download_failed.png'),
            ('tileLoading', 'themes/default/tile_loading.png'),
            ('tileWaitingForDownloadSlot', 'themes/default/tile_waiting_for_download_slot.png'),
            ('tileNetworkError', 'themes/default/tile_network_error.png')
        ]

        self.mapViewModule = None
        self._mapLayersModule = None

        # cache the map folder path
        self.mapFolderPath = self.modrana.paths.map_folder_path
        self.log.info("map folder path: %s" % self.mapFolderPath)

        self._storeTiles = None

        self.connPools = {} # connection pool dictionary

        self.cacheImageSurfaces = False  # only GTK GUI used this

        self._filterTile = self._nop

        self._tileDownloaded = Signal()

        self._dlRequestQueue = Queue()
        self._downloader = None
Example #26
0
    def __init__(self, xml_param=None, isRibParam=False):
        #
        super(NodeParam, self).__init__()
        #
        # Define signals for PyQt5
        #
        if usePySide or usePyQt5:
            #
            self.paramChangedSignal = Signal()

        self.id = None
        self.name = None
        self.label = None
        self.type = None
        self.help = None  # short description

        self.default = None
        self.value = None
        self.shaderParam = False

        self.isRibParam = isRibParam
        self.display = True
        self.enabled = True
        self.removable = False

        # extra parameter description
        self.detail = ''  # variable, uniform
        self.provider = ''  # primitive, connection, constant, variable, expression

        # ui decorative parameters
        self.subtype = ''
        self.range = ''

        self.space = None  # actual for color, point, vector, normal, matrix
        self.spaceDef = None  # default value space

        self.arraySize = None  # otherwise, it should be a list of values ( or empty list )

        self.defaultArray = []
        self.valueArray = []
        #self.spaceArray = []
        #self.spaceDefArray = []

        if xml_param != None: self.parseFromXML(xml_param)
Example #27
0
 def __init__(self, *args, **kwargs):
     RanaModule.__init__(self, *args, **kwargs)
     self.loggingEnabled = False
     self.loggingPaused = False
     self.loggingStartTimestamp = 0
     self.lastUpdateTimestamp = None
     self.lastCoords = None
     self.logName = None  #name of the current log
     self.logFilename = None  #name of the current log
     self.logPath = None  #path to the current log
     self.currentLogGPX = None
     self.currentTempLog = []
     # primary and secondary AOWay objects for
     # persistent log storage during logging
     self.log1 = None
     self.log2 = None
     # timer ids
     self.updateLogTimerId = None
     self.saveLogTimerId = None
     # signals
     self.tracklogUpdated = Signal()
     # statistics
     self.maxSpeed = 0
     self.avg1 = 0
     self.avg2 = 0
     self.avgSpeed = 0
     self.distance = 0
     self.toolsMenuDone = False
     self.category = 'logs'
     # trace
     self.traceColor = 'blue'
     self.lastTracePoint = None
     self.traceIndex = 0
     self.pxpyIndex = deque()
     self.lastX = 0
     self.lastY = 0
Example #28
0
	def __init__ ( self, xml_node = None, nodenet = None ) :
		#
		QtCore.QObject.__init__ ( self )
		#
		# Define signals for PyQt5
		#
		if usePySide or usePyQt5 :
			#
			self.nodeUpdated = Signal () # QtCore.pyqtSignal ( [QtCore.QObject] )
			self.nodeParamsUpdated = Signal () #QtCore.pyqtSignal ( [QtCore.QObject] )
			#
		self.id = None
		self.name = None
		self.label = None
		self.type = None
		
		self.version = None
		self.format = None
		self.parent = None
		self.dirty = False

		self.author = None
		self.help = None
		self.icon = None

		self.master = None

		self.code = None            # Node code (RSL, RIB, ... )
		self.control_code = None    # python code executed before node computation
		self.computed_code = None   # code collected after compute on all connected nodes
		
		self.event_code = {}
		#self.event_code [ 'ParamLabelRenamed' ] = None
		#self.event_code [ 'ParamAdded' ] = None
		#self.event_code [ 'ParamRemoved' ] = None

		self.display = True

		self.computedInputParams = None
		self.computedOutputParams = None
		self.computedLocalParams = None
		self.computedIncludes = None
		self.computedLocals = None
		self.computedCode = None

		#self.previewCode = None

		self.inputParams = []
		self.outputParams = []
		self.internals = []
		self.includes = []

		self.inputLinks = {}
		self.outputLinks = {}

		self.childs = set()

		self.nodenet = nodenet

		# position from GfxNode
		self.offset = ( 0, 0 )

		if xml_node != None :
			self.parseFromXML ( xml_node )
Example #29
0
    def __init__(self):
        singleton.modrana = self

        self.timing = []
        self.addCustomTime("modRana start", startTimestamp)
        self.addCustomTime("imports done", importsDoneTimestamp)

        # constants & variable initialization
        self.dmod = None  # device specific module
        self.gui = None
        self.GUIString = ""
        self.optLoadingOK = None

        self.d = {}  # persistent dictionary of data
        self.m = {}  # dictionary of loaded modules
        self.watches = {}  # List of data change watches
        self.maxWatchId = 0

        self.initInfo = {
            'modrana': self,
            'device': None,  # TODO: do this directly
            'name': ""
        }

        # signals
        self.notificationTriggered = Signal()
        self.shutdown_signal = Signal()

        self.mapRotationAngle = 0  # in radians
        self.notMovingSpeed = 1  # in m/s

        # per mode options
        # NOTE: this variable is automatically saved by the
        # options module
        self.keyModifiers = {}

        # initialize threading
        threads.initThreading()

        # start timing modRana launch
        self.addTime("GUI creation")

        # add the startup handling core module
        self.startup = startup.Startup(self)
        self.args = self.startup.getArgs()

        # handle any early tasks specified from CLI
        self.startup.handleEarlyTasks()

        # early CLI tasks might need a "silent" modRana
        # so the startup announcement is here
        log.info(" == modRana Starting == ")
        # load the version string (needs to be done here
        # as PWD might change after the paths module is
        # imported, for example when running
        # with the Qt 5 GUI)
        paths.load_version_string()
        version = paths.VERSION_STRING
        if version is None:
            version = "unknown version"
        log.info("  %s" % version)
        log.info("  Python %s" % platform.python_version())
        os_release = self._get_os_release()
        if os_release:
            log.info("  %s", os_release)

        # load the device module now as it might override
        # the default profile directory, so it needs to be
        # before ve init the core paths module
        self._load_device_module()

        # initialize the paths handling core module
        self.paths = paths.Paths(self)

        # add the configs handling core module
        self.configs = configs.Configs(configs_dir=self.paths.profile_path)

        # load persistent options
        self.optLoadingOK = self._load_options()
        self._options_loaded()

        # check if upgrade took place

        if self.optLoadingOK:
            savedVersionString = self.get('modRanaVersionString', "")
            versionStringFromFile = paths.VERSION_STRING
            if savedVersionString != versionStringFromFile:
                log.info("possible upgrade detected")
                self._post_upgrade_check()

        # save current version string
        self.set('modRanaVersionString', paths.VERSION_STRING)

        # load all configuration files
        self.configs.load_all()

        # start loading other modules

        # handle tasks that require the device
        # module but not GUI
        self.startup.handle_non_gui_tasks()

        # then the GUI module
        self._load_gui_module()

        # and all other modules
        self._load_modules()

        # startup done, log some statistics
        self._startup_done()
Example #30
0
 def __init__(self, *args, **kwargs):
     RanaModule.__init__(self, *args, **kwargs)
     self.internetConnectivityChanged = Signal()