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.
130 lines
4.3 KiB
130 lines
4.3 KiB
#include "DeviceChooser.h"
|
|
#include "LrfSensorWidget.h"
|
|
#ifdef QT_CREATOR_PROJECT
|
|
#include "../../App/QTPro3DGUI/mainwindow.h"
|
|
#else
|
|
#include "../../App/3dGUI/main_window.h"
|
|
#endif
|
|
#include "RangeMapWidget.h"
|
|
#include "RadarMapWidget.h"
|
|
|
|
DeviceChooser::DeviceChooser( QWidget *parent ): QWidget(parent){
|
|
m_pEnumirator = objectSensorsEnumirator::getInstance();
|
|
m_pAddDeviceDialog = NULL;
|
|
m_bIsSelectionLocked = false;
|
|
m_pParentWidget = parent;
|
|
m_pHorizontalLayout = new QHBoxLayout();
|
|
m_pHorizontalLayout->setSpacing(6);
|
|
m_pHorizontalLayout->setContentsMargins(11, 11, 11, 11);
|
|
|
|
m_pButtonCmdAdd = new QPushButton(this);
|
|
m_pButtonCmdAdd->setFixedSize(60, 276);
|
|
QIcon icon1;
|
|
icon1.addFile(QStringLiteral(":pictures/appbar.add.png"), QSize(), QIcon::Normal, QIcon::Off);
|
|
m_pButtonCmdAdd->setIcon(icon1);
|
|
m_pButtonCmdAdd->setIconSize(QSize(32, 32));
|
|
m_pButtonCmdAdd->setFlat(false);
|
|
|
|
connect(m_pButtonCmdAdd, &QPushButton::clicked, this, &DeviceChooser::showAddSourceDialog);
|
|
|
|
setLayout( m_pHorizontalLayout );
|
|
m_pHorizontalLayout->addWidget( m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop );
|
|
m_pSideSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
m_pHorizontalLayout->addItem(m_pSideSpacer);
|
|
//setFixedSize( 1400, 200 );
|
|
// Enumerate Defined! Devices
|
|
for( int index = 0; index < m_pEnumirator->getCount(); index++ ){
|
|
LrfSensorWidget *tDeviceWidget;
|
|
tDeviceWidget = new LrfSensorWidget(this);
|
|
if( tDeviceWidget!= NULL ){
|
|
m_vWidgets.push_back( tDeviceWidget );
|
|
m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
|
|
m_pHorizontalLayout->removeItem(m_pSideSpacer);
|
|
m_pHorizontalLayout->addWidget( tDeviceWidget, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addItem(m_pSideSpacer);
|
|
tDeviceWidget->attachDevice( m_pEnumirator->getSensor( index ) );
|
|
};
|
|
};
|
|
};
|
|
|
|
DeviceChooser::~DeviceChooser(){
|
|
if (m_pHorizontalLayout->children().size()){
|
|
QObjectList tQL = m_pHorizontalLayout->children();
|
|
for (QObjectList::Iterator index = tQL.begin(); index < tQL.end(); index++){
|
|
delete(*index);
|
|
};
|
|
tQL.clear();
|
|
};
|
|
};
|
|
|
|
void DeviceChooser::showAddSourceDialog( ){
|
|
if( m_pAddDeviceDialog == NULL ){
|
|
m_pAddDeviceDialog = new guiAddDeviceDialog(this);
|
|
};
|
|
if (m_pAddDeviceDialog != NULL){
|
|
m_pAddDeviceDialog->setDialogStage(0);// m_nAddSourceDialogStage);
|
|
m_pAddDeviceDialog->setModal(true);
|
|
m_pAddDeviceDialog->show();
|
|
};
|
|
};
|
|
|
|
void DeviceChooser::createNew(SENSOR_INFO *SI){
|
|
objectLGS *tLGS = NULL;
|
|
tLGS = m_pEnumirator->addSensor(SI);
|
|
if (tLGS){
|
|
LrfSensorWidget *tDeviceWidget;
|
|
tDeviceWidget = new LrfSensorWidget(this);
|
|
if( tDeviceWidget!= NULL ){
|
|
m_vWidgets.push_back( tDeviceWidget );
|
|
m_pHorizontalLayout->removeWidget( m_pButtonCmdAdd );
|
|
m_pHorizontalLayout->removeItem( m_pSideSpacer );
|
|
m_pHorizontalLayout->addWidget( tDeviceWidget, 0, Qt::AlignLeft | Qt::AlignTop );
|
|
m_pHorizontalLayout->addWidget( m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop );
|
|
m_pHorizontalLayout->addItem( m_pSideSpacer );
|
|
tDeviceWidget->attachDevice( tLGS );
|
|
};
|
|
};
|
|
};
|
|
|
|
bool DeviceChooser::unselectAllDevices( void ){
|
|
if (!m_bIsSelectionLocked){
|
|
for (int i = 0; i < m_vWidgets.size(); i++) m_vWidgets.at(i)->setSelected(false);
|
|
return true;
|
|
};
|
|
return false;
|
|
};
|
|
|
|
void DeviceChooser::setSelectedDevice(objectLGS *Device){
|
|
if (!m_bIsSelectionLocked) m_pSelectedDevice = Device;
|
|
};
|
|
|
|
void DeviceChooser::setSelectedDevice( int id ){
|
|
if( id < m_vWidgets.size() ){
|
|
if( !m_bIsSelectionLocked ) m_vWidgets.at(id)->setSelected( true );
|
|
};
|
|
};
|
|
|
|
RangeMapWidget *DeviceChooser::getRangeMap( void ){
|
|
#ifdef QT_CREATOR_PROJECT
|
|
return ((MainWindow *)m_pParentWidget)->getRangeMap();
|
|
#else
|
|
return ((mainWinow *)m_pParentWidget)->getRangeMap();
|
|
#endif
|
|
};
|
|
|
|
RadarMapWidget *DeviceChooser::getRadarMap( void ){
|
|
#ifdef QT_CREATOR_PROJECT
|
|
return ((MainWindow *)m_pParentWidget)->getRadarMap();
|
|
#else
|
|
return ((mainWinow *)m_pParentWidget)->getRadarMap();
|
|
#endif
|
|
};
|
|
|
|
GLRadar *DeviceChooser::getGlRadar( void ){
|
|
#ifdef QT_CREATOR_PROJECT
|
|
return ((MainWindow *)m_pParentWidget)->getGLRadar();
|
|
#else
|
|
return ((mainWinow *)m_pParentWidget)->getGLRadar();
|
|
#endif
|
|
};
|