Webcam Tracker  V1.0
Using openCV and an Arduino Uno
Public Member Functions | Private Attributes | List of all members

Menu like structure with clickable buttons. Member of GUI classes Graphic group. More...

#include <Menu.h>

Public Member Functions

 Menu ()
 Default constructor.
 
 Menu (cv::Size size)
 Constructor. More...
 
void addButton (cv::Point startPoint, int height, cv::String text)
 Adds a button to the menu. More...
 
cv::Mat draw ()
 Draws all buttons to the image. More...
 
void checkClicks (int x, int y)
 Checks if a mouse-click event happened inside on of the menubuttons. More...
 
vector< Button > * getButtons ()
 Gets the buttons. More...
 

Private Attributes

cv::Mat img
 Image matrix of the menu.
 
vector< Buttonbuttons
 Vector holding all buttons.
 

Detailed Description

Menu like structure with clickable buttons. Member of GUI classes Graphic group.

Constructor & Destructor Documentation

◆ Menu()

Menu::Menu ( cv::Size  size)

Constructor.

Parameters
sizeHeight and width of the menu
17 {
18  img = Mat::zeros(size, CV_8UC3);
19  rectangle(img, Point(0, 0), size, Scalar(182, 182, 182), -1);
20 
21 };
cv::Mat img
Image matrix of the menu.
Definition: Menu.h:25

Member Function Documentation

◆ addButton()

void Menu::addButton ( cv::Point  startPoint,
int  height,
cv::String  text 
)

Adds a button to the menu.

calls the Button constructor and pushes it to the button vector

Parameters
startPointX and Y coordinate of the topleft corner in pixels
heightHeight of the button in pixels
textButton text
23  {
24  buttons.push_back(Button(startPoint, height, text));
25 }
A button that can be clicked. Member of GUI classes Graphic group.
Definition: Button.h:19
vector< Button > buttons
Vector holding all buttons.
Definition: Menu.h:26

◆ draw()

Mat Menu::draw ( )

Draws all buttons to the image.

uses a iterating for loop.

Returns
the image matrix
27  {
28 
29  vector<Button>::iterator it;
30  for (it = buttons.begin(); it != buttons.end(); it++)
31  {
32  it->draw(&img);
33  }
34 
35  return img;
36 }

◆ checkClicks()

void Menu::checkClicks ( int  x,
int  y 
)

Checks if a mouse-click event happened inside on of the menubuttons.

Parameters
xX-part of the mouse event Coordinate
yY-part of the mouse event Coordinate
38  {
39 
40  vector<Button>::iterator it;
41  for (it = buttons.begin(); it != buttons.end(); it++)
42  {
43  it->checkClick(x, y);
44  }
45 
46 }

◆ getButtons()

vector< Button > * Menu::getButtons ( )

Gets the buttons.

Returns
Pointer to the vector holding all menu buttons.
48  {
49  return &buttons;
50 }