Exemplo n.º 1
0
Dlg_Physics::Dlg_Physics(QVX_Sim* pSimIn, QWidget *parent)
	: QWidget(parent)
{
	pSim = pSimIn;
	ui.setupUi(this);

	//these should be in the order of the stop condition enum
	ui.StopSelectCombo->addItem("None");
	ui.StopSelectCombo->addItem("Time Steps");
	ui.StopSelectCombo->addItem("Simulation Time");
	ui.StopSelectCombo->addItem("Temperature cycles");
	ui.StopSelectCombo->addItem("Constant Energy");
	ui.StopSelectCombo->addItem("Kinetic Floor");
	ui.StopSelectCombo->addItem("Motion Floor");

	//these should match the order of the PlotType enum
	ui.VariableCombo->addItem("Displacement");
//	ui.VariableCombo->addItem("Force");
	ui.VariableCombo->addItem("Kinetic Energy");
	ui.VariableCombo->addItem("Potential Energy");
	ui.VariableCombo->addItem("Total Energy");

	//these should match the order of the PlotDir enum
	ui.DirectionCombo->addItem("Maximum");
	ui.DirectionCombo->addItem("X Direction");
	ui.DirectionCombo->addItem("Y Direction");
	ui.DirectionCombo->addItem("Z Direction");

	//enforce type-ins
	const QValidator* DEval = new QDoubleValidator(this);
	ui.dtEdit->setValidator(DEval);

	CurPlotType = PL_DISP;
	CurPlotDir = MAXDIR;

	connect(ui.PauseButton, SIGNAL(clicked()), this, SLOT(ClickedPause()));
	connect(ui.ResetButton, SIGNAL(clicked()), this, SLOT(ClickedReset()));
	connect(ui.RecordButton, SIGNAL(clicked(bool)), this, SLOT(ClickedRecord(bool)));

	
	connect(ui.UseEquilibriumCheck, SIGNAL(clicked(bool)), this, SLOT(UseEquilibriumCheckChanged(bool)));
	connect(ui.StopSelectCombo, SIGNAL(activated(int)), this, SLOT(StopSelectChanged(int)));
	connect(ui.StopValueEdit, SIGNAL(editingFinished()), this, SLOT(StopValueEditChanged()));

	connect(ui.dtSlider, SIGNAL(valueChanged(int)), this, SLOT(dtSliderChanged(int)));
	connect(ui.dtEdit, SIGNAL(editingFinished()), this, SLOT(dtEditChanged()));
	connect(ui.BondDampSlider, SIGNAL(valueChanged(int)), this, SLOT(BondDampSliderChanged(int)));
	connect(ui.BondDampEdit, SIGNAL(editingFinished()), this, SLOT(BondDampEditChanged()));
	connect(ui.GNDDampSlider, SIGNAL(valueChanged(int)), this, SLOT(GNDDampSliderChanged(int)));
	connect(ui.GNDDampEdit, SIGNAL(editingFinished()), this, SLOT(GNDDampEditChanged()));
	connect(ui.ColDampSlider, SIGNAL(valueChanged(int)), this, SLOT(ColDampSliderChanged(int)));
	connect(ui.ColDampEdit, SIGNAL(editingFinished()), this, SLOT(ColDampEditChanged()));
	connect(ui.MaxVelLimitSlider, SIGNAL(valueChanged(int)), this, SLOT(MaxVelLimitSliderChanged(int)));
	connect(ui.UseSelfColCheck, SIGNAL(clicked(bool)), this, SLOT(UseSelfColCheckChanged(bool)));
	connect(ui.UseMaxVelLimitCheck, SIGNAL(clicked(bool)), this, SLOT(UseMaxVelLimitCheckChanged(bool)));


	connect(ui.UseTempCheck, SIGNAL(clicked(bool)), this, SLOT(UseTempCheckChanged(bool)));
	connect(ui.TempSlider, SIGNAL(valueChanged(int)), this, SLOT(TempSliderChanged(int)));
	connect(ui.TempEdit, SIGNAL(editingFinished()), this, SLOT(TempEditChanged()));
	connect(ui.Temp2Slider, SIGNAL(valueChanged(int)), this, SLOT(Temp2SliderChanged(int)));
	connect(ui.Temp2Edit, SIGNAL(editingFinished()), this, SLOT(Temp2EditChanged()));
	connect(ui.VaryTempCheck, SIGNAL(clicked(bool)), this, SLOT(VaryTempCheckChanged(bool)));
	connect(ui.TempPerSlider, SIGNAL(valueChanged(int)), this, SLOT(TempPerSliderChanged(int)));
	connect(ui.TempPerEdit, SIGNAL(editingFinished()), this, SLOT(TempPerEditChanged()));
	//connect(ui.TempPerEdit, SIGNAL(textChanged(QString)), this, SLOT(TempPerEditTextChanged(QString)));
	connect(ui.UseGravCheck, SIGNAL(clicked(bool)), this, SLOT(UseGravCheckChanged(bool)));
	connect(ui.GravSlider, SIGNAL(valueChanged(int)), this, SLOT(GravSliderChanged(int)));
	connect(ui.GravEdit, SIGNAL(editingFinished()), this, SLOT(GravEditChanged()));

	connect(ui.UseFloorCheck, SIGNAL(clicked(bool)), this, SLOT(UseFloorCheckChanged(bool)));

	connect(ui.DispDisableRadio, SIGNAL(clicked(bool)), this, SLOT(DisplayDisableChanged(bool)));
	connect(ui.DispVoxelsRadio, SIGNAL(clicked(bool)), this, SLOT(DisplayVoxChanged(bool)));
	connect(ui.DispConnRadio, SIGNAL(clicked(bool)), this, SLOT(DisplayConChanged(bool)));


	connect(ui.ViewDiscreteRadio, SIGNAL(clicked(bool)), this, SLOT(VoxDiscreteChanged(bool)));
	connect(ui.ViewDeformedRadio, SIGNAL(clicked(bool)), this, SLOT(VoxDeformedChanged(bool)));
	connect(ui.ViewSmoothRadio, SIGNAL(clicked(bool)), this, SLOT(VoxSmoothChanged(bool)));
//	connect(ui.BondsCheck, SIGNAL(clicked(bool)), this, SLOT(BondsCheckChanged(bool)));
	connect(ui.ForcesCheck, SIGNAL(clicked(bool)), this, SLOT(ForcesCheckChanged(bool)));
	connect(ui.LocalCoordCheck, SIGNAL(clicked(bool)), this, SLOT(LCsCheckChanged(bool)));

	connect(ui.TypeRadio, SIGNAL(clicked(bool)), this, SLOT(CTypeChanged(bool)));
	connect(ui.KineticERadio, SIGNAL(clicked(bool)), this, SLOT(CKinEChanged(bool)));
	connect(ui.DisplacementRadio, SIGNAL(clicked(bool)), this, SLOT(CDispChanged(bool)));
	connect(ui.StateRadio, SIGNAL(clicked(bool)), this, SLOT(CStateChanged(bool)));
	connect(ui.StrainERadio, SIGNAL(clicked(bool)), this, SLOT(CStrainEChanged(bool)));
	connect(ui.StrainRadio, SIGNAL(clicked(bool)), this, SLOT(CStrainChanged(bool)));
	connect(ui.StressRadio, SIGNAL(clicked(bool)), this, SLOT(CStressChanged(bool)));

	connect(ui.CoMCheck, SIGNAL(clicked(bool)), this, SLOT(CmMCheckChanged(bool)));
//	connect(ui.BbCheck, SIGNAL(clicked(bool)), this, SLOT(BbCheckChanged(bool)));

	connect(ui.VariableCombo, SIGNAL(activated(int)), this, SLOT(VarComboChanged(int)));
	connect(ui.DirectionCombo, SIGNAL(activated(int)), this, SLOT(DirComboChanged(int)));
	connect(ui.LogEachCheck, SIGNAL(clicked(bool)), this, SLOT(LogEachCheckChanged(bool)));
	connect(ui.SaveDataButton, SIGNAL(clicked()), this, SLOT(ClickedSaveData()));

	//set up plot for real-time display...
//	d_directPainter = new QwtPlotDirectPainter(ui.DataPlot);
	d_data = NULL;
	d_curve = NULL;

	ui.DataPlot->setAxisMaxMinor(QwtPlot::xBottom, 1);
	ui.DataPlot->setAxisMaxMinor(QwtPlot::yLeft, 1);
//	ui.DataPlot->setAutoReplot(false);
	/*


	d_curve = new QwtPlotCurve("MyData");
	
	double x[3] = {0};
	double y[3] = {0};
	x[1] = 1;
	x[2] = 2;
	y[1] = 1;

	d_curve->attach(ui.DataPlot);
	d_curve->setSamples(x, y, 3);
	ui.DataPlot->setAxisMaxMinor(QwtPlot::xBottom, 1);
	ui.DataPlot->setAxisMaxMinor(QwtPlot::yLeft, 1);
	//ui.DataPlot->setMargin(0);
	//ui.DataPlot->plotLayout()->setMargin(0);
	//ui.DataPlot->plotLayout()->setSpacing(0);
*/

//	ui.DataPlot->
	PlotUpdateTimer = new QTimer(this);
	connect(PlotUpdateTimer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));

	PlotUpdateRate = 33;
	PlotUpdateTimer->start(PlotUpdateRate); //just run continuously...

	TimestepMag = 1.0;

	UpdateUI();
	

}
Dlg_Physics::Dlg_Physics(QVX_Sim* pSimIn, QWidget *parent)
	: QWidget(parent)
{
	pSim = pSimIn;
	ui.setupUi(this);

	//these should be in the order of the stop condition enum
	ui.StopSelectCombo->addItem("None");
	ui.StopSelectCombo->addItem("Time Steps");
	ui.StopSelectCombo->addItem("Simulation Time");
	ui.StopSelectCombo->addItem("Temperature cycles");
	ui.StopSelectCombo->addItem("Constant Energy");
	ui.StopSelectCombo->addItem("Kinetic Floor");
	ui.StopSelectCombo->addItem("Motion Floor");

	//these should match the order of the PlotType enum
	ui.VariableCombo->addItem("Displacement");
	ui.VariableCombo->addItem("Angle");
	ui.VariableCombo->addItem("Kinetic Energy");
	ui.VariableCombo->addItem("Potential Energy");
	ui.VariableCombo->addItem("Total Energy");
	ui.VariableCombo->addItem("Max Voxel Movement");


	//these should match the order of the PlotDir enum
	ui.DirectionCombo->addItem("Maximum");
	ui.DirectionCombo->addItem("X Direction");
	ui.DirectionCombo->addItem("Y Direction");
	ui.DirectionCombo->addItem("Z Direction");

	//enforce type-ins
	const QValidator* DEval = new QDoubleValidator(this);
	ui.dtEdit->setValidator(DEval);

	CurPlotType = PL_DISP;
	CurPlotDir = MAXDIR;

	connect(ui.PauseButton, SIGNAL(clicked()), this, SLOT(ClickedPause()));
	connect(ui.ResetButton, SIGNAL(clicked()), this, SLOT(ClickedReset()));
	connect(ui.RecordButton, SIGNAL(clicked(bool)), this, SLOT(ClickedRecord(bool)));

	
	connect(ui.UseEquilibriumCheck, SIGNAL(clicked(bool)), this, SLOT(UseEquilibriumCheckChanged(bool)));
	connect(ui.StopSelectCombo, SIGNAL(activated(int)), this, SLOT(StopSelectChanged(int)));
	connect(ui.StopValueEdit, SIGNAL(editingFinished()), this, SLOT(StopValueEditChanged()));

	connect(ui.dtSlider, SIGNAL(valueChanged(int)), this, SLOT(dtSliderChanged(int)));
	connect(ui.dtEdit, SIGNAL(editingFinished()), this, SLOT(dtEditChanged()));
	connect(ui.BondDampSlider, SIGNAL(valueChanged(int)), this, SLOT(BondDampSliderChanged(int)));
	connect(ui.BondDampEdit, SIGNAL(editingFinished()), this, SLOT(BondDampEditChanged()));
	connect(ui.GNDDampSlider, SIGNAL(valueChanged(int)), this, SLOT(GNDDampSliderChanged(int)));
	connect(ui.GNDDampEdit, SIGNAL(editingFinished()), this, SLOT(GNDDampEditChanged()));
	connect(ui.ColDampSlider, SIGNAL(valueChanged(int)), this, SLOT(ColDampSliderChanged(int)));
	connect(ui.ColDampEdit, SIGNAL(editingFinished()), this, SLOT(ColDampEditChanged()));
	connect(ui.MaxVelLimitSlider, SIGNAL(valueChanged(int)), this, SLOT(MaxVelLimitSliderChanged(int)));
	connect(ui.UseSelfColCheck, SIGNAL(clicked(bool)), this, SLOT(UseSelfColCheckChanged(bool)));
	connect(ui.UseMaxVelLimitCheck, SIGNAL(clicked(bool)), this, SLOT(UseMaxVelLimitCheckChanged(bool)));

	connect(ui.UseVolumeEffectsCheck, SIGNAL(clicked(bool)), this, SLOT(UseVolEffectsCheckChanged(bool)));

	connect(ui.UseTempCheck, SIGNAL(clicked(bool)), this, SLOT(UseTempCheckChanged(bool)));
	connect(ui.TempSlider, SIGNAL(valueChanged(int)), this, SLOT(TempSliderChanged(int)));
	connect(ui.TempEdit, SIGNAL(editingFinished()), this, SLOT(TempEditChanged()));
	connect(ui.VaryTempCheck, SIGNAL(clicked(bool)), this, SLOT(VaryTempCheckChanged(bool)));
	connect(ui.TempPerSlider, SIGNAL(valueChanged(int)), this, SLOT(TempPerSliderChanged(int)));
	connect(ui.TempPerEdit, SIGNAL(editingFinished()), this, SLOT(TempPerEditChanged()));
	connect(ui.UseGravCheck, SIGNAL(clicked(bool)), this, SLOT(UseGravCheckChanged(bool)));
	connect(ui.GravSlider, SIGNAL(valueChanged(int)), this, SLOT(GravSliderChanged(int)));
	connect(ui.GravEdit, SIGNAL(editingFinished()), this, SLOT(GravEditChanged()));

	connect(ui.UseFloorCheck, SIGNAL(clicked(bool)), this, SLOT(UseFloorCheckChanged(bool)));

	connect(ui.DispDisableRadio, SIGNAL(clicked(bool)), this, SLOT(DisplayDisableChanged(bool)));
	connect(ui.DispVoxelsRadio, SIGNAL(clicked(bool)), this, SLOT(DisplayVoxChanged(bool)));
	connect(ui.DispConnRadio, SIGNAL(clicked(bool)), this, SLOT(DisplayConChanged(bool)));


	connect(ui.ViewDiscreteRadio, SIGNAL(clicked(bool)), this, SLOT(VoxDiscreteChanged(bool)));
	connect(ui.ViewDeformedRadio, SIGNAL(clicked(bool)), this, SLOT(VoxDeformedChanged(bool)));
	connect(ui.ViewSmoothRadio, SIGNAL(clicked(bool)), this, SLOT(VoxSmoothChanged(bool)));
	connect(ui.ForcesCheck, SIGNAL(clicked(bool)), this, SLOT(ForcesCheckChanged(bool)));
	connect(ui.LocalCoordCheck, SIGNAL(clicked(bool)), this, SLOT(LCsCheckChanged(bool)));

	connect(ui.TypeRadio, SIGNAL(clicked(bool)), this, SLOT(CTypeChanged(bool)));
	connect(ui.KineticERadio, SIGNAL(clicked(bool)), this, SLOT(CKinEChanged(bool)));
	connect(ui.DisplacementRadio, SIGNAL(clicked(bool)), this, SLOT(CDispChanged(bool)));
	connect(ui.StateRadio, SIGNAL(clicked(bool)), this, SLOT(CStateChanged(bool)));
	connect(ui.StrainERadio, SIGNAL(clicked(bool)), this, SLOT(CStrainEChanged(bool)));
	connect(ui.StrainRadio, SIGNAL(clicked(bool)), this, SLOT(CStrainChanged(bool)));
	connect(ui.StressRadio, SIGNAL(clicked(bool)), this, SLOT(CStressChanged(bool)));
	connect(ui.PressureRadio, SIGNAL(clicked(bool)), this, SLOT(CPressureChanged(bool)));

	connect(ui.CoMCheck, SIGNAL(clicked(bool)), this, SLOT(CoMCheckChanged(bool)));


	connect(ui.VariableCombo, SIGNAL(activated(int)), this, SLOT(VarComboChanged(int)));
	connect(ui.DirectionCombo, SIGNAL(activated(int)), this, SLOT(DirComboChanged(int)));
	connect(ui.LogEachCheck, SIGNAL(clicked(bool)), this, SLOT(LogEachCheckChanged(bool)));
	connect(ui.SaveDataButton, SIGNAL(clicked()), this, SLOT(ClickedSaveData()));

	//set up plot for real-time display...
	
	pPlot = new QSimplePlot();
	ui.verticalLayout_3->insertWidget(1, pPlot);
	pPlot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	PlotUpdateTimer = new QTimer(this);
	connect(PlotUpdateTimer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));

	PlotUpdateRate = 33;
	PlotUpdateTimer->start(PlotUpdateRate); //just run continuously...

	UpdateUI();
	
}