⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ebm_gui.cpp

📁 Gaussian Mixture Algorithm
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	fileedit->setText(data->x_printdata.file);	DX_pretty->setChecked(data->dx_printdata.pretty);	DX_elems->setChecked(data->dx_printdata.elems);	print_onfile->setChecked(data->dx_printdata.onfile);	fileedit->setText(data->dx_printdata.file);	DDX_pretty->setChecked(data->ddx_printdata.pretty);	DDX_elems->setChecked(data->ddx_printdata.elems);	print_onfile->setChecked(data->ddx_printdata.onfile);	fileedit->setText(data->ddx_printdata.file);}void state_idx_propgui::get_data(state_idx_data* data){	data->x_plotdata.zoom = zoombox->value();	data->x_plotdata.min = X_minbox->value();	data->x_plotdata.max = X_maxbox->value();	data->x_plotdata.visible = X_visiblecheck->isChecked();	data->x_plotdata.norm = X_normalcheck->isChecked();	data->x_plotdata.idx1_as_array = arraybutton->isChecked();	data->x_plotdata.idx3_as_RGB = rgbbutton->isChecked();	data->dx_plotdata.zoom = zoombox->value();	data->dx_plotdata.min = DX_minbox->value();	data->dx_plotdata.max = DX_maxbox->value();	data->dx_plotdata.visible = DX_visiblecheck->isChecked();	data->dx_plotdata.norm = DX_normalcheck->isChecked();	data->dx_plotdata.idx1_as_array = arraybutton->isChecked();	data->dx_plotdata.idx3_as_RGB = rgbbutton->isChecked();	data->ddx_plotdata.zoom = zoombox->value();	data->ddx_plotdata.min = DDX_minbox->value();	data->ddx_plotdata.max = DDX_maxbox->value();	data->ddx_plotdata.visible = DDX_visiblecheck->isChecked();	data->ddx_plotdata.norm = DDX_normalcheck->isChecked();	data->ddx_plotdata.idx1_as_array = arraybutton->isChecked();	data->ddx_plotdata.idx3_as_RGB = rgbbutton->isChecked();	data->x_printdata.pretty = X_pretty->isChecked();	data->x_printdata.elems = X_elems->isChecked();	data->x_printdata.onfile = print_onfile->isChecked();	data->x_printdata.file = fileedit->text();	data->dx_printdata.pretty = DX_pretty->isChecked();	data->dx_printdata.elems = DX_elems->isChecked();	data->dx_printdata.onfile = print_onfile->isChecked();	data->dx_printdata.file = fileedit->text();	data->ddx_printdata.pretty = DDX_pretty->isChecked();	data->ddx_printdata.elems = DDX_elems->isChecked();	data->ddx_printdata.onfile = print_onfile->isChecked();	data->ddx_printdata.file = fileedit->text();}void state_idx_propgui::choose_file(){	QString fichier = QFileDialog::getOpenFileName(this, "Choose file as output", QString());	fileedit->setText(fichier);}////////////////////////////////////////////////////////////////////////////// state_Idx gui displaying widget related function///////////////////////////////////////////////////////////////////////////state_idx_displayGui::state_idx_displayGui(QWidget* parent, int X_NofDisplay):	QWidget(parent){	QVBoxLayout* mainlayout = new QVBoxLayout();	mainlayout->setMargin(1);	setLayout(mainlayout);	QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);	x_displayer = new idx_displayGui(this, X_NofDisplay, "    X :");	mainlayout->addWidget(x_displayer);	dx_displayer = new idx_displayGui(this, X_NofDisplay, "   dX :");	mainlayout->addWidget(dx_displayer);	ddx_displayer = new idx_displayGui(this, X_NofDisplay, " ddX :");	mainlayout->addWidget(ddx_displayer);	setSizePolicy(policy);}void state_idx_displayGui::displayAll(state_idx* state, state_idx_data* data){	x_displayer->displayAll((void*)(&state->x), DOUBLE, &(data->x_plotdata));	dx_displayer->displayAll((void*)(&state->dx), DOUBLE, &(data->dx_plotdata));	ddx_displayer->displayAll((void*)(&state->ddx), DOUBLE, &(data->ddx_plotdata));}////////////////////////////////////////////////////////////////////////////// state_idx gui related function///////////////////////////////////////////////////////////////////////////state_Idx_Gui::state_Idx_Gui(state_idx *stateIdx, const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex){	state = stateIdx;	if(state == NULL){		ylerror("state_idx null");		return;	}	if(state->x.order() == 0) {		ylerror("Not defined for Idx0");		return;	}	initialize_data(&(data.x_plotdata), &(data.x_printdata), (void*)&(stateIdx->x), DOUBLE);	initialize_data(&(data.dx_plotdata), &(data.dx_printdata),(void*)&(stateIdx->dx), DOUBLE);	initialize_data(&(data.ddx_plotdata), &(data.ddx_printdata), (void*)&(stateIdx->ddx), DOUBLE);	fromproperties = false;	properties = new state_idx_propgui(0, state->x.order());	visible = new state_idx_displayGui(0, ((state->x.order() > 1) && (state->x.dim(2) >1)) ? state->x.dim(2) : 1);	ui.vboxLayoutcont->addWidget(visible);	dynamic_cast<state_idx_displayGui*>(visible)->displayAll(state, &data);	connect(dynamic_cast<state_idx_propgui*>(properties)->okbutton, SIGNAL( clicked() ), this, SLOT(refreshdisplay() ) );}void state_Idx_Gui::openProperties(){	dynamic_cast<state_idx_propgui*>(properties)->set_data(&data);	fromproperties = true;	properties->setModal(true);	properties->show();}void state_Idx_Gui::refreshdisplay(){	refreshform();	if(fromproperties){		// if the display settings are sets from the properties dialog, we have to update it (contrary to the case where it is sets by keyboard shortcuts)		dynamic_cast<state_idx_propgui*>(properties)->get_data(&data);		fromproperties = false;	}	if(mutex != NULL) mutex->lock();	QString errors;	// checks various possibilities for wrong or strange display settings	if((data.x_plotdata.max <= data.x_plotdata.min) && !(data.x_plotdata.norm) && data.x_plotdata.visible) errors = errors + "x max is inferior or equal to x min; ";	if((data.dx_plotdata.max <= data.dx_plotdata.min) && !(data.dx_plotdata.norm) && data.dx_plotdata.visible) errors = errors +  "dx max is inferior or equal to dx min; ";	if((data.ddx_plotdata.max <= data.ddx_plotdata.min) && !(data.ddx_plotdata.norm) && data.ddx_plotdata.visible) errors = errors +  "ddx max is inferior or equal to ddx min; ";	if((data.x_plotdata.min > idx_min(state->x)) && !(data.x_plotdata.norm) && data.x_plotdata.visible) errors = errors +  "x min is superior to the minimum of the x idx; ";	if((data.x_plotdata.max < idx_max(state->x)) && !(data.x_plotdata.norm) && data.x_plotdata.visible) errors = errors +  "x max is inferior to the maximum of the x idx; ";	if((data.dx_plotdata.min > idx_min(state->dx)) && !(data.dx_plotdata.norm) && data.dx_plotdata.visible) errors = errors +  "dx min is superior to the minimum of the dx idx; ";	if((data.dx_plotdata.max < idx_max(state->dx)) && !(data.dx_plotdata.norm) && data.dx_plotdata.visible) errors = errors +  "dx max is inferior to the maximum of the dx idx; ";	if((data.ddx_plotdata.min > idx_min(state->ddx)) && !(data.ddx_plotdata.norm) && data.ddx_plotdata.visible) errors = errors +  "ddx min is superior to the minimum of the ddx idx; ";	if((data.ddx_plotdata.max < idx_max(state->ddx)) && !(data.ddx_plotdata.norm) && data.ddx_plotdata.visible) errors = errors +  "ddx max is inferior to the maximum of the ddx idx; ";	int validate;	if(errors != NULL){		errors = "We have detected the following problems : \n" + errors + "\n";		errors = errors + "Do you still want to validate these properties ?";		validate = QMessageBox::warning(this, "Properties checking", errors, QMessageBox::Yes | QMessageBox::No);	} else validate = QMessageBox::Yes;	if(validate == QMessageBox::Yes){		dynamic_cast<state_idx_displayGui*>(visible)->displayAll(state, &data);		properties->close();		setFocus();		adjustSize();	}	if(mutex != NULL) mutex->unlock();}void state_Idx_Gui::print(){	if(mutex != NULL) mutex->lock();	if(!(data.x_printdata.onfile)){		if(data.x_printdata.pretty) { printf("X : \n"); state->x.pretty(stdout);}		if(data.x_printdata.elems) { printf("X elements : \n"); state->x.printElems();}		if(data.dx_printdata.pretty) { printf("dX : \n"); state->dx.pretty(stdout);}		if(data.dx_printdata.elems) { printf("dX elements : \n"); state->dx.printElems();}		if(data.ddx_printdata.pretty) { printf("ddX : \n"); state->ddx.pretty(stdout);}		if(data.ddx_printdata.elems) { printf("ddX elements : \n"); state->ddx.printElems();}	}	else {		ofstream stream;		stream.open( data.x_printdata.file.toAscii());		if(data.x_printdata.pretty) { stream <<  "X : \n" ; state->x.pretty(stream); }		if(data.x_printdata.elems) { stream << "X elements : \n"; state->x.printElems(stream);}		if(data.dx_printdata.pretty) {stream <<  "dX : \n"; state->dx.pretty(stream);}		if(data.dx_printdata.elems) {stream << "dX elements : \n"; state->dx.printElems(stream);}		if(data.ddx_printdata.pretty) { stream << "ddX : \n"; state->ddx.pretty(stream);}		if(data.ddx_printdata.elems) { stream << "ddX elements : \n"; state->ddx.printElems(stream);}		stream.close();	}	if(mutex != NULL) mutex->unlock();}void state_Idx_Gui::keyPressEvent( QKeyEvent* event){	if(event->key() == Qt::Key_Equal){		data.x_plotdata.zoom++;		data.dx_plotdata.zoom++;		data.ddx_plotdata.zoom++;		refreshdisplay();	}	if(event->key() == Qt::Key_Minus){		int validate;		if(data.x_plotdata.zoom == 1) validate = QMessageBox::warning(this, "properties checking", "The zoom will be set to 0. Are you sure ?", QMessageBox::Yes | QMessageBox::No);		else validate = QMessageBox::Yes;		if(validate == QMessageBox::Yes){			data.x_plotdata.zoom--;			data.dx_plotdata.zoom--;			data.ddx_plotdata.zoom--;			refreshdisplay();		}	}	if(event->key() == Qt::Key_P){		print();	}	if(event->key() == Qt::Key_Q){		close();	}}void state_Idx_Gui::setvmin(double xmin, double dxmin, double ddxmin){	data.x_plotdata.min = xmin;	data.x_plotdata.norm = false;	data.dx_plotdata.min = dxmin;	data.dx_plotdata.norm = false;	data.ddx_plotdata.min = ddxmin;	data.ddx_plotdata.norm = false;	refreshdisplay();}void state_Idx_Gui::setvmax(double xmax, double dxmax, double ddxmax){	data.x_plotdata.max = xmax;	data.x_plotdata.norm = false;	data.dx_plotdata.max = dxmax;	data.dx_plotdata.norm = false;	data.ddx_plotdata.max = ddxmax;	data.ddx_plotdata.norm = false;	refreshdisplay();}void state_Idx_Gui::setvisible(bool xvisible, bool dxvisible, bool ddxvisible){	data.x_plotdata.visible = xvisible;	data.dx_plotdata.visible = dxvisible;	data.ddx_plotdata.visible = ddxvisible;	refreshdisplay();}void state_Idx_Gui::setidx1_as_array(bool xarray, bool dxarray, bool ddxarray){	if( state->x.order() == 1){		data.x_plotdata.idx1_as_array = xarray;		data.dx_plotdata.idx1_as_array = dxarray;		data.ddx_plotdata.idx1_as_array = ddxarray;		refreshdisplay();	}}void state_Idx_Gui::setidx3_as_RGB(bool xrgb, bool dxrgb, bool ddxrgb){	if( state->x.order() >= 3){		data.x_plotdata.idx3_as_RGB = xrgb;		data.dx_plotdata.idx3_as_RGB = dxrgb;		data.ddx_plotdata.idx3_as_RGB = ddxrgb;		refreshdisplay();	}}/******************************************************//////////////////////////////////////////////////////////////////////////////////////////////// specialized gui methods//////////////////////////////////////////////////////////////////////////////////////////////*****************************************************/module_1_1_GUI::module_1_1_GUI(state_idx* in, state_idx* out, const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex),	in(in),	out(out)	{		add_box(new state_Idx_Gui(in, "in", this, mutex));		add_box(new state_Idx_Gui(out, "out", this, mutex));	}module_1_1_GUI::module_1_1_GUI(const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex)	{}/* * * * * * * * * * * * * * * * * * * * * * */module_2_1_GUI::module_2_1_GUI(state_idx* in1, state_idx* in2, state_idx* out, const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex),	in1(in1),	in2(in2),	out(out)	{		add_box(new state_Idx_Gui(in1, "in1", this, mutex));		add_box(new state_Idx_Gui(in2, "in2", this, mutex));		add_box(new state_Idx_Gui(out, "out", this, mutex));	}module_2_1_GUI::module_2_1_GUI(const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex)	{}/* * * * * * * * * * * * * * * * * * * * * * */layers_2_GUI::layers_2_GUI(layers_2<state_idx, state_idx, state_idx>* layer2, state_idx* in, state_idx* out, const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex),	layer2(layer2),	in(in),	out(out)	{		add_box(new state_Idx_Gui(in, "in", this, mutex));		add_box(new module_1_1_GUI("layer 1", this, mutex));		add_box(new state_Idx_Gui(layer2->hidden, "hidden", this, mutex));		add_box(new module_1_1_GUI("layer 2", this, mutex));		add_box(new state_Idx_Gui(out, "out", this, mutex));	}layers_2_GUI::layers_2_GUI(layers_2<state_idx, state_idx, state_idx>* layer2, const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex),	layer2(layer2)	{		add_box(new module_1_1_GUI("layer 1", this, mutex));		add_box(new state_Idx_Gui(layer2->hidden, "hidden", this, mutex));		add_box(new module_1_1_GUI("layer 2", this, mutex));	}/* * * * * * * * * * * * * * * * * * * * * * */fc_ebm1_GUI::fc_ebm1_GUI(fc_ebm1<state_idx, state_idx>* ebm1, state_idx* in, state_idx* energy, const char* title, QWidget *parent, QMutex* mutex):	ebbox(parent, title, NULL, NULL, mutex),	ebm1(ebm1),	in(in),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -