00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #ifndef SPREF_H
00096 #define SPREF_H
00097
00098
00099 #include <cassert>
00100 #include <string>
00101
00102 #include <LEDA/string.h>
00103 #include <LEDA/list.h>
00104
00105
00106 #include "SObservable.h"
00107 #include "SPrefEvent.h"
00108
00109
00110 #include <qrect.h>
00111 #include <qpoint.h>
00112
00113 using std::string;
00114
00120
00121 class SPref : public SObservable
00122 {
00123 public:
00124
00125 SPref(int blub) { assert(false); };
00126
00131 static SPref &instance();
00132
00135 ~SPref() {};
00136
00139 void load();
00140
00143 void save();
00144
00149 static string getRootDir();
00150
00151
00152 const leda_string &getJobHiddenColor() const { return _jobHiddenColor; };
00153 void setJobHiddenColor(const leda_string &s) {
00154 if( s != _jobHiddenColor ) {
00155 _jobHiddenColor = s;
00156 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00157 notifyObservers( ev );
00158 }
00159 };
00160 const leda_string &getJobReleasedColor() const { return _jobReleasedColor; };
00161 void setJobReleasedColor(const leda_string &s) {
00162 if( s != _jobReleasedColor ) {
00163 _jobReleasedColor = s;
00164 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00165 notifyObservers( ev );
00166 }
00167 };
00168 const leda_string &getJobRunningColor() const { return _jobRunningColor; };
00169 void setJobRunningColor(const leda_string &s) {
00170 if( s != _jobRunningColor ) {
00171 _jobRunningColor = s;
00172 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00173 notifyObservers( ev );
00174 }
00175 };
00176 const leda_string &getJobFinishedColor() const
00177 { return _jobFinishedColor; };
00178 void setJobFinishedColor(const leda_string &s) {
00179 if( s != _jobFinishedColor ) {
00180 _jobFinishedColor = s;
00181 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00182 notifyObservers( ev );
00183 }
00184 };
00185 const leda_string &getJobRejectedColor() const
00186 { return _jobRejectedColor; };
00187 void setJobRejectedColor(const leda_string &s) {
00188 if( s != _jobRejectedColor ) {
00189 _jobRejectedColor = s;
00190 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00191 notifyObservers( ev );
00192 }
00193 };
00194 const int &getUsePixmaps() const { return _usePixmaps; };
00195 void setUsePixmaps(const int &i) {
00196 if( _usePixmaps != i ) {
00197 _usePixmaps = i;
00198 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00199 notifyObservers( ev );
00200 }
00201 };
00202 const leda_string &getJobPixmapFile() const { return _jobPixmapFile; };
00203 void setJobPixmapFile(const leda_string &s) {
00204 if( _jobPixmapFile != s ) {
00205 _jobPixmapFile = s;
00206 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00207 notifyObservers( ev );
00208 }
00209 };
00210 void setJobLayoutSettings( const leda_string &hcol, const leda_string &recol,
00211 const leda_string &rucol, const leda_string &fcol,
00212 const leda_string &rjcol,
00213 int width, int height, const leda_string &shape,
00214 int usepix, const leda_string &pixfile) {
00215 if( (hcol != _jobHiddenColor) || (recol != _jobReleasedColor) ||
00216 (rucol != _jobRunningColor ) || (fcol != _jobFinishedColor ) ||
00217 (rjcol != _jobRejectedColor ) ||
00218 (width != _nodeWidth) || (height != _nodeHeight) ||
00219 (shape != _nodeShape) ||
00220 (_usePixmaps != usepix) || (_jobPixmapFile != pixfile) ) {
00221 _jobHiddenColor = hcol;
00222 _jobReleasedColor = recol;
00223 _jobRunningColor = rucol;
00224 _jobFinishedColor = fcol;
00225 _jobRejectedColor = rjcol;
00226 _nodeWidth = width;
00227 _nodeHeight = height;
00228 _nodeShape = shape;
00229 _usePixmaps = usepix;
00230 _jobPixmapFile = pixfile;
00231 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00232 notifyObservers( ev );
00233 }
00234 };
00235 int getNodeWidth() const { return _nodeWidth; };
00236 void setNodeWidth( int w ) {
00237 if( _nodeWidth != w ) {
00238 _nodeWidth = w;
00239 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00240 notifyObservers( ev );
00241 }
00242 };
00243 int getNodeHeight() const { return _nodeHeight; };
00244 void setNodeHeight( int h ) {
00245 if( _nodeHeight != h ) {
00246 _nodeHeight = h;
00247 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00248 notifyObservers( ev );
00249 }
00250 };
00251 const leda_string &getNodeShape() const { return _nodeShape; };
00252 void setNodeShape(const leda_string &s) {
00253 if( _nodeShape != s ) {
00254 _nodeShape = s;
00255 SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00256 notifyObservers( ev );
00257 }
00258 };
00259 const leda_string &getMachGifFile() const { return _machGifFile; };
00260 void setMachGifFile(const leda_string &s) {
00261 if( _machGifFile != s ) {
00262 _machGifFile = s;
00263 SPrefEvent ev( SPrefEvent::MACHLAYOUT );
00264 notifyObservers( ev );
00265 }
00266 };
00267
00268 const leda_string &getAlgorithm() const { return _algorithm; };
00269 const leda_string &getPlayerTasksystemFile() const { return _playerTasksystem; };
00270 const leda_string &getPlayerLogFile() const { return _playerLogFile; };
00271 void setAlgorithm(const leda_string &alg, const leda_string &playerTS,
00272 const leda_string &playerLog) {
00273 if( (_algorithm != alg) || (_playerTasksystem != playerTS) ||
00274 (_playerLogFile != playerLog) ) {
00275 _algorithm = alg;
00276 _playerTasksystem = playerTS;
00277 _playerLogFile = playerLog;
00278 SPrefEvent ev( SPrefEvent::ALGSETTINGS );
00279 notifyObservers( ev );
00280 }
00281 };
00282
00283 int getLogTextActivated() { return _logTextActivated; };
00284 const string &getLogTextStream() { return _logTextStream; };
00285 const int &getSchedFilter() const { return _schedFilter; };
00286 const int &getEditFilter() const { return _editFilter; };
00287 void setLogTextSettings( int act, const string &s, int schedfilter,
00288 int editfilter) {
00289 if( (_logTextActivated != act) || (_logTextStream != s) ||
00290 (_schedFilter != schedfilter) || (_editFilter != editfilter ) ) {
00291 _schedFilter = schedfilter;
00292 _editFilter = editfilter;
00293 _logTextStream = s;
00294 _logTextActivated = act;
00295 SPrefEvent ev( SPrefEvent::LOGSETTINGS );
00296 notifyObservers( ev );
00297 }
00298 };
00299
00300 int getLogPlayerActivated() { return _logPlayerActivated; };
00301 const string &getLogPlayerStream() { return _logPlayerStream; };
00302 void setLogPlayerSettings( int act, const string &s ) {
00303 if( (_logPlayerActivated != act) || (_logPlayerStream != s) ) {
00304 _logPlayerStream = s;
00305 _logPlayerActivated = act;
00306 SPrefEvent ev( SPrefEvent::LOGSETTINGS );
00307 notifyObservers( ev );
00308 }
00309 };
00310
00311 int getLogOptCritActivated() { return _logOptCritActivated; };
00312 void getLogOptCritValues( int &criterion, int &type, int &weighted ) {
00313 criterion = _logOptCritCriterion;
00314 type = _logOptCritType;
00315 weighted =_logOptCritWeighted;
00316 };
00317 void setLogOptCritSettings( int act, int criterion, int type, int weighted ) {
00318 if( ( _logOptCritActivated != act ) || ( _logOptCritCriterion != criterion )
00319 || ( _logOptCritType != type ) || ( _logOptCritWeighted != weighted ) ) {
00320 _logOptCritActivated = act;
00321 _logOptCritCriterion = criterion;
00322 _logOptCritType = type;
00323 _logOptCritWeighted = weighted;
00324 SPrefEvent ev( SPrefEvent::LOGSETTINGS );
00325 notifyObservers( ev );
00326 }
00327 };
00328
00329 void setSchedWinPos( QPoint p ) {
00330 _schedWinGeo.setX( p.x() );
00331 _schedWinGeo.setY( p.y() );
00332 };
00333 void setSchedWinSize( int w, int h ) {
00334 _schedWinGeo.setWidth( w );
00335 _schedWinGeo.setHeight( h );
00336 };
00337 const QRect &getSchedWinGeometry() { return _schedWinGeo; };
00338 void setDAGWinPos( QPoint p ) {
00339 _dagWinGeo.setX( p.x() );
00340 _dagWinGeo.setY( p.y() );
00341 };
00342 void setDAGWinSize( int w, int h ) {
00343 _dagWinGeo.setWidth( w );
00344 _dagWinGeo.setHeight( h );
00345 };
00346 const QRect &getDAGWinGeometry() { return _dagWinGeo; };
00347 void setMachineWinPos( QPoint p ) {
00348 _machineWinGeo.setX( p.x() );
00349 _machineWinGeo.setY( p.y() );
00350 };
00351 void setMachineWinSize( int w, int h ) {
00352 _machineWinGeo.setWidth( w );
00353 _machineWinGeo.setHeight( h );
00354 };
00355 const QRect &getMachineWinGeometry() { return _machineWinGeo; };
00356 void setMeshWinPos( QPoint p ) {
00357 _meshWinGeo.setX( p.x() );
00358 _meshWinGeo.setY( p.y() );
00359 };
00360 void setMeshWinSize( int w, int h ) {
00361 _meshWinGeo.setWidth( w );
00362 _meshWinGeo.setHeight( h );
00363 };
00364 const QRect &getMeshWinGeometry() { return _meshWinGeo; };
00365 void setGanttWinPos( QPoint p ) {
00366 _ganttWinGeo.setX( p.x() );
00367 _ganttWinGeo.setY( p.y() );
00368 };
00369 void setGanttWinSize( int w, int h ) {
00370 _ganttWinGeo.setWidth( w );
00371 _ganttWinGeo.setHeight( h );
00372 };
00373 const QRect &getGanttWinGeometry() { return _ganttWinGeo; };
00374
00375 void setRecentFiles(leda_list<string> recentFiles) {
00376 _recentFiles = recentFiles;
00377 }
00378 const leda_list<string> getRecentFiles() {
00379 return _recentFiles;
00380 }
00381
00382
00383
00384 const double &getProcTimeEps() const { return _procTimeEps; };
00385 void setProcTimeEps(const double &d) { _procTimeEps = d; };
00386
00387
00388 private:
00389
00390 static SPref _instance;
00391
00392 string _rcName;
00393
00394
00395 leda_list<string> _recentFiles;
00396 leda_string _jobHiddenColor;
00397 leda_string _jobReleasedColor;
00398 leda_string _jobRunningColor;
00399 leda_string _jobFinishedColor;
00400 leda_string _jobRejectedColor;
00401 leda_string _algorithm;
00402 leda_string _playerTasksystem;
00403 leda_string _playerLogFile;
00404 string _logTextStream;
00405 int _logTextActivated;
00406 string _logPlayerStream;
00407 int _logPlayerActivated;
00408 int _logOptCritActivated;
00409 int _logOptCritCriterion;
00410 int _logOptCritType;
00411 int _logOptCritWeighted;
00412 int _usePixmaps;
00413 leda_string _jobPixmapFile;
00414 int _nodeWidth;
00415 int _nodeHeight;
00416 leda_string _nodeShape;
00417 leda_string _machGifFile;
00418 QRect _schedWinGeo;
00419 QRect _dagWinGeo;
00420 QRect _machineWinGeo;
00421 QRect _meshWinGeo;
00422 QRect _ganttWinGeo;
00423 double _procTimeEps;
00424 int _schedFilter;
00425 int _editFilter;
00426
00427
00428
00429 SPref() { _rcName = getRootDir() + "/.schedrc"; load(); };
00430
00431 SPref(const SPref &p);
00432 SPref &operator=(const SPref &p);
00433 };
00434
00435
00436 #endif