Ejemplo n.º 1
0
void AutomatableSlider::modelChanged()
{
	QSlider::setRange( model()->minValue(), model()->maxValue() );
	updateSlider();
	connect( model(), SIGNAL( dataChanged() ),
				this, SLOT( updateSlider() ) );
}
Ejemplo n.º 2
0
void VtxSceneTabs::updateControls(){
	if(changing)
		return;
	Scene *obj=object();
	getTime();
	getRate();
	TexMipSlider->setValue(obj->tex_mip);
	ColorMipSlider->setValue(obj->color_mip);
	BumpMipSlider->setValue(obj->bump_mip);
	FreqMipSlider->setValue(obj->freq_mip);
	FOVSlider->setValue(obj->fov);
	LODSlider->setValue(obj->cellsize);
	updateSlider(ColorAmpSlider,Raster.filter_color_ampl);
	updateSlider(NormalAmpSlider,Raster.filter_normal_ampl);
	updateSlider(HDRMinSlider,Raster.hdr_min);
	updateSlider(HDRMaxSlider,Raster.hdr_max);
	m_aa_check->SetValue(Render.dealias());
	m_show_check->SetValue(Raster.filter_show());
	m_ave_check->SetValue(Render.avenorms());
	m_hdr->SetValue(Raster.hdr());
	m_shadows->SetValue(Raster.shadows());
	m_geometry->SetValue(Render.geometry());

	m_occlusion->SetValue(Adapt.overlap_test());
	m_clip->SetValue(Adapt.clip_test());
	m_backface->SetValue(Adapt.back_test());
	m_curvature->SetValue(Adapt.curve_test());

	updateSlider(ShadowBlurSlider,Raster.shadow_blur);
	updateSlider(ShadowResSlider,Raster.shadow_vsteps);
	updateSlider(ShadowFovSlider,Raster.shadow_fov);
	updateSlider(ShadowDovSlider,Raster.shadow_dov);
}
Ejemplo n.º 3
0
SimulationTimer::SimulationTimer(GUIManager& listener,
								hpreal minTime, hpreal maxTime,
								int ticksPerSimulation, hpreal tickTime):
								m_listener(listener),
								m_currentTime(minTime),
								m_minTime(minTime),
								m_maxTime(maxTime),
								m_deltaTick((maxTime - minTime)/(hpreal)ticksPerSimulation),
								m_startStopButton(new QPushButton("start")),
								m_tickTime(tickTime),
								m_timer(new QTimer(this)),
								m_timerIsRunning(false),
								m_timeSlider(new LabeledRealValuedSlider("Time", this)){

	QVBoxLayout* layout = new QVBoxLayout();
	layout->addWidget(m_timeSlider);
	layout->addWidget(m_startStopButton);
	setLayout(layout);

	connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTick()));
	connect(m_timeSlider, SIGNAL(valueChanged(hpreal)), this, SLOT(changeTime(hpreal)));
	connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(startStopTimer()));

	updateSlider();
}
Ejemplo n.º 4
0
void SimulationTimer::timerTick() {
	m_currentTime += m_deltaTick;
	if( m_currentTime > m_maxTime ){
		m_currentTime = m_minTime;
	}
	updateSlider();
	m_listener.visitScene(*this);
}
//--------------------------------------------------------------------- update
void ofxSimpleGuiColorPicker::update() {
	if(!enabled) return;
	
	if(lock) {
		updateSlider();
	}
	
//	enabled = false;
}
Ejemplo n.º 6
0
void QDoubleEditSlider::setValue(double x)
{
	setEditValue(x);
    disconnect(m_slider, SIGNAL(valueChanged(int)),
            this, SLOT(convertEditValue(int)));
	updateSlider(x);
    connect(m_slider, SIGNAL(valueChanged(int)),
            this, SLOT(convertEditValue(int)));
}
Ejemplo n.º 7
0
void MainWindow::on_zNormal_toggled() {
	if(ui.zNormal->isChecked()) { //reset the camera
		visualizeDisplay->normalizeCamera(3,sim.getImax().toDouble() * sim.getDelx().toDouble()
																			 ,sim.getJmax().toDouble() * sim.getDely().toDouble());
	}

  updateSlider();
  visualizeRender();
}
Ejemplo n.º 8
0
/*!
  Sets the maximum value of the scrollbar to the given \a maximum.
  \sa maximum()
 */
void KScrollBar::setMaximum(qreal maximum)
{
    if (maximum != m_maximum) 
	{
        m_maximum = maximum;
        emit maximumChanged(maximum);
        setValue(m_value);
		updateSlider();
    }
}
Ejemplo n.º 9
0
void RangeSelector::updateWidgets()
{
  if(parent->currentColor > ColorClasses::white)
  {
    setEnabled(true);
    updateSlider(parent->colorCalibrationView.console.colorCalibration.ranges[parent->currentColor - 2]);
  }
  else
    setEnabled(false);
}
Ejemplo n.º 10
0
void VtxMoonTabs::updateControls(){
	Moon *obj=object();
	updateSlider(SizeSlider,obj->size/MILES);
	updateSlider(CellSizeSlider,obj->detail);
	updateSlider(OrbitRadiusSlider,obj->orbit_radius/parentSize());
	updateSlider(OrbitPhaseSlider,obj->orbit_phase);
	updateSlider(OrbitTiltSlider,obj->orbit_skew);
	updateSlider(TiltSlider,obj->tilt);
	updateSlider(RotPhaseSlider,obj->rot_phase);
	updateSlider(DaySlider,obj->day);
	updateSlider(YearSlider,obj->year);
	updateSlider(ShineSlider,obj->shine);
	updateColor(AmbientSlider,obj->ambient);
	updateColor(EmissionSlider,obj->emission);
	updateColor(SpecularSlider, obj->specular);
	updateColor(DiffuseSlider,obj->diffuse);
	updateColor(ShadowSlider,obj->shadow_color);

	object_name->SetValue(object_node->node->nodeName());
}
Ejemplo n.º 11
0
    void setSliderPosition(qreal pos)
    {
        if (pos < 0.0)
            pos = 0.0;

        if (pos > sliderSize)
            pos = sliderSize;

        sliderPosition = pos;

        if (!qFuzzyCompare(pos, sliderPosition))
            updateSlider();
    }
Ejemplo n.º 12
0
void SliderSettingsDialog::okButtonPressed()
{
  // disconnect all signal receivers from
  // the min and max value edit fields
  // otherwise, they would generate an
  // uneccesary focusLost signal
  disconnect(mpMinValueEdit, 0, 0, 0);
  disconnect(mpMaxValueEdit, 0, 0, 0);
  // only now change underlying slider
  updateSlider();
  // close dialog with positive feedback
  done(QDialog::Accepted);
}
void ofxSimpleGuiSliderBase<Type>::onPress(int x, int y, int button) {
	if (button == 0 && !keyboardEdit) {
		ofNotifyEvent(onPressed, e, this);
		updateSlider();
	} else { // on right mouse click toggle keyboard input // if (button == 2) {
		keyboardEdit = !keyboardEdit;
		if (keyboardEdit) {
			keyboardInputString = getString();
		} else {
			convertKeyboardInputToValue();
		}
	}
}
Ejemplo n.º 14
0
NoatunInterface::NoatunInterface() : PlayerInterface()
{
	mTimerValue = TIMER_FAST;
	mNoatunTimer = new QTimer(this, "mNoatunTimer");

	connect(mNoatunTimer, SIGNAL(timeout()), SLOT(updateSlider()));

	connect(kapp->dcopClient(), SIGNAL(applicationRegistered(const QCString&)),
		SLOT(appRegistered(const QCString&)) );

	connect(kapp->dcopClient(), SIGNAL(applicationRemoved(const QCString&)),
		SLOT(appRemoved(const QCString&)));

	kapp->dcopClient()->setNotifications(true);
	QTimer::singleShot(0, this, SLOT(myInit()));
}
void ofxSimpleGuiSliderBase<Type>::update() {
	if(!enabled) return;
	
	if(oldValue != *value) {					// if value has changed programmatically by something else
		oldValue = targetValue = *value;			// save the value in target and oldvalue
	} else {									// otherwise lerp
		*value += (Type)((targetValue - *value) * lerpSpeed);
		oldValue = *value;							// and save oldvalue
	}
	
	if(lock) {
		updateSlider();
	}
	
	//		enabled = false;
	
}
Ejemplo n.º 16
0
//----------------------------------------------------
// Private methods
//----------------------------------------------------
void ContrastWidget::initComponents()
{
    slider = new QSlider(Qt::Horizontal);
    slider->setRange(1, 255);
    slider->setValue(1);
    connect(slider, SIGNAL(valueChanged(int)), this, SLOT(updateText(int)));
    connect(slider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));

    textBox = new QLineEdit;
    textBox->setFixedSize(40, 20);
    textBox->setMaxLength(3);
    textBox->setInputMask("000");
    textBox->setText("1");
    connect(textBox, SIGNAL(returnPressed()), this, SLOT(updateSlider()));

    layout = new QHBoxLayout;
    layout->addWidget(slider);
    layout->addWidget(textBox);

    this->setLayout(layout);
}
Ejemplo n.º 17
0
void KScrollBar::setRange( qreal min, qreal max )
{
	bool bChanged = false;
	if(m_minimum != min)
	{
		m_minimum = min;
		emit minimumChanged(min);
		bChanged = true;
	}
	if(m_maximum != max)
	{
		m_maximum = max;
		emit minimumChanged(max);
		bChanged = true;
	}
	if(bChanged)
	{
		setValue(m_value);
		updateSlider();
	}
}
Ejemplo n.º 18
0
void LevelPanel::updateDungeon()
{
	while (levelListEntries.size() < dungeon->getLevelCount())
	{
		std::size_t levelID = levelListEntries.size();
		levelListEntries.push_back(gui2::Text::make(" Level " + cNtoS(levelID + 1)));
		levelListInnerContainer->add(levelListEntries.back());
		updateLevelListEntryRect(levelID);
		setLevelListEntryColor(levelID, false);
	}

	while (levelListEntries.size() > dungeon->getLevelCount())
	{
		levelListInnerContainer->remove(levelListEntries.back());
		levelListEntries.pop_back();
	}

	levelListInnerContainer->setSize(levelListInnerContainer->getSize().x,
		levelListEntries.size() * LEVEL_LIST_ENTRY_HEIGHT);

	updateLevelButtons();
	updateDropdowns();
	updateSlider();
}
Ejemplo n.º 19
0
void MainWindow::on_origin_valueChanged() {
  updateSlider();

  visualizeRender();
}
Ejemplo n.º 20
0
 void themeChange()
 {
     construct();
     updateSlider();
 }
Ejemplo n.º 21
0
void PhMediaPanel::setLength(PhTime length)
{
	_length = length;
	updateSlider();
}
Ejemplo n.º 22
0
void PhMediaPanel::setTimeIn(PhTime timeIn)
{
	_timeIn = timeIn;
	updateSlider();
}
Ejemplo n.º 23
0
void LevelPanel::onProcessContainer(gui2::WidgetEvents& events)
{
	for (std::size_t i = 0; i < levelListEntries.size(); ++i)
	{
		auto levelEntry = levelListEntries[i];

		if (levelEntry->isMouseDown())
		{
			selectLevel(i);
		}
	}

	if (dropdownMusic->wasChanged())
	{
		try
		{
			dungeon->getLevel(getSelectedLevel()).setMusic(songIDs.at(dropdownMusic->getSelection()));
		}
		catch (...)
		{
			// No level selected or song ID somehow out of range? Ignore.
		}
	}

	if (dropdownBoss->wasChanged())
	{
		try
		{
			dungeon->getLevel(getSelectedLevel()).setBoss(bossIDs.at(dropdownBoss->getSelection()));
		}
		catch (...)
		{
			// No level selected or boss ID somehow out of range? Ignore.
		}
	}

	updateSlider();

	if (levelListSlider->isEnabled())
	{
		if ((levelListContainer->isMouseOver() || levelListSlider->isMouseOver()) && events.mouseWheelDelta != 0)
		{
			scrollVelocity -= events.mouseWheelDelta * 5;
		}

		if (std::abs(scrollVelocity) > 0.0001f)
		{
			float newSliderValue = levelListSlider->getValue() + scrollVelocity;
			if (newSliderValue > levelListSlider->getMax())
			{
				newSliderValue = levelListSlider->getMax();
				scrollVelocity = 0.f;
			}
			else if (newSliderValue < levelListSlider->getMin())
			{
				newSliderValue = levelListSlider->getMin();
				scrollVelocity = 0.f;
			}
			levelListSlider->setValue(newSliderValue);
			scrollVelocity *= 0.75f;
		}
	}

	levelListInnerContainer->setPosition(0.f, -levelListSlider->getValue());
	levelListInnerContainer->setSize(levelListContainer->getSize().x, levelListInnerContainer->getSize().y);

	if (dungeon != nullptr)
	{
		if (buttonAddLevel->isClicked())
		{
			std::size_t insertionIndex = hasSelectedLevel() ? getSelectedLevel() + 1 : dungeon->getLevelCount();
			dungeon->insertLevel(insertionIndex);

			updateDungeon();
			selectLevel(insertionIndex);
		}

		if (buttonRemoveLevel->isClicked())
		{
			if (hasSelectedLevel())
			{
				deleteConfirmMessage->show();
			}
		}

		if (deleteConfirmMessage->wasClosed() && deleteConfirmMessage->getClickedButton() == 0)
		{
			if (hasSelectedLevel())
			{
				dungeon->removeLevel(getSelectedLevel());

				updateDungeon();

				if (dungeon->getLevelCount() == 0)
				{
					deselectLevel();
				}
				else
				{
					selectLevel(selectedLevel == dungeon->getLevelCount() ? selectedLevel - 1 : selectedLevel);
				}
			}
		}

		if (buttonDuplicateLevel->isClicked())
		{
			if (hasSelectedLevel())
			{
				dungeon->insertLevel(getSelectedLevel());

				const Level & sourceLevel = dungeon->getLevel(getSelectedLevel() + 1);
				Level & destLevel = dungeon->getLevel(getSelectedLevel());
				destLevel.assign(sourceLevel);

				updateDungeon();
				selectLevel(getSelectedLevel() + 1);
			}
		}

		if (buttonMoveLevelUp->isClicked())
		{
			if (hasSelectedLevel() && getSelectedLevel() > 0)
			{
				dungeon->swapLevels(getSelectedLevel(), getSelectedLevel() - 1);

				updateDungeon();
				selectLevel(getSelectedLevel() - 1);
			}
		}

		if (buttonMoveLevelDown->isClicked())
		{
			if (hasSelectedLevel() && getSelectedLevel() < dungeon->getLevelCount() - 1)
			{
				dungeon->swapLevels(getSelectedLevel(), getSelectedLevel() + 1);

				updateDungeon();
				selectLevel(getSelectedLevel() + 1);
			}
		}
	}
}
Ejemplo n.º 24
0
MainWidget::MainWidget(const QString &token, const QString &user_id, QWidget *parent)
    : QWidget(parent), m_token(token), m_user_id(user_id), m_playState(false)
{
    m_removeCurrent = false;
    m_player = new QMediaPlayer;
    m_player->setVolume(100);

    m_mediaWebPlaylist = new QMediaPlaylist(m_player);
    m_mediaWebPlaylist->setObjectName("web");
    m_player->setPlaylist(m_mediaWebPlaylist);

    loadUserPlaylist();
    this->resize(800, 600);
    this->setWindowTitle("VK Music Player");


    QDir dir("./cache/");
    if(!dir.exists())
        dir.mkpath(".");

    QGridLayout* mainLayout = new QGridLayout;

    m_currentLabel = new QLabel;
    m_currentLabel->setFont(QFont("Arial", 16));
    m_currentLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    mainLayout->addWidget(m_currentLabel, 0, 0, 1, 9, Qt::AlignCenter);

    ImageButton *prevButton = new ImageButton("prevbutton.png");
    mainLayout->addWidget(prevButton, 2, 3, 1, 1, Qt::AlignTop | Qt::AlignRight);

    m_playPauseButton = new ImageButton("playbutton.png");
    mainLayout->addWidget(m_playPauseButton, 2, 4, 1, 1, Qt::AlignTop);

    ImageButton *nextButton = new ImageButton("nextbutton.png");
    mainLayout->addWidget(nextButton, 2, 5, 1, 1, Qt::AlignTop | Qt::AlignLeft);

    m_playlistWidget = new PlaylistWidget;
    mainLayout->addWidget(m_playlistWidget, 3, 0, 3, 9);

    m_seekslider = new QSlider;
    m_seekslider->setOrientation(Qt::Horizontal);
    mainLayout->addWidget(m_seekslider, 1, 0, 1, 7);

    m_volumeSlider = new QSlider;
    m_volumeSlider->setOrientation(Qt::Horizontal);
    m_volumeSlider->setMaximum(100);
    m_volumeSlider->setValue(100);
    m_volumeSlider->setSingleStep(1);
    mainLayout->addWidget(m_volumeSlider, 1, 7, 1, 2);

    m_timeLabel = new QLabel;
    m_timeLabel->setText("0:00");
    mainLayout->addWidget(m_timeLabel, 2, 0, 1, 2, Qt::AlignTop);

    m_volumeLabel = new QLabel;
    m_volumeLabel->setText(QString::number(m_player->volume())+"%");
    mainLayout->addWidget(m_volumeLabel, 2, 7, 1, 2, Qt::AlignTop | Qt::AlignHCenter);

    m_cacheCurrent = new QCheckBox(tr("&Save"));
    mainLayout->addWidget(m_cacheCurrent, 2, 7, 1, 2, Qt::AlignBottom | Qt::AlignRight);

    m_searchEdit = new QLineEdit;
    m_searchEdit->setPlaceholderText(tr("Search"));
    mainLayout->addWidget(m_searchEdit, 2, 0, 1, 8, Qt::AlignBottom);

    this->setLayout(mainLayout);

    connect(this, SIGNAL(playlistReady()),
            SLOT(fillPlaylistWidget_slot()));
    connect(this, SIGNAL(playStateChanged(bool)),
            SLOT(playStateChanged_slot(bool)));

    connect(m_playPauseButton, SIGNAL(pressed()), this, SLOT(playOrPause()));

    connect(nextButton, &ImageButton::pressed,
            [=](){
                m_playlistWidget->setCurrent(m_playlistWidget->getCurrentId()+1);
                m_player->play();
                emit playStateChanged(true);
            });

    connect(prevButton, &ImageButton::pressed,
            [=](){
                m_playlistWidget->setCurrent(m_playlistWidget->getCurrentId()-1);
                m_player->play();
                emit playStateChanged(true);
            });


    connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(mediaStatusChanged_slot(QMediaPlayer::MediaStatus)));

    connect(m_playlistWidget, SIGNAL(currentChanged(PlaylistMember*)),
            this, SLOT(currentChanged_slot(PlaylistMember*)));

    connect(m_player, SIGNAL(positionChanged(qint64)),
            this, SLOT(updateSlider(qint64)));

    connect(m_player, &QMediaPlayer::volumeChanged,
            [=](int v){ m_volumeLabel->setText(QString::number(v)+"%"); });

    connect(m_seekslider, &QSlider::sliderReleased,
            [=](){ m_player->setPosition(m_seekslider->value()); } );
    connect(m_seekslider, &QSlider::sliderMoved,
            [=](int time){
                m_timeLabel->setText(QString("%1:%2").arg((int)time/1000/60).arg(time/1000-time/1000/60*60 < 10 ?
                                                                                     QString("0")+QString::number(time/1000-time/1000/60*60) : QString::number(time/1000-time/1000/60*60)));
            });

    connect(m_volumeSlider,
            &QSlider::valueChanged,
            [=](int v){ m_player->setVolume(v); });

    connect(m_cacheCurrent, SIGNAL(toggled(bool)),
            this, SLOT(cacheCurrentCheckboxChecked(bool)));

    connect(m_searchEdit, SIGNAL(textChanged(QString)),
            m_playlistWidget, SLOT(searchMembersByName(QString)));
}
Ejemplo n.º 25
0
void BuyDialog::action(const ActionEvent &event)
{
    const std::string &eventId = event.getId();
    if (eventId == "quit")
    {
        close();
        return;
    }
    else if (eventId == "sort")
    {
        sort();
        if (mSortDropDown)
            config.setValue("buySortOrder", mSortDropDown->getSelected());
        return;
    }
    else if (eventId == "namefilter")
    {
        applyNameFilter(mFilterTextField->getText());
    }

    const int selectedItem = mShopItemList->getSelected();

    // The following actions require a valid selection
    if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
        return;

    if (eventId == "slider")
    {
        mAmountItems = static_cast<int>(mSlider->getValue());
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "inc" && mAmountItems < mMaxItems)
    {
        mAmountItems++;
        mSlider->setValue(mAmountItems);
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "dec" && mAmountItems > 1)
    {
        mAmountItems--;
        mSlider->setValue(mAmountItems);
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "max")
    {
        mAmountItems = mMaxItems;
        mSlider->setValue(mAmountItems);
        mAmountField->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "amount")
    {
        mAmountItems = mAmountField->getValue();
        mSlider->setValue(mAmountItems);
        updateButtonsAndLabels();
    }
    else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
    {
        ShopItem *const item = mShopItems->at(selectedItem);
        if (mNpcId == fromInt(Items, BeingId))
        {
            adminHandler->createItems(item->getId(),
                mAmountItems, item->getColor());
        }
        else if (mNpcId != fromInt(Nick, BeingId))
        {
#ifdef EATHENA_SUPPORT
            if (mNpcId == fromInt(Market, BeingId))
            {
                marketHandler->buyItem(item->getId(),
                    item->getType(),
                    item->getColor(),
                    mAmountItems);
                item->increaseQuantity(-mAmountItems);
                item->update();
            }
            else if (mNpcId == fromInt(Cash, BeingId))
            {
                cashShopHandler->buyItem(item->getPrice(),
                    item->getId(),
                    item->getColor(),
                    mAmountItems);
            }
            else
#endif
            {
                npcHandler->buyItem(mNpcId,
                    item->getId(),
                    item->getColor(),
                    mAmountItems);
            }

            updateSlider(selectedItem);
        }
        else if (mNpcId == fromInt(Nick, BeingId))
        {
#ifdef EATHENA_SUPPORT
            if (serverFeatures->haveVending())
            {
                Being *const being = actorManager->findBeingByName(mNick);
                if (being)
                {
                    vendingHandler->buy(being,
                        item->getInvIndex(),
                        mAmountItems);
                    item->increaseQuantity(-mAmountItems);
                    item->update();
                    updateSlider(selectedItem);
                }
            }
            else if (tradeWindow)
#else
            if (tradeWindow)
#endif
            {
                if (item)
                {
                    buySellHandler->sendBuyRequest(mNick,
                        item, mAmountItems);
                    tradeWindow->addAutoMoney(mNick,
                        item->getPrice() * mAmountItems);
                }
            }
        }
    }
}
Ejemplo n.º 26
0
btTypedConstraint* ObjectConstraintSlider::getConstraint() {
    btSliderConstraint* constraint { nullptr };
    QUuid otherEntityID;
    glm::vec3 pointInA;
    glm::vec3 axisInA;
    glm::vec3 pointInB;
    glm::vec3 axisInB;

    withReadLock([&]{
        constraint = static_cast<btSliderConstraint*>(_constraint);
        pointInA = _pointInA;
        axisInA = _axisInA;
        otherEntityID = _otherID;
        pointInB = _pointInB;
        axisInB = _axisInB;
    });
    if (constraint) {
        return constraint;
    }

    static int repeatMessageID = LogHandler::getInstance().newRepeatedMessageID();

    btRigidBody* rigidBodyA = getRigidBody();
    if (!rigidBodyA) {
        HIFI_FCDEBUG_ID(physics(), repeatMessageID, "ObjectConstraintSlider::getConstraint -- no rigidBodyA");
        return nullptr;
    }

    if (glm::length(axisInA) < FLT_EPSILON) {
        qCWarning(physics) << "slider axis cannot be a zero vector";
        axisInA = DEFAULT_SLIDER_AXIS;
    } else {
        axisInA = glm::normalize(axisInA);
    }

    if (!otherEntityID.isNull()) {
        // This slider is between two entities... find the other rigid body.

        if (glm::length(axisInB) < FLT_EPSILON) {
            qCWarning(physics) << "slider axis cannot be a zero vector";
            axisInB = DEFAULT_SLIDER_AXIS;
        } else {
            axisInB = glm::normalize(axisInB);
        }

        glm::quat rotA = glm::rotation(DEFAULT_SLIDER_AXIS, axisInA);
        glm::quat rotB = glm::rotation(DEFAULT_SLIDER_AXIS, axisInB);

        btTransform frameInA(glmToBullet(rotA), glmToBullet(pointInA));
        btTransform frameInB(glmToBullet(rotB), glmToBullet(pointInB));

        btRigidBody* rigidBodyB = getOtherRigidBody(otherEntityID);
        if (!rigidBodyB) {
            HIFI_FCDEBUG_ID(physics(), repeatMessageID, "ObjectConstraintSlider::getConstraint -- no rigidBodyB");
            return nullptr;
        }

        constraint = new btSliderConstraint(*rigidBodyA, *rigidBodyB, frameInA, frameInB, true);
    } else {
        // This slider is between an entity and the world-frame.

        glm::quat rot = glm::rotation(DEFAULT_SLIDER_AXIS, axisInA);

        btTransform frameInA(glmToBullet(rot), glmToBullet(pointInA));

        constraint = new btSliderConstraint(*rigidBodyA, frameInA, true);
    }

    withWriteLock([&]{
        _constraint = constraint;
    });

    // if we don't wake up rigidBodyA, we may not send the dynamicData property over the network
    forceBodyNonStatic();
    activateBody();

    updateSlider();

    return constraint;
}
Ejemplo n.º 27
0
bool ObjectConstraintSlider::updateArguments(QVariantMap arguments) {
    glm::vec3 pointInA;
    glm::vec3 axisInA;
    QUuid otherEntityID;
    glm::vec3 pointInB;
    glm::vec3 axisInB;
    float linearLow;
    float linearHigh;
    float angularLow;
    float angularHigh;

    bool needUpdate = false;
    bool somethingChanged = ObjectDynamic::updateArguments(arguments);
    withReadLock([&]{
        bool ok = true;
        pointInA = EntityDynamicInterface::extractVec3Argument("slider constraint", arguments, "point", ok, false);
        if (!ok) {
            pointInA = _pointInA;
        }

        ok = true;
        axisInA = EntityDynamicInterface::extractVec3Argument("slider constraint", arguments, "axis", ok, false);
        if (!ok) {
            axisInA = _axisInA;
        }

        ok = true;
        otherEntityID = QUuid(EntityDynamicInterface::extractStringArgument("slider constraint",
                                                                            arguments, "otherEntityID", ok, false));
        if (!ok) {
            otherEntityID = _otherID;
        }

        ok = true;
        pointInB = EntityDynamicInterface::extractVec3Argument("slider constraint", arguments, "otherPoint", ok, false);
        if (!ok) {
            pointInB = _pointInB;
        }

        ok = true;
        axisInB = EntityDynamicInterface::extractVec3Argument("slider constraint", arguments, "otherAxis", ok, false);
        if (!ok) {
            axisInB = _axisInB;
        }

        ok = true;
        linearLow = EntityDynamicInterface::extractFloatArgument("slider constraint", arguments, "linearLow", ok, false);
        if (!ok) {
            linearLow = _linearLow;
        }

        ok = true;
        linearHigh = EntityDynamicInterface::extractFloatArgument("slider constraint", arguments, "linearHigh", ok, false);
        if (!ok) {
            linearHigh = _linearHigh;
        }

        ok = true;
        angularLow = EntityDynamicInterface::extractFloatArgument("slider constraint", arguments, "angularLow", ok, false);
        if (!ok) {
            angularLow = _angularLow;
        }

        ok = true;
        angularHigh = EntityDynamicInterface::extractFloatArgument("slider constraint", arguments, "angularHigh", ok, false);
        if (!ok) {
            angularHigh = _angularHigh;
        }

        if (somethingChanged ||
            pointInA != _pointInA ||
            axisInA != _axisInA ||
            otherEntityID != _otherID ||
            pointInB != _pointInB ||
            axisInB != _axisInB ||
            linearLow != _linearLow ||
            linearHigh != _linearHigh ||
            angularLow != _angularLow ||
            angularHigh != _angularHigh) {
            // something changed
            needUpdate = true;
        }
    });

    if (needUpdate) {
        withWriteLock([&] {
            _pointInA = pointInA;
            _axisInA = axisInA;
            _otherID = otherEntityID;
            _pointInB = pointInB;
            _axisInB = axisInB;
            _linearLow = linearLow;
            _linearHigh = linearHigh;
            _angularLow = angularLow;
            _angularHigh = angularHigh;

            _active = true;

            auto ownerEntity = _ownerEntity.lock();
            if (ownerEntity) {
                ownerEntity->setDynamicDataDirty(true);
                ownerEntity->setDynamicDataNeedsTransmit(true);
            }
        });

        updateSlider();
    }

    return true;
}
Ejemplo n.º 28
0
 //______________________________________________
 bool SliderData::updateState( bool state )
 {
     if( state == _sliderHovered ) return false;
     updateSlider( state ? QStyle::SC_SliderHandle : QStyle::SC_None );
     return true;
 }
void ofxSimpleGuiColorPicker::onDragOutside(int x, int y, int button) {
	updateSlider();
}
void ofxSimpleGuiColorPicker::onPress(int x, int y, int button) {
	updateSlider();
}