//---------------------------------------- void ofLight::setup() { if(glIndex==-1){ bool bLightFound = false; // search for the first free block for(int i=0; i<OF_MAX_LIGHTS; i++) { if(getActiveLights()[i] == false) { glIndex = i; retain(glIndex); bLightFound = true; break; } } if( !bLightFound ){ ofLog(OF_LOG_ERROR, "ofLight : Trying to create too many lights: " + ofToString(glIndex)); } if(bLightFound) { // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } } } }
VanishingScrollBar::VanishingScrollBar(Qt::Orientation orientation, QWidget *parent) : QAbstractSlider(parent), _pauseAnimation(new QPauseAnimation(this)), _vanishingAnimation(new CallbackAnimation(this)) { _pauseAnimation->setDuration(durationWaiting()); _vanishingAnimation->setDuration(durationVanishing()); connect(_pauseAnimation, SIGNAL(finished()), _vanishingAnimation, SLOT(start())); connect(_vanishingAnimation, SIGNAL(finished()), this, SLOT(vanish())); _vanishingAnimation->setDuration(durationVanishing()); _vanishingAnimation->setStartValue(1.0); _vanishingAnimation->setEndValue(0.0); auto vanishingCallback = [this](const QVariant &variant) { this->setBarOpacity(variant.toDouble()); }; _vanishingAnimation->setCallback(vanishingCallback); setOrientation(orientation); onOrientationChanged(); }
//---------------------------------------- void ofLight::enable() { setup(); data->isEnabled = true; onPositionChanged(); // update the position // onOrientationChanged(); ofGetGLRenderer()->enableLight(data->glIndex); }
//---------------------------------------- void ofNode::orbit(float longitude, float latitude, float radius, const ofVec3f& centerPoint) { ofQuaternion q(latitude, ofVec3f(1,0,0), longitude, ofVec3f(0,1,0), 0, ofVec3f(0,0,1)); setPosition((ofVec3f(0,0,radius)-centerPoint)*q +centerPoint); setOrientation(q); onOrientationChanged(); onPositionChanged(); // lookAt(centerPoint);//, v - centerPoint); }
//---------------------------------------- void ofNode::rotateAround(const ofQuaternion& q, const ofVec3f& point) { ofMatrix4x4 m = getLocalTransformMatrix(); // m.setTranslation(point); // m.rotate(q); onOrientationChanged(); onPositionChanged(); }
//---------------------------------------- void ofNode::setTransformMatrix(float *m44) { memcpy(localTransformMatrix._mat, m44, sizeof(float) * 16); ofQuaternion so; localTransformMatrix.decompose(position, orientation, scale, so); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
void VanishingScrollBar::sliderChange(SliderChange change) { if (change == SliderOrientationChange) onOrientationChanged(); else wakeUp(); update(); }
//---------------------------------------- void ofNode::setTransformMatrix(const ofMatrix4x4 &m44) { localTransformMatrix = m44; ofQuaternion so; localTransformMatrix.decompose(position, orientation, scale, so); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
void Scene::setOrientationLock( OrientationLock orientationLock ) { if( m_orientationLock != orientationLock) { m_orientationLock = orientationLock; emit onOrientationLockChanged(); if( noLock == m_orientationLock ) { if( m_orientation != m_realOrientation ) { m_orientation = m_realOrientation; emit onOrientationChanged(); } } else if( lockLandscape == m_orientationLock ) { if( m_orientation != landscape ) { m_orientation = landscape; emit onOrientationChanged(); } } else if( lockPortrait == m_orientationLock ) { if( m_orientation != portrait ) { m_orientation = portrait; emit onOrientationChanged(); } } else if( lockInvertedLandscape == m_orientationLock ) { if( m_orientation != invertedLandscape ) { m_orientation = invertedLandscape; emit onOrientationChanged(); } } else if( lockInvertedPortrait == m_orientationLock ) { if( m_orientation != invertedPortrait ) { m_orientation = invertedPortrait; emit onOrientationChanged(); } } else if( lockAllLandscape == m_orientationLock ) { if( m_orientation != landscape && m_orientation != invertedLandscape ) { m_orientation = landscape; emit onOrientationChanged(); } } else if( lockAllPortrait == m_orientationLock ) { if( m_orientation != portrait && m_orientation != invertedPortrait ) { m_orientation = portrait; emit onOrientationChanged(); } } } }
//---------------------------------------- void ofNode::rotateAround(const glm::quat& q, const glm::vec3& point) { // ofLogVerbose("ofNode") << "rotateAround(const glm::quat& q, const ofVec3f& point) not implemented yet"; // ofMatrix4x4 m = getLocalTransformMatrix(); // m.setTranslation(point); // m.rotate(q); setGlobalPosition(q * (getGlobalPosition() - point) + point); onOrientationChanged(); onPositionChanged(); }
void MonitorWidget::onEnabledChanged(bool enabled) { output->setEnabled(enabled); // If we're enabling a disabled output for the first time if (enabled && !output->currentMode()) { // order here matters onResolutionChanged(ui.resolutionCombo->currentIndex()); onOrientationChanged(ui.orientationCombo->currentIndex()); onBehaviorChanged(ui.behaviorCombo->currentIndex()); } }
void Scene::setOrientation( Orientation orientation ) { m_realOrientation = orientation; if( noLock == m_orientationLock ) { m_orientation = orientation; emit onOrientationChanged(); } else if ( lockLandscape == m_orientationLock ) { if( landscape == orientation) { m_orientation = orientation; emit onOrientationChanged(); } } else if ( lockPortrait == m_orientationLock ) { if( portrait == orientation) { m_orientation = orientation; emit onOrientationChanged(); } } else if ( lockInvertedLandscape == m_orientationLock ) { if( invertedLandscape == orientation) { m_orientation = orientation; emit onOrientationChanged(); } } else if ( lockInvertedPortrait == m_orientationLock ) { if( invertedPortrait == orientation) { m_orientation = orientation; emit onOrientationChanged(); } } else if ( lockAllLandscape == m_orientationLock ) { if( landscape == orientation || invertedLandscape == orientation ) { m_orientation = orientation; emit onOrientationChanged(); } } else if ( lockAllPortrait == m_orientationLock ) { if( portrait == orientation || invertedPortrait == orientation ) { m_orientation = orientation; emit onOrientationChanged(); } } }
//---------------------------------------- void ofNode::orbitRad(float longitude, float latitude, float radius, const glm::vec3& centerPoint) { glm::quat q = glm::angleAxis(longitude, glm::vec3(0, 1, 0)) * glm::angleAxis(latitude, glm::vec3(1, 0, 0)); glm::vec4 p { 0.f, 0.f, 1.f, 0.f }; // p is a direction, not a position, so .w == 0 p = q * p; // rotate p on unit sphere based on quaternion p = p * radius; // scale p by radius from its position on unit sphere setGlobalPosition(centerPoint + p); setOrientation(q); onOrientationChanged(); onPositionChanged(); }
//---------------------------------------- void ofNode::setTransformMatrix(const ofMatrix4x4 &m44) { localTransformMatrix = m44; ofVec3f position; ofQuaternion orientation; ofVec3f scale; ofQuaternion so; localTransformMatrix.decompose(position, orientation, scale, so); this->position = position; this->orientation = orientation; this->scale = scale; updateAxis(); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
//---------------------------------------- void ofNode::setTransformMatrix(const glm::mat4 &m44) { localTransformMatrix = m44; glm::vec3 scale; glm::quat orientation; glm::vec3 translation; glm::vec3 skew; glm::vec4 perspective; glm::decompose(m44, scale, orientation, translation, skew, perspective); this->position = translation; this->scale = scale; this->orientation = orientation; updateAxis(); onPositionChanged(); onOrientationChanged(); onScaleChanged(); }
DynamicAlbumList::DynamicAlbumList(MWidget *parent) : DynamicMList(parent, MContentItem::IconAndTwoTextLabels, 1), albumListDeleteConfirm(NULL) { connect(this, SIGNAL(panningStopped()), this, SLOT(doTasklet())); connect(AppWindow::instance(), SIGNAL(orientationChanged(M::Orientation)), this, SLOT(onOrientationChanged(M::Orientation))); MPListModel *albumListModel = new MPListModel(this, "", MPListModel::Album); albumTasklet = new PhotosTasklet(parent); setItemModel(albumListModel); setTasklet(albumTasklet); MContentItemCreator *albumThumbnailCreator = dynamic_cast<MContentItemCreator *>(cellCreator()); albumThumbnailCreator->setCellProcessor(new AlbumThumbnailsCellProcessor(this)); onOrientationChanged(AppWindow::instance()->orientation()); setColumns(2); setObjectName("albumList"); connect(this, SIGNAL(itemClicked(const QModelIndex&)), this, SLOT(onClick(const QModelIndex&))); QPixmapCache::setCacheLimit (4096); QTimer::singleShot(1500, this, SLOT(doTasklet())); }
//---------------------------------------- void ofLight::setup() { if(data->glIndex==-1){ bool bLightFound = false; // search for the first free block for(size_t i=0; i<ofLightsData().size(); i++) { if(ofLightsData()[i].expired()) { data->glIndex = i; data->isEnabled = true; ofLightsData()[i] = data; bLightFound = true; break; } } if(!bLightFound && ofIsGLProgrammableRenderer()){ ofLightsData().push_back(data); data->glIndex = ofLightsData().size() - 1; data->isEnabled = true; bLightFound = true; } if( bLightFound ){ // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } }else{ ofLogError("ofLight") << "setup(): couldn't get active GL light, maximum number of "<< ofLightsData().size() << " reached"; } } }
void Scene::lockCurrentOrientation( bool lock ) { if( m_lockCurrentOrientation != lock ) { m_lockCurrentOrientation = lock; if( m_lockCurrentOrientation ) { if( m_orientation == landscape ) { m_orientationLock = lockLandscape; } else if ( m_orientation == invertedLandscape ) { m_orientationLock = lockInvertedLandscape; } else if ( m_orientation == portrait ) { m_orientationLock = lockPortrait; } else { m_orientationLock = lockInvertedPortrait; } } else { m_orientationLock = noLock; if( m_realOrientation != m_orientation) { m_orientation = m_realOrientation; emit onOrientationChanged(); } } emit onOrientationLockChanged(); } }
//---------------------------------------- void ofNode::rotate(const glm::quat& q) { orientation = q * (const glm::quat&)orientation; createMatrix(); onOrientationChanged(); }
//---------------------------------------- void ofNode::setOrientation(const glm::quat& q) { orientation = q; createMatrix(); onOrientationChanged(); }
//---------------------------------------- void ofNode::rotate(const ofQuaternion& q) { orientation *= q; createMatrix(); onOrientationChanged(); }
//---------------------------------------- void ofNode::setOrientation(const ofQuaternion& q) { orientation = q; createMatrix(); onOrientationChanged(); }
RemoteSettingsDialog::RemoteSettingsDialog(const QString &name, QWidget *parent) : QDialog(parent), m_scrollArea(new QScrollArea(this)), m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Vertical, this)), m_grid(new QGridLayout(this)) { this->setWindowTitle(tr("%1 settings").arg(name)); this->setAttribute(Qt::WA_DeleteOnClose, true); QWidget *scrollWidget = new QWidget(m_scrollArea); QVBoxLayout *vbox = new QVBoxLayout(scrollWidget); vbox->setContentsMargins(0, 0, 0, 0); m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_scrollArea->setWidgetResizable(true); m_scrollArea->setWidget(scrollWidget); QFile file(REMOTES_DIRECTORY + name + "/settings.xml"); if (!file.open(QIODevice::ReadOnly)) { qWarning() << "Cannot open file" << file.fileName(); return; } QXmlStreamReader reader; reader.setDevice(&file); reader.readNextStartElement(); while (!reader.atEnd()) { if (!reader.attributes().isEmpty()) { if (reader.name() == "group") { vbox->addWidget(new SeparatorLabel(reader.attributes().value("name").toString(), this)); } else if (reader.name() == "list") { RemoteSettingsSelector *selector = new RemoteSettingsSelector(reader.attributes().value("name").toString(), this); selector->setKey(QString("%1/%2").arg(name).arg(reader.attributes().value("key").toString())); selector->setDefaultValue(reader.attributes().value("default").toString()); selector->setHandler(reader.attributes().value("onChanged").toString()); reader.readNextStartElement(); if (selector->model()) { while (reader.name() == "element") { if (!reader.attributes().isEmpty()) { selector->model()->addItem(reader.attributes().value("name").toString(), reader.attributes().value("value").toString()); } reader.readNextStartElement(); } } selector->load(); vbox->addWidget(selector); } else if (reader.name() == "boolean") { RemoteSettingsCheckbox *checkbox = new RemoteSettingsCheckbox(this); checkbox->setText(reader.attributes().value("name").toString()); checkbox->setKey(QString("%1/%2").arg(name).arg(reader.attributes().value("key").toString())); checkbox->setDefaultValue(reader.attributes().value("default").toString()); checkbox->setHandler(reader.attributes().value("onChanged").toString()); checkbox->load(); vbox->addWidget(checkbox); } else if (reader.name() == "integer") { RemoteSettingsSpinbox *spinbox = new RemoteSettingsSpinbox(this); spinbox->setKey(QString("%1/%2").arg(name).arg(reader.attributes().value("key").toString())); spinbox->setDefaultValue(reader.attributes().value("default").toString()); spinbox->setHandler(reader.attributes().value("onChanged").toString()); spinbox->setMinimum(reader.attributes().value("minimum").toString().toInt()); spinbox->setMaximum(reader.attributes().value("maximum").toString().toInt()); spinbox->setSingleStep(reader.attributes().value("step").toString().toInt()); spinbox->load(); vbox->addWidget(new QLabel(reader.attributes().value("name").toString(), this)); vbox->addWidget(spinbox); } else if (reader.name() == "text") { RemoteSettingsLineEdit *lineEdit = new RemoteSettingsLineEdit(this); lineEdit->setKey(QString("%1/%2").arg(name).arg(reader.attributes().value("key").toString())); lineEdit->setDefaultValue(reader.attributes().value("default").toString()); lineEdit->setHandler(reader.attributes().value("onChanged").toString()); lineEdit->load(); vbox->addWidget(new QLabel(reader.attributes().value("name").toString(), this)); vbox->addWidget(lineEdit); } } reader.readNextStartElement(); } file.close(); this->connect(Screen::instance(), SIGNAL(currentOrientationChanged(Qt::Orientation)), this, SLOT(onOrientationChanged(Qt::Orientation))); this->connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this->onOrientationChanged(Screen::instance()->currentOrientation()); }