Ejemplo n.º 1
0
void  DownloadSession::addPart(const PartFile& partFile)
{
	if (partFile.m_values == ReturnValues::good)// && partFile.m_partHash == calculatePartHash(partFile))
	{
		if (!flushPart(partFile))
		{
			setEnd(StatusValue::notSave);
			return;
		}
	}
	else if (partFile.m_values == ReturnValues::noPart)
	{
		unsetPart();
	}
	else if (partFile.m_values == ReturnValues::noDistribution)
	{
		setEnd(StatusValue::notDistribution);
		return;
	}

	if (getPart())
	{
		write();
	}
}
Ejemplo n.º 2
0
static Ref<Range> expandToParagraphBoundary(PassRefPtr<Range> range)
{
    Ref<Range> paragraphRange = range->cloneRange();
    setStart(paragraphRange.ptr(), startOfParagraph(range->startPosition()));
    setEnd(paragraphRange.ptr(), endOfParagraph(range->endPosition()));
    return paragraphRange;
}
Ejemplo n.º 3
0
void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(TextCheckingTypeMask textCheckingOptions, const TextCheckingParagraph& fullParagraphToCheck, bool asynchronous)
{
    if (fullParagraphToCheck.isRangeEmpty() || fullParagraphToCheck.isEmpty())
        return;

    // Since the text may be quite big chunk it up and adjust to the sentence boundary.
    const int kChunkSize = 16 * 1024;
    int start = fullParagraphToCheck.checkingStart();
    int end = fullParagraphToCheck.checkingEnd();
    start = std::min(start, end);
    end = std::max(start, end);
    const int kNumChunksToCheck = asynchronous ? (end - start + kChunkSize - 1) / (kChunkSize) : 1;
    int currentChunkStart = start;
    RefPtr<Range> checkRange = fullParagraphToCheck.checkingRange();
    if (kNumChunksToCheck == 1 && asynchronous) {
        markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), checkRange.get(), asynchronous, 0);
        return;
    }

    for (int iter = 0; iter < kNumChunksToCheck; ++iter) {
        checkRange = fullParagraphToCheck.subrange(currentChunkStart, kChunkSize);
        setStart(checkRange.get(), startOfSentence(VisiblePosition(checkRange->startPosition())));
        setEnd(checkRange.get(), endOfSentence(VisiblePosition(checkRange->endPosition())));

        int checkingLength = 0;
        markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), checkRange.get(), asynchronous, iter, &checkingLength);
        currentChunkStart += checkingLength;
    }
}
Ejemplo n.º 4
0
static PassRefPtrWillBeRawPtr<Range> expandToParagraphBoundary(PassRefPtrWillBeRawPtr<Range> range)
{
    RefPtrWillBeRawPtr<Range> paragraphRange = range->cloneRange();
    setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->startPosition())));
    setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPosition())));
    return paragraphRange;
}
Ejemplo n.º 5
0
static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range)
{
    RefPtr<Range> paragraphRange = range->cloneRange(IGNORE_EXCEPTION);
    setStart(paragraphRange.get(), startOfParagraph(range->startPosition()));
    setEnd(paragraphRange.get(), endOfParagraph(range->endPosition()));
    return paragraphRange;
}
Ejemplo n.º 6
0
Edge::Edge(Vertex *start, Vertex *end) :
    LineGraphicsItem(start, end)
{
    setStart(start);
    setEnd(end);
    veigth = GlobalSettings::getEdgeVeight();
}
Ejemplo n.º 7
0
	IntervalAnchor::IntervalAnchor(string id, double begin, double end)
		    : ContentAnchor(id) {

		typeSet.insert("IntervalAnchor");
		this->begin = 0;
		setEnd(end);
		setBegin(begin);
	}
Ejemplo n.º 8
0
int Timer::timeDiff()
{
    setEnd();
    int time_used = ((m_end.tv_sec - m_begin.tv_sec) * 1000000 \
                    +(m_end.tv_usec - m_begin.tv_usec));
    setBegin();
    return time_used;
}
Ejemplo n.º 9
0
static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range)
{
    ExceptionCode ec = 0;
    RefPtr<Range> paragraphRange = range->cloneRange(ec);
    setStart(paragraphRange.get(), startOfParagraph(range->startPosition()));
    setEnd(paragraphRange.get(), endOfParagraph(range->endPosition()));
    return paragraphRange;
}
Ejemplo n.º 10
0
/**
 * Construct an IF instructon instance.
 *
 * @param _condition The condition expression to evaluate.
 * @param thenToken  The token for the terminating THEN keyword.
 *                   This is where we mark the end of the
 *                   instruction.
 */
RexxInstructionIf::RexxInstructionIf(RexxInternalObject *_condition, RexxToken *thenToken)
{
    condition = _condition;
    //get the location from the THEN token and use its location to set
    // the end of the instruction.  Note that the THEN is traced on its
    // own, but using the start of the THEN gives a fuller picture of things.
    SourceLocation location = thenToken->getLocation();
    setEnd(location.getLineNumber(), location.getOffset());
}
TransformInterpolator::TransformInterpolator(const MATRIX &start, const MATRIX &end, unsigned int totalSteps)
: d(new TransformInterpolatorPrivate)
{
	d->totalSteps = totalSteps;
	d->currentStep = 0;
	d->startTransform = start;
    MatrixToQuaternion(d->startRotation, start);	
	setEnd(end);
}
CurveSegmentModel*LinearCurveSegmentModel::clone(
        const id_type<CurveSegmentModel>& id,
        QObject *parent) const
{
    auto cs = new LinearCurveSegmentModel{id, parent};
    cs->setStart(this->start());
    cs->setEnd(this->end());

    // Previous and following shall be set afterwards by the cloner.
    return cs;
}
Ejemplo n.º 13
0
void DownloadSession::connectSeeder(const boost::system::error_code &err)
{
	if (err)
	{
		setEnd(StatusValue::notConnect);
		return;
	}

	m_file.open(m_fileLocation, std::ios::out | std::ios::binary);
	if (!m_file)
	{
		display(std::to_string(GetLastError()));
		setEnd(StatusValue::notOpen);
		return;
	}

	m_receiveBuffer = (char*)& m_receivedPart;
	m_sendBuffer = (char*)& m_partNumber;
	write();
}
Ejemplo n.º 14
0
SegmentModel*GammaSegment::clone(
        const Id<SegmentModel>& id,
        QObject* parent) const
{
    auto cs = new GammaSegment{id, parent};
    cs->setStart(this->start());
    cs->setEnd(this->end());

    cs->gamma = gamma;
    // Previous and following shall be set afterwards by the cloner.
    return cs;
}
Ejemplo n.º 15
0
SGMScanInfo& SGMScanInfo::operator =(const SGMScanInfo &other){
	if(this != &other){
		AMDbObject::operator=(other);
		setScanName(other.scanName());
		setHasEdge(other.hasEdge());
		setEdge(other.edge());
		setEnergy(other.energy());
		setStart(other.start());
		setMiddle(other.middle());
		setEnd(other.end());
	}
	return *this;
}
Ejemplo n.º 16
0
 void Ramp::configure(const std::string& parameters) {
     if (parameters.empty()) return;
     std::vector<std::string> values = Op::split(parameters, " ");
     std::size_t required = 2;
     if (values.size() < required) {
         std::ostringstream ex;
         ex << "[configuration error] term <" << className() << ">"
                 << " requires <" << required << "> parameters";
         throw fl::Exception(ex.str(), FL_AT);
     }
     setStart(Op::toScalar(values.at(0)));
     setEnd(Op::toScalar(values.at(1)));
 }
Ejemplo n.º 17
0
static void onRsnSetInfo( HWND hwnd, const RS_INFO *pInfo ) {

    setLower      ( hwnd, pInfo->_lower       );
    setUpper      ( hwnd, pInfo->_upper       );
    setSaveStart2 ( hwnd, pInfo->_lower       );
    setSaveEnd2   ( hwnd, pInfo->_upper       );
    setStart      ( hwnd, pInfo->_start       );
    setEnd        ( hwnd, pInfo->_end         );
    setMinRange   ( hwnd, pInfo->_minRange    );
    setGranularity( hwnd, pInfo->_granularity );

    invalidateRect( hwnd );
    invalidateCursor();
}
Ejemplo n.º 18
0
SGMScanInfo::SGMScanInfo(const QString &scanName, QPair<QString, double> edgeAndEnergy, SGMEnergyPosition start, SGMEnergyPosition middle, SGMEnergyPosition end, QObject *parent) :
	AMDbObject(parent)
{
	setName(scanName);
	setScanName(scanName);
	if(!edgeAndEnergy.first.isEmpty() && edgeAndEnergy.second > 0)
		hasEdge_ = true;
	else
		hasEdge_ = false;
	edge_ = edgeAndEnergy.first;
	energy_ = edgeAndEnergy.second;
	setStart(start);
	setMiddle(middle);
	setEnd(end);
}
Ejemplo n.º 19
0
void DownloadSession::writeHandler(const boost::system::error_code &err, std::size_t bytes)
{
	if (!err)
	{
		std::fill(m_receivedPart.m_part, m_receivedPart.m_part + PARTSIZE, 0);
		m_receivedPart.m_partSize = 0;
		m_receivedPart.m_partHash = 0;
		m_receivedPart.m_partNumber = 0;

		read();
	}
	else
	{
		setEnd(StatusValue::notWrite);
		return;
	}
}
Ejemplo n.º 20
0
int SampleChannel::loadByPatch(const char *f, int i)
{
	int res = load(f);

		volume      = G_Patch.getVol(i);
		key         = G_Patch.getKey(i);
		index       = G_Patch.getIndex(i);
		mode        = G_Patch.getMode(i);
		mute        = G_Patch.getMute(i);
		mute_s      = G_Patch.getMute_s(i);
		solo        = G_Patch.getSolo(i);
		boost       = G_Patch.getBoost(i);
		panLeft     = G_Patch.getPanLeft(i);
		panRight    = G_Patch.getPanRight(i);
		readActions = G_Patch.getRecActive(i);
		recStatus   = readActions ? REC_READING : REC_STOPPED;

		readPatchMidiIn(i);
		midiInReadActions = G_Patch.getMidiValue(i, "InReadActions");
		midiInPitch       = G_Patch.getMidiValue(i, "InPitch");
		readPatchMidiOut(i);

	if (res == SAMPLE_LOADED_OK) {
		setBegin(G_Patch.getBegin(i));
		setEnd  (G_Patch.getEnd(i, wave->size));
		setPitch(G_Patch.getPitch(i));
	}
	else {
		// volume = DEFAULT_VOL;
		// mode   = DEFAULT_CHANMODE;
		// status = STATUS_WRONG;
		// key    = 0;

		if (res == SAMPLE_LEFT_EMPTY)
			status = STATUS_EMPTY;
		else
		if (res == SAMPLE_READ_ERROR)
			status = STATUS_MISSING;
		sendMidiLplay();
	}

	return res;
}
ImplicitList::ImplicitList(InternalType* _poStart, InternalType* _poStep, InternalType* _poEnd)
{
    m_iSize     = -1;
    m_eOutType  = ScilabGeneric;
    m_bComputed = false;
    m_poStart   = NULL;
    m_poStep    = NULL;
    m_poEnd     = NULL;
    m_pDblStart = NULL;
    m_pDblStep  = NULL;
    m_pDblEnd   = NULL;

    setStart(_poStart);
    setStep(_poStep);
    setEnd(_poEnd);
    compute();
#ifndef NDEBUG
    Inspector::addItem(this);
#endif
}
void SymbolicList::evalDollar(GVN & gvn, const GVN::Value * dollarVal)
{
    if (GVN::Value * const dollar = gvn.getExistingValue(symbol::Symbol(L"$")))
    {
        if (GVN::Value * v = evalDollar(gvn, getStart(), dollar, dollarVal))
        {
            setStart(v);
        }

        if (GVN::Value * v = evalDollar(gvn, getStep(), dollar, dollarVal))
        {
            setStep(v);
        }

        if (GVN::Value * v = evalDollar(gvn, getEnd(), dollar, dollarVal))
        {
            setEnd(v);
        }
    }
}
Ejemplo n.º 23
0
std::vector<sk_sp<sksg::GeometryNode>> AttachTrimGeometryEffect(
    const Json::Value& jtrim, AttachContext* ctx, std::vector<sk_sp<sksg::GeometryNode>>&& geos) {

    enum class Mode {
        kMerged,   // "m": 1
        kSeparate, // "m": 2
    } gModes[] = { Mode::kMerged, Mode::kSeparate };

    const auto mode = gModes[SkTPin<int>(ParseDefault(jtrim["m"], 1) - 1,
                                         0, SK_ARRAY_COUNT(gModes) - 1)];

    std::vector<sk_sp<sksg::GeometryNode>> inputs;
    if (mode == Mode::kMerged) {
        inputs.push_back(sksg::Merge::Make(std::move(geos), sksg::Merge::Mode::kMerge));
    } else {
        inputs = std::move(geos);
    }

    std::vector<sk_sp<sksg::GeometryNode>> trimmed;
    trimmed.reserve(inputs.size());
    for (const auto& i : inputs) {
        const auto trimEffect = sksg::TrimEffect::Make(i);
        trimmed.push_back(trimEffect);

        const auto adapter = sk_make_sp<TrimEffectAdapter>(std::move(trimEffect));
        BindProperty<ScalarValue>(jtrim["s"], &ctx->fAnimators,
            [adapter](const ScalarValue& s) {
                adapter->setStart(s);
            });
        BindProperty<ScalarValue>(jtrim["e"], &ctx->fAnimators,
            [adapter](const ScalarValue& e) {
                adapter->setEnd(e);
            });
        BindProperty<ScalarValue>(jtrim["o"], &ctx->fAnimators,
            [adapter](const ScalarValue& o) {
                adapter->setOffset(o);
            });
    }

    return trimmed;
}
Ejemplo n.º 24
0
ProcessModel::ProcessModel(
        const TimeValue& duration,
        const Id<Process::ProcessModel>& id,
        QObject* parent) :
    Curve::CurveProcessModel {duration, id, Metadata<ObjectKey_k, ProcessModel>::get(), parent}
{
    pluginModelList = new iscore::ElementPluginModelList{iscore::IDocument::documentContext(*parent), this};
    setUseParentDuration(true);
    // Named shall be enough ?
    setCurve(new Curve::Model{Id<Curve::Model>(45345), this});

    auto s1 = new Curve::DefaultCurveSegmentModel(Id<Curve::SegmentModel>(1), m_curve);
    s1->setStart({0., 0.0});
    s1->setEnd({1., 1.});

    m_curve->addSegment(s1);
    connect(m_curve, &Curve::Model::changed,
            this, &ProcessModel::curveChanged);

    metadata.setName(QString("Mapping.%1").arg(*this->id().val()));
}
Ejemplo n.º 25
0
void Line3DOverlay::setProperties(const QVariantMap& properties) {
    Base3DOverlay::setProperties(properties);

    auto start = properties["start"];
    // if "start" property was not there, check to see if they included aliases: startPoint
    if (!start.isValid()) {
        start = properties["startPoint"];
    }
    if (start.isValid()) {
        setStart(vec3FromVariant(start));
    }

    auto end = properties["end"];
    // if "end" property was not there, check to see if they included aliases: endPoint
    if (!end.isValid()) {
        end = properties["endPoint"];
    }
    if (end.isValid()) {
        setEnd(vec3FromVariant(end));
    }
}
Ejemplo n.º 26
0
void DownloadSession::readHandler(const boost::system::error_code &err, std::size_t bytes)
{
	if (!err)
	{
		//-------------------------------------------
		//std::string str("RECEIVE: ");
		//str += std::to_string(m_receivedPart.m_partSize) + "  " + std::to_string(m_receivedPart.m_partHash) + "  " + std::to_string(m_receivedPart.m_partNumber);
		//display(str);
		display(std::to_string(m_receivedPart.m_partNumber));
		//-------------------------------------------

		addPart(m_receivedPart);
	}
	else
	{
		std::string str("RECEIVE FALSE: ");
		str += std::to_string(m_receivedPart.m_partSize) + "  " + std::to_string(m_receivedPart.m_partHash) + "  " + std::to_string(m_receivedPart.m_partNumber);
		display(str);
		setEnd(StatusValue::notRead);
		return;
	}
}
Ejemplo n.º 27
0
void Line3DOverlay::setProperties(const QScriptValue& properties) {
    Base3DOverlay::setProperties(properties);

    QScriptValue start = properties.property("start");
    // if "start" property was not there, check to see if they included aliases: startPoint
    if (!start.isValid()) {
        start = properties.property("startPoint");
    }
    if (start.isValid()) {
        QScriptValue x = start.property("x");
        QScriptValue y = start.property("y");
        QScriptValue z = start.property("z");
        if (x.isValid() && y.isValid() && z.isValid()) {
            glm::vec3 newStart;
            newStart.x = x.toVariant().toFloat();
            newStart.y = y.toVariant().toFloat();
            newStart.z = z.toVariant().toFloat();
            setStart(newStart);
        }
    }

    QScriptValue end = properties.property("end");
    // if "end" property was not there, check to see if they included aliases: endPoint
    if (!end.isValid()) {
        end = properties.property("endPoint");
    }
    if (end.isValid()) {
        QScriptValue x = end.property("x");
        QScriptValue y = end.property("y");
        QScriptValue z = end.property("z");
        if (x.isValid() && y.isValid() && z.isValid()) {
            glm::vec3 newEnd;
            newEnd.x = x.toVariant().toFloat();
            newEnd.y = y.toVariant().toFloat();
            newEnd.z = z.toVariant().toFloat();
            setEnd(newEnd);
        }
    }
}
Ejemplo n.º 28
0
static void scroll( HWND hwnd, int direction, int timeOut ) {

    LONG page_size = getEnd( hwnd ) - getStart( hwnd );
    if ( page_size <= getGranularity( hwnd ) ) {
        page_size = getGranularity( hwnd );
    }
    if ( page_size <= 0 ) {
        page_size = 1;
    }

    LONG delta = 0;
    if ( -1 == direction ) {
        delta = -page_size;
        if ( getStart( hwnd ) + delta < getLower( hwnd ) ) {
            delta = getLower( hwnd ) - getStart( hwnd );
        }
    } else {
        delta = page_size;
        if ( getUpper( hwnd ) < getEnd( hwnd ) + delta ) {
            delta = getUpper( hwnd ) - getEnd( hwnd );
        }
    }

    int start = adjust( hwnd, getStart( hwnd ) + delta );
    int end   = adjust( hwnd, getEnd  ( hwnd ) + delta );
    if ( start != getStart( hwnd ) || end != getEnd( hwnd ) ) {
        setStart( hwnd, start );
        setEnd  ( hwnd, end   );
        invalidateRect( hwnd );
        invalidateCursor();
        notifyParent( hwnd );
    }

    // TODO: discuss SPI_GETKEYBOARDDELAY
    if ( 0 < timeOut ) {
        SetTimer( hwnd, 1, timeOut, 0 );
    }
}
Ejemplo n.º 29
0
void CurvePresenter::updateSegmentsType(const QString& segmentName)
{
    // They keep their start / end and previous / following but change type.
    // TODO maybe it would be better to encapsulate this ?
    auto factory = SingletonCurveSegmentList::instance().get(segmentName);

    QVector<QByteArray> newSegments;
    newSegments.resize(m_model->segments().size());
    int i = 0;
    for(CurveSegmentModel* segment : m_model->segments())
    {
        CurveSegmentModel* current;
        if(segment->selection.get())
        {
            auto ns = factory->make(segment->id(), nullptr);
            ns->setStart(segment->start());
            ns->setEnd(segment->end());
            ns->setPrevious(segment->previous());
            ns->setFollowing(segment->following());

            current = ns;
        }
        else
        {
            current = segment;
        }

        Serializer<DataStream> s{&newSegments[i++]};
        s.readFrom(*current);
    }

    m_commandDispatcher.submitCommand(
                new UpdateCurve{
                    iscore::IDocument::path(m_model),
                    std::move(newSegments)
                });
}
Ejemplo n.º 30
0
static void onKey(
    HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags )
{
    long start = getStart( hwnd );
    long end   = getEnd( hwnd );

    const BOOL controlKey = GetAsyncKeyState( VK_CONTROL ) < 0;

    if ( VK_ESCAPE == vk ) {
        if ( htNone != getHTCode( hwnd ) ) {
            setHTCode( hwnd, htNone );
            const LONG oldStart = getSaveStart( hwnd );
            const LONG oldEnd   = getSaveEnd  ( hwnd );
            setStart( hwnd, oldStart );
            setEnd  ( hwnd, oldEnd   );
            invalidateRect( hwnd );
            //onLButtonUp( hwnd, 0, 0, 0 ); // TODO retain capture anyway?
            // TODO notify parent
            return; //** FUNCTION EXIT POINT
        }
    }

    const UINT left_key  = isVertical( hwnd ) ? VK_UP   : VK_LEFT ;
    const UINT right_key = isVertical( hwnd ) ? VK_DOWN : VK_RIGHT;

    long granularity = getGranularity( hwnd );
    if ( granularity <= 0 ) {
        granularity = 1;
    }

    if ( left_key == vk ) {
        if ( controlKey ) {
            if ( getMinRange( hwnd ) < end - start ) {
                end -= granularity;
            }
        } else if ( getLower( hwnd ) < start ) {
            start -= granularity;
            end   -= granularity;
        }
    } else if ( right_key == vk ) {
        if ( end < getUpper( hwnd ) ) {
            end += granularity;
            if ( !controlKey ) {
                start += granularity;
            }
        }
    } else if ( VK_PRIOR == vk ) {
        scroll( hwnd, -1, 0 );
        return; //*** FUNCTION EXIT POINT
    } else if ( VK_NEXT == vk ) {
        scroll( hwnd, 1, 0 );
        return; //*** FUNCTION EXIT POINT
    } else if ( VK_HOME == vk ) {
        const long range = abs( getLower( hwnd ) - start );
        start -= range;
        end   -= range;
    } else if ( VK_END == vk ) {
        const long range = abs( getUpper( hwnd ) - end );
        start += range;
        end   += range;
    }

    start = adjust( hwnd, start );
    end   = adjust( hwnd, end   );
    if ( start != getStart( hwnd ) || end != getEnd( hwnd ) ) {
        setStart( hwnd, start );
        setEnd  ( hwnd, end );
        invalidateRect( hwnd );
        invalidateCursor();
        notifyParent( hwnd );
    }
}