• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1839 (tree)
日時2010-06-05 14:40:50
作者satofumi

ログメッセージ

adjusted indent width

変更サマリ

差分

--- trunk/programs/UrgRecorder/RecordConnection.cpp (revision 1838)
+++ trunk/programs/UrgRecorder/RecordConnection.cpp (revision 1839)
@@ -18,19 +18,19 @@
1818
1919 struct RecordConnection::pImpl
2020 {
21- string error_message_;
22- Connection* connection_;
23- ofstream send_fout_;
24- ofstream receive_fout_;
21+ string error_message_;
22+ Connection* connection_;
23+ ofstream send_fout_;
24+ ofstream receive_fout_;
2525
2626
27- pImpl(Connection* connection,
28- const char* send_save_file, const char* receive_save_file)
29- : error_message_("no error."), connection_(connection)
30- {
31- send_fout_.open(send_save_file);
32- receive_fout_.open(receive_save_file);
33- }
27+ pImpl(Connection* connection,
28+ const char* send_save_file, const char* receive_save_file)
29+ : error_message_("no error."), connection_(connection)
30+ {
31+ send_fout_.open(send_save_file);
32+ receive_fout_.open(receive_save_file);
33+ }
3434 };
3535
3636
@@ -37,7 +37,7 @@
3737 RecordConnection::RecordConnection(Connection* connection,
3838 const char* send_save_file,
3939 const char* receive_save_file)
40- : pimpl(new pImpl(connection, send_save_file, receive_save_file))
40+ : pimpl(new pImpl(connection, send_save_file, receive_save_file))
4141 {
4242 }
4343
@@ -49,79 +49,79 @@
4949
5050 const char* RecordConnection::what(void) const
5151 {
52- return pimpl->error_message_.c_str();
52+ return pimpl->error_message_.c_str();
5353 }
5454
5555
5656 bool RecordConnection::connect(const char* device, long baudrate)
5757 {
58- return pimpl->connection_->connect(device, baudrate);
58+ return pimpl->connection_->connect(device, baudrate);
5959 }
6060
6161
6262 void RecordConnection::disconnect(void)
6363 {
64- pimpl->connection_->disconnect();
64+ pimpl->connection_->disconnect();
6565 }
6666
6767
6868 bool RecordConnection::setBaudrate(long baudrate)
6969 {
70- return pimpl->connection_->setBaudrate(baudrate);
70+ return pimpl->connection_->setBaudrate(baudrate);
7171 }
7272
7373
7474 long RecordConnection::baudrate(void) const
7575 {
76- return pimpl->connection_->baudrate();
76+ return pimpl->connection_->baudrate();
7777 }
7878
7979
8080 bool RecordConnection::isConnected(void) const
8181 {
82- return pimpl->connection_->isConnected();
82+ return pimpl->connection_->isConnected();
8383 }
8484
8585
8686 int RecordConnection::send(const char* data, size_t count)
8787 {
88- int n = pimpl->connection_->send(data, count);
89- if (n > 0) {
90- pimpl->send_fout_.write(data, n);
91- }
92- return n;
88+ int n = pimpl->connection_->send(data, count);
89+ if (n > 0) {
90+ pimpl->send_fout_.write(data, n);
91+ }
92+ return n;
9393 }
9494
9595
9696 int RecordConnection::receive(char* data, size_t count, int timeout)
9797 {
98- int n = pimpl->connection_->receive(data, count, timeout);
99- if (n > 0) {
100- pimpl->receive_fout_.write(data, n);
101- }
102- return n;
98+ int n = pimpl->connection_->receive(data, count, timeout);
99+ if (n > 0) {
100+ pimpl->receive_fout_.write(data, n);
101+ }
102+ return n;
103103 }
104104
105105
106106 size_t RecordConnection::size(void) const
107107 {
108- return pimpl->connection_->size();
108+ return pimpl->connection_->size();
109109 }
110110
111111
112112 void RecordConnection::flush(void)
113113 {
114- pimpl->connection_->flush();
114+ pimpl->connection_->flush();
115115 }
116116
117117
118118 void RecordConnection::clear(void)
119119 {
120- pimpl->connection_->clear();
120+ pimpl->connection_->clear();
121121 }
122122
123123
124124 void RecordConnection::ungetc(const char ch)
125125 {
126- pimpl->connection_->ungetc(ch);
126+ pimpl->connection_->ungetc(ch);
127127 }
--- trunk/programs/UrgRecorder/RecordConnection.h (revision 1838)
+++ trunk/programs/UrgRecorder/RecordConnection.h (revision 1839)
@@ -16,31 +16,31 @@
1616
1717 class RecordConnection : public qrk::Connection
1818 {
19- RecordConnection(void);
20- RecordConnection(const RecordConnection& rhs);
21- RecordConnection& operator = (const RecordConnection& rhs);
19+ RecordConnection(void);
20+ RecordConnection(const RecordConnection& rhs);
21+ RecordConnection& operator = (const RecordConnection& rhs);
2222
23- struct pImpl;
24- const std::auto_ptr<pImpl> pimpl;
23+ struct pImpl;
24+ const std::auto_ptr<pImpl> pimpl;
2525
2626 public:
27- RecordConnection(qrk::Connection* connection,
28- const char* send_save_file, const char* receive_save_file);
29- ~RecordConnection(void);
27+ RecordConnection(qrk::Connection* connection,
28+ const char* send_save_file, const char* receive_save_file);
29+ ~RecordConnection(void);
3030
31- const char* what(void) const;
31+ const char* what(void) const;
3232
33- bool connect(const char* device, long baudrate);
34- void disconnect(void);
35- bool setBaudrate(long baudrate);
36- long baudrate(void) const;
37- bool isConnected(void) const;
38- int send(const char* data, size_t count);
39- int receive(char* data, size_t count, int timeout);
40- size_t size(void) const;
41- void flush(void);
42- void clear(void);
43- void ungetc(const char ch);
33+ bool connect(const char* device, long baudrate);
34+ void disconnect(void);
35+ bool setBaudrate(long baudrate);
36+ long baudrate(void) const;
37+ bool isConnected(void) const;
38+ int send(const char* data, size_t count);
39+ int receive(char* data, size_t count, int timeout);
40+ size_t size(void) const;
41+ void flush(void);
42+ void clear(void);
43+ void ungetc(const char ch);
4444 };
4545
4646 #endif /* !RECORD_CONNECTION_H */
--- trunk/programs/UrgRecorder/main.cpp (revision 1838)
+++ trunk/programs/UrgRecorder/main.cpp (revision 1839)
@@ -13,22 +13,22 @@
1313
1414 int main(int argc, char *argv[])
1515 {
16- QApplication app(argc, argv);
17- bool record_intensity_ = false;
18- for (int i = 1; i < argc; ++i) {
19- if (! strcmp(argv[i], "-i")) {
20- record_intensity_ = true;
16+ QApplication app(argc, argv);
17+ bool record_intensity_ = false;
18+ for (int i = 1; i < argc; ++i) {
19+ if (! strcmp(argv[i], "-i")) {
20+ record_intensity_ = true;
21+ }
2122 }
22- }
2323
24- // ロケールの設定
25- // !!!
24+ // ロケールの設定
25+ // !!!
2626
27- // アプリケーションの起動
28- UrgRecorderWidget widget;
29- if (record_intensity_) {
30- widget.setIntensityMode();
31- }
32- widget.show();
33- return app.exec();
27+ // アプリケーションの起動
28+ UrgRecorderWidget widget;
29+ if (record_intensity_) {
30+ widget.setIntensityMode();
31+ }
32+ widget.show();
33+ return app.exec();
3434 }
--- trunk/programs/UrgRecorder/UrgRecorderWidget.cpp (revision 1838)
+++ trunk/programs/UrgRecorder/UrgRecorderWidget.cpp (revision 1839)
@@ -32,257 +32,260 @@
3232
3333 namespace
3434 {
35- const char* Organization = "Hokuyo LTD.";
36- const char* Application = "URG Recorder";
35+ const char* Organization = "Hokuyo LTD.";
36+ const char* Application = "URG Recorder";
3737
38- enum {
39- DefaultCaptureTimes = 10,
40- };
38+ enum {
39+ DefaultCaptureTimes = 10,
40+ };
4141 }
4242
4343
4444 struct UrgRecorderWidget::pImpl
4545 {
46- UrgRecorderWidget* widget_;
47- SerialConnectionWidget connection_widget_;
46+ UrgRecorderWidget* widget_;
47+ SerialConnectionWidget connection_widget_;
4848
49- UrgUsbCom urg_usb_;
50- FindComPorts urg_finder_;
51- UrgDevice urg_;
52- Connection* serial_connection_;
49+ UrgUsbCom urg_usb_;
50+ FindComPorts urg_finder_;
51+ UrgDevice urg_;
52+ Connection* serial_connection_;
5353
54- QTimer capture_timer_;
55- QString save_directory_;
56- size_t capture_max_;
57- size_t total_times_;
58- bool is_raw_record_;
54+ QTimer capture_timer_;
55+ QString save_directory_;
56+ size_t capture_max_;
57+ size_t total_times_;
58+ bool is_raw_record_;
5959
60- bool intensity_mode_;
60+ bool intensity_mode_;
6161
6262
63- pImpl(UrgRecorderWidget* widget)
64- : widget_(widget), serial_connection_(NULL),
65- capture_max_(1), total_times_(0), is_raw_record_(false),
66- intensity_mode_(false)
67- {
68- urg_finder_.addBaseName("/dev/ttyACM");
69- urg_finder_.addBaseName("/dev/tty.usbmodem");
70- urg_finder_.addDriverName("URG Series USB Device Driver");
71- urg_finder_.addDriverName("URG-X002 USB Device Driver");
72- }
63+ pImpl(UrgRecorderWidget* widget)
64+ : widget_(widget), serial_connection_(NULL),
65+ capture_max_(1), total_times_(0), is_raw_record_(false),
66+ intensity_mode_(false)
67+ {
68+ urg_finder_.addBaseName("/dev/ttyACM");
69+ urg_finder_.addBaseName("/dev/tty.usbmodem");
70+ urg_finder_.addDriverName("URG Series USB Device Driver");
71+ urg_finder_.addDriverName("URG-X002 USB Device Driver");
72+ }
7373
7474
75- void initializeForm(void)
76- {
77- // 位置と大きさを読み出す
78- loadSettings();
75+ void initializeForm(void)
76+ {
77+ // 位置と大きさを読み出す
78+ loadSettings();
7979
80- // ConnectionWidget の配置
81- widget_->connection_layout_->addWidget(&connection_widget_);
82- widget_->connection_dummy_label_->hide();
80+ // ConnectionWidget の配置
81+ widget_->connection_layout_->addWidget(&connection_widget_);
82+ widget_->connection_dummy_label_->hide();
8383
84- // イベントの接続
85- connect(&connection_widget_, SIGNAL(rescanRequest()),
86- widget_, SLOT(rescanPressed()));
87- connect(&connection_widget_,
88- SIGNAL(connectRequest(bool, const std::string&)),
89- widget_, SLOT(connectPressed(bool, const std::string&)));
84+ // イベントの接続
85+ connect(&connection_widget_, SIGNAL(rescanRequest()),
86+ widget_, SLOT(rescanPressed()));
87+ connect(&connection_widget_,
88+ SIGNAL(connectRequest(bool, const std::string&)),
89+ widget_, SLOT(connectPressed(bool, const std::string&)));
9090
91- connect(widget_->times_spinbox_, SIGNAL(valueChanged(int)),
92- widget_, SLOT(timesChanged(int)));
91+ connect(widget_->times_spinbox_, SIGNAL(valueChanged(int)),
92+ widget_, SLOT(timesChanged(int)));
9393
94- connect(widget_->record_button_, SIGNAL(clicked()),
95- widget_, SLOT(recordPressed()));
96- connect(widget_->cancel_button_, SIGNAL(clicked()),
97- widget_, SLOT(cancelPressed()));
94+ connect(widget_->record_button_, SIGNAL(clicked()),
95+ widget_, SLOT(recordPressed()));
96+ connect(widget_->cancel_button_, SIGNAL(clicked()),
97+ widget_, SLOT(cancelPressed()));
9898
99- connect(widget_->raw_button_, SIGNAL(toggled(bool)),
100- widget_, SLOT(rawButtonChanged(bool)));
99+ connect(widget_->raw_button_, SIGNAL(toggled(bool)),
100+ widget_, SLOT(rawButtonChanged(bool)));
101101
102- connect(&capture_timer_, SIGNAL(timeout()), widget_, SLOT(recordData()));
103- }
102+ connect(&capture_timer_, SIGNAL(timeout()),
103+ widget_, SLOT(recordData()));
104+ }
104105
105106
106- void loadSettings(void)
107- {
108- QSettings settings(Organization, Application);
109- widget_->restoreGeometry(settings.value("geometry").toByteArray());
110- int capture_times =
111- settings.value("capture_times", DefaultCaptureTimes).toInt();
112- widget_->times_spinbox_->setValue(capture_times);
113- widget_->times_progress_->setMaximum(capture_times);
107+ void loadSettings(void)
108+ {
109+ QSettings settings(Organization, Application);
110+ widget_->restoreGeometry(settings.value("geometry").toByteArray());
111+ int capture_times =
112+ settings.value("capture_times", DefaultCaptureTimes).toInt();
113+ widget_->times_spinbox_->setValue(capture_times);
114+ widget_->times_progress_->setMaximum(capture_times);
114115
115- is_raw_record_ = settings.value("raw_button_checked", false).toBool();
116- widget_->raw_button_->setChecked(is_raw_record_);
117- rawButtonChanged(is_raw_record_);
118- }
116+ is_raw_record_ = settings.value("raw_button_checked", false).toBool();
117+ widget_->raw_button_->setChecked(is_raw_record_);
118+ rawButtonChanged(is_raw_record_);
119+ }
119120
120121
121- void saveSettings(void)
122- {
123- QSettings settings(Organization, Application);
124- settings.setValue("geometry", widget_->saveGeometry());
125- settings.setValue("capture_times", widget_->times_spinbox_->value());
126- settings.setValue("raw_button_checked", widget_->raw_button_->isChecked());
127- }
122+ void saveSettings(void)
123+ {
124+ QSettings settings(Organization, Application);
125+ settings.setValue("geometry", widget_->saveGeometry());
126+ settings.setValue("capture_times", widget_->times_spinbox_->value());
127+ settings.setValue("raw_button_checked",
128+ widget_->raw_button_->isChecked());
129+ }
128130
129131
130- void setRecording(bool recording)
131- {
132- widget_->record_button_->setEnabled(! recording);
133- widget_->cancel_button_->setEnabled(recording);
134- widget_->output_group_->setEnabled(! recording);
135- widget_->times_group_->setEnabled(! recording);
136- }
132+ void setRecording(bool recording)
133+ {
134+ widget_->record_button_->setEnabled(! recording);
135+ widget_->cancel_button_->setEnabled(recording);
136+ widget_->output_group_->setEnabled(! recording);
137+ widget_->times_group_->setEnabled(! recording);
138+ }
137139
138140
139- void recordPressed(void)
140- {
141- setRecording(true);
141+ void recordPressed(void)
142+ {
143+ setRecording(true);
142144
143- // 出力先ディレクトリの作成
144- save_directory_ =
145- QDateTime::currentDateTime().toString("yyyy-MM-dd_hh_mm_ss");
146- QDir dir;
147- dir.mkdir(save_directory_);
145+ // 出力先ディレクトリの作成
146+ save_directory_ =
147+ QDateTime::currentDateTime().toString("yyyy-MM-dd_hh_mm_ss");
148+ QDir dir;
149+ dir.mkdir(save_directory_);
148150
149- // 取得モードの設定
150- is_raw_record_ = widget_->raw_button_->isChecked();
151- if (is_raw_record_) {
152- is_raw_record_ = true;
153- serial_connection_ = urg_.connection();
154- string send_file = save_directory_.toStdString() + "/send.txt";
155- string receive_file = save_directory_.toStdString() + "/receive.txt";
156- urg_.setConnection(new RecordConnection(serial_connection_,
157- send_file.c_str(),
158- receive_file.c_str()));
151+ // 取得モードの設定
152+ is_raw_record_ = widget_->raw_button_->isChecked();
153+ if (is_raw_record_) {
154+ is_raw_record_ = true;
155+ serial_connection_ = urg_.connection();
156+ string send_file = save_directory_.toStdString() + "/send.txt";
157+ string receive_file =
158+ save_directory_.toStdString() + "/receive.txt";
159+ urg_.setConnection(new RecordConnection(serial_connection_,
160+ send_file.c_str(),
161+ receive_file.c_str()));
159162
160- // ログに URG の情報を含めるための呼び出し
161- urg_.loadParameter();
162- }
163+ // ログに URG の情報を含めるための呼び出し
164+ urg_.loadParameter();
165+ }
163166
164- // データ取得の開始
165- capture_max_ = widget_->times_spinbox_->value();
166- total_times_ = 0;
167- if (intensity_mode_) {
168- urg_.setCaptureMode(IntensityCapture);
169- } else {
170- urg_.setCaptureMode(AutoCapture);
167+ // データ取得の開始
168+ capture_max_ = widget_->times_spinbox_->value();
169+ total_times_ = 0;
170+ if (intensity_mode_) {
171+ urg_.setCaptureMode(IntensityCapture);
172+ } else {
173+ urg_.setCaptureMode(AutoCapture);
174+ }
175+ capture_timer_.setInterval(urg_.scanMsec() / 2);
176+ capture_timer_.start();
171177 }
172- capture_timer_.setInterval(urg_.scanMsec() / 2);
173- capture_timer_.start();
174- }
175178
176179
177- void recordData(void)
178- {
179- vector<long> data;
180- vector<long> intensity_data;
180+ void recordData(void)
181+ {
182+ vector<long> data;
183+ vector<long> intensity_data;
181184
182- int n;
183- if (intensity_mode_) {
184- n = urg_.captureWithIntensity(data, intensity_data);
185- } else {
186- n = urg_.capture(data);
187- }
185+ int n;
186+ if (intensity_mode_) {
187+ n = urg_.captureWithIntensity(data, intensity_data);
188+ } else {
189+ n = urg_.capture(data);
190+ }
188191
189- if (n <= 0) {
190- return;
191- }
192- ++total_times_;
192+ if (n <= 0) {
193+ return;
194+ }
195+ ++total_times_;
193196
194- if (! is_raw_record_) {
197+ if (! is_raw_record_) {
195198
196- // ファイルへのデータ書き出し
197- char buffer[] = "/data_xxxx.csv";
198- snprintf(buffer, sizeof(buffer), "/data_%04d.csv", total_times_);
199- QFile file(save_directory_ + QString(buffer));
200- if (! file.open(QIODevice::WriteOnly)) {
201- // !!! エラー表示
202- return;
203- }
199+ // ファイルへのデータ書き出し
200+ char buffer[] = "/data_xxxx.csv";
201+ snprintf(buffer, sizeof(buffer), "/data_%04d.csv", total_times_);
202+ QFile file(save_directory_ + QString(buffer));
203+ if (! file.open(QIODevice::WriteOnly)) {
204+ // !!! エラー表示
205+ return;
206+ }
204207
205- QTextStream fout(&file);
206- saveFile(fout, data, intensity_data);
207- }
208+ QTextStream fout(&file);
209+ saveFile(fout, data, intensity_data);
210+ }
208211
209- widget_->times_progress_->setValue(total_times_);
210- if (total_times_ >= capture_max_) {
211- stopRecording();
212+ widget_->times_progress_->setValue(total_times_);
213+ if (total_times_ >= capture_max_) {
214+ stopRecording();
215+ }
212216 }
213- }
214217
215218
216- void stopRecording(void)
217- {
218- setRecording(false);
219- capture_timer_.stop();
220- widget_->times_progress_->setValue(0);
219+ void stopRecording(void)
220+ {
221+ setRecording(false);
222+ capture_timer_.stop();
223+ widget_->times_progress_->setValue(0);
221224
222- urg_.stop();
225+ urg_.stop();
223226
224- if (is_raw_record_) {
225- Connection* connection = urg_.connection();
226- if (connection != serial_connection_) {
227- delete connection;
228- urg_.setConnection(serial_connection_);
229- }
227+ if (is_raw_record_) {
228+ Connection* connection = urg_.connection();
229+ if (connection != serial_connection_) {
230+ delete connection;
231+ urg_.setConnection(serial_connection_);
232+ }
233+ }
230234 }
231- }
232235
233236
234- void saveFile(QTextStream& fout, vector<long>& data,
235- vector<long>& intensity_data)
236- {
237- (void)intensity_data;
237+ void saveFile(QTextStream& fout, const vector<long>& data,
238+ vector<long>& intensity_data)
239+ {
240+ (void)intensity_data;
238241
239- size_t n = data.size();
240- for (size_t i = 0; i < n; ++i) {
241- long length = data[i];
242- double radian = urg_.index2rad(i);
243- double x = length * cos(radian);
244- double y = length * sin(radian);
245- fout << i << ',' << length << ','
246- << radian << ',' << x << ',' << y << endl;
242+ size_t n = data.size();
243+ for (size_t i = 0; i < n; ++i) {
244+ long length = data[i];
245+ double radian = urg_.index2rad(i);
246+ double x = length * cos(radian);
247+ double y = length * sin(radian);
248+ fout << i << ',' << length << ','
249+ << radian << ',' << x << ',' << y << endl;
250+ }
247251 }
248- }
249252
250253
251- void rawButtonChanged(bool checked)
252- {
253- if (checked) {
254- widget_->sample_text_->clear();
255- widget_->sample_text_->
256- insertPlainText("# receive data sample\n"
257- "MD0044072501000\n"
258- "99b\n"
259- "...");
260- } else {
261- widget_->sample_text_->clear();
262- widget_->sample_text_->
263- insertPlainText("# index, length, radian, x, y\n"
264- "0,669,-2.08621,-329.749,-582.088\n"
265- "1,667,-2.08008,-325.196,-582.354\n"
266- "...");
254+ void rawButtonChanged(bool checked)
255+ {
256+ if (checked) {
257+ widget_->sample_text_->clear();
258+ widget_->sample_text_->
259+ insertPlainText("# receive data sample\n"
260+ "MD0044072501000\n"
261+ "99b\n"
262+ "...");
263+ } else {
264+ widget_->sample_text_->clear();
265+ widget_->sample_text_->
266+ insertPlainText("# index, length, radian, x, y\n"
267+ "0,669,-2.08621,-329.749,-582.088\n"
268+ "1,667,-2.08008,-325.196,-582.354\n"
269+ "...");
270+ }
267271 }
268- }
269272 };
270273
271274
272275 UrgRecorderWidget::UrgRecorderWidget(QWidget* parent)
273- : QWidget(parent), pimpl(new pImpl(this))
276+ : QWidget(parent), pimpl(new pImpl(this))
274277 {
275- setupUi(this);
278+ setupUi(this);
276279
277- // フォームを初期化し、最初の表示を行う
278- pimpl->initializeForm();
279- rescanPressed();
280+ // フォームを初期化し、最初の表示を行う
281+ pimpl->initializeForm();
282+ rescanPressed();
280283
281- pimpl->connection_widget_.setFocus();
284+ pimpl->connection_widget_.setFocus();
282285
283- // Ctrl-q, Alt-F4 で終了させる
284- (void) new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
285- (void) new QShortcut(Qt::ALT + Qt::Key_F4, this, SLOT(close()));
286+ // Ctrl-q, Alt-F4 で終了させる
287+ (void) new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
288+ (void) new QShortcut(Qt::ALT + Qt::Key_F4, this, SLOT(close()));
286289 }
287290
288291
@@ -293,30 +296,30 @@
293296
294297 void UrgRecorderWidget::setIntensityMode(void)
295298 {
296- pimpl->intensity_mode_ = true;
299+ pimpl->intensity_mode_ = true;
297300 }
298301
299302
300303 void UrgRecorderWidget::closeEvent(QCloseEvent* event)
301304 {
302- static_cast<void>(event);
305+ static_cast<void>(event);
303306
304- pimpl->urg_.stop();
305- pimpl->saveSettings();
307+ pimpl->urg_.stop();
308+ pimpl->saveSettings();
306309 }
307310
308311
309312 void UrgRecorderWidget::rescanPressed(void)
310313 {
311- vector<string> devices;
312- pimpl->urg_finder_.find(devices);
313- for (vector<string>::iterator it = devices.begin();
314- it != devices.end(); ++it) {
315- if (pimpl->urg_usb_.isUsbCom(it->c_str())) {
316- *it = *it + " [URG]";
314+ vector<string> devices;
315+ pimpl->urg_finder_.find(devices);
316+ for (vector<string>::iterator it = devices.begin();
317+ it != devices.end(); ++it) {
318+ if (pimpl->urg_usb_.isUsbCom(it->c_str())) {
319+ *it = *it + " [URG]";
320+ }
317321 }
318- }
319- pimpl->connection_widget_.setDevices(devices);
322+ pimpl->connection_widget_.setDevices(devices);
320323 }
321324
322325
@@ -323,62 +326,63 @@
323326 void UrgRecorderWidget::connectPressed(bool connection,
324327 const string& device)
325328 {
326- // !!! 接続処理をスレッドで行うように調整する
327- bool connected = connection;
329+ // !!! 接続処理をスレッドで行うように調整する
330+ bool connected = connection;
328331
329- if (connection) {
330- if (! pimpl->urg_.connect(device.c_str())) {
331- QMessageBox::warning(this, tr("Connection error"), pimpl->urg_.what());
332- connected = false;
332+ if (connection) {
333+ if (! pimpl->urg_.connect(device.c_str())) {
334+ QMessageBox::warning(this, tr("Connection error"),
335+ pimpl->urg_.what());
336+ connected = false;
337+ }
338+ } else {
339+ pimpl->stopRecording();
333340 }
334- } else {
335- pimpl->stopRecording();
336- }
337341
338- record_group_->setEnabled(connected);
339- cancel_button_->setEnabled(false);
342+ record_group_->setEnabled(connected);
343+ cancel_button_->setEnabled(false);
340344
341- pimpl->connection_widget_.setConnected(connected);
345+ pimpl->connection_widget_.setConnected(connected);
342346
343- if (connected) {
344- // フォーカスを Record ボタンに移動させる
345- record_button_->setFocus();
346- }
347+ if (connected) {
348+ // フォーカスを Record ボタンに移動させる
349+ record_button_->setFocus();
350+ }
347351 }
348352
349353
350354 void UrgRecorderWidget::recordPressed(void)
351355 {
352- if (pimpl->capture_timer_.isActive()) {
353- return;
354- }
355- pimpl->recordPressed();
356+ if (pimpl->capture_timer_.isActive()) {
357+ return;
358+ }
359+ pimpl->recordPressed();
356360 }
357361
358362
359363 void UrgRecorderWidget::cancelPressed(void)
360364 {
361- pimpl->stopRecording();
365+ pimpl->stopRecording();
362366 }
363367
364368
365369 void UrgRecorderWidget::timesChanged(int times)
366370 {
367- times_progress_->setMaximum(times);
371+ times_progress_->setMaximum(times);
368372
369- // 再描画が行われるように、2回ほど値をセットしている
370- times_progress_->setValue(1);
371- times_progress_->setValue(0);
373+ // 再描画が行われるように、2回ほど値をセットしている
374+ times_progress_->setValue(1);
375+ times_progress_->setValue(0);
372376 }
373377
374378
375379 void UrgRecorderWidget::recordData(void)
376380 {
377- pimpl->recordData();
381+ pimpl->recordData();
378382 }
379383
380384
381385 void UrgRecorderWidget::rawButtonChanged(bool checked)
382386 {
383- pimpl->rawButtonChanged(checked);
387+ pimpl->rawButtonChanged(checked);
384388 }
--- trunk/programs/UrgRecorder/UrgRecorderWidget.h (revision 1838)
+++ trunk/programs/UrgRecorder/UrgRecorderWidget.h (revision 1839)
@@ -16,30 +16,30 @@
1616
1717 class UrgRecorderWidget : public QWidget, private Ui::UrgRecorderWidgetForm
1818 {
19- Q_OBJECT;
19+ Q_OBJECT;
2020
2121 public:
22- UrgRecorderWidget(QWidget* parent = 0);
23- ~UrgRecorderWidget(void);
22+ UrgRecorderWidget(QWidget* parent = 0);
23+ ~UrgRecorderWidget(void);
2424
25- void setIntensityMode(void);
25+ void setIntensityMode(void);
2626
2727 private slots:
28- void closeEvent(QCloseEvent* event);
29- void rescanPressed(void);
30- void connectPressed(bool connection, const std::string& device);
31- void recordPressed(void);
32- void cancelPressed(void);
33- void timesChanged(int times);
34- void recordData(void);
35- void rawButtonChanged(bool checked);
28+ void closeEvent(QCloseEvent* event);
29+ void rescanPressed(void);
30+ void connectPressed(bool connection, const std::string& device);
31+ void recordPressed(void);
32+ void cancelPressed(void);
33+ void timesChanged(int times);
34+ void recordData(void);
35+ void rawButtonChanged(bool checked);
3636
3737 private:
38- UrgRecorderWidget(const UrgRecorderWidget& rhs);
39- UrgRecorderWidget& operator = (const UrgRecorderWidget& rhs);
38+ UrgRecorderWidget(const UrgRecorderWidget& rhs);
39+ UrgRecorderWidget& operator = (const UrgRecorderWidget& rhs);
4040
41- struct pImpl;
42- std::auto_ptr<pImpl> pimpl;
41+ struct pImpl;
42+ std::auto_ptr<pImpl> pimpl;
4343 };
4444
4545 #endif /* !URG_RECORDER_WIDGET_H */
旧リポジトリブラウザで表示