#include <layoutCanvas.hpp>
Collaboration diagram for LayoutCanvas:
Public Member Functions | |
LayoutCanvas (wxWindow *parent, wxWindowID id, Grid initialLayout) | |
Constructor. | |
~LayoutCanvas () | |
Destructor. | |
void | setCellSize (int newCellSize) |
Member setting. | |
void | setFittingCellSize () |
Calculates the optimal cell size for the window size. | |
void | drawScene () |
The grid is drawn in this method. | |
void | setGrid (Grid newGrid, bool changed) |
Sets the grid to be painted. | |
void | setVisible (bool enableds, bool disableds, bool inputs, bool outputs, bool spaces) |
Sets the cell status that have to be drawn. | |
void | setAssignedInputs (vector< coordinate > inputs) |
Sets the coordinates of the assigned inputs. | |
void | setAssignedOutputs (vector< coordinate > outputs) |
Sets the coordinates of the assigned outputs. | |
Private Member Functions | |
void | OnPaint (wxPaintEvent &WXUNUSED(event)) |
Paint event. | |
void | OnLeftDown (wxMouseEvent &event) |
Left button mouse click event. | |
void | OnScroll (wxScrollWinEvent &event) |
Scrollbar change method. | |
void | OnTimer (wxTimerEvent &event) |
Timer event method. | |
void | adjustScrollbars () |
Sets the scrollbars of the window. | |
void | adjustCenter () |
Calculates the top/left of the painting. | |
void | drawMargins (wxDC &dc) |
Draws the margins of the grid. | |
void | drawGrid (wxDC &dc) |
Draws the grid points. | |
void | drawCells (wxDC &dc) |
Draws the cells of the grid. | |
void | drawIO (wxDC &dc) |
Draws the assigned inputs and outputs. | |
void | drawNumber (int i, int j, int number, wxDC &dc) |
Draws a number. | |
void | OnResize (wxSizeEvent &event) |
Resize method. | |
coordinate | viewToReal (coordinate view) |
Converts a window coordinate to a grid logical coordinate. | |
coordinate | realToView (coordinate real) |
Converts a grid logical coordinate to a window coordinate. | |
void | drawCell (int i, int j, wxColour color, wxDC &dc) |
Draws a cell. | |
void | clear (wxDC &dc) |
Erases the window. | |
void | initTransitions () |
Initializes the transition grid. | |
void | resetTransitions (int value) |
Sets all the cells of the transition grid. | |
wxColour | calculateColour (wxColour initial, wxColour final, int percent) |
Calculates an intermediate colour. | |
Private Attributes | |
int | width |
Width of the grid. | |
int | height |
Height of the grid. | |
int | centerX |
X coordinate of the centered top/left of the grid. | |
int | centerY |
Y coordinate of the centered top/left of the grid. | |
int | cellSize |
Size in pixels of the molecules to be drawn. | |
int | scrollX |
X coordinate of the widget scoll bars. | |
int | scrollY |
Y coordinate of the widget scoll bars. | |
bool | inputs |
Show inputs? | |
bool | outputs |
Show outputs? | |
bool | enableds |
Show enabled molecules? | |
bool | disableds |
Show disabled molecules? | |
bool | spaces |
Show no space molecules? | |
Grid | layout |
The grid being drawn. | |
Grid | previous |
The previous grid (used for some eye candy feature). | |
matrix | transitions |
Matrix of transition percentage. | |
wxTimer | chrono |
Timer. | |
vector< coordinate > | assignedInputs |
List of assigned inputs to be drawn as numbers. | |
vector< coordinate > | assignedOutputs |
List of assigned outputs to be drawn as numbers. | |
bool | transition |
Should we use gradient transitions? |
This class is a wxWindows widget which draws a grid on the screen. It has an event which is triggered when clicking on a cell of the grid to allow the modification of it.
Definition at line 47 of file layoutCanvas.hpp.
|
Constructor.
Definition at line 105 of file layoutCanvas.cpp. References CELL_SIZE, NUMTRANSITIONS, and TIMERINTERVAL. |
|
Destructor.
Definition at line 132 of file layoutCanvas.cpp. |
|
Calculates the top/left of the painting. The painting have to be centered if the window size is bigger than the painting size. The centered top and left coordinates are calculated here. Definition at line 278 of file layoutCanvas.cpp. References cellSize, centerX, centerY, height, and width. Referenced by adjustScrollbars(), OnResize(), setCellSize(), and setGrid(). |
|
Sets the scrollbars of the window. Because the painting can be bigger than the actual size of the window, two scrollbars are set to allow the user to navigate through all the area of the painting. Definition at line 191 of file layoutCanvas.cpp. References adjustCenter(), cellSize, drawScene(), height, and width. Referenced by OnResize(), setCellSize(), and setGrid(). Here is the call graph for this function: ![]() |
|
Calculates an intermediate colour.
Definition at line 805 of file layoutCanvas.cpp. References NUMTRANSITIONS. Referenced by drawCells(). |
|
Erases the window.
Definition at line 727 of file layoutCanvas.cpp. Referenced by drawScene(), and OnPaint(). |
|
Draws a cell.
Definition at line 353 of file layoutCanvas.cpp. References cellSize, realToView(), coordinate::x, and coordinate::y. Referenced by drawCells(). Here is the call graph for this function: ![]() |
|
Draws the cells of the grid.
Definition at line 410 of file layoutCanvas.cpp. References calculateColour(), disableds, drawCell(), enableds, Grid::getHeight(), Grid::getWidth(), inputs, layout, nDISABLED, nDONTCARE, nENABLED, nINPUT, nNOSPACE, nOUTPUT, outputs, previous, spaces, and transitions. Referenced by drawScene(), and OnPaint(). Here is the call graph for this function: ![]() |
|
Draws the grid points. Draws the grid of the grid. This is, the points of the grid but not the cells.
Definition at line 390 of file layoutCanvas.cpp. References cellSize, centerX, centerY, height, scrollX, scrollY, and width. Referenced by drawScene(), and OnPaint(). |
|
Draws the assigned inputs and outputs.
Definition at line 665 of file layoutCanvas.cpp. References assignedInputs, drawNumber(), and inputs. Referenced by drawScene(), and OnPaint(). Here is the call graph for this function: ![]() |
|
Draws the margins of the grid. Those margins are drawn around the grid when the window size is bigger than the grid painting size.
Definition at line 585 of file layoutCanvas.cpp. References cellSize, centerX, centerY, height, scrollX, scrollY, and width. Referenced by drawScene(), and OnPaint(). |
|
Draws a number.
Definition at line 708 of file layoutCanvas.cpp. References realToView(), coordinate::x, and coordinate::y. Referenced by drawIO(). Here is the call graph for this function: ![]() |
|
The grid is drawn in this method. The draw scene has been split into several draw methods. This method has to be called when anything of the grid changes to refresh the window. Definition at line 246 of file layoutCanvas.cpp. References clear(), drawCells(), drawGrid(), drawIO(), and drawMargins(). Referenced by adjustScrollbars(), OnResize(), OnScroll(), setVisible(), and LayoutView::updateCanvas(). Here is the call graph for this function: ![]() |
|
Initializes the transition grid.
Definition at line 734 of file layoutCanvas.cpp. References Grid::getHeight(), Grid::getWidth(), layout, NUMTRANSITIONS, and transitions. Referenced by setGrid(). Here is the call graph for this function: ![]() |
|
Left button mouse click event. Method called when the left button of the mouse is clicked on the window. The event is sent here if necessary.
Definition at line 159 of file layoutCanvas.cpp. References height, LayoutCanvasEvent::setX(), LayoutCanvasEvent::setY(), transition, viewToReal(), width, coordinate::x, and coordinate::y. Here is the call graph for this function: ![]() |
|
Paint event. This method is called every time the window receives a paint event. The grid must be painted here. Definition at line 142 of file layoutCanvas.cpp. References clear(), drawCells(), drawGrid(), drawIO(), and drawMargins(). Here is the call graph for this function: ![]() |
|
Resize method. This method is called on the window resize events. The grid is redrawn.
Definition at line 264 of file layoutCanvas.cpp. References adjustCenter(), adjustScrollbars(), and drawScene(). Here is the call graph for this function: ![]() |
|
Scrollbar change method. Method called when the user uses the scrollbars. Some painting variables are updated and the window is repainted to show the scrolled zone.
Definition at line 216 of file layoutCanvas.cpp. References drawScene(), scrollX, and scrollY. Here is the call graph for this function: ![]() |
|
Timer event method. Method called on every timer event. The transition grid is refreshed in this method.
Definition at line 754 of file layoutCanvas.cpp. References NUMTRANSITIONS, and transitions. |
|
Converts a grid logical coordinate to a window coordinate.
Definition at line 336 of file layoutCanvas.cpp. References cellSize, centerX, centerY, scrollX, scrollY, coordinate::x, and coordinate::y. Referenced by drawCell(), and drawNumber(). |
|
Sets all the cells of the transition grid.
Definition at line 784 of file layoutCanvas.cpp. References Grid::getHeight(), layout, and transitions. Referenced by setGrid(). Here is the call graph for this function: ![]() |
|
Sets the coordinates of the assigned inputs. The input cells that have been assigned must be painted in a different way, this method is used to set the coordinates of the assigned inputs.
Definition at line 640 of file layoutCanvas.cpp. References assignedInputs. Referenced by ResultsView::setInputs(), and LayoutView::updateInputs(). |
|
Sets the coordinates of the assigned outputs. The output cells that have been assigned must be painted in a different way, this method is used to set the coordinates of the assigned outputs.
Definition at line 655 of file layoutCanvas.cpp. References assignedOutputs. Referenced by ResultsView::setOutputs(), and LayoutView::updateOutputs(). |
|
Member setting. Sets the size (in pixels) of the cells.
Definition at line 373 of file layoutCanvas.cpp. References adjustCenter(), adjustScrollbars(), and cellSize. Referenced by setFittingCellSize(). Here is the call graph for this function: ![]() |
|
Calculates the optimal cell size for the window size. This method calculates the maximum cell size that can be used to allow all the grid to be painted in the window, without having to use scrollbars. Definition at line 528 of file layoutCanvas.cpp. References height, setCellSize(), and width. Here is the call graph for this function: ![]() |
|
Sets the grid to be painted.
Definition at line 551 of file layoutCanvas.cpp. References adjustCenter(), adjustScrollbars(), chrono, Grid::getHeight(), Grid::getWidth(), height, Grid::init(), initTransitions(), layout, previous, resetTransitions(), TIMERINTERVAL, and width. Referenced by SimulationView::setGrid(), ResultsView::updateGrid(), RuleView::updateGrids(), LayoutView::updateGrids(), ForbiddenPatternView::updateGrids(), and ResultsView::updateInitialGrid(). Here is the call graph for this function: ![]() |
|
Sets the cell status that have to be drawn. The cell status which it's wanted to be painted can be customized. This way we can paint only inputs and outputs, for example.
Definition at line 620 of file layoutCanvas.cpp. References drawScene(). Referenced by LayoutView::OnAssignInput(), LayoutView::OnAssignOutput(), and LayoutView::onlyAssign(). Here is the call graph for this function: ![]() |
|
Converts a window coordinate to a grid logical coordinate.
Definition at line 310 of file layoutCanvas.cpp. References cellSize, centerX, centerY, height, scrollX, scrollY, width, coordinate::x, and coordinate::y. Referenced by OnLeftDown(). |
|
List of assigned inputs to be drawn as numbers.
Definition at line 119 of file layoutCanvas.hpp. Referenced by drawIO(), and setAssignedInputs(). |
|
List of assigned outputs to be drawn as numbers.
Definition at line 121 of file layoutCanvas.hpp. Referenced by setAssignedOutputs(). |
|
Size in pixels of the molecules to be drawn.
Definition at line 90 of file layoutCanvas.hpp. Referenced by adjustCenter(), adjustScrollbars(), drawCell(), drawGrid(), drawMargins(), realToView(), setCellSize(), and viewToReal(). |
|
X coordinate of the centered top/left of the grid.
Definition at line 86 of file layoutCanvas.hpp. Referenced by adjustCenter(), drawGrid(), drawMargins(), realToView(), and viewToReal(). |
|
Y coordinate of the centered top/left of the grid.
Definition at line 88 of file layoutCanvas.hpp. Referenced by adjustCenter(), drawGrid(), drawMargins(), realToView(), and viewToReal(). |
|
Timer.
Definition at line 117 of file layoutCanvas.hpp. Referenced by setGrid(). |
|
Show disabled molecules?
Definition at line 102 of file layoutCanvas.hpp. Referenced by drawCells(). |
|
Show enabled molecules?
Definition at line 100 of file layoutCanvas.hpp. Referenced by drawCells(). |
|
Height of the grid.
Definition at line 84 of file layoutCanvas.hpp. Referenced by adjustCenter(), adjustScrollbars(), drawGrid(), drawMargins(), OnLeftDown(), setFittingCellSize(), setGrid(), and viewToReal(). |
|
Show inputs?
Definition at line 96 of file layoutCanvas.hpp. Referenced by drawCells(), and drawIO(). |
|
The grid being drawn.
Definition at line 106 of file layoutCanvas.hpp. Referenced by drawCells(), initTransitions(), resetTransitions(), and setGrid(). |
|
Show outputs?
Definition at line 98 of file layoutCanvas.hpp. Referenced by drawCells(). |
|
The previous grid (used for some eye candy feature).
Definition at line 108 of file layoutCanvas.hpp. Referenced by drawCells(), and setGrid(). |
|
X coordinate of the widget scoll bars.
Definition at line 92 of file layoutCanvas.hpp. Referenced by drawGrid(), drawMargins(), OnScroll(), realToView(), and viewToReal(). |
|
Y coordinate of the widget scoll bars.
Definition at line 94 of file layoutCanvas.hpp. Referenced by drawGrid(), drawMargins(), OnScroll(), realToView(), and viewToReal(). |
|
Show no space molecules?
Definition at line 104 of file layoutCanvas.hpp. Referenced by drawCells(). |
|
Should we use gradient transitions?
Definition at line 123 of file layoutCanvas.hpp. Referenced by OnLeftDown(). |
|
Matrix of transition percentage. This matrix is the grandient percentage to be drawn between the actual grid and the previous one. Is used to draw the molecules in a gradient way to make it more eye candy to the user. Definition at line 115 of file layoutCanvas.hpp. Referenced by drawCells(), initTransitions(), OnTimer(), and resetTransitions(). |
|
Width of the grid.
Definition at line 82 of file layoutCanvas.hpp. Referenced by adjustCenter(), adjustScrollbars(), drawGrid(), drawMargins(), OnLeftDown(), setFittingCellSize(), setGrid(), and viewToReal(). |