/home/enzo/treballs/fib/pfc/nanocomp/src/layoutCanvas.hpp

Go to the documentation of this file.
00001 /*
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   This program is distributed in the hope that it will be useful,       *
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00011  *   GNU General Public License for more details.                          *
00012  *                                                                         *
00013  *   You should have received a copy of the GNU General Public License     *
00014  *   along with this program; if not, write to the                         *
00015  *   Free Software Foundation, Inc.,                                       *
00016  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00017                                                                           */
00018 
00030 #ifndef _LAYOUTCANVAS_H_
00031 #define _LAYOUTCANVAS_H_
00032 
00033 #include <wx/wx.h>
00034 #include "grid.hpp"
00035 #include <vector>
00036 
00038 
00039 struct coordinate
00040 {
00041     int x; 
00042     int y; 
00043 };
00044 
00045 using namespace std;
00046 
00047 class LayoutCanvas : public wxWindow
00048 {
00049 public:
00050     LayoutCanvas(wxWindow *parent, wxWindowID id, Grid initialLayout);
00051     ~LayoutCanvas();
00052     void setCellSize(int newCellSize);
00053     void setFittingCellSize();
00054     void drawScene();
00055     void setGrid(Grid newGrid, bool changed);
00056     void setVisible(bool enableds, bool disableds, bool inputs, bool outputs, bool spaces);
00057     void setAssignedInputs(vector<coordinate> inputs);
00058     void setAssignedOutputs(vector<coordinate> outputs);
00059 
00060 private:
00061     DECLARE_EVENT_TABLE()
00062     void OnPaint(wxPaintEvent& WXUNUSED(event));
00063     void OnLeftDown(wxMouseEvent& event);
00064     void OnScroll(wxScrollWinEvent& event);
00065     void OnTimer(wxTimerEvent& event);
00066     void adjustScrollbars();
00067     void adjustCenter();
00068     void drawMargins(wxDC &dc);
00069     void drawGrid(wxDC &dc);
00070     void drawCells(wxDC &dc);
00071     void drawIO(wxDC &dc);
00072     void drawNumber(int i, int j, int number, wxDC &dc);
00073     void OnResize(wxSizeEvent& event);
00074     coordinate viewToReal(coordinate view);
00075     coordinate realToView(coordinate real);
00076     void drawCell(int i, int j, wxColour color, wxDC &dc);
00077     void clear(wxDC &dc);
00078     void initTransitions();
00079     void resetTransitions(int value);
00080     wxColour calculateColour(wxColour initial, wxColour final, int percent);
00082     int width;
00084     int height;
00086     int centerX;
00088     int centerY;
00090     int cellSize;
00092     int scrollX;
00094     int scrollY;
00096     bool inputs;
00098     bool outputs;
00100     bool enableds;
00102     bool disableds;
00104     bool spaces;
00106     Grid layout;
00108     Grid previous;
00110 
00115     matrix transitions;
00117     wxTimer chrono;
00119     vector<coordinate> assignedInputs;
00121     vector<coordinate> assignedOutputs;
00123     bool transition;
00124 };
00125 
00135 class LayoutCanvasEvent: public wxNotifyEvent
00136 {
00137 public:
00138     LayoutCanvasEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
00139 
00140     int getX();
00141     int getY();
00142     void setX(int y);
00143     void setY(int y);
00144 
00145 private:
00147     int x;
00149     int y;
00150 };
00151 
00152 BEGIN_DECLARE_EVENT_TYPES()
00153     DECLARE_EVENT_TYPE(LAYOUT_CANVAS_ACTION, -1)
00154 END_DECLARE_EVENT_TYPES()
00155 
00156 typedef void (wxEvtHandler::*LayoutCanvasEventFunction)(LayoutCanvasEvent&);
00157 
00158 #define EVT_LAYOUT_CANVAS(id, fn) \
00159     DECLARE_EVENT_TABLE_ENTRY( LAYOUT_CANVAS_ACTION, id, -1, \
00160     (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) \
00161     wxStaticCastEvent( LayoutCanvasEventFunction, & fn ), (wxObject *) NULL ),
00162     
00163 #endif

Generated on Fri Sep 1 23:55:14 2006 for NanoComp by  doxygen 1.4.6