int main( int argc, char **argv ) {
  
  gprint( PRINT_INFO, "Error: Your project is unfinished and you're "
          "going to fail and everyone is going to laugh at you and "
          "it's a really bad day sorry\n" );
  
  MONOLITH monolith( argc, argv );
  
#ifdef WITHOUT_QT // main driver for both platforms without Qt
  monolith.run();
#else // end main drive for both platforms without Qt.

#ifdef __APPLE__ // monolith.run has to be here for OS X. Do not edit! (@franckamayou)
  monolith.run(); 
#endif // __APPLE__

  QApplication a( argc, argv );
  MainWindow w;
  w.setWindowTitle( "GUI Interface - Graphics II" );
  w.setGeometry(700, 0, w.width(), w.height());

  // This is where the connection is for the default number of particles.
  monolith.defaultNumberOfParticles(w.getDefaultNumOfParticles());
  /*
  For connecting more variables and sliders we only need to expose the slider variables
  that already exist in maindwindow in the .h. Then do the linking functions here. The functions used
  as slots should probably have an internal variable to keep track of what the previous value was so
  that the proper modification can be made.
  */
  //QObject::connect(w.slider, SIGNAL(valueChanged(int)), &monolith, SLOT(ParticleAdd()));
  QObject::connect(&w, SIGNAL(sigChangeNumberOfParticles(int)), &monolith, SLOT(slotParticleAdd(int)));
  QObject::connect(&w, SIGNAL(sigFreezeParticles(bool)), &monolith, SLOT(slotFreezeParticles(bool)));
  QObject::connect(&w, SIGNAL(sigMorphPercentage(int)), &monolith, SLOT(slotMorphPercentage(int)));
  
  //Watch and learn
  monolith.setMorphPercentageCallback((boost::function<void(int)>)boost::bind(&MainWindow::setMorphPercentageOut, &w, _1));

  QObject::connect(&w, SIGNAL(sigEnableMorphing(bool)), &monolith, SLOT(slotEnableMorphing(bool)));
  QObject::connect(&w, SIGNAL(sigEnableRaytracing(bool)), &monolith, SLOT(slotEnableRaytracing(bool)));
  QObject::connect(&w, SIGNAL(sigEnableParticleSystem(bool)), &monolith, SLOT(slotEnableParticleSystem(bool)));
  //QObject::connect(&w, SIGNAL(sigParticleFieldFunction(int)), &monolith, SLOT(slotParticleFieldFunction(int)));
  QObject::connect(&w, SIGNAL(sigEnableMorphMatching(bool)), &monolith, SLOT(slotEnableMorphMatching(bool)));
  QObject::connect(&w, SIGNAL(sigUpdateVectorField(std::string*)), &monolith, SLOT(slotUpdateVectorField(std::string*)));
  QObject::connect(&w, SIGNAL(sigSetMaxAcceleration(int)), &monolith, SLOT(slotMaxAcceleration(int)));
  QObject::connect(&w, SIGNAL(sigSetFrictionMagnitude(int)), &monolith, SLOT(slotFriction(int)));
  QObject::connect(&w, SIGNAL(sigCameraSpeed(int)), &monolith, SLOT(slotSpeed(int)));
  QObject::connect(&w, SIGNAL(sigSetMaxSpeed(int)), &monolith, SLOT(slotMaxSpeed(int)));
  QObject::connect(&w, SIGNAL(sigFlameVecParams(float[3],double,float,float)),
                   &monolith, SLOT(slotUpdateFlameVecFunc(float[3], double, float, float)));
  QObject::connect(&w, SIGNAL(sigChangeCurrentView(int)), &monolith, SLOT(slotCurrentView(int))) ;
  QObject::connect(&w, SIGNAL(sigFlameVecParams()), &monolith, SLOT(slotUpdateFlameVecFunc()));
  QObject::connect(&w, SIGNAL(sigTornadoVecParams(float,float,float)),
                   &monolith, SLOT(slotUpdateTornadoVecFunc(float, float, float)));
  QObject::connect(&w, SIGNAL(sigTornadoVecParams()), &monolith, SLOT(slotUpdateTornadoVecFunc()));
  QObject::connect(&w, SIGNAL(sigMorphToWhiskyBottle()),&monolith,SLOT(slotMorphToWhiskyBottle()));
  QObject::connect(&w, SIGNAL(sigMorphToWineBottle()), &monolith, SLOT(slotMorphToWineBottle()));
  QObject::connect(&w, SIGNAL(sigSetParticleLife(float,float)), &monolith, SLOT(slotSetParticleLife(float, float)));
  QObject::connect(&w, SIGNAL(sigMusicVolume(int)), &monolith, SLOT(slotMusicVolume( int )));
  QObject::connect(&monolith, SIGNAL(sigEnableParticlesMelted(bool)), &w, SLOT(on_particleSystemEnabler_toggled_melted(bool)));
  QObject::connect(&monolith, SIGNAL(sigEnableParticlesMelted(bool)), &w, SLOT(slotEnableParticleSystem(bool)));
  QObject::connect(&w, SIGNAL(sigUserDefVecParams(std::string, std::string, std::string)),
                   &monolith, SLOT(slotUpdateVectorField(std::string, std::string, std::string)));
  //  QObject::connect(&monolith, SIGNAL(sigEnableParticles(bool)), &w, SLOT(on_particleSystemEnabler_toggled(bool)));
  QObject::connect(&w, SIGNAL(sigEnableVRCameraControl(bool)), &monolith, SLOT(slotEnableVRCameraControl(bool)));
  QObject::connect(&w, SIGNAL(sigVRCameraCoordinates(float,float)), &monolith, SLOT(slotVRCameraCoordinates(float,float)));
  QObject::connect(&w, SIGNAL(sigPartColorFunc(int)), &monolith, SLOT(slotPartColorFunc(int)));
  QObject::connect(&monolith, SIGNAL(sigUpdateUdfMessage(QString)), &w, SLOT(updateUdfMessage(QString)));

  w.show();

#ifndef __APPLE__ // monolith.start has to be here for Linux. 
   monolith.start();
#endif

  a.exec();
#ifdef __APPLE__ // glutMainloop has to be called here for OS X. Do not edit (@franckamayou)
  glutMainLoop();
#endif

#endif // WITHOUT_QT
  return EXIT_SUCCESS;
  
}
Exemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->userDefinedBox->setVisible(false);
    ui->tornadoParamsGroup->setVisible( false );

    connect(ui->numberOfParticlesSpinBox, SIGNAL(valueChanged(int)),
            this, SIGNAL(sigChangeNumberOfParticles(int)));
    connect(ui->freezeParticlesCheckBox, SIGNAL(toggled(bool)),
            this, SIGNAL(sigFreezeParticles(bool)));
    connect(ui->morphingEnabler, SIGNAL(toggled(bool)),
            this, SIGNAL(sigEnableMorphing(bool)));
    connect(ui->morphMatchingCheckbox, SIGNAL(toggled(bool)),
            this, SIGNAL(sigEnableMorphMatching(bool)));


    connect(ui->morphPercentageSlider, SIGNAL(valueChanged(int)),
            this, SIGNAL(sigMorphPercentage(int)));
    connect(ui->particleSystemEnabler, SIGNAL(toggled(bool)),
            this, SIGNAL(sigEnableParticleSystem(bool)));

    connect(ui->WineBottleRadioButton, SIGNAL(clicked()),
            this, SIGNAL(sigMorphToWineBottle()));
    connect(ui->WhiskyBottleRadioButton, SIGNAL(clicked()),
            this, SIGNAL(sigMorphToWhiskyBottle()));
    connect(ui->maxAccelerationSlider, SIGNAL(valueChanged(int)),
            this, SIGNAL(sigSetMaxAcceleration(int)));
    connect(ui->frictionHorizontalSlider, SIGNAL(valueChanged(int)),
            this, SIGNAL(sigSetFrictionMagnitude(int)));
	connect(ui->speedHorizontalSlider, SIGNAL(valueChanged(int)),
            this, SIGNAL(sigCameraSpeed(int)));

    connect(ui->maxSpeedSlider, SIGNAL(valueChanged(int)),
            this, SIGNAL(sigSetMaxSpeed(int)));
    
    connect(ui->userDefinedShowButton, SIGNAL(clicked()),
            this, SIGNAL(sigUserDefVecParams(Parameters*)));

//    connect(ui->tornadoShowButton, SIGNAL(clicked()),
//            this, SIGNAL(sigTornadoVecParams(Parameters*)));

    //connect(ui->particleFieldFunctionComboBox, SIGNAL(currentIndexChanged(int)),
    //        this, SIGNAL(sigParticleFieldFunction(int)));

    /* Attempt to get the 'connect' work the other way */
    //connect(this, SIGNAL(sigMorphPercentageOut(int)),
    //        ui->morphPercentageSlider, SLOT(setValue(int)));

    ui->currentViewComboBox->addItem("Ortho");
    ui->currentViewComboBox->addItem("Ortho2D");
    ui->currentViewComboBox->addItem("Identity");
    ui->currentViewComboBox->addItem("Frustum");

    // Make sure that the Particle Parameters display default values at start.
    ui->minLifeInput->setPlainText( "9.0" );
    ui->maxLifeInput->setPlainText( "12.0" );
    ui->paramATextInput->setPlainText( "100.0" );
    ui->paramBTextInput->setPlainText( "100.0" );
    ui->paramCTextInput->setPlainText( "4.0" );
    ui->xFieldTextInput->setPlainText( "0.0" );
    ui->yFieldTextInput->setPlainText( "0.45" );
    ui->zFieldTextInput->setPlainText( "0.0" );
    ui->powerSlider->setSliderPosition( 10 );
    ui->scaleSlider->setSliderPosition( 1 );
    ui->rangeSlider->setSliderPosition( 24 );

    connect(ui->currentViewComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(sigChangeCurrentView(int)));

}