Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "ObjectList.h"
00012
00013 #include <vector>
00014 #include <string>
00015 #include <QWidget>
00016 #include <QPushButton>
00017 #include <QVBoxLayout>
00018 #include <QString>
00019 #include <QTableWidget>
00020 #include <QHeaderView>
00021 #include <QFileDialog>
00022 #include <QGroupBox>
00023 #include <QLabel>
00024 #include <QMessageBox>
00025
00026 #include <ros/ros.h>
00027
00028
00029
00030
00031
00032
00033 #include "../../Workers/ObjectRecognition/ObjectProperties.h"
00034
00035
00036
00037
00038
00039 #include <iostream>
00040 #include <fstream>
00041
00042 #define THIS ObjectList
00043
00044
00045 THIS::THIS(QWidget *parent): QWidget( parent )
00046 {
00047
00048 setMinimumSize(100,100);
00049
00050 QPushButton* loadObjectButton;
00051
00052 loadObjectButton = new QPushButton("Load");
00053 deleteObjectButton = new QPushButton("Delete");;
00054 deleteObjectButton->setEnabled(false);
00055
00056 m_objectsList = new QTableWidget();
00057 m_objectsList->setColumnCount ( 2 );
00058 m_objectsList->setRowCount( 0 );
00059 QStringList headerList;
00060 headerList << "Name" << "Type";
00061 m_objectsList->setHorizontalHeaderLabels (headerList);
00062 m_objectsList->horizontalHeader()->setResizeMode(0, QHeaderView::Interactive);
00063 m_objectsList->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
00064 m_objectsList->verticalHeader()->hide();
00065 m_objectsList->setSelectionBehavior(QAbstractItemView::SelectRows);
00066 m_objectsList->setSortingEnabled(true);
00067
00068
00069 QVBoxLayout* mainLayout = new QVBoxLayout();
00070
00071 QGridLayout* listLayout = new QGridLayout();
00072 listLayout->addWidget(m_objectsList,0,0,1,2);
00073 listLayout->addWidget(loadObjectButton,1,0);
00074 listLayout->addWidget(deleteObjectButton,1,1);
00075
00076 heading=new QLabel( "Objects (0)" );
00077 QFont font;
00078 font.setBold(true);
00079 heading->setFont(font);
00080
00081 mainLayout->addWidget( heading );
00082 mainLayout->addLayout( listLayout );
00083 mainLayout->setSpacing(0);
00084 setLayout(mainLayout);
00085
00086
00087 connect(loadObjectButton,SIGNAL(clicked()),this,SLOT(loadObject()));
00088 connect(deleteObjectButton,SIGNAL(clicked()),this,SLOT(deleteObject()));
00089
00090 m_LastOpenPath = "/objectProperties";
00091 }
00092
00093 THIS::~THIS(){}
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 void THIS::deleteObject(){
00149 m_objectsList->setSortingEnabled(false);
00150
00151 QList<QTableWidgetItem *> selectedItems = m_objectsList->selectedItems();
00152
00153 int i=0;
00154 while(i<m_objectsList->rowCount())
00155 {
00156 if(selectedItems.contains(m_objectsList->item(i,0)))
00157 {
00158
00159
00160 m_objectsList->removeRow(i);
00161 --i;
00162 }
00163 ++i;
00164 }
00165 m_objectsList->setSortingEnabled(true);
00166 deleteObjectButton->setEnabled(m_objectsList->rowCount()>0);
00167 heading->setText("Objects ("+QString::number(m_objectsList->rowCount()) +")");
00168 }
00169
00170 void THIS::loadObject()
00171 {
00172 QStringList files = QFileDialog::getOpenFileNames(this, tr("Load Object"), m_LastOpenPath,"Objectproperties (*.objprop)");
00173
00174 for (int i = 0; i < files.size(); i++)
00175 {
00176 QString file=files.at(i);
00177 QDir fileDir( file );
00178 fileDir.cdUp();
00179 m_LastOpenPath = fileDir.absolutePath();
00180
00181 std::ifstream in(file.toStdString().c_str());
00182
00183 ROS_INFO_STREAM("file: " << file.toStdString());
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 }
00224 }
00225
00226 #undef THIS