Beispiel #1
0
void Fixture::setMaterial(Material *material)
{
    if (m_material == material)
        return;

    if (m_material)
        m_material->disconnect();

    m_material = material;

    if (m_fixture) {
        m_fixture->SetDensity(m_material->density());
        m_fixture->SetFriction(m_material->friction());
        m_fixture->SetRestitution(m_material->restitution());
    }

    connect(m_material, SIGNAL(densityChanged(const float &)),
            this, SLOT(onDensityChanged(const float &)));

    connect(m_material, SIGNAL(frictionChanged(const float &)),
            this, SLOT(onFrictionChanged(const float &)));

    connect(m_material, SIGNAL(restitutionChanged(const float &)),
            this, SLOT(onRestitutionChanged(const float &)));

    emit materialChanged();
}
void FormMaterialIndicesManager::changeMaterial(int index){
    if(bSkipUpdating) return;
    // copy current settings
    ui->listWidgetMaterialIndices->item(lastMaterialIndex)->setText("Material"+QString::number(lastMaterialIndex+1));

    QString m_name = ui->listWidgetMaterialIndices->item(lastMaterialIndex)->text();
    for(int i = 0 ; i < METALLIC_TEXTURE ; i++){        
        materialIndices[i][m_name].copySettings(imagesPointers[i]->imageProp);
    }

    lastMaterialIndex = index;

    // update current mask color
    QColor bgColor = ui->listWidgetMaterialIndices->item(lastMaterialIndex)->backgroundColor();
    FBOImageProporties::currentMaterialIndeks = bgColor.red()*255*255 + bgColor.green()*255 + bgColor.blue();

    // load different material
    m_name = ui->listWidgetMaterialIndices->item(index)->text();
    for(int i = 0 ; i < METALLIC_TEXTURE ; i++){
        imagesPointers[i]->imageProp.copySettings(materialIndices[i][m_name]);
        imagesPointers[i]->reloadSettings();
    }


    QString cText = ui->listWidgetMaterialIndices->item(lastMaterialIndex)->text();
    ui->listWidgetMaterialIndices->item(lastMaterialIndex)->setText(cText+" (selected material)");



    emit materialChanged();
}
void MyMaterialEditor::setShininess(double s)
{
    if (m_material.shininess != float(s)) {
        m_material.shininess = float(s);
        emit materialChanged(m_material);
    }
}
Beispiel #4
0
void Material::setBasicColor(const QColor& value)
{
    Q_D(Material);
    if (d->basicColor != value) {
        d->basicColor = value;
        emit basicColorChanged();
        emit materialChanged();
    }
}
Beispiel #5
0
void Material::setAmbientColor(const QColor& value)
{
    Q_D(Material);
    if (d->ambientColor != value) {
        d->ambientColor = value;
        emit ambientColorChanged();
        emit materialChanged();
    }
}
Beispiel #6
0
void Material::setDiffuseColor(const QColor& value)
{
    Q_D(Material);
    if (d->diffuseColor != value) {
        d->diffuseColor = value;
        emit diffuseColorChanged();
        emit materialChanged();
    }
}
Beispiel #7
0
void Material::setSpecularColor(const QColor& value)
{
    Q_D(Material);
    if (d->specularColor != value) {
        d->specularColor = value;
        emit specularColorChanged();
        emit materialChanged();
    }
}
Beispiel #8
0
void Material::setEmittedLight(const QColor& value)
{
    Q_D(Material);
    if (d->emittedLight != value) {
        d->emittedLight = value;
        emit emittedLightChanged();
        emit materialChanged();
    }
}
Beispiel #9
0
void QGLMaterial::setTextureCombineMode(QGLMaterial::TextureCombineMode mode, int layer)
{
    Q_D(QGLMaterial);
    if (d->textureModes.value(layer, Modulate) != mode) {
        d->textureModes[layer] = mode;
        emit texturesChanged();
        emit materialChanged();
    }
}
void QGLColorMaterial::setColor(const QColor &color)
{
    Q_D(QGLColorMaterial);
    if (d->color != color) {
        d->color = color;
        emit colorChanged();
        emit materialChanged();
    }
}
Beispiel #11
0
void QGLMaterial::setTexture(QGLTexture2D *value, int layer)
{
    Q_ASSERT(layer >= 0);
    Q_D(QGLMaterial);
    QGLTexture2D *prev = d->textures.value(layer, 0);
    if (prev != value) {
        delete prev;
        d->textures[layer] = value;
        emit texturesChanged();
        emit materialChanged();
    }
}
Beispiel #12
0
/*!
    Sets ambientColor() to 20% of \a value, and diffuseColor() to 80% of
    \a value.  This is a convenience function for quickly setting ambient
    and diffuse lighting colors based on a flat color.

    \sa ambientColor(), diffuseColor()
*/
void QGLMaterial::setColor(const QColor& value)
{
    Q_D(QGLMaterial);
    d->ambientColor.setRgbF
        (value.redF() * 0.2f, value.greenF() * 0.2f,
         value.blueF() * 0.2f, value.alphaF());
    d->diffuseColor.setRgbF
        (value.redF() * 0.8f, value.greenF() * 0.8f,
         value.blueF() * 0.8f, value.alphaF());
    emit ambientColorChanged();
    emit diffuseColorChanged();
    emit materialChanged();
}
Beispiel #13
0
void Material::setShininess(qreal value)
{
    Q_D(Material);
    if (value < 0)
        value = 0;
    else if (value > 128)
        value = 128;
    if (d->shininess != value) {
        d->shininess = value;
        emit shininessChanged();
        emit materialChanged();
    }
}
void FormMaterialIndicesManager::pasteImageFromClipboard(QImage& _image){


    int mIndex = FBOImageProporties::currentMaterialIndeks;
    if(updateMaterials(_image)){
          image    = _image;
          imageProp.init(image);
          emit materialChanged();
          FBOImageProporties::currentMaterialIndeks = mIndex;
          emit imageLoaded(image.width(),image.height());
          // repaint all materials
          if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){
              toggleMaterials(true);
          }
    }
}
Beispiel #15
0
QLightNodePage::QLightNodePage(QWidget* parent /*= 0*/) : QWizardPage(parent)
{
	setupUi(this);
	setTitle(tr("Add new light"));
	setSubTitle(tr("Create a new light source for the current scene"));
	registerField("lightfov", m_fov, "value", SIGNAL(valueChanged(double)));
	registerField("radius", m_radius, "value", SIGNAL(valueChanged(double)));
	registerField("lightname", m_name);
	registerField("shadowmapbias", m_shadowMapBias, "value", SIGNAL(valueChanged(double)));
	registerField("shadowcontext", m_shadowContext);
	registerField("lightingcontext", m_lightContext);	
	registerField("material", m_material, "materialFile", SIGNAL(materialChanged()));	
	registerField("slices", m_slices);
	registerField("lambda", m_lambda);
		
}
void FormMaterialIndicesManager::setImage(QImage _image){

    if (imageProp.glWidget_ptr->isValid()){
        // remember the last id
        int mIndex = FBOImageProporties::currentMaterialIndeks;
        if(updateMaterials(_image)){
              image    = _image;
              imageProp.init(image);
              emit materialChanged();
        }

        FBOImageProporties::currentMaterialIndeks = mIndex ;

    }
    else
        qDebug() << Q_FUNC_INFO << "Invalid context.";
}
void FormMaterialIndicesManager::toggleMaterials(bool toggle){

    if(toggle == false){
        FBOImageProporties::currentMaterialIndeks = MATERIALS_DISABLED; // render normaly
        emit materialChanged();
    }else{ // if material group is enabled -> replot all materials

        int lastMaterial = lastMaterialIndex;
        // repaint all materials
        for(int m = 0 ; m < ui->listWidgetMaterialIndices->count() ; m++){
            QCoreApplication::processEvents();
            changeMaterial(m);
        }
        changeMaterial(lastMaterial);
    }

    emit  materialsToggled(toggle);

}
void MyMaterialEditor::selectColor(int id)
{
    colour *c;
    switch (id) {
    case 0: c = &m_material.ambient; break;
    case 1: c = &m_material.diffuse; break;
    case 2: c = &m_material.specular; break;
    case 3: c = &m_material.emission; break;
    }

    QColor initial = QColor::fromRgbF((*c)[0], (*c)[1], (*c)[2], (*c)[3]);
    QColor current = QColorDialog::getColor(initial, this, "Select Color",
                                            QColorDialog::ShowAlphaChannel);

    if (current.isValid()) {
        double r, g, b, a;
        current.getRgbF(&r, &g, &b, &a);
        c->set(r, g, b, a);
        updateButton(id, *c);
        emit materialChanged(m_material);
    }
}
bool FormMaterialIndicesManager::loadFile(const QString &fileName)
{
    QFileInfo fileInfo(fileName);
    QImage _image;

    // Targa support added
    if(fileInfo.completeSuffix().compare("tga") == 0){
        TargaImage tgaImage;
        _image = tgaImage.read(fileName);
    }else{
        QImageReader loadedImage(fileName);
        _image = loadedImage.read();
    }

    if (_image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load material image %1.").arg(QDir::toNativeSeparators(fileName)));
        return false;
    }

    qDebug() << "<FormImageProp> Open material image:" << fileName;


    (*FormImageProp::recentDir).setPath(fileName);

    int mIndex = FBOImageProporties::currentMaterialIndeks;
    if(updateMaterials(_image)){
          image    = _image;
          imageProp.init(image);
          emit materialChanged();
          FBOImageProporties::currentMaterialIndeks = mIndex;
          emit imageLoaded(image.width(),image.height());
          // repaint all materials
          if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){
              toggleMaterials(true);
          }
    }
    return true;
}
Beispiel #20
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
	m_ui(new Ui::MainWindow),
	m_materialDock(new MaterialDock(this)),
	m_transformDock(new TransformDock(this)),
	m_meshDock(new MeshDock(this)),
	m_textureDialog(new TextureDialog(this)),
	m_UVEditor(new UVEditor(this)),
	m_settings(new QSettings(this)),
	m_shaderSignalMapper(new QSignalMapper(this)),
	m_actionEnableUserShaders(nullptr),
	m_actionLocateUserShaders(nullptr),
	m_actionReloadUserShaders(nullptr)
{
	m_ui->setupUi(this);

	m_pathImport = m_settings->value(WMIT_SETTINGS_IMPORTVAL, QDir::currentPath()).toString();
	m_pathExport = m_settings->value(WMIT_SETTINGS_EXPORTVAL, QDir::currentPath()).toString();

	m_materialDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_materialDock->hide();

	m_transformDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_transformDock->hide();

	m_meshDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_meshDock->hide();

	m_UVEditor->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_UVEditor->hide();

	addDockWidget(Qt::RightDockWidgetArea, m_materialDock, Qt::Horizontal);
	addDockWidget(Qt::RightDockWidgetArea, m_transformDock, Qt::Horizontal);
	addDockWidget(Qt::RightDockWidgetArea, m_meshDock, Qt::Horizontal);
	addDockWidget(Qt::LeftDockWidgetArea, m_UVEditor, Qt::Horizontal);

	// UI is ready and now we can load window previous state (will do nothing if state wasn't saved).
	// 3DView specifics are loaded later on viewerInitialized event
	resize(QSettings().value("Window/size", size()).toSize());
	move(QSettings().value("Window/position", pos()).toPoint());
	restoreState(QSettings().value("Window/state", QByteArray()).toByteArray());

	m_ui->actionOpen->setIcon(QIcon::fromTheme("document-open", style()->standardIcon(QStyle::SP_DirOpenIcon)));
	m_ui->menuOpenRecent->setIcon(QIcon::fromTheme("document-open-recent"));
	m_ui->actionClearRecentFiles->setIcon(QIcon::fromTheme("edit-clear-list"));
	m_ui->actionSave->setIcon(QIcon::fromTheme("document-save", style()->standardIcon(QStyle::SP_DialogSaveButton)));
	m_ui->actionSaveAs->setIcon(QIcon::fromTheme("document-save-as"));
	m_ui->actionClose->setIcon(QIcon::fromTheme("window-close"));
	m_ui->actionExit->setIcon(QIcon::fromTheme("application-exit", style()->standardIcon(QStyle::SP_DialogCloseButton)));
	m_ui->actionAboutApplication->setIcon(QIcon::fromTheme("help-about"));

	connect(m_ui->centralWidget, SIGNAL(viewerInitialized()), this, SLOT(viewerInitialized()));
	connect(m_ui->menuFile, SIGNAL(aboutToShow()), this, SLOT(updateRecentFilesMenu()));
	connect(m_ui->actionOpen, SIGNAL(triggered()), this, SLOT(actionOpen()));
	connect(m_ui->menuOpenRecent, SIGNAL(triggered(QAction*)), this, SLOT(actionOpenRecent(QAction*)));
	connect(m_ui->actionClearRecentFiles, SIGNAL(triggered()), this, SLOT(actionClearRecentFiles()));
	connect(m_ui->actionClear_Missing_Files, SIGNAL(triggered()), this, SLOT(actionClearMissingFiles()));
	connect(m_ui->actionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
	connect(m_ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
	connect(m_ui->actionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
	connect(m_ui->actionUVEditor, SIGNAL(toggled(bool)), m_UVEditor, SLOT(setVisible(bool)));
	connect(m_ui->actionSetupTextures, SIGNAL(triggered()), this, SLOT(actionSetupTextures()));
	connect(m_ui->actionAppendModel, SIGNAL(triggered()), this, SLOT(actionAppendModel()));
	connect(m_ui->actionImport_Animation, SIGNAL(triggered()), this, SLOT(actionImport_Animation()));
	connect(m_ui->actionImport_Connectors, SIGNAL(triggered()), this, SLOT(actionImport_Connectors()));
	connect(m_ui->actionShowAxes, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setAxisIsDrawn(bool)));
	connect(m_ui->actionShowGrid, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setGridIsDrawn(bool)));
	connect(m_ui->actionShowLightSource, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setDrawLightSource(bool)));
	connect(m_ui->actionLink_Light_Source_To_Camera, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setLinkLightToCamera(bool)));
	connect(m_ui->actionAnimate, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setAnimateState(bool)));
	connect(m_ui->actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt()));
	connect(m_ui->actionSetTeamColor, SIGNAL(triggered()), this, SLOT(actionSetTeamColor()));

	/// Material dock
	m_materialDock->toggleViewAction()->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
	m_ui->menuModel->insertAction(m_ui->menuModel->actions().value(0) ,m_materialDock->toggleViewAction());

	connect(m_materialDock, SIGNAL(materialChanged(WZMaterial)), this, SLOT(materialChangedFromUI(WZMaterial)));

	/// Transform dock
	m_transformDock->toggleViewAction()->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
	m_ui->menuModel->insertAction(m_ui->menuModel->actions().value(0) ,m_transformDock->toggleViewAction());

	// transformations
	connect(m_transformDock, SIGNAL(scaleXYZChanged(double)), this, SLOT(scaleXYZChanged(double)));
	connect(m_transformDock, SIGNAL(scaleXChanged(double)), this, SLOT(scaleXChanged(double)));
	connect(m_transformDock, SIGNAL(scaleYChanged(double)), this, SLOT(scaleYChanged(double)));
	connect(m_transformDock, SIGNAL(scaleZChanged(double)), this, SLOT(scaleZChanged(double)));
	connect(m_transformDock, SIGNAL(reverseWindings()), this, SLOT(reverseWindings()));
	connect(m_transformDock, SIGNAL(flipNormals()), this, SLOT(flipNormals()));
	connect(m_transformDock, SIGNAL(applyTransformations()), &m_model, SLOT(applyTransformations()));
	connect(m_transformDock, SIGNAL(changeActiveMesh(int)), &m_model, SLOT(setActiveMesh(int)));
	connect(m_transformDock, SIGNAL(recalculateTB()), &m_model, SLOT(slotRecalculateTB()));
	connect(m_transformDock, SIGNAL(removeMesh()), this, SLOT(removeMesh()));
	connect(m_transformDock, SIGNAL(mirrorAxis(int)), this, SLOT(mirrorAxis(int)));
	connect(m_transformDock, SIGNAL(centerMesh(int)), this, SLOT(centerMesh(int)));
	connect(&m_model, SIGNAL(meshCountChanged(int,QStringList)), m_transformDock, SLOT(setMeshCount(int,QStringList)));

	/// Mesh dock
	m_meshDock->toggleViewAction()->setShortcut(QKeySequence(Qt::Key_M));
	m_ui->menuModel->insertAction(m_ui->menuModel->actions().value(0), m_meshDock->toggleViewAction());

	connect(m_meshDock, SIGNAL(connectorsWereUpdated()), this, SLOT(updateModelRender()));
	connect(&m_model, SIGNAL(meshCountChanged(int,QStringList)), m_meshDock, SLOT(setMeshCount(int,QStringList)));

	/// Reset state
	clear();
}
void QtGlMaterialEditor::emit_material_changed()
{
  emit materialChanged(getMaterial());
}
Beispiel #22
0
void Viewer::emitMaterialChanged()
{
  emit materialChanged();
}
Beispiel #23
0
void SubassemblyView::init ( void )
{
  setObjectName( subassembly_->name().toLatin1() );

  drawer_ = Space3D::OCSubassemblyDrawFactory::drawer( subassembly_, view() );

  modify_input_ = new SubassemblyModifyInput( this );

  dimensions_[0] = dimensions_[1] = dimensions_[2] = 0;

  dimension_name_ = view()->genSelectionName();

  ListViewItem* previous_item = parent()->previousItem( parent()->listViewItem(),
							 subassembly_->id() );

  list_view_item_ = new ListViewItem( parent()->listViewItem(), previous_item );

  list_view_item_->setData( lC::formatName( subassembly_->name() )
                + QString( " <%1>" ).arg( subassembly_->id() ),
                            lC::NAME );
  list_view_item_->setData( trC( subassembly_->type() ), lC::TYPE );
  list_view_item_->setData( tr( "Model: %1.%2 <%3>" ).
		    arg( lC::formatName( subassembly_->subassembly()->name()) ).
		    arg( trC( subassembly_->subassembly()->type() ) ).
            arg( lC::idToString( subassembly_->subassembly()->ID() ) ),
                            lC::DETAIL );
  //TODO
  //list_view_item_->listView()->ensureItemVisible( list_view_item_ );

  QListIterator<std::shared_ptr<AssemblyConstraint>> constraint =
    subassembly_->constraints().constraints();

  ListViewItem* constraint_item = 0;
  while ( constraint.hasNext() ) {
    constraint_item = new ListViewItem( list_view_item_, constraint_item );
    constraint_item->setData( trC( lC::STR::CONSTRAINT ), lC::NAME );
    constraint_item->setData( trC( constraint.peekNext()->type() ), lC::TYPE );
    constraint_item->setData( QVariant(), lC::DETAIL );

    updateChangedConstraint( 0, constraint.peekNext().get() );

    // Are there any offset constraints which need dimensions?
    if ( constraint.peekNext()->type() == lC::STR::MATE_OFFSET ||
     constraint.peekNext()->type() == lC::STR::ALIGN_OFFSET )
      updateChangedOffset( constraint.peekNext().get() );
    constraint.next();
  }

#if 0
  connect( subassembly_, SIGNAL( locationChanged() ), SLOT( updateLocation() ) );
  connect( subassembly_, SIGNAL( solidChanged() ), SLOT( updateTessellation() ) );
#else
  connect( subassembly_, SIGNAL( locationChanged() ), SLOT( updateTessellation() ) );
#endif
  connect( subassembly_, SIGNAL( materialChanged() ), SLOT( updateMaterial() ) );

  connect( subassembly_, SIGNAL( constraintCreated( const AssemblyConstraint*) ),
	   SLOT( updateNewConstraint( const AssemblyConstraint* ) ) );
  connect( subassembly_, SIGNAL( constraintChanged( const AssemblyConstraint*,
						    const AssemblyConstraint*) ),
	   SLOT( updateChangedConstraint( const AssemblyConstraint*,
					  const AssemblyConstraint* ) ) );
  connect( subassembly_, SIGNAL( constraintOffsetChanged( const AssemblyConstraint*) ),
	   SLOT( updateChangedOffset( const AssemblyConstraint* ) ) );

 connect( subassembly_, SIGNAL( constraintCanceled() ),
	   SLOT( updateCanceledConstraint() ) );

  connect( subassembly_->subassembly(), SIGNAL( nameChanged(const QString&) ),
	   SLOT( updateModelName( const QString& ) ) );

  connect( parent(), SIGNAL( orientationChanged( const GLdouble* ) ),
	   SLOT( updateViewNormal( const GLdouble* ) ) );

  if ( offset_info_dialog_ == 0 )
    offset_info_dialog_ = new OffsetInfoDialog( parent()->lCMW() );
}