You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
275 lines
9.5 KiB
275 lines
9.5 KiB
#include "main_window.h"
|
|
|
|
mainWinow* mainWinow::_instance = 0;
|
|
|
|
void mainWinow::changeEvent(QEvent *event){
|
|
if(event->type() == QEvent::WindowStateChange ){
|
|
if (!isMinimized()) {
|
|
setAttribute(Qt::WA_Mapped);
|
|
};
|
|
};
|
|
};
|
|
|
|
mainWinow::mainWinow() : QMainWindow(){
|
|
m_pSettings = basicSettingsProvider::getInstance()->getSubNode(NULL, (CSTR)"APPLICATION_GUI");
|
|
m_pFactory = cortexLayersFactory::getInstance();
|
|
m_pCortex = NULL;
|
|
m_bChangesAreSaved = true;
|
|
m_pMainWidget = new QWidget( NULL );
|
|
m_pMainWidget->setObjectName("m_pMainWidget");
|
|
setCentralWidget( m_pMainWidget );
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
|
layout->setContentsMargins(5, 5, 5, 5);
|
|
|
|
//m_pMainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
m_pLayerTable = new QTableWidget( this );
|
|
m_pLayerTable->setColumnCount( 5 );
|
|
m_pLayerTable->setSortingEnabled( false );
|
|
m_pLayerTable->setSelectionMode( QAbstractItemView::SingleSelection );
|
|
m_pLayerTable->setSelectionBehavior( QAbstractItemView::SelectRows );
|
|
m_pLayerTable->setGridStyle( Qt::DashLine );
|
|
m_pLayerTable->setCornerButtonEnabled( true );
|
|
layout->addWidget(m_pLayerTable);
|
|
|
|
QTableWidgetItem* __qtablewidgetitem;
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
__qtablewidgetitem->setText("Type");
|
|
m_pLayerTable->setHorizontalHeaderItem( 0, __qtablewidgetitem );
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
__qtablewidgetitem->setText("Filter");
|
|
m_pLayerTable->setHorizontalHeaderItem( 1, __qtablewidgetitem );
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
__qtablewidgetitem->setText("FIlter Size");
|
|
m_pLayerTable->setHorizontalHeaderItem( 2, __qtablewidgetitem );
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
__qtablewidgetitem->setText("Input");
|
|
m_pLayerTable->setHorizontalHeaderItem( 3, __qtablewidgetitem );
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
__qtablewidgetitem->setText("Output");
|
|
m_pLayerTable->setHorizontalHeaderItem( 4, __qtablewidgetitem );
|
|
|
|
connect(m_pLayerTable, &QTableWidget::cellClicked, this, &mainWinow::selectLayerRow );
|
|
|
|
|
|
QHBoxLayout* hlayout = new QHBoxLayout;
|
|
hlayout->setContentsMargins(5, 5, 5, 5);
|
|
|
|
m_pTabWidget = new QTabWidget( this );
|
|
m_pTabWidget->setObjectName( "m_pTabWidget" );
|
|
|
|
m_pTabLayerVisual = new QWidget();
|
|
m_pTabLayerVisual->setObjectName("m_pTabLayerVisual");
|
|
QHBoxLayout* hlayout1 = new QHBoxLayout;
|
|
hlayout1->setContentsMargins(5, 5, 5, 5);
|
|
m_pLayerPreview = new CortexLayerWidget( m_pTabLayerVisual );
|
|
if( m_pLayerPreview->init() ){
|
|
|
|
};
|
|
hlayout1->addWidget(m_pLayerPreview);
|
|
m_pTabLayerVisual->setLayout(hlayout1);
|
|
|
|
|
|
m_pTabWidget->addTab(m_pTabLayerVisual, "Layer Visual");
|
|
|
|
m_pTabCategories = new QWidget();
|
|
m_pTabCategories->setObjectName("m_pTabCategories");
|
|
m_pTabWidget->addTab(m_pTabCategories, "Classes");
|
|
|
|
m_pTabLearning = new QWidget();
|
|
m_pTabLearning->setObjectName("m_pTabLearning");
|
|
m_pTabWidget->addTab(m_pTabLearning, "Learning");
|
|
|
|
m_pTabInput = new QWidget();
|
|
m_pTabInput->setObjectName("m_pTabInput");
|
|
QHBoxLayout* hlayout2 = new QHBoxLayout;
|
|
hlayout2->setContentsMargins(5, 5, 5, 5);
|
|
m_pInputStream = new MediaDestWidget( m_pTabInput );
|
|
if( m_pInputStream->init() ){
|
|
m_pAVLIBSource = new videoAVLIBSource();
|
|
if (m_pAVLIBSource != NULL) {
|
|
if( m_pAVLIBSource->_open("C:\\KeepVid Pro Downloaded\\The Renter.mp4") ){
|
|
m_pAVLIBSource->attachDestination(m_pInputStream);
|
|
};
|
|
};
|
|
};
|
|
hlayout2->addWidget(m_pInputStream);
|
|
m_pTabInput->setLayout(hlayout2);
|
|
|
|
m_pTabWidget->addTab(m_pTabInput, "Input");
|
|
|
|
m_pTabOutput = new QWidget();
|
|
m_pTabOutput->setObjectName("m_pTabOutput");
|
|
m_pOutputStream = new MediaDestWidget( m_pTabOutput );
|
|
m_pOutputStream->init();
|
|
|
|
m_pTabWidget->addTab(m_pTabOutput, "Output");
|
|
|
|
m_pTabProcessingUnits = new QWidget();
|
|
m_pTabProcessingUnits->setObjectName("m_pTabProcessingUnits");
|
|
m_pTabWidget->addTab(m_pTabProcessingUnits, "Processing Unit");
|
|
|
|
|
|
hlayout->addWidget(m_pTabWidget);
|
|
layout->addItem( hlayout );
|
|
|
|
m_pMainWidget->setLayout(layout);
|
|
|
|
|
|
|
|
setObjectName("Mainwindow");
|
|
/* Menu Things */
|
|
actionNew_Network = new QAction( QIcon(":/general/file.png"), "&New", this );
|
|
actionNew_Network->setShortcuts(QKeySequence::New);
|
|
actionNew_Network->setStatusTip(tr("Create a new Network"));
|
|
connect( actionNew_Network, &QAction::triggered, this, &mainWinow::newNetwork );
|
|
|
|
actionOpen = new QAction( QIcon(":/layout/PNG/layout/049.png"), "&Open", this );
|
|
actionOpen->setShortcuts(QKeySequence::Open);
|
|
actionOpen->setStatusTip(tr("Open Network Config"));
|
|
connect( actionOpen, &QAction::triggered, this, &mainWinow::open );
|
|
|
|
actionSave = new QAction( QIcon(":/layout/PNG/layout/048.png"), "&Save", this );
|
|
actionSave->setShortcuts(QKeySequence::Save);
|
|
actionSave->setStatusTip(tr("Save Network Config"));
|
|
connect(actionSave, &QAction::triggered, this, &mainWinow::save);
|
|
|
|
actionSave_As = new QAction( QIcon(":/layout/PNG/layout/048.png"), "Save &As", this );
|
|
actionSave_As->setShortcuts(QKeySequence::SaveAs);
|
|
actionSave_As->setStatusTip(tr("Save Network Config in Another File"));
|
|
connect(actionSave_As, &QAction::triggered, this, &mainWinow::saveAs);
|
|
|
|
actionExit = new QAction( QIcon(":/layout/PNG/layout/076.png"), "&Exit", this);
|
|
actionExit->setShortcuts(QKeySequence::Close);
|
|
actionExit->setStatusTip(tr("Exit Application"));
|
|
connect(actionExit, &QAction::triggered, this, &mainWinow::exitApp);
|
|
|
|
menuFile = menuBar()->addMenu(QIcon(":/menu/PNG/devices/008.png"),"&File");
|
|
menuFile->setObjectName("menuFile");
|
|
menuFile->addAction(actionNew_Network);
|
|
menuFile->addAction(actionOpen);
|
|
menuFile->addAction(actionSave);
|
|
menuFile->addAction(actionSave_As);
|
|
menuFile->addAction(actionExit);
|
|
|
|
toolBar = addToolBar("Yoba!");
|
|
toolBar->setObjectName("toolBar");
|
|
toolBar->setOrientation(Qt::Horizontal);
|
|
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
toolBar->setFloatable(true);
|
|
|
|
tbActionAdd = toolBar->addAction(QIcon(":/layout/PNG/layout/064.png"), "Add Layer");
|
|
tbActionInsert = toolBar->addAction(QIcon(":/layout/PNG/layout/067.png"), "Insert Layer");
|
|
tbActionEdit = toolBar->addAction(QIcon(":/layout/PNG/layout/073.png"), "Edit Layer");
|
|
tbActionEdit->setEnabled(false);
|
|
tbActionDelete = toolBar->addAction(QIcon(":/layout/PNG/layout/066.png"), "Delete Layer");
|
|
tbActionDelete->setEnabled(false);
|
|
toolBar->addSeparator();
|
|
tbActionLoadWeights = toolBar->addAction(QIcon(":/layout/PNG/layout/024.png"), "Load Weights");
|
|
tbActionLoadWeights->setEnabled(false);
|
|
|
|
insertToolBarBreak(toolBar);
|
|
statusBar()->showMessage("Init Done.");
|
|
|
|
setWindowTitle(tr("Neural Network Manager"));
|
|
setMinimumSize(160, 160);
|
|
};
|
|
|
|
mainWinow::~mainWinow(){
|
|
if (m_pAVLIBSource != NULL) {
|
|
m_pAVLIBSource->_stop();
|
|
delete(m_pAVLIBSource);
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Returns the single instance of the object.
|
|
*/
|
|
mainWinow* mainWinow::getInstance() {
|
|
// check if the instance has been created yet
|
|
if (0 == _instance){
|
|
// if not, then create it
|
|
_instance = new mainWinow();
|
|
};
|
|
// return the single instance
|
|
return _instance;
|
|
};
|
|
|
|
void mainWinow::newNetwork(){
|
|
if (m_pFactory != NULL) {
|
|
m_pFactory->cleanFactory();
|
|
};
|
|
};
|
|
|
|
void mainWinow::open(){
|
|
QString fileName;
|
|
fileName = QFileDialog::getOpenFileName(this, "Open Data", "data/", "Data Files (*.cfg *.raw *.jpg *.bmp)");
|
|
char fName[MAX_PATH];
|
|
sprintf( fName, "%s", fileName.toStdString().c_str() );
|
|
if( strlen(fName) ){
|
|
char tBuff[1024];
|
|
sprintf(tBuff, "Neural Network Manager: %s", fName );
|
|
setWindowTitle(tBuff);
|
|
if (m_pCortex != NULL) {
|
|
for (uint32_t index = m_pLayerTable->rowCount(); index > -1; index-- ) m_pLayerTable->removeRow(index);
|
|
delete(m_pCortex);
|
|
m_pCortex = NULL;
|
|
};
|
|
m_pCortex = m_pFactory->parseConfig(fName);
|
|
if( m_pCortex!= NULL ) {
|
|
for( uint32_t index = 0; index < m_pCortex->getLayersCount(); index++ ){
|
|
char tBuff[256];
|
|
m_pLayerTable->insertRow(index);
|
|
QTableWidgetItem * __qtablewidgetitem;
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
__qtablewidgetitem->setText( m_pCortex->getLayer(index)->getString() );
|
|
m_pLayerTable->setItem( index, 0, __qtablewidgetitem );
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
sprintf(tBuff, "%dx%dx%d", m_pCortex->getLayer(index)->getInputSizeWidth(), m_pCortex->getLayer(index)->getInputSizeHeight(), m_pCortex->getLayer(index)->getInputSizeChannels() );
|
|
__qtablewidgetitem->setText(tBuff );
|
|
m_pLayerTable->setItem(index, 3, __qtablewidgetitem);
|
|
__qtablewidgetitem = new QTableWidgetItem();
|
|
sprintf(tBuff, "%dx%dx%d", m_pCortex->getLayer(index)->getOutputSizeWidth(), m_pCortex->getLayer(index)->getOutputSizeHeight(), m_pCortex->getLayer(index)->getOutputSizeChannels());
|
|
__qtablewidgetitem->setText(tBuff);
|
|
m_pLayerTable->setItem(index, 4, __qtablewidgetitem);
|
|
};
|
|
tbActionLoadWeights->setEnabled(true);
|
|
};
|
|
};
|
|
};
|
|
|
|
void mainWinow::save(){
|
|
m_bChangesAreSaved = true;
|
|
};
|
|
|
|
void mainWinow::saveAs(){
|
|
QString fileName;
|
|
fileName = QFileDialog::getSaveFileName(this, "Save Data As ...", "data/", "Data Files (*.raw *.jpg *.bmp)");
|
|
m_bChangesAreSaved = true;
|
|
};
|
|
|
|
void mainWinow::exitApp() {
|
|
if (m_bChangesAreSaved) {
|
|
QApplication::quit();
|
|
} else {
|
|
QMessageBox::StandardButton reply;
|
|
reply = QMessageBox::question( this, "Unsaved Data", "Are you sure to Quit?", QMessageBox::Yes | QMessageBox::No);
|
|
if( reply == QMessageBox::Yes ){
|
|
QApplication::quit();
|
|
};
|
|
};
|
|
};
|
|
|
|
void mainWinow::contextMenuEvent(QContextMenuEvent* event){
|
|
QMenu menu(this);
|
|
//menu.addAction(cutAct);
|
|
//menu.addAction(copyAct);
|
|
//menu.addAction(pasteAct);
|
|
menu.exec(event->globalPos());
|
|
};
|
|
|
|
void mainWinow::selectLayerRow( int row, int col ){
|
|
tbActionEdit->setEnabled(true);
|
|
tbActionDelete->setEnabled(true);
|
|
m_pLayerPreview->attachCortexLayer(m_pCortex->getLayer(row));
|
|
};
|