void TriskarSmallBody::setCircle(boost::shared_ptr<Circle> parameter){
	clearPointers();
	this->type_position = CirclePosition;
	this->parameter_circle = parameter;
	if(parameter->getHasPose()){
		this->calculateDesireAngle(parameter->getQuaterion());
	}
}
Esempio n. 2
0
void ImageDecoderQt::internalReadImage(size_t frameIndex)
{
    ASSERT(m_reader);

    if (m_reader->supportsAnimation())
        m_reader->jumpToImage(frameIndex);
    else if (frameIndex) {
        setFailed();
        return clearPointers();
    }

    if (!internalHandleCurrentImage(frameIndex))
      setFailed();

    // Attempt to return some memory
    for (int i = 0; i < m_frameBufferCache.size(); ++i) {
        if (m_frameBufferCache[i].status() != ImageFrame::FrameComplete)
            return;
    }

    clearPointers();
}
Esempio n. 3
0
void ImageDecoderQt::internalDecodeSize()
{
    ASSERT(m_reader);

    // If we have a QSize() something failed
    QSize size = m_reader->size();
    if (size.isEmpty()) {
        setFailed();
        return clearPointers();
    }

    setSize(size.width(), size.height());
}
Esempio n. 4
0
void AudioManager::unloadAudio()
{
	//unload the audio content
	if(mp_soundBuffers)
		delete[] mp_soundBuffers;
	if(mp_sounds)
		delete[] mp_sounds;
	if(mp_music)
		delete[] mp_music;

	clearPointers();	//clear the pointers

	m_isLoaded = false;	//set the state of the manager
}
Esempio n. 5
0
bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
{
    // Now get the QImage from Qt and place it in the RGBA32Buffer
    QImage img;
    if (!m_reader->read(&img)) {
        clearPointers();
        return false;
    }

    // now into the RGBA32Buffer - even if the image is not
    QSize imageSize = img.size();
    RGBA32Buffer* const buffer = &m_frameBufferCache[frameIndex];
    buffer->setRect(m_reader->currentImageRect());
    buffer->setStatus(RGBA32Buffer::FrameComplete);
    buffer->setDuration(m_reader->nextImageDelay());
    buffer->setDecodedImage(img);
    return true;
}
void TriskarSmallBody::setLandmark(boost::shared_ptr<Landmark>  parameter){
	clearPointers();
	this->type_position = LandmarkPosition;
	this->parameter_landmark = parameter;
	if(parameter->getHasPose()){
		this->calculateDesireAngle(parameter->getQuaterion());
	}
	if(this->parameter_landmark->getTypeLandmark() == Place_Landmark){
		float pos_x, pos_y;
		bool exist = theatre_place.getPoinDestination(this->parameter_landmark->getIdLandmakr(),&pos_x,&pos_y);
		Point temp_point;
		temp_point.setX(pos_x);
		temp_point.setY(pos_y);
		//temp_point.setQuaterion(parameter_point->getQuaterionX(),parameter_point->getQuaterionY(),parameter_point->getQuaterionZ(),parameter_point->getQuaterionW());
		//Set point in the planner
		this->sendtPoint(temp_point);
	}
}
Esempio n. 7
0
void ImageDecoderQt::internalDecodeSize()
{
    ASSERT(m_reader);

    // If we have a QSize() something failed
    QSize size = m_reader->size();
    if (size.isEmpty()) {
        setFailed();
        return clearPointers();
    }

    setSize(size.width(), size.height());

    // We don't need the tables set by prepareScaleDataIfNecessary,
    // but their dimensions are used by ImageDecoder::scaledSize().
    prepareScaleDataIfNecessary();
    if (m_scaled)
        m_reader->setScaledSize(scaledSize());
}
Esempio n. 8
0
bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
{
    QPixmap pixmap = QPixmap::fromImageReader(m_reader.get());

    if (pixmap.isNull()) {
        frameCount();
        repetitionCount();
        clearPointers();
        return false;
    }

    // now into the ImageFrame - even if the image is not
    ImageFrame* const buffer = &m_frameBufferCache[frameIndex];
    buffer->setOriginalFrameRect(m_reader->currentImageRect());
    buffer->setStatus(ImageFrame::FrameComplete);
    buffer->setDuration(m_reader->nextImageDelay());
    buffer->setPixmap(pixmap);
    return true;
}
Esempio n. 9
0
bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
{
    ImageFrame* const buffer = &m_frameBufferCache[frameIndex];
    QSize imageSize = m_reader->scaledSize();
    if (imageSize.isEmpty())
        imageSize = m_reader->size();

    if (!buffer->setSize(imageSize.width(), imageSize.height()))
        return false;

    QImage image(reinterpret_cast<uchar*>(buffer->getAddr(0, 0)), imageSize.width(), imageSize.height(), sizeof(ImageFrame::PixelData) * imageSize.width(), m_reader->imageFormat());

    buffer->setDuration(m_reader->nextImageDelay());
    m_reader->read(&image);

    // ImageFrame expects ARGB32.
    if (buffer->premultiplyAlpha()) {
        if (image.format() != QImage::Format_ARGB32_Premultiplied)
            image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
    } else {
        if (image.format() != QImage::Format_ARGB32)
            image = image.convertToFormat(QImage::Format_ARGB32);
    }

    if (reinterpret_cast<const uchar*>(image.constBits()) != reinterpret_cast<const uchar*>(buffer->getAddr(0, 0))) {
        // The in-buffer was replaced during decoding with another, so copy into it manually.
        memcpy(buffer->getAddr(0, 0), image.constBits(),  image.byteCount());
    }

    if (image.isNull()) {
        frameCount();
        repetitionCount();
        clearPointers();
        return false;
    }

    buffer->setOriginalFrameRect(image.rect());
    buffer->setHasAlpha(image.hasAlphaChannel());
    buffer->setStatus(ImageFrame::FrameComplete);

    return true;
}
Esempio n. 10
0
void VelocityTracker::addMovement(const MotionEvent* event) {
    int32_t actionMasked = event->getActionMasked();

    switch (actionMasked) {
    case AMOTION_EVENT_ACTION_DOWN:
    case AMOTION_EVENT_ACTION_HOVER_ENTER:
        // Clear all pointers on down before adding the new movement.
        clear();
        break;
    case AMOTION_EVENT_ACTION_POINTER_DOWN: {
        // Start a new movement trace for a pointer that just went down.
        // We do this on down instead of on up because the client may want to query the
        // final velocity for a pointer that just went up.
        BitSet32 downIdBits;
        downIdBits.markBit(event->getPointerId(event->getActionIndex()));
        clearPointers(downIdBits);
        break;
    }
    case AMOTION_EVENT_ACTION_MOVE:
    case AMOTION_EVENT_ACTION_HOVER_MOVE:
        break;
    default:
        // Ignore all other actions because they do not convey any new information about
        // pointer movement.  We also want to preserve the last known velocity of the pointers.
        // Note that ACTION_UP and ACTION_POINTER_UP always report the last known position
        // of the pointers that went up.  ACTION_POINTER_UP does include the new position of
        // pointers that remained down but we will also receive an ACTION_MOVE with this
        // information if any of them actually moved.  Since we don't know how many pointers
        // will be going up at once it makes sense to just wait for the following ACTION_MOVE
        // before adding the movement.
        return;
    }

    size_t pointerCount = event->getPointerCount();
    if (pointerCount > MAX_POINTERS) {
        pointerCount = MAX_POINTERS;
    }

    BitSet32 idBits;
    for (size_t i = 0; i < pointerCount; i++) {
        idBits.markBit(event->getPointerId(i));
    }

    uint32_t pointerIndex[MAX_POINTERS];
    for (size_t i = 0; i < pointerCount; i++) {
        pointerIndex[i] = idBits.getIndexOfBit(event->getPointerId(i));
    }

    nsecs_t eventTime;
    Position positions[pointerCount];

    size_t historySize = event->getHistorySize();
    for (size_t h = 0; h < historySize; h++) {
        eventTime = event->getHistoricalEventTime(h);
        for (size_t i = 0; i < pointerCount; i++) {
            uint32_t index = pointerIndex[i];
            positions[index].x = event->getHistoricalX(i, h);
            positions[index].y = event->getHistoricalY(i, h);
        }
        addMovement(eventTime, idBits, positions);
    }

    eventTime = event->getEventTime();
    for (size_t i = 0; i < pointerCount; i++) {
        uint32_t index = pointerIndex[i];
        positions[index].x = event->getX(i);
        positions[index].y = event->getY(i);
    }
    addMovement(eventTime, idBits, positions);
}