Back to index

fet  5.18.0
lockunlock.cpp
Go to the documentation of this file.
00001 /*
00002 File lockunlock.cpp
00003 */
00004 
00005 /***************************************************************************
00006                                 FET
00007                           -------------------
00008    copyright            : (C) by Lalescu Liviu
00009     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00010  ***************************************************************************
00011                           lockunlock.cpp  -  description
00012                              -------------------
00013     begin                : Dec 2008
00014     copyright            : (C) by Liviu Lalescu (http://lalescu.ro/liviu/) and Volker Dirr (http://www.timetabling.de/)
00015  ***************************************************************************
00016  *                                                                         *
00017  *   FET program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 //#include <QSpinBox>
00025 
00026 //extern QSpinBox* pcommunicationSpinBox;
00027 
00028 #include <iostream>
00029 using namespace std;
00030 
00031 #include "lockunlock.h"
00032 #include "timetable_defs.h"
00033 #include "timetable.h"
00034 #include "solution.h"
00035 
00036 extern bool students_schedule_ready;
00037 extern bool teachers_schedule_ready;
00038 extern bool rooms_schedule_ready;
00039 
00040 extern Solution best_solution;
00041 
00042 extern Timetable gt;
00043 
00044 QSet<int> idsOfLockedTime;
00045 QSet<int> idsOfLockedSpace;
00046 QSet<int> idsOfPermanentlyLockedTime;
00047 QSet<int> idsOfPermanentlyLockedSpace;
00048 
00049 CommunicationSpinBox communicationSpinBox;
00050 
00051 
00052 CommunicationSpinBox::CommunicationSpinBox()
00053 {
00054        minValue=0;
00055        maxValue=9;
00056        value=0;
00057 }
00058 
00059 CommunicationSpinBox::~CommunicationSpinBox()
00060 {
00061 }
00062 
00063 void CommunicationSpinBox::increaseValue()
00064 {
00065        assert(maxValue>minValue);
00066        assert(value>=minValue && value<=maxValue);
00067        value++;
00068        if(value>maxValue)
00069               value=minValue;
00070               
00071        //cout<<"comm. spin box: increased value, crt value=="<<value<<endl;
00072        
00073        emit(valueChanged(value));
00074 }
00075 
00076 
00077 void LockUnlock::computeLockedUnlockedActivitiesTimeSpace()
00078 {
00079        //by Volker Dirr
00080        idsOfLockedTime.clear();
00081        idsOfLockedSpace.clear();
00082        idsOfPermanentlyLockedTime.clear();
00083        idsOfPermanentlyLockedSpace.clear();
00084 
00085        foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
00086               if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME && tc->weightPercentage==100.0 && tc->active){
00087                      ConstraintActivityPreferredStartingTime* c=(ConstraintActivityPreferredStartingTime*) tc;
00088                      if(c->day >= 0  &&  c->hour >= 0) {
00089                             if(c->permanentlyLocked)
00090                                    idsOfPermanentlyLockedTime.insert(c->activityId);
00091                             else
00092                                    idsOfLockedTime.insert(c->activityId);
00093                      }
00094               }
00095        }
00096        
00097        foreach(SpaceConstraint* sc, gt.rules.spaceConstraintsList){
00098               if(sc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM && sc->weightPercentage==100.0 && sc->active){
00099                      ConstraintActivityPreferredRoom* c=(ConstraintActivityPreferredRoom*) sc;
00100 
00101                      if(c->permanentlyLocked)
00102                             idsOfPermanentlyLockedSpace.insert(c->activityId);
00103                      else
00104                             idsOfLockedSpace.insert(c->activityId);
00105               }
00106        }
00107 }
00108 
00109 void LockUnlock::computeLockedUnlockedActivitiesOnlyTime()
00110 {
00111        //by Volker Dirr
00112        idsOfLockedTime.clear();
00113        idsOfPermanentlyLockedTime.clear();
00114 
00115        foreach(TimeConstraint* tc, gt.rules.timeConstraintsList){
00116               if(tc->type==CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME && tc->weightPercentage==100.0 && tc->active){
00117                      ConstraintActivityPreferredStartingTime* c=(ConstraintActivityPreferredStartingTime*) tc;
00118                      if(c->day >= 0  &&  c->hour >= 0) {
00119                             if(c->permanentlyLocked)
00120                                    idsOfPermanentlyLockedTime.insert(c->activityId);
00121                             else
00122                                    idsOfLockedTime.insert(c->activityId);
00123                      }
00124               }
00125        }
00126 }
00127 
00128 void LockUnlock::computeLockedUnlockedActivitiesOnlySpace()
00129 {
00130        //by Volker Dirr
00131        idsOfLockedSpace.clear();
00132        idsOfPermanentlyLockedSpace.clear();
00133 
00134        foreach(SpaceConstraint* sc, gt.rules.spaceConstraintsList){
00135               if(sc->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM && sc->weightPercentage==100.0 && sc->active){
00136                      ConstraintActivityPreferredRoom* c=(ConstraintActivityPreferredRoom*) sc;
00137 
00138                      if(c->permanentlyLocked)
00139                             idsOfPermanentlyLockedSpace.insert(c->activityId);
00140                      else
00141                             idsOfLockedSpace.insert(c->activityId);
00142               }
00143        }
00144 }
00145 
00146 void LockUnlock::increaseCommunicationSpinBox()
00147 {
00148 /*     assert(pcommunicationSpinBox!=NULL);
00149        
00150        int q=pcommunicationSpinBox->value();     //needed to display locked and unlocked times and rooms
00151        //cout<<"communication spin box old value: "<<pcommunicationSpinBox->value()<<", ";
00152        q++;
00153        assert(pcommunicationSpinBox->maximum()>pcommunicationSpinBox->minimum());
00154        if(q > pcommunicationSpinBox->maximum())
00155               q=pcommunicationSpinBox->minimum();
00156        pcommunicationSpinBox->setValue(q);*/
00157        //cout<<"changed to new value: "<<pcommunicationSpinBox->value()<<endl;
00158        
00159        communicationSpinBox.increaseValue();
00160 }
00161