void ChangeMinDaysSelectivelyForm::ok() { enum {ANY=0, YES=1, NO=2}; enum {NOCHANGE=0}; oldWeight=oldDays=oldConsecutive=oldNActs=-2; newWeight=newDays=newConsecutive=-2; QString oldWeightS=oldWeightLineEdit->text(); weight_sscanf(oldWeightS, "%lf", &oldWeight); if(!(oldWeight==-1 || (oldWeight>=0.0 && oldWeight<=100.0))){ QMessageBox::warning(this, tr("FET warning"), tr("Old weight must be -1 or both >=0 and <=100")); return; } QString newWeightS=newWeightLineEdit->text(); weight_sscanf(newWeightS, "%lf", &newWeight); if(!(newWeight==-1 || (newWeight>=0.0 && newWeight<=100.0))){ QMessageBox::warning(this, tr("FET warning"), tr("New weight must be -1 or both >=0 and <=100")); return; } oldDays=oldDaysSpinBox->value(); if(!(oldDays==-1 || (oldDays>=1 && oldDays<=gt.rules.nDaysPerWeek))){ QMessageBox::warning(this, tr("FET warning"), tr("Old min days must be -1 or both >=1 and <=n_days_per_week")); return; } newDays=newDaysSpinBox->value(); if(!(newDays==-1 || (newDays>=1 && newDays<=gt.rules.nDaysPerWeek))){ QMessageBox::warning(this, tr("FET warning"), tr("New min days must be -1 or both >=1 and <=n_days_per_week")); return; } oldConsecutive=oldConsecutiveComboBox->currentIndex(); assert(oldConsecutive>=0 && oldConsecutive<=2); newConsecutive=newConsecutiveComboBox->currentIndex(); assert(newConsecutive>=0 && newConsecutive<=2); oldNActs=oldNActsSpinBox->value(); if(!(oldNActs==-1 || oldNActs>=1)){ QMessageBox::warning(this, tr("FET warning"), tr("Old n_acts must be -1 or >=1")); return; } this->accept(); }
void AddConstraintTeachersMaxBuildingChangesPerDayForm::addCurrentConstraint() { SpaceConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<100.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage). It has to be 100")); return; } ctr=new ConstraintTeachersMaxBuildingChangesPerDay(weight, maxChangesSpinBox->value()); bool tmp2=gt.rules.addSpaceConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void AddConstraintStudentsSetMinGapsBetweenBuildingChangesForm::addCurrentConstraint() { SpaceConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<100.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage). It has to be 100")); return; } QString students_name=studentsComboBox->currentText(); StudentsSet* s=gt.rules.searchStudentsSet(students_name); if(s==NULL){ QMessageBox::warning(this, tr("FET information"), tr("Invalid students set")); return; } ctr=new ConstraintStudentsSetMinGapsBetweenBuildingChanges(weight, students_name, minGapsSpinBox->value()); bool tmp2=gt.rules.addSpaceConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void AddConstraintBasicCompulsoryTimeForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it has to be 100%")); return; } ctr=new ConstraintBasicCompulsoryTime(weight); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - there must be another constraint of this " "type. Please edit that one")); delete ctr; } }
void ModifyConstraintStudentsSetHomeRoomForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } QString students=studentsComboBox->currentText(); assert(gt.rules.searchStudentsSet(students)!=NULL); int i=roomsComboBox->currentIndex(); if(i<0 || roomsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid room")); return; } QString room=roomsComboBox->currentText(); this->_ctr->weightPercentage=weight; this->_ctr->roomName=room; this->_ctr->studentsName=students; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintStudentsMaxHoursContinuouslyForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } int maxHours=maxHoursSpinBox->value(); ctr=new ConstraintStudentsMaxHoursContinuously(weight, maxHours); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void ModifyConstraintStudentsSetMaxHoursContinuouslyForm::ok() { if(studentsComboBox->currentIndex()<0){ showWarningCannotModifyConstraintInvisibleSubgroupConstraint(this, this->_ctr->students); return; } double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } QString students_name=studentsComboBox->currentText(); StudentsSet* s=gt.rules.searchStudentsSet(students_name); if(s==NULL){ QMessageBox::warning(this, tr("FET information"), tr("Invalid students set")); return; } this->_ctr->weightPercentage=weight; this->_ctr->students=students_name; this->_ctr->maxHoursContinuously=maxHoursSpinBox->value(); gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void ModifyConstraintTeacherMaxBuildingChangesPerWeekForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<100.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage). It has to be 100")); return; } QString teacher_name=teachersComboBox->currentText(); int t=gt.rules.searchTeacher(teacher_name); if(t==-1){ QMessageBox::warning(this, tr("FET information"), tr("Invalid teacher")); return; } this->_ctr->weightPercentage=weight; this->_ctr->teacherName=teacher_name; this->_ctr->maxBuildingChangesPerWeek=maxChangesSpinBox->value(); gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintTeachersMinDaysPerWeekForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it has to be 100%")); return; } int min_days=minDaysSpinBox->value(); ctr=new ConstraintTeachersMinDaysPerWeek(weight, min_days); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void AddConstraintStudentsSetMaxHoursDailyForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } int maxHours=maxHoursSpinBox->value(); QString students_name=studentsComboBox->currentText(); StudentsSet* s=gt.rules.searchStudentsSet(students_name); if(s==NULL){ QMessageBox::warning(this, tr("FET information"), tr("Invalid students set")); return; } ctr=new ConstraintStudentsSetMaxHoursDaily(weight, maxHours, students_name); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void ModifyConstraintStudentsSetMaxGapsPerDayForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it must be 100%")); return; } QString students_name=studentsComboBox->currentText(); StudentsSet* s=gt.rules.searchStudentsSet(students_name); if(s==NULL){ QMessageBox::warning(this, tr("FET information"), tr("Invalid students set")); return; } this->_ctr->weightPercentage=weight; this->_ctr->maxGaps=maxGapsSpinBox->value(); this->_ctr->students=students_name; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void ModifyConstraintStudentsMaxDaysPerWeekForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it has to be 100%")); return; } int max_days=maxDaysSpinBox->value(); this->_ctr->weightPercentage=weight; this->_ctr->maxDaysPerWeek=max_days; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void ModifyConstraintActivityEndsStudentsDayForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it must be 100%")); return; } int tmp2=activitiesComboBox->currentIndex(); assert(tmp2<gt.rules.activitiesList.size()); assert(tmp2<activitiesList.size()); if(tmp2<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } int id=activitiesList.at(tmp2); this->_ctr->weightPercentage=weight; this->_ctr->activityId=id; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void ModifyConstraintTeacherMaxHoursContinuouslyForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } int max_hours=maxHoursSpinBox->value(); QString teacher_name=teachersComboBox->currentText(); int teacher_ID=gt.rules.searchTeacher(teacher_name); if(teacher_ID<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid teacher")); return; } this->_ctr->weightPercentage=weight; this->_ctr->maxHoursContinuously=max_hours; this->_ctr->teacherName=teacher_name; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintTeachersActivityTagMaxHoursDailyForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET warning"), tr("Invalid weight (percentage)")); return; } QString activityTagName=activityTagsComboBox->currentText(); int activityTagIndex=gt.rules.searchActivityTag(activityTagName); if(activityTagIndex<0){ QMessageBox::warning(this, tr("FET warning"), tr("Invalid activity tag")); return; } int max_hours=maxHoursSpinBox->value(); ctr=new ConstraintTeachersActivityTagMaxHoursDaily(weight, max_hours, activityTagName); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void ModifyConstraintActivityPreferredStartingTimeForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } int day=dayComboBox->currentIndex(); if(day<0 || day>=gt.rules.nDaysPerWeek){ QMessageBox::warning(this, tr("FET information"), tr("Invalid day")); return; } int startHour=startHourComboBox->currentIndex(); if(startHour<0 || startHour>=gt.rules.nHoursPerDay){ QMessageBox::warning(this, tr("FET information"), tr("Invalid start hour")); return; } int tmp2=activitiesComboBox->currentIndex(); assert(tmp2<gt.rules.activitiesList.size()); assert(tmp2<activitiesList.size()); if(tmp2<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } int id=activitiesList.at(tmp2); bool permanentlyLocked=permLockedCheckBox->isChecked(); if(1){ ConstraintActivityPreferredStartingTime apst; apst.activityId=id; apst.weightPercentage=weight; apst.day=day; apst.hour=startHour; apst.permanentlyLocked=permanentlyLocked; bool duplicate=false; foreach(TimeConstraint* tc, gt.rules.timeConstraintsList) if(tc!=this->_ctr && tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME) if( ( *((ConstraintActivityPreferredStartingTime*)tc) ) == apst){ duplicate=true; break; } if(duplicate){ QMessageBox::warning(this, tr("FET information"), tr("Cannot proceed, current constraint is equal to another one (it is duplicated)")); return; } }
void AddConstraintTeacherIntervalMaxDaysPerWeekForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it has to be 100%")); return; } int max_days=maxDaysSpinBox->value(); QString teacher_name=teachersComboBox->currentText(); int teacher_ID=gt.rules.searchTeacher(teacher_name); if(teacher_ID<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid teacher")); return; } int startHour=startHourComboBox->currentIndex(); int endHour=endHourComboBox->currentIndex(); if(startHour<0 || startHour>=gt.rules.nHoursPerDay){ QMessageBox::warning(this, tr("FET information"), tr("Start hour invalid")); return; } if(endHour<0 || endHour>gt.rules.nHoursPerDay){ QMessageBox::warning(this, tr("FET information"), tr("End hour invalid")); return; } if(endHour<=startHour){ QMessageBox::warning(this, tr("FET information"), tr("Start hour cannot be greater or equal than end hour")); return; } ctr=new ConstraintTeacherIntervalMaxDaysPerWeek(weight, max_days, teacher_name, startHour, endHour); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void AddConstraintSubjectActivityTagPreferredRoomsForm::addConstraint() { SpaceConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } if(selectedRoomsListWidget->count()==0){ QMessageBox::warning(this, tr("FET information"), tr("Empty list of selected rooms")); return; } if(selectedRoomsListWidget->count()==1){ QMessageBox::warning(this, tr("FET information"), tr("Only one selected room - please use constraint subject activity tag preferred room if you want a single room")); return; } if(subjectsComboBox->currentIndex()<0 || subjectsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid selected subject")); return; } QString subject=subjectsComboBox->currentText(); if(activityTagsComboBox->currentIndex()<0 || activityTagsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid selected activity tag")); return; } QString activityTag=activityTagsComboBox->currentText(); QStringList roomsList; for(int i=0; i<selectedRoomsListWidget->count(); i++) roomsList.append(selectedRoomsListWidget->item(i)->text()); ctr=new ConstraintSubjectActivityTagPreferredRooms(weight, subject, activityTag, roomsList); bool tmp2=gt.rules.addSpaceConstraint(ctr); if(tmp2){ QString s=tr("Constraint added:"); s+="\n\n"; s+=ctr->getDetailedDescription(gt.rules); LongTextMessageBox::information(this, tr("FET information"), s); } else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void ModifyConstraintActivityPreferredRoomForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } int i=activitiesComboBox->currentIndex(); if(i<0 || activitiesComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } Activity* act=gt.rules.activitiesList.at(i); i=roomsComboBox->currentIndex(); if(i<0 || roomsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid room")); return; } QString room=roomsComboBox->currentText(); this->_ctr->weightPercentage=weight; this->_ctr->roomName=room; if(_ctr->activityId!=act->id){ int oldId=_ctr->activityId; int newId=act->id; QSet<ConstraintActivityPreferredRoom*> cs=gt.rules.aprHash.value(oldId, QSet<ConstraintActivityPreferredRoom*>()); assert(cs.contains(_ctr)); cs.remove(_ctr); gt.rules.aprHash.insert(oldId, cs); cs=gt.rules.aprHash.value(newId, QSet<ConstraintActivityPreferredRoom*>()); assert(!cs.contains(_ctr)); cs.insert(_ctr); gt.rules.aprHash.insert(newId, cs); this->_ctr->activityId=act->id; } this->_ctr->permanentlyLocked=permLockedCheckBox->isChecked(); gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); LockUnlock::computeLockedUnlockedActivitiesOnlySpace(); LockUnlock::increaseCommunicationSpinBox(); this->close(); }
void ModifyConstraintTeacherIntervalMaxDaysPerWeekForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - it has to be 100%")); return; } int max_days=maxDaysSpinBox->value(); QString teacher_name=teachersComboBox->currentText(); int teacher_ID=gt.rules.searchTeacher(teacher_name); if(teacher_ID<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid teacher")); return; } int startHour=startHourComboBox->currentIndex(); int endHour=endHourComboBox->currentIndex(); if(startHour<0 || startHour>=gt.rules.nHoursPerDay){ QMessageBox::warning(this, tr("FET information"), tr("Start hour invalid")); return; } if(endHour<0 || endHour>gt.rules.nHoursPerDay){ QMessageBox::warning(this, tr("FET information"), tr("End hour invalid")); return; } if(endHour<=startHour){ QMessageBox::warning(this, tr("FET information"), tr("Start hour cannot be greater or equal than end hour")); return; } this->_ctr->weightPercentage=weight; this->_ctr->maxDaysPerWeek=max_days; this->_ctr->teacherName=teacher_name; this->_ctr->startHour=startHour; this->_ctr->endHour=endHour; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintActivitiesMaxSimultaneousInSelectedTimeSlotsForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<100.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage). It has to be 100")); return; } QList<int> days; QList<int> hours; for(int j=0; j<gt.rules.nDaysPerWeek; j++) for(int i=0; i<gt.rules.nHoursPerDay; i++) if(selectedTimesTable->item(i, j)->text()==YES){ days.append(j); hours.append(i); } int maxSimultaneous=maxSimultaneousSpinBox->value(); if(maxSimultaneous==0){ QMessageBox::warning(this, tr("FET information"), tr("You specified max simultaneous activities to be 0. This is " "not perfect from efficiency point of view, because you can use instead constraint activity(ies) preferred time slots, " "and help FET to find a timetable easier and faster, with an equivalent result. Please correct.")); return; } if(this->selectedActivitiesList.count()==0){ QMessageBox::warning(this, tr("FET information"), tr("Empty list of activities")); return; } //we allow even only one activity /*if(this->selectedActivitiesList.count()==1){ QMessageBox::warning(this, tr("FET information"), tr("Only one selected activity")); return; }*/ ctr=new ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(weight, selectedActivitiesList, days, hours, maxSimultaneous); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void AddConstraintTwoActivitiesOrderedForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } int fid; int tmp2=firstActivitiesComboBox->currentIndex(); assert(tmp2<gt.rules.activitiesList.size()); assert(tmp2<firstActivitiesList.size()); if(tmp2<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } else fid=firstActivitiesList.at(tmp2); int sid; int tmp3=secondActivitiesComboBox->currentIndex(); assert(tmp3<gt.rules.activitiesList.size()); assert(tmp3<secondActivitiesList.size()); if(tmp3<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } else sid=secondActivitiesList.at(tmp3); if(sid==fid){ QMessageBox::warning(this, tr("FET information"), tr("Same activities - impossible")); return; } ctr=new ConstraintTwoActivitiesOrdered(weight, fid, sid); bool tmp4=gt.rules.addTimeConstraint(ctr); if(tmp4) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - error?")); delete ctr; } }
void ModifyConstraintActivitiesMaxSimultaneousInSelectedTimeSlotsForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<100.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage). It has to be 100")); return; } this->_ctr->weightPercentage=weight; QList<int> days; QList<int> hours; for(int j=0; j<gt.rules.nDaysPerWeek; j++) for(int i=0; i<gt.rules.nHoursPerDay; i++) if(selectedTimesTable->item(i, j)->text()==YES){ days.append(j); hours.append(i); } this->_ctr->selectedDays=days; this->_ctr->selectedHours=hours; int maxSimultaneous=maxSimultaneousSpinBox->value(); if(maxSimultaneous==0){ QMessageBox::warning(this, tr("FET information"), tr("You specified max simultaneous activities to be 0. This is " "not perfect from efficiency point of view, because you can use instead constraint activity(ies) preferred time slots, " "and help FET to find a timetable easier and faster, with an equivalent result. Please correct.")); return; } this->_ctr->maxSimultaneous=maxSimultaneous; if(this->selectedActivitiesList.count()==0){ QMessageBox::warning(this, tr("FET information"), tr("Empty list of activities")); return; } //we allow even only one activity /*if(this->selectedActivitiesList.count()==1){ QMessageBox::warning(this, tr("FET information"), tr("Only one selected activity")); return; }*/ this->_ctr->activitiesIds=selectedActivitiesList; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintActivityPreferredStartingTimeForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } int day=dayComboBox->currentIndex(); if(day<0 || day>=gt.rules.nDaysPerWeek){ QMessageBox::warning(this, tr("FET information"), tr("Invalid day")); return; } int startHour=startHourComboBox->currentIndex(); if(startHour<0 || startHour>=gt.rules.nHoursPerDay){ QMessageBox::warning(this, tr("FET information"), tr("Invalid start hour")); return; } int id; int tmp2=activitiesComboBox->currentIndex(); assert(tmp2<gt.rules.activitiesList.size()); assert(tmp2<activitiesList.size()); if(tmp2<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } else id=activitiesList.at(tmp2); ctr=new ConstraintActivityPreferredStartingTime(weight, id, day, startHour, permLockedCheckBox->isChecked()); bool tmp3=gt.rules.addTimeConstraint(ctr); if(tmp3){ LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); LockUnlock::computeLockedUnlockedActivitiesOnlyTime(); LockUnlock::increaseCommunicationSpinBox(); } else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - duplicate")); delete ctr; } }
void AddConstraintActivityPreferredRoomsForm::addConstraint() { SpaceConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } if(selectedRoomsListWidget->count()==0){ QMessageBox::warning(this, tr("FET information"), tr("Empty list of selected rooms")); return; } if(selectedRoomsListWidget->count()==1){ QMessageBox::warning(this, tr("FET information"), tr("Only one selected room - please use constraint activity preferred room if you want a single room")); return; } int id; int tmp2=activitiesComboBox->currentIndex(); if(tmp2<0 || tmp2>=gt.rules.activitiesList.size() || tmp2>=activitiesList.size()){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } else id=activitiesList.at(tmp2); QStringList roomsList; for(int i=0; i<selectedRoomsListWidget->count(); i++) roomsList.append(selectedRoomsListWidget->item(i)->text()); ctr=new ConstraintActivityPreferredRooms(weight, id, roomsList); bool tmp3=gt.rules.addSpaceConstraint(ctr); if(tmp3){ QString s=tr("Constraint added:"); s+="\n\n"; s+=ctr->getDetailedDescription(gt.rules); LongTextMessageBox::information(this, tr("FET information"), s); } else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }
void ModifyConstraintActivityPreferredTimeSlotsForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage)")); return; } int i=activitiesComboBox->currentIndex(); assert(i<activitiesList.size()); if(i<0 || activitiesComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity")); return; } int id=activitiesList.at(i); QList<int> days_L; QList<int> hours_L; //int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS]; //int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS]; int n=0; for(int j=0; j<gt.rules.nDaysPerWeek; j++) for(i=0; i<gt.rules.nHoursPerDay; i++) if(preferredTimesTable->item(i, j)->text()==YES){ days_L.append(j); hours_L.append(i); n++; } if(n<=0){ int t=QMessageBox::question(this, tr("FET question"), tr("Warning: 0 slots selected. Are you sure?"), QMessageBox::Yes, QMessageBox::Cancel); if(t==QMessageBox::Cancel) return; } this->_ctr->weightPercentage=weight; this->_ctr->p_activityId=id; this->_ctr->p_nPreferredTimeSlots_L=n; this->_ctr->p_days_L=days_L; this->_ctr->p_hours_L=hours_L; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintSubjectActivityTagPreferredRoomForm::addConstraint() { SpaceConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } int i=subjectsComboBox->currentIndex(); if(i<0 || subjectsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid subject")); return; } QString subject=subjectsComboBox->currentText(); i=activityTagsComboBox->currentIndex(); if(i<0 || activityTagsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid activity tag")); return; } QString activityTag=activityTagsComboBox->currentText(); i=roomsComboBox->currentIndex(); if(i<0 || roomsComboBox->count()<=0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid room")); return; } QString room=roomsComboBox->currentText(); ctr=new ConstraintSubjectActivityTagPreferredRoom(weight, subject, activityTag, room); bool tmp2=gt.rules.addSpaceConstraint(ctr); if(tmp2){ QString s=tr("Constraint added:"); s+="\n\n"; s+=ctr->getDetailedDescription(gt.rules); LongTextMessageBox::information(this, tr("FET information"), s); } else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - error ?")); delete ctr; } }
void SecondMinDaysDialog::yesPressed() { double wt; QString tmp=percText->text(); weight_sscanf(tmp, "%lf", &wt); if(wt<0.0 || wt>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight (percentage) - must be >=0 and <=100.0")); return; } weight=wt; accept(); }
void ModifyConstraintSubjectActivityTagPreferredRoomsForm::ok() { double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } if(selectedRoomsListWidget->count()==0){ QMessageBox::warning(this, tr("FET information"), tr("Empty list of selected rooms")); return; } /*if(selectedRoomsListWidget->count()==1){ QMessageBox::warning(this, tr("FET information"), tr("Only one selected room - please use constraint subject activity tag preferred room if you want a single room")); return; }*/ if(subjectsComboBox->currentIndex()<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid selected subject")); return; } QString subject=subjectsComboBox->currentText(); if(activityTagsComboBox->currentIndex()<0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid selected activity tag")); return; } QString activityTag=activityTagsComboBox->currentText(); QStringList roomsList; for(int i=0; i<selectedRoomsListWidget->count(); i++) roomsList.append(selectedRoomsListWidget->item(i)->text()); this->_ctr->weightPercentage=weight; this->_ctr->subjectName=subject; this->_ctr->activityTagName=activityTag; this->_ctr->roomsNames=roomsList; gt.rules.internalStructureComputed=false; setRulesModifiedAndOtherThings(>.rules); this->close(); }
void AddConstraintStudentsSetMinHoursDailyForm::addCurrentConstraint() { TimeConstraint *ctr=NULL; double weight; QString tmp=weightLineEdit->text(); weight_sscanf(tmp, "%lf", &weight); if(weight<0.0 || weight>100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight")); return; } if(weight!=100.0){ QMessageBox::warning(this, tr("FET information"), tr("Invalid weight - it has to be 100%")); return; } if(!ENABLE_STUDENTS_MIN_HOURS_DAILY_WITH_ALLOW_EMPTY_DAYS && allowEmptyDaysCheckBox->isChecked()){ QMessageBox::warning(this, tr("FET warning"), tr("Empty days for students min hours daily constraints are not enabled. You must enable them from the Settings->Advanced menu.")); return; } if(allowEmptyDaysCheckBox->isChecked() && minHoursSpinBox->value()<2){ QMessageBox::warning(this, tr("FET warning"), tr("If you allow empty days, the min hours must be at least 2 (to make it a non-trivial constraint)")); return; } int minHours=minHoursSpinBox->value(); QString students_name=studentsComboBox->currentText(); StudentsSet* s=gt.rules.searchStudentsSet(students_name); if(s==NULL){ QMessageBox::warning(this, tr("FET information"), tr("Invalid students set")); return; } ctr=new ConstraintStudentsSetMinHoursDaily(weight, minHours, students_name, allowEmptyDaysCheckBox->isChecked()); bool tmp2=gt.rules.addTimeConstraint(ctr); if(tmp2) LongTextMessageBox::information(this, tr("FET information"), tr("Constraint added:")+"\n\n"+ctr->getDetailedDescription(gt.rules)); else{ QMessageBox::warning(this, tr("FET information"), tr("Constraint NOT added - please report error")); delete ctr; } }