18 #include "ui_mainwindow.h" 20 using namespace se2ez;
31 connect(
ui_->xSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
updateOriginX(
double)));
32 connect(
ui_->ySpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
updateOriginY(
double)));
33 connect(
ui_->zoomSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
updateScale(
double)));
34 connect(
ui_->grid, SIGNAL(stateChanged(
int)),
this, SLOT(
updateState()));
36 connect(
ui_->record, SIGNAL(clicked()),
this, SLOT(
record()));
37 connect(
ui_->screenshot, SIGNAL(clicked()),
this, SLOT(
screenshot()));
39 QTimer::singleShot(1. /
ui_->fps->value() * 1000,
this, SLOT(
process()));
46 for (
const auto &panel : *
panels_)
47 panel.second->update(
last_, now);
75 QTimer::singleShot(1. /
ui_->fps->value() * 1000,
this, SLOT(
process()));
92 QWidget::resizeEvent(e);
97 ui_->tabWidget->addTab(panel, panel->
name);
102 connect(panel, SIGNAL(stateChanged()),
this, SLOT(
updateState()));
136 for (
int i =
ui_->tabWidget->count() - 1; i >= 0; --i)
138 const std::string &name =
ui_->tabWidget->tabText(i).toStdString();
139 panels_->find(name)->second->draw(painter, canvas);
145 const std::string &name =
ui_->tabWidget->tabText(
ui_->tabWidget->currentIndex()).toUtf8().constData();
147 if (it !=
panels_->end() && it->second->click(event, x, y, sx, sy))
150 for (
int i = 0; i <
ui_->tabWidget->count(); ++i)
152 const std::string &name =
ui_->tabWidget->tabText(i).toUtf8().constData();
155 if (it !=
panels_->end() && it->second->click(event, x, y, sx, sy))
165 ui_->record->setText(QString(
"Recording..."));
166 ui_->record->setDown(
true);
179 ui_->record->setText(QString(
"Record"));
180 ui_->record->setDown(
false);
192 log::format(
"ffmpeg -framerate %2% -i \"%1%/%%08d.png\" " 193 "-pix_fmt rgb24 -c:v qtrle \"%1%/%1%.mov\"",
197 log::format(
"ffmpeg -i \"%1%/%1%.mov\" -c:v libx264 -preset slow -crf 22 \"%1%/%1%.mkv\"",
void updateScale(double scale)
Slot called when the scale is updated.
void createDirectory(const std::string &dir)
Creates a directory.
The main widget that acts a container for other widgets (canvas, panels). It also delegates the drawi...
boost::posix_time::ptime last_
RenderArea * canvas_
The canvas widget.
~MainWindow()
Destructor Nothing intresting for now.
void setOriginY(double y)
void setScale(double scale)
void addPanel(Panel *panel)
Adds a panel to the main GUI.
MainWindow(QWidget *parent=nullptr)
Constructor. Nothing intresting for now.
#define SE2EZ_INFORM(fmt,...)
void updateOriginY(double y)
Slot called when the origin is updated.
void draw(QPainter &painter, RenderArea *canvas)
Asks all the panels to draw their respective information.
void takeScreenshot(const std::string &file)
Ui::MainWindow * ui_
UI (User Interface) pointer.
void updateOriginX(double x)
Slot called when the origin is updated.
boost::posix_time::ptime getDate()
Get the current time (up to milliseconds)
unsigned int shotnum_
Number of screenshots taken.
void setOriginX(double x)
std::string format(const std::string &fmt, Args &&... args)
void updateState()
calls the update function from canvas to draw the updated state
void paint(bool force=false)
void resizeEvent(QResizeEvent *e) override
The canvas widget. It contains all the drawing functions as well as all the general settings for draw...
const std::string runCommand(const std::string &cmd)
Runs a command cmd and returns stdout as a string.
std::thread * camera_
Thread used to record the camera.
const std::string resolvePath(const std::string &path)
Resolves file paths to their canonical form.
virtual void initialize(MainWindow::PanelMapPtr p)
void click(QMouseEvent *event, double x, double y, int sx, int sy)
Asks the top panel to click at the location.
PanelMapPtr panels_
Holds the panels.
std::string directory_
Directory to save screenshots/videos.