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

📄 fetmainform.cpp

📁 基于遗传算法的排课软件源码 根据需要安排合理的课程时间等
💻 CPP
📖 第 1 页 / 共 4 页
字号:
////// C++ Implementation: $MODULE$//// Description:////// Author: Lalescu Liviu <liviu@lalescu.ro>, (C) 2003//// Copyright: See COPYING file that comes with this distribution////#include "genetictimetable_defs.h"#include "genetictimetable.h"#include "fetmainform.h"#include "timetableallocatehoursform.h"#include "timetableviewstudentsform.h"#include "timetableviewteachersform.h"#include "timetableviewstudentswithroomsform.h"#include "timetableviewteacherswithroomsform.h"#include "timetableviewstudentswithrooms2form.h"#include "timetableviewteacherswithrooms2form.h"#include "timetableshowconflictstimeform.h"#include "timetableallocateroomsform.h"#include "timetableallocatehoursroomsform.h"#include "timetableviewroomsform.h"#include "timetableshowconflictsspaceform.h"#include "timetableviewrooms2form.h"#include "timetableshowconflictstimespaceform.h"#include "institutionnameform.h"#include "commentsform.h"#include "daysform.h"#include "hoursform.h"#include "subjectsform.h"#include "subjecttagsform.h"#include "teachersform.h"#include "yearsform.h"#include "groupsform.h"#include "subgroupsform.h"#include "activitiesform.h"#include "equipmentsform.h"#include "buildingsform.h"#include "roomsform.h"#include "alltimeconstraintsform.h"#include "allspaceconstraintsform.h"#include "helpaboutform.h"#include "helpfaqform.h"#include "helptimeconstraintsform.h"#include "helptimeconstraintssubtagsform.h"#include "populationnumberform.h"#include "fet.h"#include "constraint2activitiesconsecutiveform.h"#include "constraint2activitiesorderedform.h"#include "constraint2activitiesgroupedform.h"#include "constraintactivitiespreferredtimesform.h"#include "constraintactivitiessamestartingtimeform.h"#include "constraintactivitiessamestartinghourform.h"#include "constraintteachernotavailableform.h"#include "constraintbasiccompulsorytimeform.h"#include "constraintbasiccompulsoryspaceform.h"#include "constraintteacherrequiresroomform.h"#include "constraintteachersubjectrequireroomform.h"#include "constraintroomnotavailableform.h"#include "constraintactivitypreferredroomform.h"#include "constraintminimizenumberofroomsforstudentsform.h"#include "constraintminimizenumberofroomsforteachersform.h"#include "constraintroomtypenotallowedsubjectsform.h"#include "constraintsubjectrequiresequipmentsform.h"#include "constraintsubjectsubjecttagrequireequipmentsform.h"#include "constraintstudentssetnotavailableform.h"#include "constraintbreakform.h"#include "constraintteachermaxdaysperweekform.h"#include "constraintteachersmaxhourscontinuouslyform.h"#include "constraintteachersmaxhoursdailyform.h"#include "constraintteacherssubgroupsmaxhoursdailyform.h"#include "constraintactivitypreferredtimeform.h"#include "constraintstudentssetnogapsform.h"#include "constraintstudentsnogapsform.h"#include "constraintteachersnogapsform.h"#include "constraintstudentsearlyform.h"#include "constraintstudentssetintervalmaxdaysperweekform.h"#include "constraintstudentssetnhoursdailyform.h"#include "constraintstudentsnhoursdailyform.h"#include "constraintactivityendsdayform.h"#include "constraintactivitiesnotoverlappingform.h"#include "constraintminndaysbetweenactivitiesform.h"#include "constraintactivitypreferredtimesform.h"#include "constraintteacherssubjecttagsmaxhourscontinuouslyform.h"#include "constraintteacherssubjecttagmaxhourscontinuouslyform.h"#include "constraintactivitiessameroomform.h"#include "constraintactivitypreferredroomsform.h"#include "constraintsubjectpreferredroomform.h"#include "constraintsubjectsubjecttagpreferredroomform.h"#include "constraintsubjectpreferredroomsform.h"#include "constraintsubjectsubjecttagpreferredroomsform.h"#include "constraintmaxbuildingchangesperdayforteachersform.h"#include "constraintmaxbuildingchangesperdayforstudentsform.h"#include "constraintmaxroomchangesperdayforteachersform.h"#include "constraintmaxroomchangesperdayforstudentsform.h"#include <qmessagebox.h>#include <qfiledialog.h>#include <qstring.h>#include <qdir.h>#include <qpopupmenu.h>bool simulation_running; //true if the user started an allocation of the timetablebool students_schedule_ready;bool teachers_schedule_ready;bool rooms_schedule_ready;bool students_schedule_ready2;bool teachers_schedule_ready2;bool rooms_schedule_ready2;SpaceChromosome best_space_chromosome;TimeChromosome best_time_chromosome;TimeSpaceChromosome best_time_space_chromosome;FetMainForm* fetMainForm_pointer;QString timeConflictsString; //the string that contains a log of the broken time constraintsQString spaceConflictsString; //the string that contains a log of the broken space constraintsQString timeSpaceConflictsString; //the string that contains a log of the broken time&space constraintsQTranslator* ptranslator;extern QApplication* pqapplication;FetMainForm::FetMainForm() : FetMainForm_template(){	ptranslator=NULL;	fetMainForm_pointer=this;		if(FET_LANGUAGE=="EN")		this->languageEnglish();	else if(FET_LANGUAGE=="FR")		this->languageFrench();	else if(FET_LANGUAGE=="RO")		this->languageRomanian();	else if(FET_LANGUAGE=="CA")		this->languageCatalan();	else if(FET_LANGUAGE=="MY")		this->languageMalay();	else if(FET_LANGUAGE=="PL")		this->languagePolish();	else if(FET_LANGUAGE=="TR")		this->languageTurkish();	//new data	if(gt.rules.initialized)		gt.rules.kill();	gt.rules.init();	bool tmp=gt.rules.addTimeConstraint(new ConstraintBasicCompulsoryTime(1.0));	assert(tmp);	tmp=gt.rules.addSpaceConstraint(new ConstraintBasicCompulsorySpace(1.0));	assert(tmp);	students_schedule_ready=false;	teachers_schedule_ready=false;	rooms_schedule_ready=false;	students_schedule_ready2=false;	teachers_schedule_ready2=false;	rooms_schedule_ready2=false;		languageMenu->setCheckable(true);}FetMainForm::~FetMainForm(){	if(QMessageBox::information( this, QObject::tr("FET - exiting"),	 QObject::tr("File not saved - do you want to save it?"),	 QObject::tr("&Yes"), QObject::tr("&No"), QString::null, 0 , 1 ) == 0)		this->fileSave();	fetMainForm_pointer=NULL;	INPUT_FILENAME_XML = "";}void FetMainForm::fileExit(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	close();}void FetMainForm::fileNew(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	INPUT_FILENAME_XML="";	int confirm=0;	switch( QMessageBox::information( this, QObject::tr("FET application"),	 QObject::tr("Are you sure you want to load new data (rules) ?"),	 QObject::tr("&Yes"), QObject::tr("&No"), 0 , 1 ) ) {	case 0: // Yes		confirm=1;		break;	case 1: // No		confirm=0;		break;	}	if(confirm){		if(gt.rules.initialized)			gt.rules.kill();		gt.rules.init();		bool tmp=gt.rules.addTimeConstraint(new ConstraintBasicCompulsoryTime(1.0));		assert(tmp);		tmp=gt.rules.addSpaceConstraint(new ConstraintBasicCompulsorySpace(1.0));		assert(tmp);		students_schedule_ready=false;		teachers_schedule_ready=false;		students_schedule_ready2=false;		teachers_schedule_ready2=false;		rooms_schedule_ready2=false;	}}void FetMainForm::fileOpen(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	int confirm=1;	if(confirm){		QString s = QFileDialog::getOpenFileName(WORKING_DIRECTORY, QObject::tr("FET xml files (*.fet);;Old FET xml files (*.xml);;All files (*)"),			this, QObject::tr("open file dialog"), QObject::tr("Choose a file"));		if(s.isNull())			return;				if(gt.rules.read(s)){			students_schedule_ready=false;			teachers_schedule_ready=false;			students_schedule_ready2=false;			teachers_schedule_ready2=false;			rooms_schedule_ready2=false;			INPUT_FILENAME_XML = s;		}		else{			QMessageBox::information(this, QObject::tr("FET info"), QObject::tr("Invalid file"), QObject::tr("&OK"));		}		//get the directory		int tmp=s.findRev("/");		WORKING_DIRECTORY=s.left(tmp+1);	}}void FetMainForm::fileSaveAs(){	QString s = QFileDialog::getSaveFileName(		INPUT_FILENAME_XML, QObject::tr("FET xml files (*.fet);;All files (*)"),		this, QObject::tr("Save file dialog"), QObject::tr("Choose a filename to save under" ));	if(s==NULL)		return;			if(s.right(4)!=".fet")		s+=".fet";	int tmp=s.findRev("/");	WORKING_DIRECTORY=s.left(tmp+1);	if(QFile::exists(s))		if(QMessageBox::information( this, QObject::tr("FET"),		 QObject::tr("File exists - are you sure you want to overwrite existing file?"),		 QObject::tr("&Yes"), QObject::tr("&No"), 0 , 1 ) == 1)		 	return;				INPUT_FILENAME_XML = s;	gt.rules.write(INPUT_FILENAME_XML);}void FetMainForm::fileSave(){	if(INPUT_FILENAME_XML == "")		fileSaveAs();	else		gt.rules.write(INPUT_FILENAME_XML);}void FetMainForm::dataInstitutionName(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	InstitutionNameForm* institutionNameForm=new InstitutionNameForm();	institutionNameForm->exec();}void FetMainForm::dataComments(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	CommentsForm* commentsForm=new CommentsForm();	commentsForm->exec();}void FetMainForm::dataDays(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	DaysForm* daysForm=new DaysForm();	daysForm->exec();}void FetMainForm::dataHours(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	HoursForm* hoursForm=new HoursForm();	hoursForm->exec();}void FetMainForm::dataTeachers(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	TeachersForm* teachersForm=new TeachersForm();	teachersForm->exec();}void FetMainForm::dataSubjects(){	if(simulation_running){		QMessageBox::information(this, QObject::tr("FET information"),			QObject::tr("Allocation in course.\nPlease stop simulation before this."));		return;	}	SubjectsForm* subjectsForm=new SubjectsForm();	subjectsForm->exec();}void FetMainForm::dataSubjectTags()

⌨️ 快捷键说明

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