Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give PixyMon a graphical editor for color signatures. #24

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/host/pixymon/icons/sigedit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions src/host/pixymon/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "flash.h"
#include "ui_mainwindow.h"
#include "configdialog.h"
#include "sigeditdialog.h"
#include "dataexport.h"
#include "sleeper.h"
#include "aboutdialog.h"
Expand Down Expand Up @@ -60,6 +61,7 @@ MainWindow::MainWindow(int argc, char *argv[], QWidget *parent) :
m_pixyConnected = false;
m_pixyDFUConnected = false;
m_configDialog = NULL;
m_sigEditDialog = NULL;
m_fwInstructions = NULL;
m_fwMessage = NULL;
m_versionIncompatibility = false;
Expand Down Expand Up @@ -87,6 +89,9 @@ MainWindow::MainWindow(int argc, char *argv[], QWidget *parent) :
m_ui->actionConfigure->setIcon(QIcon(":/icons/icons/config.png"));
m_ui->toolBar->addAction(m_ui->actionConfigure);

m_ui->actionEdit_Signatures->setIcon(QIcon(":/icons/icons/sigedit.png"));
m_ui->toolBar->addAction(m_ui->actionEdit_Signatures);

updateButtons();

m_parameters.add("Pixy start command", PT_STRING, "runprogArg 8 1",
Expand Down Expand Up @@ -153,6 +158,7 @@ void MainWindow::updateButtons()
m_ui->actionRaw_video->setEnabled(false);
m_ui->actionCooked_video->setEnabled(false);
m_ui->actionConfigure->setEnabled(false);
m_ui->actionEdit_Signatures->setEnabled(false);
m_ui->actionLoad_Pixy_parameters->setEnabled(false);
m_ui->actionSave_Pixy_parameters->setEnabled(false);
m_ui->actionSave_Image->setEnabled(false);
Expand All @@ -165,6 +171,7 @@ void MainWindow::updateButtons()
m_ui->actionRaw_video->setEnabled(false);
m_ui->actionCooked_video->setEnabled(false);
m_ui->actionConfigure->setEnabled(true);
m_ui->actionEdit_Signatures->setEnabled(true);
m_ui->actionLoad_Pixy_parameters->setEnabled(true);
m_ui->actionSave_Pixy_parameters->setEnabled(true);
m_ui->actionSave_Image->setEnabled(true);
Expand All @@ -177,6 +184,7 @@ void MainWindow::updateButtons()
m_ui->actionRaw_video->setEnabled(true);
m_ui->actionCooked_video->setEnabled(true);
m_ui->actionConfigure->setEnabled(true);
m_ui->actionEdit_Signatures->setEnabled(true);
m_ui->actionLoad_Pixy_parameters->setEnabled(true);
m_ui->actionSave_Pixy_parameters->setEnabled(true);
m_ui->actionSave_Image->setEnabled(true);
Expand All @@ -189,6 +197,7 @@ void MainWindow::updateButtons()
m_ui->actionRaw_video->setEnabled(true);
m_ui->actionCooked_video->setEnabled(true);
m_ui->actionConfigure->setEnabled(true);
m_ui->actionEdit_Signatures->setEnabled(true);
m_ui->actionLoad_Pixy_parameters->setEnabled(true);
m_ui->actionSave_Pixy_parameters->setEnabled(true);
m_ui->actionSave_Image->setEnabled(true);
Expand All @@ -201,6 +210,7 @@ void MainWindow::updateButtons()
m_ui->actionRaw_video->setEnabled(false);
m_ui->actionCooked_video->setEnabled(false);
m_ui->actionConfigure->setEnabled(false);
m_ui->actionEdit_Signatures->setEnabled(false);
m_ui->actionLoad_Pixy_parameters->setEnabled(false);
m_ui->actionSave_Pixy_parameters->setEnabled(false);
m_ui->actionSave_Image->setEnabled(false);
Expand All @@ -209,6 +219,9 @@ void MainWindow::updateButtons()

if (m_configDialog)
m_ui->actionConfigure->setEnabled(false);

if (m_sigEditDialog)
m_ui->actionEdit_Signatures->setEnabled(false);
}

void MainWindow::close()
Expand All @@ -224,6 +237,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
m_configDialog->close();
m_configDialog = NULL;
}
if (m_sigEditDialog)
{
m_sigEditDialog->close();
m_sigEditDialog = NULL;
}
if (m_interpreter)
{
m_waiting = WAIT_EXITTING;
Expand All @@ -243,6 +261,11 @@ void MainWindow::handleRunState(int state)
m_configDialog->close();
m_configDialog = NULL;
}
if (m_sigEditDialog)
{
m_sigEditDialog->close();
m_sigEditDialog = NULL;
}
DBG("closing interpreter");
m_interpreter->close();
}
Expand Down Expand Up @@ -415,6 +438,11 @@ void MainWindow::handleConnected(Device device, bool state)
m_configDialog->close();
m_configDialog = NULL;
}
if (m_sigEditDialog)
{
m_sigEditDialog->close();
m_sigEditDialog = NULL;
}

// reset versionIncompatibility because we've unplugged, so we'll try again
if (device==NONE && !state && m_versionIncompatibility)
Expand Down Expand Up @@ -446,6 +474,15 @@ void MainWindow::handleConfigDialogFinished()
}
}

void MainWindow::handleSigEditDialogFinished()
{
if (m_sigEditDialog)
{
m_sigEditDialog = NULL;
updateButtons();
}
}

void MainWindow::on_actionAbout_triggered()
{
AboutDialog *about;
Expand Down Expand Up @@ -534,6 +571,17 @@ void MainWindow::on_actionConfigure_triggered()
}
}

void MainWindow::on_actionEdit_Signatures_triggered()
{
if (m_interpreter)
{
m_sigEditDialog = new SigEditDialog(this, m_interpreter);
connect(m_sigEditDialog, SIGNAL(finished(int)), this, SLOT(handleSigEditDialogFinished()));
m_sigEditDialog->setAttribute(Qt::WA_DeleteOnClose);
updateButtons();
}
}

void MainWindow::on_actionRaw_video_triggered()
{
if (m_interpreter)
Expand Down Expand Up @@ -690,6 +738,11 @@ void MainWindow::on_actionExit_triggered()
m_configDialog->close();
m_configDialog = NULL;
}
if (m_sigEditDialog)
{
m_sigEditDialog->close();
m_sigEditDialog = NULL;
}
if (m_interpreter)
{
m_waiting = WAIT_EXITTING;
Expand Down
4 changes: 4 additions & 0 deletions src/host/pixymon/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Interpreter;
class Flash;
class ConnectEvent;
class ConfigDialog;
class SigEditDialog;
class QSettings;
class QMessageBox;

Expand All @@ -56,12 +57,14 @@ private slots:
void handleActionScriptlet(QString action, QStringList scriptlet);
void handleLoadParams();
void handleConfigDialogFinished();
void handleSigEditDialogFinished();
void interpreterFinished();
void handleVersion(ushort major, ushort minor, ushort build, QString type);
void on_actionAbout_triggered();
void on_actionPlay_Pause_triggered();
void on_actionDefault_program_triggered();
void on_actionConfigure_triggered();
void on_actionEdit_Signatures_triggered();
void on_actionHelp_triggered();
void on_actionSave_Image_triggered();
void on_actionSave_Pixy_parameters_triggered();
Expand Down Expand Up @@ -94,6 +97,7 @@ private slots:
ConnectEvent *m_connect;
Flash *m_flash;
ConfigDialog *m_configDialog;
SigEditDialog *m_sigEditDialog;
std::vector<QAction *> m_actions;
Ui::MainWindow *m_ui;

Expand Down
11 changes: 10 additions & 1 deletion src/host/pixymon/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
<x>0</x>
<y>0</y>
<width>677</width>
<height>21</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionConfigure"/>
<addaction name="actionEdit_Signatures"/>
<addaction name="actionSave_Pixy_parameters"/>
<addaction name="actionLoad_Pixy_parameters"/>
<addaction name="actionSave_Image"/>
Expand Down Expand Up @@ -149,6 +150,14 @@
<string>Load Pixy parameters...</string>
</property>
</action>
<action name="actionEdit_Signatures">
<property name="text">
<string>Edit Signatures...</string>
</property>
<property name="toolTip">
<string>Edit color signatures</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
Expand Down
9 changes: 6 additions & 3 deletions src/host/pixymon/pixymon.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ SOURCES += main.cpp\
monparameterdb.cpp \
cccmodule.cpp \
debug.cpp \
blobs2.cpp
blobs2.cpp \
sigeditdialog.cpp

HEADERS += mainwindow.h \
videowidget.h \
Expand Down Expand Up @@ -78,15 +79,17 @@ HEADERS += mainwindow.h \
monparameterdb.h \
cccmodule.h \
debug.h \
blobs2.h
blobs2.h \
sigeditdialog.h

INCLUDEPATH += ../../common/inc

QMAKE_CXXFLAGS_DEBUG += -O0
QMAKE_CXXFLAGS += -Wno-unused-parameter
FORMS += mainwindow.ui \
configdialog.ui \
about.ui
about.ui \
sigeditdialog.ui

# LIBS += ./libusb-1.0.dll.a

Expand Down
1 change: 1 addition & 0 deletions src/host/pixymon/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<file>icons/cooked.png</file>
<file>icons/pixy.png</file>
<file>icons/home.png</file>
<file>icons/sigedit.png</file>
</qresource>
</RCC>
Loading