model.h
Go to the documentation of this file.00001 #ifndef VVMODEL_H
00002 #define VVMODEL_H
00003
00010 #include <config.h>
00011 #include <string>
00012 #include <set>
00013 #include <QString>
00014 #include <QStringList>
00015 #include <QObject>
00016 #include <QList>
00017 #include <QMetaMethod>
00018
00019 #include <util/watchdog.h>
00020
00021 class Viewer;
00022 class QPoint;
00023 class QAction;
00024
00025 namespace storage
00026 {
00027 class VVEStorage;
00028 }
00029
00044 class Model : public util::FileObject
00045 {
00046 Q_OBJECT
00047 public:
00048
00050
00051
00057 Model(QObject* parent);
00058
00063 virtual ~Model() {}
00065
00067
00068
00074 virtual void step() = 0;
00075
00082 virtual void modifiedFiles( const std::set<std::string>& )
00083 { this->modifiedFiles(); }
00087 virtual void modifiedFiles() {}
00088
00093 virtual void reread() {}
00094
00101 virtual QString helpString() const;
00102
00104
00106
00107
00108
00109
00110
00111
00112
00120 virtual bool serialize(storage::VVEStorage& ) { return false; }
00121
00130 virtual int versionNumber(const QString& ) { return 0; }
00131
00137 virtual QString version() const { return ""; }
00138
00140
00142
00143
00154 virtual void preDraw( Viewer* ) { this->preDraw(); }
00158 virtual void preDraw() {}
00159
00167 virtual void draw( Viewer* ) { this->draw(); }
00171 virtual void draw() {}
00172
00184 virtual void postDraw( Viewer* ) { this->postDraw(); }
00188 virtual void postDraw() {}
00189
00205 virtual void initDraw( Viewer* ) { this->initDraw(); }
00209 virtual void initDraw() {}
00210
00219 virtual void finalizeDraw( Viewer* ) { this->finalizeDraw(); }
00223 virtual void finalizeDraw() {}
00224
00234 virtual void drawWithNames( Viewer * ) { this->drawWithNames(); }
00238 virtual void drawWithNames() {}
00239
00251 virtual void postSelection(const QPoint& pos, Viewer* viewer);
00252
00256 int animationPeriod();
00257
00261 QString statusMessage() const;
00262
00268 void setStatusMessage(const QString& msg);
00269
00273 QList<QAction*> actions() const;
00274
00280 QAction* menuItem(const QString& text) const;
00281
00287 QAction* addMenuItem(const QString& text, QObject* receiver, const char* slot);
00288
00292 QAction* addMenuItem(const QString& text, const char* slot);
00293
00297 QAction* addMenuItem(const QString& text);
00298
00304 bool removeMenuItem(const QString& text);
00305
00312 bool removeMenuItem(const QString& text, QObject* receiver, const char* slot);
00313
00317 bool removeMenuItem(const QString& text, const char* slot);
00318
00322 void addAction(QAction *action);
00323
00327 void addActions(QList<QAction*> actions);
00328
00332 void insertAction(QAction* before, QAction* action);
00333
00337 void insertActions(QAction* before, QList<QAction*> action);
00338
00342 void removeAction(QAction* action);
00344
00346
00347
00354 virtual void initPrint() {}
00355
00363 virtual void print() {}
00364
00372 virtual void finalizePrint() {}
00373
00375
00377
00378
00382 virtual void run();
00383
00387 virtual void stop();
00388
00392 virtual void restart();
00394
00399 const QStringList& arguments() const { return _arguments; }
00400
00401
00402 QString errorString() const { return error_string; }
00403
00405
00406 void setError(bool error, QString err = QString()) { _error = error; error_string = err; }
00408
00409 public slots:
00413 void registerFile( std::string filename );
00414
00418 void unregisterFile( std::string filename );
00419
00423 void setExitCode(int code);
00424
00429 void setAnimationPeriod(int ms);
00430
00432
00433
00436 bool saveSnapshot(const QString& filename);
00437
00443 bool saveNextSnapshot();
00444
00450 bool loadSnapshot();
00451
00457 bool loadSnapshot(const QString& filename);
00459
00461
00462
00467 void screenshot(const QString &fileName, bool overwrite=false);
00469
00470 signals:
00472
00473
00476 void fileRegister( std::string );
00480 void fileUnregister( std::string );
00484 void runModel();
00488 void stopModel();
00492 void restartModel();
00496 void changedExitCode(int);
00497
00501 void menuActionInserted(QAction *before, QAction* act);
00502
00506 void menuActionRemoved(QAction* act);
00507
00514 void savingSnapshot(const QString& filename, Model*);
00515
00520 void savingNextSnapshot(bool, Model*);
00521
00525 void loadingSnapshot(bool auto_naming, Model*);
00526
00533 void loadingSnapshot(const QString& filename, Model*);
00534
00538 void savingScreenshot(const QString& filename, bool overwrite);
00539
00541
00542 private:
00543 QStringList _arguments;
00544 QList<QAction*> _actions;
00545 bool _error;
00546 QString error_string;
00547 };
00548
00549 #endif // VVMODEL_H
00550