Esempio n. 1
0
/*!
    Zoom the plot until \a lowerTime and \a upperTime will be visible
    in the range.
*/
void UiTimeAxis::zoomAll(double lowerTime, double upperTime)
{
    double interval = upperTime - lowerTime;

    if (interval <= 0) return;

    setReference(mMajorStepTime);
    updateRange();
    while (upperTime < mRangeUpper) {
        zoom(1, 0);
        setReference(mMajorStepTime);
        updateRange();
    }

    while (upperTime > mRangeUpper) {
        zoom(-1, 0);
        setReference(mMajorStepTime);
        updateRange();
    }


    setReference(mMajorStepTime-(mRangeUpper-upperTime)/2);
    updateRange();

}
Esempio n. 2
0
ofxParamVecSlider<Type>* ofxParamVecSlider<Type>::setup(string _name, Type& val, const Type& min, const Type& max, float width, float height)
{
	ofxVecSlider_<Type>::setup(_name, val, min, max, width, height);
	ofxVecSlider_<Type>::value.addListener(this, &ofxParamVecSlider::onChange);
	setReference(val);
	return this;
}
Esempio n. 3
0
/*!
    Zoom by specified number of \a steps centered around the given
    x coordinate \a xCenter.
*/
void UiTimeAxis::zoom(int steps, double xCenter)
{
    double center = pixelToTimeRelativeRef(xCenter);
    double newValue = 0;

    double factor = 0.5;
    int majorUnitValue = closestUnitDigit(mMajorStepTime);
    if (steps < 0) {
        steps = -steps;
        factor = 2.0;
        if (majorUnitValue == 2)
            factor = 2.5;
    }
    else {
        factor = 0.5;
        if (majorUnitValue == 5)
            factor = 0.4;
    }
    factor = factor*steps;

    newValue = mMajorStepTime * factor;

    // lower and upper limit on the major step
    if (factor < 1 && newValue < qPow(10, MinStepAsPowOf10)) return;
    if (factor > 1 && newValue > qPow(10, MaxStepAsPowOf10)) return;

    // zoom around the center point
    mMajorStepTime = newValue;
    //mRefTime = center - (center-mRefTime)*factor;
    setReference(center - (center-mRefTime)*factor);

    updateRange();
}
Esempio n. 4
0
NamespaceDef::NamespaceDef(const char *df,int dl,
                           const char *name,const char *lref,
                           const char *fName) : 
   Definition(df,dl,name)
{
  if (fName)
  {
    fileName = stripExtension(fName);
  }
  else
  {
    fileName="namespace";
    fileName+=name;
  }
  classSDict = new ClassSDict(17);
  namespaceSDict = new NamespaceSDict(17);
  m_innerCompounds = new SDict<Definition>(17);
  usingDirList = 0;
  usingDeclList = 0;
  m_allMembersDict = 0;
  setReference(lref);
  memberGroupSDict = new MemberGroupSDict;
  memberGroupSDict->setAutoDelete(TRUE);
  visited=FALSE;
  m_subGrouping=Config_getBool("SUBGROUPING");
}
Esempio n. 5
0
void RMSD::set(const PDB&pdb, string mytype ){

	setReference(pdb.getPositions());
	setAlign(pdb.getOccupancy());
	setDisplace(pdb.getBeta());
        setType(mytype);
}
Esempio n. 6
0
tRotatedPoint::tRotatedPoint(void *theOwner,tElement *REFDOT, tElement *AXIS, tReal angle):tDot(theOwner)
{
	refDot = NULL;
	Axis = NULL;

	setAngle(angle);
	setReference(REFDOT);
	setAxis(AXIS);
}
Esempio n. 7
0
/*!
    Move the time axis \a differenceInPixels number of pixels
*/
void UiTimeAxis::moveAxis(int differenceInPixels)
{

    setReference(mRefTime +
               (differenceInPixels*(mMajorStepTime/MajorStepPixelWidth)));


    updateRange();
    update();
}
void hkbStateMachineTransitionInfoArray::updateReferences(long &ref){
    std::lock_guard <std::mutex> guard(mutex);
    auto update = [&](const HkxSharedPtr & shdptr){
        shdptr.data() ? shdptr.data()->setReference(++ref), shdptr.data()->updateReferences(++ref) : NULL;
    };
    setReference(ref);
    for (auto i = 0; i < transitions.size(); i++){
        update(transitions.at(i).transition);
        update(transitions.at(i).condition);
    }
}
Esempio n. 9
0
NamespaceDef::NamespaceDef(const char *df,int dl,int dc,
                           const char *name,const char *lref,
                           const char *fName, const char*type,
                           bool isPublished) :
   Definition(df,dl,dc,name)
  ,m_isPublished(isPublished)
{
  if (fName)
  {
    if (lref)
    {
      fileName = stripExtension(fName);
    }
    else
    {
      fileName = convertNameToFile(stripExtension(fName));
    }
  }
  else
  {
    setFileName(name);
  }
  classSDict = new ClassSDict(17);
  namespaceSDict = new NamespaceSDict(17);
  m_innerCompounds = new SDict<Definition>(17);
  usingDirList = 0;
  usingDeclList = 0;
  m_allMembersDict = 0;
  setReference(lref);
  memberGroupSDict = new MemberGroupSDict;
  memberGroupSDict->setAutoDelete(TRUE);
  visited=FALSE;
  m_subGrouping=Config_getBool(SUBGROUPING);
  if (type && !strcmp("module", type))
  {
    m_type = MODULE;
  }
  else if (type && !strcmp("constants", type))
  {
    m_type = CONSTANT_GROUP;
  }
  else if (type && !strcmp("library", type))
  {
    m_type = LIBRARY;
  }
  else
  {
    m_type = NAMESPACE;
  }
}
Esempio n. 10
0
/* Initialize stuff:
*  - Start Vref module
*  - Clear all fail flags
*  - Internal reference (default: external vcc)
*  - Mux between a and b channels (b channels)
*  - Calibrate with 32 averages and low speed
*  - When first calibration is done it sets:
*     - Resolution (default: 10 bits)
*     - Conversion speed and sampling time (both set to medium speed)
*     - Averaging (set to 4)
*/
void ADC_Module::analog_init() {

    // default settings:
    /*
        - 10 bits resolution
        - 4 averages
        - vcc reference
        - no interrupts
        - pga gain=1
        - conversion speed = medium
        - sampling speed = medium
    initiate to 0 (or 1) so the corresponding functions change it to the correct value
    */
    analog_res_bits = 0;
    analog_max_val = 0;
    analog_num_average = 0;
    analog_reference_internal = 1;
    var_enableInterrupts = 0;
    pga_value = 1;

    conversion_speed = 0;
    sampling_speed =  0;

    // the first calibration will use 32 averages and lowest speed,
    // when this calibration is over the averages and speed will be set to default by wait_for_cal and init_calib will be cleared.
    init_calib = 1;

    fail_flag = ADC_ERROR_CLEAR; // clear all errors

    // Internal reference initialization
    VREF_TRM = VREF_TRM_CHOPEN | 0x20; // enable module and set the trimmer to medium (max=0x3F=63)
	VREF_SC = VREF_SC_VREFEN | VREF_SC_REGEN | VREF_SC_ICOMPEN | VREF_SC_MODE_LV(1); // (=0xE1) enable 1.2 volt ref with all compensations

	// select b channels
	*ADC_CFG2_muxsel = 1;

    // set reference to vcc/external
	setReference(ADC_REF_EXTERNAL);

    // set resolution to 10
    setResolution(10);

    // calibrate at low speed and max repetitions
    setAveraging(32);
    setConversionSpeed(ADC_LOW_SPEED);
    setSamplingSpeed(ADC_LOW_SPEED);
    // begin init calibration
	calibrate();
}
Esempio n. 11
0
/* Initialize stuff:
*  - Start Vref module
*  - Clear all fail flags
*  - Internal reference (default: external vcc)
*  - Mux between a and b channels (b channels)
*  - Calibrate with 32 averages and low speed
*  - When first calibration is done it sets:
*     - Resolution (default: 10 bits)
*     - Conversion speed and sampling time (both set to medium speed)
*     - Averaging (set to 4)
*/
void ADC_Module::analog_init() {

    // default settings:
    /*
        - 10 bits resolution
        - 4 averages
        - vcc reference
        - no interrupts
        - pga gain=1
        - conversion speed = medium
        - sampling speed = medium
    initiate to 0 (or 1) so the corresponding functions change it to the correct value
    */
    analog_res_bits = 0;
    analog_max_val = 0;
    analog_num_average = 0;
    analog_reference_internal = 2;
    var_enableInterrupts = 0;
    pga_value = 1;

    conversion_speed = 0;
    sampling_speed =  0;

    calibrating = 0;

    fail_flag = ADC_ERROR_CLEAR; // clear all errors

    num_measurements = 0;

    // select b channels
    // *ADC_CFG2_muxsel = 1;
    setBit(ADC_CFG2, ADC_CFG2_MUXSEL_BIT);

    // set reference to vcc
    setReference(ADC_REF_3V3);

    // set resolution to 10
    setResolution(10);

    // the first calibration will use 32 averages and lowest speed,
    // when this calibration is over the averages and speed will be set to default by wait_for_cal and init_calib will be cleared.
    init_calib = 1;
    setAveraging(32);
    setConversionSpeed(ADC_LOW_SPEED);
    setSamplingSpeed(ADC_LOW_SPEED);

    // begin init calibration
    calibrate();
}
Esempio n. 12
0
/**************************************
 * Adc328::begin
 **************************************/
void Adc328::begin(Adc328Ref ref, Adc328Channel channel)
{
    // Turn off interrupts.
    volatile uint8_t savedSREG = SREG;
    cli();
    
    // Disable ADC power reduction.
    PRR &= ~(1 << PRADC);
    
    // ADC setup.
    ADCSRA = 0x07;    // Auto trigger disable, clear ADIF & ADIE, DIV128
    ADCSRB = 0x00;
    DIDR0  = 0x0F;    // Disable digital inputs on ADC channels AD0 - AD3
    setReference(ref);
    setChannel(channel);
    ADCSRA |= 0x80;   // Enable ADC
    
    // Restore interrupt state.
    SREG = savedSREG;
}
Esempio n. 13
0
/*! create a new file definition, where \a p is the file path, 
    \a nm the file name, and \a lref is an HTML anchor name if the
    file was read from a tag file or 0 otherwise
*/
FileDef::FileDef(const char *p,const char *nm,
                 const char *lref,const char *dn)
   : Definition((QCString)p+nm,1,nm)
{
  path=p;
  filepath=path+nm;
  filename=nm;
  diskname=dn;
  if (diskname.isEmpty()) diskname=nm;
  setReference(lref);
  classSDict        = 0;
  includeList       = 0;
  includeDict       = 0; 
  includedByList    = 0;
  includedByDict    = 0; 
  namespaceSDict    = 0; 
  srcDefDict        = 0;
  srcMemberDict     = 0;
  usingDirList      = 0;
  usingDeclList     = 0;
  package           = 0;
  isSource          = FALSE; 
  docname           = nm;
  dir               = 0;
  if (Config_getBool("FULL_PATH_NAMES"))
  {
    docname.prepend(stripFromPath(path.copy()));
  }
  SrcLangExt lang = getLanguageFromFileName(name());
  setLanguage(lang);
  //m_isJava          = lang==SrcLangExt_Java;
  //m_isCSharp        = lang==SrcLangExt_CSharp;
  memberGroupSDict = 0;
  acquireFileVersion();
  m_subGrouping=Config_getBool("SUBGROUPING");
}
Decode_Status VideoDecoderVP8::decodePicture(vbp_data_vp8 *data, int32_t picIndex) {
    VAStatus vaStatus = VA_STATUS_SUCCESS;
    Decode_Status status;
    uint32_t bufferIDCount = 0;
    VABufferID bufferIDs[5];

    vbp_picture_data_vp8 *picData = &(data->pic_data[picIndex]);
    VAPictureParameterBufferVP8 *picParams = picData->pic_parms;

    status = setReference(picParams);
    CHECK_STATUS("setReference");

    vaStatus = vaBeginPicture(mVADisplay, mVAContext, mAcquiredBuffer->renderBuffer.surface);
    CHECK_VA_STATUS("vaBeginPicture");
    // setting mDecodingFrame to true so vaEndPicture will be invoked to end the picture decoding.
    mDecodingFrame = true;

    vaStatus = vaCreateBuffer(
                   mVADisplay,
                   mVAContext,
                   VAPictureParameterBufferType,
                   sizeof(VAPictureParameterBufferVP8),
                   1,
                   picParams,
                   &bufferIDs[bufferIDCount]);
    CHECK_VA_STATUS("vaCreatePictureParameterBuffer");
    bufferIDCount++;

    vaStatus = vaCreateBuffer(
                   mVADisplay,
                   mVAContext,
                   VAProbabilityBufferType,
                   sizeof(VAProbabilityDataBufferVP8),
                   1,
                   data->prob_data,
                   &bufferIDs[bufferIDCount]);
    CHECK_VA_STATUS("vaCreateProbabilityBuffer");
    bufferIDCount++;

    vaStatus = vaCreateBuffer(
                   mVADisplay,
                   mVAContext,
                   VAIQMatrixBufferType,
                   sizeof(VAIQMatrixBufferVP8),
                   1,
                   data->IQ_matrix_buf,
                   &bufferIDs[bufferIDCount]);
    CHECK_VA_STATUS("vaCreateIQMatrixBuffer");
    bufferIDCount++;

    /* Here picData->num_slices is always equal to 1 */
    for (uint32_t i = 0; i < picData->num_slices; i++) {
        vaStatus = vaCreateBuffer(
                       mVADisplay,
                       mVAContext,
                       VASliceParameterBufferType,
                       sizeof(VASliceParameterBufferVP8),
                       1,
                       &(picData->slc_data[i].slc_parms),
                       &bufferIDs[bufferIDCount]);
        CHECK_VA_STATUS("vaCreateSliceParameterBuffer");
        bufferIDCount++;

        vaStatus = vaCreateBuffer(
                       mVADisplay,
                       mVAContext,
                       VASliceDataBufferType,
                       picData->slc_data[i].slice_size, //size
                       1,        //num_elements
                       picData->slc_data[i].buffer_addr + picData->slc_data[i].slice_offset,
                       &bufferIDs[bufferIDCount]);
        CHECK_VA_STATUS("vaCreateSliceDataBuffer");
        bufferIDCount++;
    }

    vaStatus = vaRenderPicture(
                   mVADisplay,
                   mVAContext,
                   bufferIDs,
                   bufferIDCount);
    CHECK_VA_STATUS("vaRenderPicture");

    vaStatus = vaEndPicture(mVADisplay, mVAContext);
    mDecodingFrame = false;
    CHECK_VA_STATUS("vaEndPicture");

    return DECODE_SUCCESS;
}
Decode_Status VideoDecoderAVCSecure::decodeSlice(vbp_data_h264 *data, uint32_t picIndex, uint32_t sliceIndex) {

    Decode_Status status;
    VAStatus vaStatus;
    uint32_t bufferIDCount = 0;
    // maximum 4 buffers to render a slice: picture parameter, IQMatrix, slice parameter, slice data
    VABufferID bufferIDs[4];

    vbp_picture_data_h264 *picData = &(data->pic_data[picIndex]);
    vbp_slice_data_h264 *sliceData = &(picData->slc_data[sliceIndex]);
    VAPictureParameterBufferH264 *picParam = picData->pic_parms;
    VASliceParameterBufferH264 *sliceParam = &(sliceData->slc_parms);

    if (sliceParam->first_mb_in_slice == 0 || mDecodingFrame == false) {
        // either condition indicates start of a new frame
        if (sliceParam->first_mb_in_slice != 0) {
            WTRACE("The first slice is lost.");
            // TODO: handle the first slice lost
        }
        if (mDecodingFrame) {
            // interlace content, complete decoding the first field
            vaStatus = vaEndPicture(mVADisplay, mVAContext);
            CHECK_VA_STATUS("vaEndPicture");

            // for interlace content, top field may be valid only after the second field is parsed
            mAcquiredBuffer->pictureOrder= picParam->CurrPic.TopFieldOrderCnt;
        }

        // Check there is no reference frame loss before decoding a frame

        // Update  the reference frames and surface IDs for DPB and current frame
        status = updateDPB(picParam);
        CHECK_STATUS("updateDPB");

        //We have to provide a hacked DPB rather than complete DPB for libva as workaround
        status = updateReferenceFrames(picData);
        CHECK_STATUS("updateReferenceFrames");

        vaStatus = vaBeginPicture(mVADisplay, mVAContext, mAcquiredBuffer->renderBuffer.surface);
        CHECK_VA_STATUS("vaBeginPicture");

        // start decoding a frame
        mDecodingFrame = true;

        vaStatus = vaCreateBuffer(
            mVADisplay,
            mVAContext,
            VAPictureParameterBufferType,
            sizeof(VAPictureParameterBufferH264),
            1,
            picParam,
            &bufferIDs[bufferIDCount]);
        CHECK_VA_STATUS("vaCreatePictureParameterBuffer");
        bufferIDCount++;

        vaStatus = vaCreateBuffer(
            mVADisplay,
            mVAContext,
            VAIQMatrixBufferType,
            sizeof(VAIQMatrixBufferH264),
            1,
            data->IQ_matrix_buf,
            &bufferIDs[bufferIDCount]);
        CHECK_VA_STATUS("vaCreateIQMatrixBuffer");
        bufferIDCount++;
    }

    status = setReference(sliceParam);
    CHECK_STATUS("setReference");

    // find which naluinfo is correlated to current slice
    int naluIndex = 0;
    uint32_t accumulatedHeaderLen = 0;
    uint32_t headerLen = 0;
    for (; naluIndex < mMetadata.naluNumber; naluIndex++)  {
        headerLen = mMetadata.naluInfo[naluIndex].naluHeaderLen;
        if (headerLen == 0) {
            WTRACE("lenght of current NAL unit is 0.");
            continue;
        }
        accumulatedHeaderLen += STARTCODE_PREFIX_LEN;
        if (accumulatedHeaderLen + headerLen > sliceData->slice_offset) {
            break;
        }
        accumulatedHeaderLen += headerLen;
    }

    if (sliceData->slice_offset != accumulatedHeaderLen) {
        WTRACE("unexpected slice offset %d, accumulatedHeaderLen = %d", sliceData->slice_offset, accumulatedHeaderLen);
    }

    sliceParam->slice_data_size = mMetadata.naluInfo[naluIndex].naluLen;
    uint32_t sliceOffset = mMetadata.naluInfo[naluIndex].naluOffset;
    uint32_t slice_offset_shift =  sliceOffset % 16;
    sliceParam->slice_data_offset += slice_offset_shift;
    sliceData->slice_size = (sliceParam->slice_data_size + slice_offset_shift + 0xF) & ~0xF;

    vaStatus = vaCreateBuffer(
        mVADisplay,
        mVAContext,
        VASliceParameterBufferType,
        sizeof(VASliceParameterBufferH264),
        1,
        sliceParam,
        &bufferIDs[bufferIDCount]);
    CHECK_VA_STATUS("vaCreateSliceParameterBuffer");
    bufferIDCount++;

    // sliceData->slice_offset - accumulatedHeaderLen is the absolute offset to start codes of current NAL unit
    // offset points to first byte of NAL unit

    if (mInputBuffer != NULL) {
        vaStatus = vaCreateBuffer(
            mVADisplay,
            mVAContext,
            VASliceDataBufferType,
            sliceData->slice_size,  //Slice size
            1,                      // num_elements
            mInputBuffer + sliceOffset - slice_offset_shift,
            &bufferIDs[bufferIDCount]);
    } else {
        vaStatus = vaCreateBuffer(
            mVADisplay,
            mVAContext,
            VAProtectedSliceDataBufferType,
            sliceData->slice_size, //size
            1,        //num_elements
            (uint8_t*)sliceOffset, // IMR offset
            &bufferIDs[bufferIDCount]);
    }
    CHECK_VA_STATUS("vaCreateSliceDataBuffer");
    bufferIDCount++;

    vaStatus = vaRenderPicture(
        mVADisplay,
        mVAContext,
        bufferIDs,
        bufferIDCount);
    CHECK_VA_STATUS("vaRenderPicture");

    return DECODE_SUCCESS;
}
Esempio n. 16
0
void AssemblyModel::setAssembly(U2AssemblyDbi * dbi, const U2Assembly & assm) {
    assert(dbi != NULL);
    assert(assemblyDbi == NULL);
    assemblyDbi = dbi;
    assembly = assm;

    // check if have reference
    if(!assembly.referenceId.isEmpty()) {
        switch (U2DbiUtils::toType(assembly.referenceId)) {
            case U2Type::Sequence: {
                Project * prj = AppContext::getProject();
                SAFE_POINT(prj != NULL, tr("No active project found!"), );

                Document* refDoc = prj->findDocumentByURL(U2DbiUtils::ref2Url(dbiHandle.dbi->getDbiRef()));
                SAFE_POINT(refDoc != NULL, tr("No reference document found in the project"), );

                U2SequenceObject* refObj = qobject_cast<U2SequenceObject*>(refDoc->getObjectById(assembly.referenceId));
                SAFE_POINT(refObj != NULL, tr("No reference object found in the project"), );

                setReference(refObj);
                break;
            }

            case U2Type::CrossDatabaseReference: {
                // 1. get cross reference by ref id
                U2CrossDatabaseReferenceDbi * crossDbi = dbiHandle.dbi->getCrossDatabaseReferenceDbi();
                U2OpStatusImpl status;
                U2CrossDatabaseReference crossRef = crossDbi->getCrossReference(assembly.referenceId, status);
                SAFE_POINT_OP(status,);

                // 2. find project and load reference doc to project
                Project * prj = AppContext::getProject();
                SAFE_POINT(prj!=NULL, tr("No active project found!"), );

                Document* refDoc = prj->findDocumentByURL(crossRef.dataRef.dbiRef.dbiId);
                Task * t = NULL;
                if( refDoc != NULL ) { // document already in project, load if it is not loaded
                    if (refDoc->isLoaded()) {
                        sl_referenceLoaded();
                    } else {
                        t = new LoadUnloadedDocumentTask(refDoc);
                    }

                    connect(refDoc, SIGNAL(si_loadedStateChanged()), SLOT(sl_referenceDocLoadedStateChanged()));
                } else { // no document at project -> create doc, add it to project and load it
                    t = createLoadReferenceAndAddToProjectTask(crossRef);
                    if (NULL == t) {
                        QString refUrl = crossRef.dataRef.dbiRef.dbiId;
                        QString refName = crossRef.dataRef.entityId;

                        QMessageBox::warning(QApplication::activeWindow(), tr("Warning"),
                                             tr("A file '%1' with the reference sequence '%2' not found!\n"
                                                "Try to open another file with a reference sequence and associate it with the assembly.").arg(refUrl).arg(refName),
                                             QMessageBox::Ok, QMessageBox::Ok);
                        dissociateReference();
                    }
                }

                // 4. run task and wait for finished in referenceLoaded()
                if(t != NULL) {
                    startLoadReferenceTask(t);
                }

                break;
            }

            default: {
                dissociateReference();
                FAIL(tr("Unexpected object is set as reference"), );
            }
        }
    }
}