gui_scene.hpp

Idź do dokumentacji tego pliku.
00001 #ifndef __GUI_SCENE_HPP__
00002 #define __GUI_SCENE_HPP__
00003 
00004 #include <iostream>
00005 #include <fstream>
00006 #include <QWidget>
00007 #include <QPolygonF>
00008 #include <QRectF>
00009 #include <QVector>
00010 #include <QImage>
00011 #include <QTextStream>
00012 #include <QGraphicsView>
00013 #include <vector>
00014 #include <QGridLayout>
00015 #include <QSpinBox>
00016 #include <QPushButton>
00017 #include <QLabel>
00018 #include <QDialog>
00019 #include <QMouseEvent>
00020 #include <QPoint>
00021 #include <QComboBox>
00022 #include "gui_animal.hpp"
00023 #include "obstacle.hpp"
00024 #include "vector2D.hpp"
00025 
00026 
00027 class GUI_Scene : public QGraphicsView {
00028   Q_OBJECT
00029         
00030         
00031 public:
00032         enum mode{NONE, ADDOBSTACLE, ADDANIMAL, REMOVE};
00033 
00034         GUI_Scene(QWidget *parent = 0, qreal w=500, qreal h=500);
00035         ~GUI_Scene();
00036 
00037         
00038         void setEditMode(mode);
00039         
00043         QWidget* getParamBox();
00044         
00045         vector<GUI_Animal*> getAnimals() const;
00046         
00047         GUI_Animal* getCurrAnimal() ;
00048         
00049         void addToFile(ostream &F);
00050         
00051         
00055         void addAnimal(const Vector2D &origin = Vector2D(0,0));
00056         
00057         
00058         friend ostream& operator<< (ostream &Strm, const GUI_Scene &scene);
00059         friend ostream& operator<< (ostream &Strm, const vector<GUI_Animal*> &anim);
00060         friend istream & operator>> (istream &Strm, GUI_Scene &scene);
00061 
00062 signals:
00063         void changed();
00064         
00065   protected:
00066           mode _currMode;
00067   
00068     void drawBackground(QPainter *, const QRectF &);
00069 
00073         bool isSelectedAnimal(QPoint point);
00074   
00075     virtual void mouseDoubleClickEvent(QMouseEvent *);
00076 
00080         virtual void mousePressEvent(QMouseEvent *);
00081   
00082     virtual void mouseMoveEvent(QMouseEvent *);
00083     virtual void mouseReleaseEvent(QMouseEvent *);
00084     virtual void keyPressEvent(QKeyEvent *);
00085 
00086     void createPotentialMap();
00087     void clearPolygon();
00088     bool selectSheep(QPoint);
00089   
00090         vector<GUI_Animal*> _animals; //< zwierzeta umieszczone na scenie */
00091         vector<Obstacle> _obstacle; //< przeszkody umieszczone na scenie */
00092   
00093     qreal _width; //< szerokosc sceny [m] */
00094     qreal _height; //< wysokosc sceny [m] */
00095     qreal _scale; //< skala, ile px to 1m,  px -> m */
00096   
00097   private:
00098     QImage image;
00099   
00100         QWidget *_paramBox; //< wskazuje na okienko parametrow dla biezacego/wybranego elementu */
00101         GUI_Animal *_currAnimal;  //< biezacy zwierzak, jesli -1, to zwierzak nie zostal wybrany */
00102         int _currObstacle; //< biezaca przeszkoda, jesli -1 to nie zostala wybrana */
00103         
00104   
00105     bool potentialMap;
00106     bool antiAliased;
00107 
00108     //QPolygonF newObstacle;
00109     QGraphicsPolygonItem *newObstacle;
00110 //    SimSheep *selectedSheep;
00111   
00115         void getParamBoxAnimal(QWidget *widget);
00116   
00117 
00118 };
00119 
00120 ostream& operator<< (ostream &Strm, const GUI_Scene &scene);
00121 ostream& operator<< (ostream &Strm, const vector<GUI_Animal*> &anim);
00122 istream & operator>> (istream &Strm, GUI_Scene &scene);
00123 
00124 
00125 #endif
00126 

Wygenerowano Tue Jan 22 12:58:54 2008 dla Zwierzaki programem  doxygen 1.5.2