Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gui.hpp

Go to the documentation of this file.
00001 #ifndef _GUI_HPP
00002 #define _GUI_HPP
00003 
00004 #include "geometry.hpp"
00005 #include "coloring.hpp"
00006 #include "arak.hpp"
00007 #include "estimation.hpp"
00008 
00009 #include <qapplication.h>
00010 #include <CGAL/IO/Qt_widget.h>
00011 #include <CGAL/IO/Qt_widget_layer.h>
00012 #include <qmainwindow.h>
00013 #include <qtimer.h>
00014 #include <qmutex.h>
00015 #include <qlabel.h>
00016 
00025 inline CGAL::Qt_widget& operator<<(CGAL::Qt_widget& widget, 
00026            Arak::Geometry::Polygon& poly) {
00027   assert(poly.is_convex()); // TODO: if polygon is non-convex, first
00028           // partition it into convex polygons using
00029           // CGAL::approx_convex_partition_2.
00030   int n = poly.size();
00031   if (n == 1)
00032     widget << poly[0];
00033   else if (n == 2)
00034     widget << *(poly.edges_begin());
00035   else if (n > 2) {
00036     const Arak::Geometry::Point p = poly[0];
00037     const Arak::Geometry::Point q = poly[1];
00038     for (int i = 2; i < n; i++)
00039       widget << Arak::Geometry::Triangle(poly[0], poly[i - 1], poly[i]);
00040   }
00041   return widget;
00042 }
00043 
00044 namespace Arak {
00045 
00046 
00047   enum VizType {
00048     PROC_AND_BD = 0,
00049     COLORING,
00050     PT_COL_EST_AND_BD,
00051     QUERY_PTS_AND_BD
00052   };
00053 
00054   QApplication* InitGui(int argc, 
00055       char** argv, 
00056       int width, 
00057       int height, 
00058       Coloring& c,
00059       ArakProcess& p,
00060       GridColorEstimator& e,
00061       QMutex& mutex,
00062       bool toolbar = true,
00063       double refreshRateHz = 2.0);
00064 
00065   class ColoringQTLayer : public CGAL::Qt_widget_layer {
00066     friend class ColoringQTWidget;
00067   protected:
00068     Coloring& c;
00069     ArakProcess& p;
00070     GridColorEstimator& e;
00071     QMutex& mutex;
00072     VizType curType;
00073   public:
00074     ColoringQTLayer(Coloring& c, 
00075         ArakProcess& p, 
00076         GridColorEstimator& e, 
00077         QMutex& mutex);
00078     void draw();
00079   };
00080 
00081   class ColoringQTWidget : public CGAL::Qt_widget {
00082     Q_OBJECT
00083   protected:
00084     QMainWindow* win;
00085     ColoringQTLayer* layer;
00086     QTimer* timer;
00087   private slots:
00088     void timeout();
00089   public:
00090     ColoringQTWidget(QMainWindow& win, 
00091          ColoringQTLayer& layer, 
00092          double refreshRateHz = 2.0);
00093     void mousePressEvent(QMouseEvent *e);
00094   };
00095 }
00096 
00097 #endif

Generated on Wed May 25 14:39:17 2005 for Arak by doxygen 1.3.6