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

7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
7 years ago
7 years ago
​
​
7 years ago
7 years ago
7 years ago
​
​
7 years ago
​
  1. #include "DeviceChooser.h"
  2. #include "LrfSensorWidget.h"
  3. #ifdef QT_CREATOR_PROJECT
  4. #include "../../App/QTPro3DGUI/mainwindow.h"
  5. #else
  6. #include "../../App/3dGUI/main_window.h"
  7. #endif
  8. #include "RangeMapWidget.h"
  9. #include "RadarMapWidget.h"
  10. DeviceChooser::DeviceChooser( QWidget *parent ): QWidget(parent){
  11. m_pEnumirator = objectSensorsEnumirator::getInstance();
  12. m_pAddDeviceDialog = NULL;
  13. m_bIsSelectionLocked = false;
  14. m_pParentWidget = parent;
  15. m_pHorizontalLayout = new QHBoxLayout();
  16. m_pHorizontalLayout->setSpacing(6);
  17. m_pHorizontalLayout->setContentsMargins(11, 11, 11, 11);
  18. m_pButtonCmdAdd = new QPushButton(this);
  19. m_pButtonCmdAdd->setFixedSize(60, 276);
  20. QIcon icon1;
  21. icon1.addFile(QStringLiteral(":pictures/appbar.add.png"), QSize(), QIcon::Normal, QIcon::Off);
  22. m_pButtonCmdAdd->setIcon(icon1);
  23. m_pButtonCmdAdd->setIconSize(QSize(32, 32));
  24. m_pButtonCmdAdd->setFlat(false);
  25. connect(m_pButtonCmdAdd, &QPushButton::clicked, this, &DeviceChooser::showAddSourceDialog);
  26. setLayout( m_pHorizontalLayout );
  27. m_pHorizontalLayout->addWidget( m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop );
  28. m_pSideSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
  29. m_pHorizontalLayout->addItem(m_pSideSpacer);
  30. //setFixedSize( 1400, 200 );
  31. // Enumerate Defined! Devices
  32. for( int index = 0; index < m_pEnumirator->getCount(); index++ ){
  33. LrfSensorWidget *tDeviceWidget;
  34. tDeviceWidget = new LrfSensorWidget(this);
  35. if( tDeviceWidget!= NULL ){
  36. m_vWidgets.push_back( tDeviceWidget );
  37. m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
  38. m_pHorizontalLayout->removeItem(m_pSideSpacer);
  39. m_pHorizontalLayout->addWidget( tDeviceWidget, 0, Qt::AlignLeft | Qt::AlignTop);
  40. m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
  41. m_pHorizontalLayout->addItem(m_pSideSpacer);
  42. tDeviceWidget->attachDevice( m_pEnumirator->getSensor( index ) );
  43. };
  44. };
  45. };
  46. DeviceChooser::~DeviceChooser(){
  47. if (m_pHorizontalLayout->children().size()){
  48. QObjectList tQL = m_pHorizontalLayout->children();
  49. for (QObjectList::Iterator index = tQL.begin(); index < tQL.end(); index++){
  50. delete(*index);
  51. };
  52. tQL.clear();
  53. };
  54. };
  55. void DeviceChooser::showAddSourceDialog( ){
  56. if( m_pAddDeviceDialog == NULL ){
  57. m_pAddDeviceDialog = new guiAddDeviceDialog(this);
  58. };
  59. if (m_pAddDeviceDialog != NULL){
  60. m_pAddDeviceDialog->setDialogStage(0);// m_nAddSourceDialogStage);
  61. m_pAddDeviceDialog->setModal(true);
  62. m_pAddDeviceDialog->show();
  63. };
  64. };
  65. void DeviceChooser::createNew(SENSOR_INFO *SI){
  66. objectLGS *tLGS = NULL;
  67. tLGS = m_pEnumirator->addSensor(SI);
  68. if (tLGS){
  69. LrfSensorWidget *tDeviceWidget;
  70. tDeviceWidget = new LrfSensorWidget(this);
  71. if( tDeviceWidget!= NULL ){
  72. m_vWidgets.push_back( tDeviceWidget );
  73. m_pHorizontalLayout->removeWidget( m_pButtonCmdAdd );
  74. m_pHorizontalLayout->removeItem( m_pSideSpacer );
  75. m_pHorizontalLayout->addWidget( tDeviceWidget, 0, Qt::AlignLeft | Qt::AlignTop );
  76. m_pHorizontalLayout->addWidget( m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop );
  77. m_pHorizontalLayout->addItem( m_pSideSpacer );
  78. tDeviceWidget->attachDevice( tLGS );
  79. };
  80. };
  81. };
  82. bool DeviceChooser::unselectAllDevices( void ){
  83. if (!m_bIsSelectionLocked){
  84. for (int i = 0; i < m_vWidgets.size(); i++) m_vWidgets.at(i)->setSelected(false);
  85. return true;
  86. };
  87. return false;
  88. };
  89. void DeviceChooser::setSelectedDevice(objectLGS *Device){
  90. if (!m_bIsSelectionLocked) m_pSelectedDevice = Device;
  91. };
  92. void DeviceChooser::setSelectedDevice( int id ){
  93. if( id < m_vWidgets.size() ){
  94. if( !m_bIsSelectionLocked ) m_vWidgets.at(id)->setSelected( true );
  95. };
  96. };
  97. RangeMapWidget *DeviceChooser::getRangeMap( void ){
  98. #ifdef QT_CREATOR_PROJECT
  99. return ((MainWindow *)m_pParentWidget)->getRangeMap();
  100. #else
  101. return ((mainWinow *)m_pParentWidget)->getRangeMap();
  102. #endif
  103. };
  104. RadarMapWidget *DeviceChooser::getRadarMap( void ){
  105. #ifdef QT_CREATOR_PROJECT
  106. return ((MainWindow *)m_pParentWidget)->getRadarMap();
  107. #else
  108. return ((mainWinow *)m_pParentWidget)->getRadarMap();
  109. #endif
  110. };
  111. GLRadar *DeviceChooser::getGlRadar( void ){
  112. #ifdef QT_CREATOR_PROJECT
  113. return ((MainWindow *)m_pParentWidget)->getGLRadar();
  114. #else
  115. return ((mainWinow *)m_pParentWidget)->getGLRadar();
  116. #endif
  117. };