Beispiel #1
0
def launch_viewer(request):
    project = loadProject(request)

    objectId = request.GET.get('objectId')
    # Fix this, now we should use newer notation: . instead of ::
    if '::' in objectId:
        idParts = objectId.split("::")
        if idParts[1] != 'None':
            # We use the logic in Pointer.get to handle the 'extended'
            # parts that can come as part of the id (eg: 2::outputAverages::1)
            protObj = project.getObject(int(idParts[0]))
            pointer = Pointer(value=protObj)
            pointer.setExtendedParts(idParts[1:])
            obj = pointer.get()
        else:
            #
            obj = project.getObject(int(idParts[0]))
    else:
        obj = project.getObject(int(objectId))

    if obj is not None:
        if obj.isPointer():
            obj = obj.get()

        viewers = findViewers(obj.getClassName(), WEB_DJANGO)

        if len(viewers) == 0:
            views = []

            if isinstance(obj, EMProtocol):
                for _, output in obj.iterOutputAttributes(EMObject):
                    objViewers = findViewers(output.getClassName(), WEB_DJANGO)
                    if objViewers:
                        views += objViewers[0](project=project)._visualize(output) or []

            if not views:
                views = [MessageView("No viewers found for object type: %s" % obj.getClassName())]

            urls = [viewToUrl(request, view) for view in views]
        else:
            viewerClass = viewers[0]
            viewer = viewerClass(project=project, protocol=obj)

            # Lets assume if there is a viewer for the protocol
            # it will be a ProtocolViewer with a Form
            if issubclass(viewerClass, ProtocolViewer):
                urls = [viewerForm(project, obj, viewer, request)]
            else:
                views = viewer._visualize(obj)
                urls = [viewToUrl(request, v) for v in views]
    else:
        views = [MessageView("Object not found to visualize")]
        urls = [viewToUrl(request, view) for view in views]

    jsonStr = json.dumps(urls, ensure_ascii=False)

    return HttpResponse(jsonStr, content_type='application/javascript')
Beispiel #2
0
def get_resmap_plot(request):
    # LOAD Project
    project = loadProject(request)

    # Create protocol
    newProtocol = project.newProtocol(ProtResMap)

    # GET and SET Parameters
    newAng = request.GET.get('ang')
    newProtocol.prewhitenAng.set(float(newAng))

    newRamp = request.GET.get('ramp')
    newProtocol.prewhitenRamp.set(float(newRamp))

    def setPointerValue(inputPointer, uniqueIdKey):
        uniqueId = request.GET.get(uniqueIdKey)
        parts = uniqueId.split('.')
        inputPointer.set(project.mapper.selectById(parts[0]))
        inputPointer.setExtendedParts(parts[1:])

    useSplit = request.GET.get('useSplit', None) is not None
    newProtocol.useSplitVolume.set(useSplit)

    if not useSplit:
        setPointerValue(newProtocol.inputVolume, 'inputId')
    else:
        setPointerValue(newProtocol.volumeHalf1, 'inputId')
        setPointerValue(newProtocol.volumeHalf2, 'splitId')

    useMask = request.GET.get('useMask', None) is not None
    newProtocol.applyMask.set(useMask)

    if useMask:
        setPointerValue(newProtocol.maskVolume, 'maskId')

    # Extra Params
    pValue = request.GET.get('pValue', None)
    if pValue is not None:
        newProtocol.pVal.set(pValue)

    minRes = request.GET.get('minRes', None)
    if minRes is not None:
        newProtocol.minRes.set(minRes)

    maxRes = request.GET.get('maxRes', None)
    if maxRes is not None:
        newProtocol.maxRes.set(maxRes)

    stepRes = request.GET.get('stepRes', None)
    if stepRes is not None:
        newProtocol.stepRes.set(stepRes)

    plotUrl, _ = getPlotResMap(request, newProtocol)

    return HttpResponse(plotUrl, content_type='application/javascript')
Beispiel #3
0
def get_resmap_plot(request):
    # LOAD Project
    projectName = request.session['projectName']
    project = loadProject(request)
    
    # Create protocol
    newProtocol = project.newProtocol(ProtResMap)
    
    # GET and SET Parameters
    newAng = request.GET.get('ang')
    newProtocol.prewhitenAng.set(float(newAng))
  
    newRamp = request.GET.get('ramp')
    newProtocol.prewhitenRamp.set(float(newRamp))
    
    inputId = request.GET.get('inputId')
    inputVolume = project.mapper.selectById(inputId)
    newProtocol.inputVolume.set(inputVolume)
    
    useSplit = request.GET.get('useSplit', None)
    if useSplit is not None:
        newProtocol.useSplitVolume = True
        splitId = request.GET.get('splitId', None)
        splitVolume = project.mapper.selectById(splitId)
        newProtocol.splitVolume.set(splitVolume.get())
        
    useMask = request.GET.get('useMask', None)
    if useSplit is not None:
        newProtocol.applyMask = True
        maskId = request.GET.get('maskId',  None)
        inputMask = project.mapper.selectById(maskId)
        newProtocol.maskVolume.set(inputMask.get())
        
    # Extra Params
    pValue = request.GET.get('pValue', None)
    if pValue is not None:
        newProtocol.pVal.set(float(pValue))
        
    minRes = request.GET.get('minRes', None)
    if minRes is not None:
        newProtocol.minRes.set(float(minRes))
        
    maxRes = request.GET.get('maxRes', None)
    if maxRes is not None:
        newProtocol.maxRes.set(float(maxRes))
        
    stepRes = request.GET.get('stepRes', None)
    if stepRes is not None:
        newProtocol.stepRes.set(float(stepRes))

    plotUrl, _ = getPlotResMap(request, newProtocol)
    
    return HttpResponse(plotUrl, mimetype='application/javascript')   
Beispiel #4
0
def get_resmap_plot(request):
    # LOAD Project
    projectName = request.session['projectName']
    project = loadProject(request)
    
    # Create protocol
    newProtocol = project.newProtocol(ProtResMap)
    
    # GET and SET Parameters
    newAng = request.GET.get('ang')
    newProtocol.prewhitenAng.set(float(newAng))
  
    newRamp = request.GET.get('ramp')
    newProtocol.prewhitenRamp.set(float(newRamp))
    
    inputId = request.GET.get('inputId')
    inputVolume = project.mapper.selectById(inputId)
    newProtocol.inputVolume.set(inputVolume)
    
    useSplit = request.GET.get('useSplit', None)
    if useSplit is not None:
        newProtocol.useSplitVolume = True
        splitId = request.GET.get('splitId', None)
        splitVolume = project.mapper.selectById(splitId)
        newProtocol.splitVolume.set(splitVolume.get())
        
    useMask = request.GET.get('useMask', None)
    if useSplit is not None:
        newProtocol.applyMask = True
        maskId = request.GET.get('maskId',  None)
        inputMask = project.mapper.selectById(maskId)
        newProtocol.maskVolume.set(inputMask.get())
        
    # Extra Params
    pValue = request.GET.get('pValue', None)
    if pValue is not None:
        newProtocol.pVal.set(float(pValue))
        
    minRes = request.GET.get('minRes', None)
    if minRes is not None:
        newProtocol.minRes.set(float(minRes))
        
    maxRes = request.GET.get('maxRes', None)
    if maxRes is not None:
        newProtocol.maxRes.set(float(maxRes))
        
    stepRes = request.GET.get('stepRes', None)
    if stepRes is not None:
        newProtocol.stepRes.set(float(stepRes))

    plotUrl, _ = getPlotResMap(request, newProtocol)
    
    return HttpResponse(plotUrl, mimetype='application/javascript')