• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1817 (tree)
日時2010-05-09 18:04:32
作者satofumi

ログメッセージ

luabind TcpipSocket.h

変更サマリ

差分

--- trunk/libs/lua/luabindSyncGui_slave.h (revision 1816)
+++ trunk/libs/lua/luabindSyncGui_slave.h (nonexistent)
@@ -1,26 +0,0 @@
1-#ifndef QRK_LUABIND_SYNC_GUI_SLAVE_H
2-#define QRK_LUABIND_SYNC_GUI_SLAVE_H
3-
4-/*!
5- \file
6- \brief Lua への gui_sync (slave) モジュール登録
7-
8- \author Satofumi KAMIMURA
9-
10- $Id$
11-*/
12-
13-#include <lua.hpp>
14-
15-
16-namespace qrk
17-{
18- /*!
19- \brief Lua への sync_gui (slave) モジュール登録
20-
21- \param[in,out] L Lua 変数
22- */
23- extern void luabindSyncGui_slave(lua_State* L);
24-}
25-
26-#endif /* !QRK_LUABIND_SYNC_GUI_SLAVE_H */
Deleted: svn:keywords
## -1 +0,0 ##
-Id Date Author Rev URL
\ No newline at end of property
--- trunk/libs/lua/luabindSyncGui_slave.cpp (revision 1816)
+++ trunk/libs/lua/luabindSyncGui_slave.cpp (nonexistent)
@@ -1,17 +0,0 @@
1-/*!
2- \file
3- \brief Lua への gui_sync (slave) モジュール登録
4-
5- \author Satofumi KAMIMURA
6-
7- $Id$
8-*/
9-
10-#include "luabindSyncGui_slave.h"
11-
12-
13-void qrk::luabindSyncGui_slave(lua_State* L)
14-{
15- static_cast<void>(L);
16- // !!!
17-}
Deleted: svn:keywords
## -1 +0,0 ##
-Id Date Author Rev URL
\ No newline at end of property
--- trunk/libs/lua/luabindSyncGui_master.cpp (revision 1816)
+++ trunk/libs/lua/luabindSyncGui_master.cpp (nonexistent)
@@ -1,48 +0,0 @@
1-/*!
2- \file
3- \brief Lua への gui_sync (master) モジュール登録
4-
5- \author Satofumi KAMIMURA
6-
7- $Id$
8-*/
9-
10-#include "luabindSyncGui_master.h"
11-#include "Component.h"
12-#include "MasterLayer.h"
13-#include "Color.h"
14-#include "master_ColorSurface.h"
15-#include "master_Label.h"
16-#include <luabind/luabind.hpp>
17-
18-using namespace qrk;
19-using namespace qrk::sync_master;
20-using namespace luabind;
21-
22-
23-void qrk::luabindSyncGui_master(lua_State* L)
24-{
25- module(L)
26- [
27- class_<MasterLayer>("MasterLayer")
28- .def(constructor<>())
29- .def("setAlpha", &MasterLayer::setAlpha)
30- .def("draw", &MasterLayer::draw)
31- .def("clear", &MasterLayer::clear)
32- .def("push_front", &MasterLayer::push_front)
33- .def("push_back", &MasterLayer::push_back)
34- .def("remove", &MasterLayer::remove)
35- .def("registerId", &MasterLayer::registerId),
36-
37- class_<ColorSurface, Surface>("ColorSurface")
38- .def(constructor<const Rect<long>&, const Color&>())
39- .def("rect", &ColorSurface::rect)
40- .def("setAlpha", &ColorSurface::setAlpha)
41- .def("draw", &ColorSurface::draw),
42-
43- class_<Label, Component>("Label")
44- .def(constructor<Surface&>())
45- .def("setPosition", &Label::setPosition)
46- .def("position", &Label::position)
47- ];
48-}
Deleted: svn:keywords
## -1 +0,0 ##
-Id Date Author Rev URL
\ No newline at end of property
--- trunk/libs/lua/luabindSyncGui_master.h (revision 1816)
+++ trunk/libs/lua/luabindSyncGui_master.h (nonexistent)
@@ -1,26 +0,0 @@
1-#ifndef QRK_LUABIND_SYNC_GUI_MASTER_H
2-#define QRK_LUABIND_SYNC_GUI_MASTER_H
3-
4-/*!
5- \file
6- \brief Lua への gui_sync (master) モジュール登録
7-
8- \author Satofumi KAMIMURA
9-
10- $Id$
11-*/
12-
13-#include <lua.hpp>
14-
15-
16-namespace qrk
17-{
18- /*!
19- \brief Lua への sync_gui (master) モジュール登録
20-
21- \param[in,out] L Lua 変数
22- */
23- extern void luabindSyncGui_master(lua_State* L);
24-}
25-
26-#endif /* !QRK_LUABIND_SYNC_GUI_MASTER_H */
Deleted: svn:keywords
## -1 +0,0 ##
-Id Date Author Rev URL
\ No newline at end of property
--- trunk/libs/lua/luabindGui.cpp (revision 1816)
+++ trunk/libs/lua/luabindGui.cpp (revision 1817)
@@ -150,112 +150,112 @@
150150
151151 class_<MultiSurface, Surface>("MultiSurface")
152152 .def(constructor<Surface&>())
153- .def("rect", &MultiSurface::rect)
154- .def("setAlpha", &MultiSurface::setAlpha)
155- .def("draw", &MultiSurface::draw)
156- .def("push_front", &MultiSurface::push_front),
153+ .def("rect", &MultiSurface::rect)
154+ .def("setAlpha", &MultiSurface::setAlpha)
155+ .def("draw", &MultiSurface::draw)
156+ .def("push_front", &MultiSurface::push_front),
157157
158- class_<Component>("Component"),
158+ class_<Component>("Component"),
159159
160- class_<Label, Component>("Label")
161- .def(constructor<Surface&>())
162- .def("setPosition", &Label::setPosition)
163- .def("position", &Label::position)
164- .def("rect", &Label::rect),
160+ class_<Label, Component>("Label")
161+ .def(constructor<Surface&>())
162+ .def("setPosition", &Label::setPosition)
163+ .def("position", &Label::position)
164+ .def("rect", &Label::rect),
165165
166- class_<Button, Component>("Button")
167- .def(constructor<Surface&, Surface&, Surface&>()),
166+ class_<Button, Component>("Button")
167+ .def(constructor<Surface&, Surface&, Surface&>()),
168168
169- class_<Menu, Component>("Menu")
170- .enum_("Align")
171- [
172- value("Left", Menu::Left),
173- value("Center", Menu::Center),
174- value("Right", Menu::Right),
175- value("Top", Menu::Top),
176- value("Middle", Menu::Middle),
177- value("Bottom", Menu::Bottom)
178- ]
179- .def(constructor<const Rect<long>&, Menu::Align>())
180- .def("setAlpha", &Menu::setAlpha)
181- .def("alpha", &Menu::alpha)
182- .def("setPosition", &Menu::setPosition)
183- .def("setButtonStep", &Menu::setButtonStep)
184- .def("addButton", &Menu::addButton)
185- .def("setEnableNoSelect", &Menu::setEnableNoSelect)
186- .def("setEnableRotate", &Menu::setEnableRotate)
187- .def("indexSize", &Menu::indexSize)
188- .def("setIndex", &Menu::setIndex)
189- .def("index", &Menu::index)
190- .def("isClicked", &Menu::isClicked)
191- .def("clickedId", &Menu::clickedId),
169+ class_<Menu, Component>("Menu")
170+ .enum_("Align")
171+ [
172+ value("Left", Menu::Left),
173+ value("Center", Menu::Center),
174+ value("Right", Menu::Right),
175+ value("Top", Menu::Top),
176+ value("Middle", Menu::Middle),
177+ value("Bottom", Menu::Bottom)
178+ ]
179+ .def(constructor<const Rect<long>&, Menu::Align>())
180+ .def("setAlpha", &Menu::setAlpha)
181+ .def("alpha", &Menu::alpha)
182+ .def("setPosition", &Menu::setPosition)
183+ .def("setButtonStep", &Menu::setButtonStep)
184+ .def("addButton", &Menu::addButton)
185+ .def("setEnableNoSelect", &Menu::setEnableNoSelect)
186+ .def("setEnableRotate", &Menu::setEnableRotate)
187+ .def("indexSize", &Menu::indexSize)
188+ .def("setIndex", &Menu::setIndex)
189+ .def("index", &Menu::index)
190+ .def("isClicked", &Menu::isClicked)
191+ .def("clickedId", &Menu::clickedId),
192192
193- class_<ChatMessage, Component>("ChatMessage")
194- .def(constructor<Font&, const Rect<long>&>())
195- .def("setPosition", &ChatMessage::setPosition)
196- .def("position", &ChatMessage::position)
197- .def("setDrawTimeout", &ChatMessage::setDrawTimeout)
198- .def("setFadeoutTime", &ChatMessage::setFadeoutTime)
199- .def("setOffset", &ChatMessage::setOffset)
200- .def("clear", &ChatMessage::clear)
201- .def("print", &ChatMessage::print)
202- .def("newline", &ChatMessage::newline),
193+ class_<ChatMessage, Component>("ChatMessage")
194+ .def(constructor<Font&, const Rect<long>&>())
195+ .def("setPosition", &ChatMessage::setPosition)
196+ .def("position", &ChatMessage::position)
197+ .def("setDrawTimeout", &ChatMessage::setDrawTimeout)
198+ .def("setFadeoutTime", &ChatMessage::setFadeoutTime)
199+ .def("setOffset", &ChatMessage::setOffset)
200+ .def("clear", &ChatMessage::clear)
201+ .def("print", &ChatMessage::print)
202+ .def("newline", &ChatMessage::newline),
203203
204- def("left", (long(*)(const Component&, long))&left),
205- def("center", (long(*)(const Component&, long))&center),
206- def("right", (long(*)(const Component&, long))&right),
207- def("top", (long(*)(const Component&, long))&top),
208- def("middle", (long(*)(const Component&, long))&middle),
209- def("bottom", (long(*)(const Component&, long))&bottom),
204+ def("left", (long(*)(const Component&, long))&left),
205+ def("center", (long(*)(const Component&, long))&center),
206+ def("right", (long(*)(const Component&, long))&right),
207+ def("top", (long(*)(const Component&, long))&top),
208+ def("middle", (long(*)(const Component&, long))&middle),
209+ def("bottom", (long(*)(const Component&, long))&bottom),
210210
211- def("left", (long(*)(const Surface&, long))&left),
212- def("center", (long(*)(const Surface&, long))&center),
213- def("right", (long(*)(const Surface&, long))&right),
214- def("top", (long(*)(const Surface&, long))&top),
215- def("middle", (long(*)(const Surface&, long))&middle),
216- def("bottom", (long(*)(const Surface&, long))&bottom)
217- ];
211+ def("left", (long(*)(const Surface&, long))&left),
212+ def("center", (long(*)(const Surface&, long))&center),
213+ def("right", (long(*)(const Surface&, long))&right),
214+ def("top", (long(*)(const Surface&, long))&top),
215+ def("middle", (long(*)(const Surface&, long))&middle),
216+ def("bottom", (long(*)(const Surface&, long))&bottom)
217+ ];
218218
219- LuaHandler::registerValue(L, "SDLK_BACKSPACE", SDLK_BACKSPACE);
220- LuaHandler::registerValue(L, "SDLK_ESCAPE", SDLK_ESCAPE);
221- LuaHandler::registerValue(L, "SDLK_RETURN", SDLK_RETURN);
222- LuaHandler::registerValue(L, "SDLK_F4", SDLK_F4);
223- LuaHandler::registerValue(L, "SDLK_LEFT", SDLK_LEFT);
224- LuaHandler::registerValue(L, "SDLK_RIGHT", SDLK_RIGHT);
219+ LuaHandler::registerValue(L, "SDLK_BACKSPACE", SDLK_BACKSPACE);
220+ LuaHandler::registerValue(L, "SDLK_ESCAPE", SDLK_ESCAPE);
221+ LuaHandler::registerValue(L, "SDLK_RETURN", SDLK_RETURN);
222+ LuaHandler::registerValue(L, "SDLK_F4", SDLK_F4);
223+ LuaHandler::registerValue(L, "SDLK_LEFT", SDLK_LEFT);
224+ LuaHandler::registerValue(L, "SDLK_RIGHT", SDLK_RIGHT);
225225
226- LuaHandler::registerValue(L, "SDLK_a", SDLK_a);
227- LuaHandler::registerValue(L, "SDLK_b", SDLK_b);
228- LuaHandler::registerValue(L, "SDLK_c", SDLK_c);
229- LuaHandler::registerValue(L, "SDLK_d", SDLK_d);
230- LuaHandler::registerValue(L, "SDLK_e", SDLK_e);
231- LuaHandler::registerValue(L, "SDLK_f", SDLK_f);
232- LuaHandler::registerValue(L, "SDLK_g", SDLK_g);
233- LuaHandler::registerValue(L, "SDLK_h", SDLK_h);
234- LuaHandler::registerValue(L, "SDLK_i", SDLK_i);
235- LuaHandler::registerValue(L, "SDLK_j", SDLK_j);
236- LuaHandler::registerValue(L, "SDLK_k", SDLK_k);
237- LuaHandler::registerValue(L, "SDLK_l", SDLK_l);
238- LuaHandler::registerValue(L, "SDLK_m", SDLK_m);
239- LuaHandler::registerValue(L, "SDLK_n", SDLK_n);
240- LuaHandler::registerValue(L, "SDLK_o", SDLK_o);
241- LuaHandler::registerValue(L, "SDLK_p", SDLK_p);
242- LuaHandler::registerValue(L, "SDLK_q", SDLK_q);
243- LuaHandler::registerValue(L, "SDLK_r", SDLK_r);
244- LuaHandler::registerValue(L, "SDLK_s", SDLK_s);
245- LuaHandler::registerValue(L, "SDLK_t", SDLK_t);
246- LuaHandler::registerValue(L, "SDLK_u", SDLK_u);
247- LuaHandler::registerValue(L, "SDLK_v", SDLK_v);
248- LuaHandler::registerValue(L, "SDLK_w", SDLK_w);
249- LuaHandler::registerValue(L, "SDLK_x", SDLK_x);
250- LuaHandler::registerValue(L, "SDLK_y", SDLK_y);
251- LuaHandler::registerValue(L, "SDLK_z", SDLK_z);
226+ LuaHandler::registerValue(L, "SDLK_a", SDLK_a);
227+ LuaHandler::registerValue(L, "SDLK_b", SDLK_b);
228+ LuaHandler::registerValue(L, "SDLK_c", SDLK_c);
229+ LuaHandler::registerValue(L, "SDLK_d", SDLK_d);
230+ LuaHandler::registerValue(L, "SDLK_e", SDLK_e);
231+ LuaHandler::registerValue(L, "SDLK_f", SDLK_f);
232+ LuaHandler::registerValue(L, "SDLK_g", SDLK_g);
233+ LuaHandler::registerValue(L, "SDLK_h", SDLK_h);
234+ LuaHandler::registerValue(L, "SDLK_i", SDLK_i);
235+ LuaHandler::registerValue(L, "SDLK_j", SDLK_j);
236+ LuaHandler::registerValue(L, "SDLK_k", SDLK_k);
237+ LuaHandler::registerValue(L, "SDLK_l", SDLK_l);
238+ LuaHandler::registerValue(L, "SDLK_m", SDLK_m);
239+ LuaHandler::registerValue(L, "SDLK_n", SDLK_n);
240+ LuaHandler::registerValue(L, "SDLK_o", SDLK_o);
241+ LuaHandler::registerValue(L, "SDLK_p", SDLK_p);
242+ LuaHandler::registerValue(L, "SDLK_q", SDLK_q);
243+ LuaHandler::registerValue(L, "SDLK_r", SDLK_r);
244+ LuaHandler::registerValue(L, "SDLK_s", SDLK_s);
245+ LuaHandler::registerValue(L, "SDLK_t", SDLK_t);
246+ LuaHandler::registerValue(L, "SDLK_u", SDLK_u);
247+ LuaHandler::registerValue(L, "SDLK_v", SDLK_v);
248+ LuaHandler::registerValue(L, "SDLK_w", SDLK_w);
249+ LuaHandler::registerValue(L, "SDLK_x", SDLK_x);
250+ LuaHandler::registerValue(L, "SDLK_y", SDLK_y);
251+ LuaHandler::registerValue(L, "SDLK_z", SDLK_z);
252252
253- LuaHandler::registerValue(L, "SDL_KEYDOWN", SDL_KEYDOWN);
254- LuaHandler::registerValue(L, "SDL_KEYUP", SDL_KEYUP);
253+ LuaHandler::registerValue(L, "SDL_KEYDOWN", SDL_KEYDOWN);
254+ LuaHandler::registerValue(L, "SDL_KEYUP", SDL_KEYUP);
255255
256- LuaHandler::registerValue(L, "KMOD_NONE", KMOD_NONE);
257- LuaHandler::registerValue(L, "KMOD_LCTRL", KMOD_LCTRL);
258- LuaHandler::registerValue(L, "KMOD_RCTRL", KMOD_RCTRL);
259- LuaHandler::registerValue(L, "KMOD_LALT", KMOD_LALT);
260- LuaHandler::registerValue(L, "KMOD_RALT", KMOD_RALT);
256+ LuaHandler::registerValue(L, "KMOD_NONE", KMOD_NONE);
257+ LuaHandler::registerValue(L, "KMOD_LCTRL", KMOD_LCTRL);
258+ LuaHandler::registerValue(L, "KMOD_RCTRL", KMOD_RCTRL);
259+ LuaHandler::registerValue(L, "KMOD_LALT", KMOD_LALT);
260+ LuaHandler::registerValue(L, "KMOD_RALT", KMOD_RALT);
261261 }
--- trunk/libs/lua/Makefile (revision 1816)
+++ trunk/libs/lua/Makefile (revision 1817)
@@ -4,7 +4,7 @@
44 # Compile options
55 CC = $(CXX)
66 CXXFLAGS = -g -O0 -Wall -W -Werror $(INCLUDES) `sdl-config --cflags`
7-INCLUDES = -I/usr/include/lua5.1 -I.. -I../system -I../system/sdl -I../gui -I../geometry -I../audio -I../common -I../running -I../range_finder -I../coordinate -I../monitoring -I../running/beego_drive -I/usr/include/lua5.1 -I../timestamp -I../math -I../input
7+INCLUDES = -I/usr/include/lua5.1 -I.. -I../system -I../system/sdl -I../connection -I../gui -I../geometry -I../audio -I../common -I../running -I../range_finder -I../coordinate -I../monitoring -I../running/beego_drive -I/usr/include/lua5.1 -I../timestamp -I../math -I../input
88
99 # Target
1010 LUA_LIB = lua.a
@@ -64,7 +64,7 @@
6464
6565 # DO NOT DELETE
6666
67-LuaHandler.o: LuaHandler.h ../system/log_printf.h
67+LuaHandler.o: LuaHandler.h ../system/fileExist.h ../system/log_printf.h
6868 TestScriptedStateMachine.o: TestScriptedStateMachine.h ScriptedStateMachine.h
6969 lua_runStateMachine.o: lua_runStateMachine.h ScriptedStateMachine.h
7070 lua_runStateMachine.o: LuaHandler.h luabindInit.h ../system/delay.h
@@ -93,7 +93,8 @@
9393 luabindInit.o: luabindInit.h LuaHandler.h ../system/log_printf.h
9494 luabindInput.o: luabindInput.h ../input/convertToRoman.h
9595 luabindInput.o: ../input/convertToJp.h ../input/Utf8.h ../input/utf8_string.h
96-luabindNetwork.o: luabindNetwork.h
96+luabindNetwork.o: luabindNetwork.h ../connection/Connection.h
97+luabindNetwork.o: ../connection/TcpipSocket.h
9798 luabindRangeFinder.o: luabindRangeFinder.h ../monitoring/mUrgDevice.h
9899 luabindRangeFinder.o: ../range_finder/UrgDevice.h ../coordinate/Coordinate.h
99100 luabindRangeFinder.o: ../geometry/Position.h ../geometry/Angle.h
@@ -106,10 +107,6 @@
106107 luabindRunning.o: ../geometry/Angle.h ../running/Running.h
107108 luabindRunning.o: ../geometry/Point.h ../timestamp/Timestamp.h
108109 luabindRunning.o: ../running/WheelDirect.h
109-luabindSyncGui_master.o: luabindSyncGui_master.h ../gui/Component.h
110-luabindSyncGui_master.o: ../geometry/Rect.h ../geometry/Point.h
111-luabindSyncGui_master.o: ../common/Color.h
112-luabindSyncGui_slave.o: luabindSyncGui_slave.h
113110 luabindSystem.o: luabindSystem.h ../system/delay.h ../system/ticks.h
114111 luabindSystem.o: ../system/CycleTimer.h ../system/StopWatch.h
115112 luabindUrgDistance.o: luabindUrgDistance.h ../monitoring/mUrgDistance.h
--- trunk/libs/lua/luabindNetwork.h (revision 1816)
+++ trunk/libs/lua/luabindNetwork.h (revision 1817)
@@ -17,6 +17,8 @@
1717 {
1818 /*!
1919 \brief Lua への network モジュール登録
20+
21+ \param[in,out] L Lua 変数
2022 */
2123 extern void luabindNetwork(lua_State* L);
2224 }
--- trunk/libs/lua/lua_runStateMachine.h (revision 1816)
+++ trunk/libs/lua/lua_runStateMachine.h (revision 1817)
@@ -15,7 +15,12 @@
1515
1616 namespace qrk
1717 {
18- //! 状態遷移の実行
18+ /*!
19+ \brief 状態遷移の実行
20+
21+ \param[in,out] L Lua 変数
22+ \param[in] 最初の状態名
23+ */
1924 extern void lua_runStateMachine(lua_State* L, const char* first_state);
2025 }
2126
--- trunk/libs/lua/luabindNetwork.cpp (revision 1816)
+++ trunk/libs/lua/luabindNetwork.cpp (revision 1817)
@@ -8,20 +8,57 @@
88 */
99
1010 #include "luabindNetwork.h"
11+#include "Connection.h"
12+#include "TcpipSocket.h"
1113 #include <luabind/luabind.hpp>
14+#include <algorithm>
15+#include <string>
1216
1317 using namespace qrk;
1418 using namespace luabind;
19+using namespace std;
1520
1621
22+namespace
23+{
24+ string connection_receive(Connection* connection, size_t size, int timeout)
25+ {
26+ enum { BufferSize = 1024 };
27+ char buffer[BufferSize];
28+
29+ size_t actual_size = min(size, static_cast<size_t>(BufferSize - 1));
30+ int n = connection->receive(buffer, actual_size, timeout);
31+
32+ if (n <= 0) {
33+ return "";
34+ }
35+
36+ buffer[n] = '\0';
37+ return buffer;
38+ }
39+}
40+
41+
1742 void qrk::luabindNetwork(lua_State* L)
1843 {
19- static_cast<void>(L);
20-#if 0
21- lua_State* lua = luabindInit();
44+ module(L)
45+ [
46+ class_<Connection>("Connection"),
2247
23- module(lua)
24- [
25- ];
26-#endif
48+ class_<TcpipSocket, Connection>("TcpipSocket")
49+ .def(constructor<>())
50+ .def(constructor<void*>())
51+ .def("what", &TcpipSocket::what)
52+ .def("connect", &TcpipSocket::connect)
53+ .def("disconnect", &TcpipSocket::disconnect)
54+ .def("isConnected", &TcpipSocket::isConnected)
55+ .def("send", &TcpipSocket::send)
56+ //.def("receive", &TcpipSocket::receive)
57+ .def("size", &TcpipSocket::size)
58+ .def("flush", &TcpipSocket::flush)
59+ .def("clear", &TcpipSocket::clear)
60+ .def("ungetc", &TcpipSocket::ungetc),
61+
62+ def("conection_receive", &connection_receive)
63+ ];
2764 }
--- trunk/libs/gui/Makefile (revision 1816)
+++ trunk/libs/gui/Makefile (revision 1817)
@@ -93,6 +93,7 @@
9393 Font.o: ../system/DetectOS.h Font.h ../common/Color.h SdlTtfInit.h
9494 Font.o: ../system/log_printf.h
9595 ImageSurface.o: ImageSurface.h Surface.h ../geometry/Rect.h SDL_GL_Texture.h
96+ImageSurface.o: ../system/log_printf.h
9697 Label.o: Label.h Component.h ../geometry/Rect.h ../geometry/Point.h Surface.h
9798 Layer.o: Layer.h LayerInterface.h Component.h ../geometry/Rect.h
9899 Layer.o: ../geometry/Point.h Screen.h
--- trunk/libs/input/Makefile (revision 1816)
+++ trunk/libs/input/Makefile (revision 1817)
@@ -55,4 +55,5 @@
5555 Utf8.o: Utf8.h
5656 convertToJp.o: convertToJp.h roman_table.h kana_table.h Utf8.h
5757 convertToRoman.o: convertToRoman.h roman_table.h Utf8.h
58+rubi_parse.o: rubi_parse.h
5859 utf8_string.o: utf8_string.h Utf8.h
--- trunk/libs/connection/qt/TcpipAccepter.cpp (revision 1816)
+++ trunk/libs/connection/qt/TcpipAccepter.cpp (revision 1817)
@@ -19,38 +19,38 @@
1919
2020 struct TcpipAccepter::pImpl
2121 {
22- string error_message_;
23- string server_name_;
24- QTcpServer tcp_server_;
22+ string error_message_;
23+ string server_name_;
24+ QTcpServer tcp_server_;
2525
2626
27- pImpl(void) : error_message_("no error."), server_name_("unknown")
28- {
29- }
27+ pImpl(void) : error_message_("no error."), server_name_("unknown")
28+ {
29+ }
3030
3131
32- bool activate(long port)
33- {
34- return tcp_server_.listen(QHostAddress::Any, port);
35- }
32+ bool activate(long port)
33+ {
34+ return tcp_server_.listen(QHostAddress::Any, port);
35+ }
3636
3737
38- void deactivate(void)
39- {
40- tcp_server_.close();
41- }
38+ void deactivate(void)
39+ {
40+ tcp_server_.close();
41+ }
4242
4343
44- TcpipSocket* accept(int timeout)
45- {
46- if (tcp_server_.hasPendingConnections()) {
47- return new TcpipSocket(tcp_server_.nextPendingConnection());
44+ TcpipSocket* accept(int timeout)
45+ {
46+ if (tcp_server_.hasPendingConnections()) {
47+ return new TcpipSocket(tcp_server_.nextPendingConnection());
4848
49- } else if (tcp_server_.waitForNewConnection(timeout)) {
50- return new TcpipSocket(tcp_server_.nextPendingConnection());
49+ } else if (tcp_server_.waitForNewConnection(timeout)) {
50+ return new TcpipSocket(tcp_server_.nextPendingConnection());
51+ }
52+ return NULL;
5153 }
52- return NULL;
53- }
5454 };
5555
5656
@@ -66,29 +66,29 @@
6666
6767 const char* TcpipAccepter::what(void) const
6868 {
69- return pimpl->error_message_.c_str();
69+ return pimpl->error_message_.c_str();
7070 }
7171
7272
7373 bool TcpipAccepter::activate(long port)
7474 {
75- return pimpl->activate(port);
75+ return pimpl->activate(port);
7676 }
7777
7878
7979 void TcpipAccepter::deactivate(void)
8080 {
81- pimpl->deactivate();
81+ pimpl->deactivate();
8282 }
8383
8484
8585 TcpipSocket* TcpipAccepter::accept(int timeout)
8686 {
87- return pimpl->accept(timeout);
87+ return pimpl->accept(timeout);
8888 }
8989
9090
9191 const char* TcpipAccepter::name(void)
9292 {
93- return pimpl->server_name_.c_str();
93+ return pimpl->server_name_.c_str();
9494 }
--- trunk/libs/connection/qt/TcpipSocket.cpp (revision 1816)
+++ trunk/libs/connection/qt/TcpipSocket.cpp (revision 1817)
@@ -17,19 +17,19 @@
1717
1818 struct TcpipSocket::pImpl
1919 {
20- QTcpSocket* socket_;
21- long baudrate_;
20+ QTcpSocket* socket_;
21+ long baudrate_;
2222
2323
24- pImpl(QTcpSocket* socket) : socket_(socket), baudrate_(0)
25- {
26- }
24+ pImpl(QTcpSocket* socket) : socket_(socket), baudrate_(0)
25+ {
26+ }
2727
2828
29- ~pImpl(void)
30- {
31- delete socket_;
32- }
29+ ~pImpl(void)
30+ {
31+ delete socket_;
32+ }
3333 };
3434
3535
@@ -39,7 +39,7 @@
3939
4040
4141 TcpipSocket::TcpipSocket(void* socket)
42- : pimpl(new pImpl(static_cast<QTcpSocket*>(socket)))
42+ : pimpl(new pImpl(static_cast<QTcpSocket*>(socket)))
4343 {
4444 }
4545
@@ -52,104 +52,104 @@
5252
5353 const char* TcpipSocket::what(void) const
5454 {
55- return pimpl->socket_->errorString().toStdString().c_str();
55+ return pimpl->socket_->errorString().toStdString().c_str();
5656 }
5757
5858
5959 bool TcpipSocket::connect(const char* host, long port)
6060 {
61- pimpl->socket_->connectToHost(host, port);
61+ pimpl->socket_->connectToHost(host, port);
6262
63- enum { ConnectionTimeout = 3000 };
64- bool ret = pimpl->socket_->waitForConnected(ConnectionTimeout);
63+ enum { ConnectionTimeout = 3000 };
64+ bool ret = pimpl->socket_->waitForConnected(ConnectionTimeout);
6565
66- return ret;
66+ return ret;
6767 }
6868
6969
7070 void TcpipSocket::disconnect(void)
7171 {
72- pimpl->socket_->disconnectFromHost();
72+ pimpl->socket_->disconnectFromHost();
7373 }
7474
7575
7676 bool TcpipSocket::setBaudrate(long baudrate)
7777 {
78- // 実装しない
79- pimpl->baudrate_ = baudrate;
80- return true;
78+ // 実装しない
79+ pimpl->baudrate_ = baudrate;
80+ return true;
8181 }
8282
8383
8484 long TcpipSocket::baudrate(void) const
8585 {
86- // 実装しない
87- return pimpl->baudrate_;
86+ // 実装しない
87+ return pimpl->baudrate_;
8888 }
8989
9090
9191 bool TcpipSocket::isConnected(void) const
9292 {
93- return pimpl->socket_->isValid();
93+ return pimpl->socket_->isValid();
9494 }
9595
9696
9797 int TcpipSocket::send(const char* data, size_t count)
9898 {
99- return pimpl->socket_->write(data, count);
99+ return pimpl->socket_->write(data, count);
100100 }
101101
102102
103103 int TcpipSocket::receive(char* data, size_t count, int timeout)
104104 {
105- if (count == 0) {
106- return 0;
107- }
108-
109- size_t filled = 0;
110- do {
111- int n = pimpl->socket_->read(&data[filled], count - filled);
112- if (n < 0) {
113- return n;
105+ if (count == 0) {
106+ return 0;
114107 }
115- if (n > 0) {
116- filled += n;
117- }
118108
119- if ((filled < count) && (! pimpl->socket_->waitForReadyRead(timeout))) {
120- break;
121- }
122- } while (filled < count);
109+ size_t filled = 0;
110+ do {
111+ int n = pimpl->socket_->read(&data[filled], count - filled);
112+ if (n < 0) {
113+ return n;
114+ }
115+ if (n > 0) {
116+ filled += n;
117+ }
123118
124- return filled;
119+ if ((filled < count) && (! pimpl->socket_->waitForReadyRead(timeout))) {
120+ break;
121+ }
122+ } while (filled < count);
123+
124+ return filled;
125125 }
126126
127127
128128 size_t TcpipSocket::size(void) const
129129 {
130- return pimpl->socket_->bytesAvailable();
130+ return pimpl->socket_->bytesAvailable();
131131 }
132132
133133
134134 void TcpipSocket::flush(void)
135135 {
136- pimpl->socket_->flush();
136+ pimpl->socket_->flush();
137137 }
138138
139139
140140 void TcpipSocket::clear(void)
141141 {
142- // 受信バッファの内容を読み捨てる
143- enum { BufferSize = 256 };
144- char buffer[BufferSize];
142+ // 受信バッファの内容を読み捨てる
143+ enum { BufferSize = 256 };
144+ char buffer[BufferSize];
145145
146- while (receive(buffer, BufferSize, 0) == BufferSize) {
147- ;
148- }
146+ while (receive(buffer, BufferSize, 0) == BufferSize) {
147+ ;
148+ }
149149 }
150150
151151
152152 void TcpipSocket::ungetc(const char ch)
153153 {
154- pimpl->socket_->ungetChar(ch);
154+ pimpl->socket_->ungetChar(ch);
155155 }
--- trunk/libs/connection/TcpipSocket.h (revision 1816)
+++ trunk/libs/connection/TcpipSocket.h (revision 1817)
@@ -11,6 +11,7 @@
1111 */
1212
1313 #include "Connection.h"
14+#include <string>
1415 #include <memory>
1516
1617
--- trunk/programs/UrgViewer/RangeViewWidget.h (revision 1816)
+++ trunk/programs/UrgViewer/RangeViewWidget.h (revision 1817)
@@ -15,7 +15,7 @@
1515
1616 namespace qrk
1717 {
18- class RangeSensorParameter;
18+ class RangeSensorParameter;
1919 }
2020 class CaptureSettingWidget;
2121
@@ -25,26 +25,26 @@
2525 */
2626 class RangeViewWidget : public QWidget
2727 {
28- Q_OBJECT;
28+ Q_OBJECT;
2929
3030 public:
31- RangeViewWidget(CaptureSettingWidget* parent = 0);
32- ~RangeViewWidget(void);
31+ RangeViewWidget(CaptureSettingWidget* parent = 0);
32+ ~RangeViewWidget(void);
3333
34- void setParameter(const qrk::RangeSensorParameter& parameter);
34+ void setParameter(const qrk::RangeSensorParameter& parameter);
3535
3636 protected:
37- void paintEvent(QPaintEvent* event);
37+ void paintEvent(QPaintEvent* event);
3838
3939 protected slots:
40- void isRangeChanged(int first_index, int last_index);
40+ void isRangeChanged(int first_index, int last_index);
4141
4242 private:
43- RangeViewWidget(const RangeViewWidget& rhs);
44- RangeViewWidget& operator = (const RangeViewWidget& rhs);
43+ RangeViewWidget(const RangeViewWidget& rhs);
44+ RangeViewWidget& operator = (const RangeViewWidget& rhs);
4545
46- struct pImpl;
47- std::auto_ptr<pImpl> pimpl;
46+ struct pImpl;
47+ std::auto_ptr<pImpl> pimpl;
4848 };
4949
5050 #endif /* !RANGE_VIEW_WIDGET_H */
--- trunk/programs/UrgViewer/CaptureSettingWidget.cpp (revision 1816)
+++ trunk/programs/UrgViewer/CaptureSettingWidget.cpp (revision 1817)
@@ -18,141 +18,141 @@
1818
1919 struct CaptureSettingWidget::pImpl
2020 {
21- CaptureSettingWidget* widget_;
21+ CaptureSettingWidget* widget_;
2222
23- const RangeSensor& sensor_;
24- QButtonGroup mode_group_;
25- QButtonGroup times_group_;
23+ const RangeSensor& sensor_;
24+ QButtonGroup mode_group_;
25+ QButtonGroup times_group_;
2626
27- RangeSensorParameter parameter_;
27+ RangeSensorParameter parameter_;
2828
29- RangeViewWidget range_view_widget_;
29+ RangeViewWidget range_view_widget_;
3030
31- bool apply_completed_;
31+ bool apply_completed_;
3232
3333
34- pImpl(CaptureSettingWidget* widget, const RangeSensor& sensor)
35- : widget_(widget), sensor_(sensor), range_view_widget_(widget_),
36- apply_completed_(true)
37- {
38- }
34+ pImpl(CaptureSettingWidget* widget, const RangeSensor& sensor)
35+ : widget_(widget), sensor_(sensor), range_view_widget_(widget_),
36+ apply_completed_(true)
37+ {
38+ }
3939
4040
41- void initializeForm(void)
42- {
43- // フォーム
44- widget_->intensity_button_->hide();
45- widget_->dummy_label_->hide();
46- widget_->preview_layout_->addWidget(&range_view_widget_);
41+ void initializeForm(void)
42+ {
43+ // フォーム
44+ widget_->intensity_button_->hide();
45+ widget_->dummy_label_->hide();
46+ widget_->preview_layout_->addWidget(&range_view_widget_);
4747
48- // モード
49- mode_group_.addButton(widget_->intensity_button_, ME);
50- mode_group_.addButton(widget_->gd_button_, GD);
51- mode_group_.addButton(widget_->md_button_, MD);
52- times_group_.addButton(widget_->infinity_times_button_);
53- times_group_.addButton(widget_->n_times_button_);
48+ // モード
49+ mode_group_.addButton(widget_->intensity_button_, ME);
50+ mode_group_.addButton(widget_->gd_button_, GD);
51+ mode_group_.addButton(widget_->md_button_, MD);
52+ times_group_.addButton(widget_->infinity_times_button_);
53+ times_group_.addButton(widget_->n_times_button_);
5454
55- // フォームイベント
56- connect(widget_->apply_button_, SIGNAL(clicked()),
57- widget_, SLOT(applyPressed()));
58- connect(widget_->cancel_button_, SIGNAL(clicked()),
59- widget_, SLOT(close()));
60- connect(widget_->load_button_, SIGNAL(clicked()),
61- widget_, SLOT(loadPressed()));
62- connect(&mode_group_, SIGNAL(buttonClicked(int)),
63- widget_, SLOT(modeChanged(int)));
55+ // フォームイベント
56+ connect(widget_->apply_button_, SIGNAL(clicked()),
57+ widget_, SLOT(applyPressed()));
58+ connect(widget_->cancel_button_, SIGNAL(clicked()),
59+ widget_, SLOT(close()));
60+ connect(widget_->load_button_, SIGNAL(clicked()),
61+ widget_, SLOT(loadPressed()));
62+ connect(&mode_group_, SIGNAL(buttonClicked(int)),
63+ widget_, SLOT(modeChanged(int)));
6464
65- connect(widget_->range_first_spinbox_, SIGNAL(editingFinished()),
66- widget_, SLOT(firstFinished()));
67- connect(widget_->range_last_spinbox_, SIGNAL(editingFinished()),
68- widget_, SLOT(lastFinished()));
69- connect(widget_->range_first_spinbox_, SIGNAL(valueChanged(int)),
70- widget_, SLOT(isRangeChanged()));
71- connect(widget_->range_last_spinbox_, SIGNAL(valueChanged(int)),
72- widget_, SLOT(isRangeChanged()));
65+ connect(widget_->range_first_spinbox_, SIGNAL(editingFinished()),
66+ widget_, SLOT(firstFinished()));
67+ connect(widget_->range_last_spinbox_, SIGNAL(editingFinished()),
68+ widget_, SLOT(lastFinished()));
69+ connect(widget_->range_first_spinbox_, SIGNAL(valueChanged(int)),
70+ widget_, SLOT(isRangeChanged()));
71+ connect(widget_->range_last_spinbox_, SIGNAL(valueChanged(int)),
72+ widget_, SLOT(isRangeChanged()));
7373
74- connect(&times_group_, SIGNAL(buttonClicked(int)),
75- widget_, SLOT(timesChanged()));
74+ connect(&times_group_, SIGNAL(buttonClicked(int)),
75+ widget_, SLOT(timesChanged()));
7676
77- connect(widget_->line_group_spinbox_, SIGNAL(valueChanged(int)),
78- widget_, SLOT(lineGroupsChanged()));
79- connect(widget_->frame_skips_spinbox_, SIGNAL(valueChanged(int)),
80- widget_, SLOT(frameSkipsChanged()));
81- connect(widget_->capture_times_spinbox_, SIGNAL(valueChanged(int)),
82- widget_, SLOT(captureTimesChanged()));
77+ connect(widget_->line_group_spinbox_, SIGNAL(valueChanged(int)),
78+ widget_, SLOT(lineGroupsChanged()));
79+ connect(widget_->frame_skips_spinbox_, SIGNAL(valueChanged(int)),
80+ widget_, SLOT(frameSkipsChanged()));
81+ connect(widget_->capture_times_spinbox_, SIGNAL(valueChanged(int)),
82+ widget_, SLOT(captureTimesChanged()));
8383
8484
85- // キー割り付け
86- (void) new QShortcut(Qt::CTRL + Qt::Key_Q, widget_, SLOT(quitPressed()));
87- (void) new QShortcut(Qt::CTRL + Qt::Key_W, widget_, SLOT(close()));
85+ // キー割り付け
86+ (void)new QShortcut(Qt::CTRL + Qt::Key_Q, widget_, SLOT(quitPressed()));
87+ (void)new QShortcut(Qt::CTRL + Qt::Key_W, widget_, SLOT(close()));
8888
89- // 初期設定
90- setMode(MD);
91- setTimes(InfinityTimes);
92- }
89+ // 初期設定
90+ setMode(MD);
91+ setTimes(InfinityTimes);
92+ }
9393
9494
95- void createSettings(CaptureSettings& settings)
96- {
97- settings.type = static_cast<CaptureType>(mode_group_.checkedId());
95+ void createSettings(CaptureSettings& settings)
96+ {
97+ settings.type = static_cast<CaptureType>(mode_group_.checkedId());
9898
99- settings.capture_first = widget_->range_first_spinbox_->value();
100- settings.capture_last = widget_->range_last_spinbox_->value();
101- settings.skip_lines = widget_->line_group_spinbox_->value();
102- settings.skip_frames = widget_->frame_skips_spinbox_->value();
103- if (widget_->infinity_times_button_->isChecked()) {
104- settings.remain_times = 0;
105- } else {
106- settings.remain_times = widget_->capture_times_spinbox_->value();
99+ settings.capture_first = widget_->range_first_spinbox_->value();
100+ settings.capture_last = widget_->range_last_spinbox_->value();
101+ settings.skip_lines = widget_->line_group_spinbox_->value();
102+ settings.skip_frames = widget_->frame_skips_spinbox_->value();
103+ if (widget_->infinity_times_button_->isChecked()) {
104+ settings.remain_times = 0;
105+ } else {
106+ settings.remain_times = widget_->capture_times_spinbox_->value();
107+ }
107108 }
108- }
109109
110110
111- void setMode(int type)
112- {
113- QAbstractButton* selected_button = mode_group_.button(type);
114- if (selected_button) {
115- selected_button->click();
111+ void setMode(int type)
112+ {
113+ QAbstractButton* selected_button = mode_group_.button(type);
114+ if (selected_button) {
115+ selected_button->click();
116+ }
116117 }
117- }
118118
119119
120- void setTimes(size_t times)
121- {
122- if (times <= 99) {
123- widget_->n_times_button_->click();
124- } else {
125- widget_->infinity_times_button_->click();
120+ void setTimes(size_t times)
121+ {
122+ if (times <= 99) {
123+ widget_->n_times_button_->click();
124+ } else {
125+ widget_->infinity_times_button_->click();
126+ }
126127 }
127- }
128128
129129
130- void setTimesEnabled(bool enable)
131- {
132- bool infinity_checked = widget_->infinity_times_button_->isChecked();
133- bool n_times_checked = (! infinity_checked);
130+ void setTimesEnabled(bool enable)
131+ {
132+ bool infinity_checked = widget_->infinity_times_button_->isChecked();
133+ bool n_times_checked = (! infinity_checked);
134134
135- widget_->infinity_times_button_->setEnabled(enable);
136- widget_->n_times_button_->setEnabled(enable);
137- widget_->capture_times_spinbox_->setEnabled(enable && n_times_checked);
138- }
135+ widget_->infinity_times_button_->setEnabled(enable);
136+ widget_->n_times_button_->setEnabled(enable);
137+ widget_->capture_times_spinbox_->setEnabled(enable && n_times_checked);
138+ }
139139
140140
141- void updateApplyButton(void)
142- {
143- if (apply_completed_) {
144- widget_->apply_button_->setEnabled(true);
141+ void updateApplyButton(void)
142+ {
143+ if (apply_completed_) {
144+ widget_->apply_button_->setEnabled(true);
145+ }
145146 }
146- }
147147 };
148148
149149
150150 CaptureSettingWidget::CaptureSettingWidget(const qrk::RangeSensor& sensor,
151151 QWidget* parent)
152- : QWidget(parent), pimpl(new pImpl(this, sensor))
152+ : QWidget(parent), pimpl(new pImpl(this, sensor))
153153 {
154- setupUi(this);
155- pimpl->initializeForm();
154+ setupUi(this);
155+ pimpl->initializeForm();
156156 }
157157
158158
@@ -163,176 +163,176 @@
163163
164164 void CaptureSettingWidget::closeEvent(QCloseEvent* event)
165165 {
166- static_cast<void>(event);
166+ static_cast<void>(event);
167167
168- emit widgetClose("CaptureSettingWidget");
169- close();
168+ emit widgetClose("CaptureSettingWidget");
169+ close();
170170 }
171171
172172
173173 void CaptureSettingWidget::applyPressed(void)
174174 {
175- apply_button_->setEnabled(false);
175+ apply_button_->setEnabled(false);
176176
177- pimpl->apply_completed_ = false;
177+ pimpl->apply_completed_ = false;
178178
179- CaptureSettings settings;
180- pimpl->createSettings(settings);
179+ CaptureSettings settings;
180+ pimpl->createSettings(settings);
181181
182- // 新しいパラメータを送信
183- emit setCaptureSettings(settings);
182+ // 新しいパラメータを送信
183+ emit setCaptureSettings(settings);
184184
185- // 再接続の要求を送信
186- emit reconnectRequest();
185+ // 再接続の要求を送信
186+ emit reconnectRequest();
187187 }
188188
189189
190190 void CaptureSettingWidget::loadPressed(void)
191191 {
192- if (! pimpl->sensor_.isConnected()) {
193- return;
194- }
192+ if (! pimpl->sensor_.isConnected()) {
193+ return;
194+ }
195195
196- pimpl->parameter_ = pimpl->sensor_.parameter();
197- pimpl->range_view_widget_.setParameter(pimpl->parameter_);
196+ pimpl->parameter_ = pimpl->sensor_.parameter();
197+ pimpl->range_view_widget_.setParameter(pimpl->parameter_);
198198
199- // 読み出した取得範囲の情報を、フォームに反映させる
200- int first_index = pimpl->parameter_.area_min;
201- int last_index = pimpl->parameter_.area_max;
202- range_first_spinbox_->setValue(first_index);
203- range_last_spinbox_->setValue(last_index);
199+ // 読み出した取得範囲の情報を、フォームに反映させる
200+ int first_index = pimpl->parameter_.area_min;
201+ int last_index = pimpl->parameter_.area_max;
202+ range_first_spinbox_->setValue(first_index);
203+ range_last_spinbox_->setValue(last_index);
204204
205- setApplyEnabled(true);
205+ setApplyEnabled(true);
206206
207- emit rangeChanged(first_index, last_index);
207+ emit rangeChanged(first_index, last_index);
208208 }
209209
210210
211211 void CaptureSettingWidget::reconnectCompleted(void)
212212 {
213- pimpl->apply_completed_ = true;
213+ pimpl->apply_completed_ = true;
214214 }
215215
216216
217217 void CaptureSettingWidget::firstFinished(void)
218218 {
219- // last の値を first 以上にする
220- int first_value = range_first_spinbox_->value();
221- if (first_value > range_last_spinbox_->value()) {
222- range_last_spinbox_->setValue(first_value);
223- }
219+ // last の値を first 以上にする
220+ int first_value = range_first_spinbox_->value();
221+ if (first_value > range_last_spinbox_->value()) {
222+ range_last_spinbox_->setValue(first_value);
223+ }
224224 }
225225
226226
227227 void CaptureSettingWidget::lastFinished(void)
228228 {
229- int last_value = range_last_spinbox_->value();
229+ int last_value = range_last_spinbox_->value();
230230
231- // !!! この実装が汚いのをなんとかする
232- if (pimpl->parameter_.area_min != pimpl->parameter_.area_max) {
233- // パラメータ読み出し後のみ、制限をつける
234- if (last_value > pimpl->parameter_.area_max) {
235- last_value = pimpl->parameter_.area_max;
236- range_last_spinbox_->setValue(last_value);
231+ // !!! この実装が汚いのをなんとかする
232+ if (pimpl->parameter_.area_min != pimpl->parameter_.area_max) {
233+ // パラメータ読み出し後のみ、制限をつける
234+ if (last_value > pimpl->parameter_.area_max) {
235+ last_value = pimpl->parameter_.area_max;
236+ range_last_spinbox_->setValue(last_value);
237+ }
237238 }
238- }
239239
240- // first の値を last 以下にする
241- if (last_value < range_first_spinbox_->value()) {
242- range_first_spinbox_->setValue(last_value);
243- }
240+ // first の値を last 以下にする
241+ if (last_value < range_first_spinbox_->value()) {
242+ range_first_spinbox_->setValue(last_value);
243+ }
244244 }
245245
246246
247247 void CaptureSettingWidget::isRangeChanged(void)
248248 {
249- emit rangeChanged(range_first_spinbox_->value(),
250- range_last_spinbox_->value());
249+ emit rangeChanged(range_first_spinbox_->value(),
250+ range_last_spinbox_->value());
251251
252- pimpl->updateApplyButton();
252+ pimpl->updateApplyButton();
253253 }
254254
255255
256256 void CaptureSettingWidget::modeChanged(int type)
257257 {
258- // GD, MD 各モードでの setEnable() を調整する
259- bool md_enable = ((type == MD) || (type == ME)) ? true : false;
258+ // GD, MD 各モードでの setEnable() を調整する
259+ bool md_enable = ((type == MD) || (type == ME)) ? true : false;
260260
261- frame_skips_label_->setEnabled(md_enable);
262- frame_skips_spinbox_->setEnabled(md_enable);
261+ frame_skips_label_->setEnabled(md_enable);
262+ frame_skips_spinbox_->setEnabled(md_enable);
263263
264- capture_times_label_->setEnabled(md_enable);
265- pimpl->setTimesEnabled(md_enable);
264+ capture_times_label_->setEnabled(md_enable);
265+ pimpl->setTimesEnabled(md_enable);
266266
267- pimpl->updateApplyButton();
267+ pimpl->updateApplyButton();
268268 }
269269
270270
271271 void CaptureSettingWidget::timesChanged(void)
272272 {
273- // Infinity のときに、n_times_spinbox_ を無効にする
274- pimpl->setTimesEnabled(true);
273+ // Infinity のときに、n_times_spinbox_ を無効にする
274+ pimpl->setTimesEnabled(true);
275275
276- pimpl->updateApplyButton();
276+ pimpl->updateApplyButton();
277277 }
278278
279279
280280 void CaptureSettingWidget::setIntensityMode(bool enable_cluster)
281281 {
282- intensity_button_->show();
283- setMode(ME);
284- gd_button_->hide();
285- md_button_->hide();
282+ intensity_button_->show();
283+ setMode(ME);
284+ gd_button_->hide();
285+ md_button_->hide();
286286
287- // UTM 以外の場合は "まとめる数" の属性が指定できないため、無効にする
288- line_group_label_->setEnabled(enable_cluster);
289- line_group_spinbox_->setEnabled(enable_cluster);
287+ // UTM 以外の場合は "まとめる数" の属性が指定できないため、無効にする
288+ line_group_label_->setEnabled(enable_cluster);
289+ line_group_spinbox_->setEnabled(enable_cluster);
290290 }
291291
292292
293293 void CaptureSettingWidget::setMode(CaptureType type)
294294 {
295- pimpl->setMode(type);
295+ pimpl->setMode(type);
296296 }
297297
298298
299299 void CaptureSettingWidget::setTimes(size_t times)
300300 {
301- pimpl->setTimes(times);
301+ pimpl->setTimes(times);
302302 }
303303
304304
305305 void CaptureSettingWidget::setApplyEnabled(bool enable)
306306 {
307- apply_button_->setEnabled(enable);
307+ apply_button_->setEnabled(enable);
308308 }
309309
310310
311311 void CaptureSettingWidget::quitPressed(void)
312312 {
313- emit quit();
313+ emit quit();
314314 }
315315
316316
317317 void CaptureSettingWidget::setConnected(bool connection)
318318 {
319- load_button_->setEnabled(connection);
319+ load_button_->setEnabled(connection);
320320 }
321321
322322
323323 void CaptureSettingWidget::lineGroupsChanged(void)
324324 {
325- pimpl->updateApplyButton();
325+ pimpl->updateApplyButton();
326326 }
327327
328328
329329 void CaptureSettingWidget::frameSkipsChanged(void)
330330 {
331- pimpl->updateApplyButton();
331+ pimpl->updateApplyButton();
332332 }
333333
334334
335335 void CaptureSettingWidget::captureTimesChanged(void)
336336 {
337- pimpl->updateApplyButton();
337+ pimpl->updateApplyButton();
338338 }
--- trunk/programs/UrgViewer/UrgViewerWindow.cpp (revision 1816)
+++ trunk/programs/UrgViewer/UrgViewerWindow.cpp (revision 1817)
@@ -41,507 +41,519 @@
4141
4242 namespace
4343 {
44- const char* Version = "1.0.3";
44+ const char* Version = "1.0.3";
4545
46- const char* Organization = "Hokuyo LTD.";
47- const char* Application = "URG Viewer";
48- const char* UrgDefaultAddress = "192.168.0.10";
46+ const char* Organization = "Hokuyo LTD.";
47+ const char* Application = "URG Viewer";
48+ const char* UrgDefaultAddress = "192.168.0.10";
4949
50- enum {
51- UrgDefaultPort = 10940,
52- InvalidTimestamp = -1,
53- };
50+ enum {
51+ UrgDefaultPort = 10940,
52+ InvalidTimestamp = -1,
53+ };
5454 }
5555
5656
5757 struct UrgViewerWindow::pImpl
5858 {
59- UrgViewerWindow* widget_;
59+ UrgViewerWindow* widget_;
6060
61- mUrgDevice urg_;
62- SerialDevice* serial_connection_;
63- TcpipSocket ethernet_connection_;
61+ mUrgDevice urg_;
62+ SerialDevice* serial_connection_;
63+ TcpipSocket ethernet_connection_;
6464
65- FindComPorts com_finder_;
66- UrgUsbCom urg_usb_;
65+ FindComPorts com_finder_;
66+ UrgUsbCom urg_usb_;
6767
68- CaptureSettingWidget capture_setting_widget_;
69- LengthViewWidget length_view_widget_;
68+ CaptureSettingWidget capture_setting_widget_;
69+ LengthViewWidget length_view_widget_;
7070
71- UrgDrawWidget urg_draw_widget_;
72- SerialConnectionWidget serial_connection_widget_;
73- EthernetConnectionWidget ethernet_connection_widget_;
74- RangeSensorConnectThread connect_thread_;
75- bool draw_intensity_;
76- Lock urg_mutex_;
71+ UrgDrawWidget urg_draw_widget_;
72+ SerialConnectionWidget serial_connection_widget_;
73+ EthernetConnectionWidget ethernet_connection_widget_;
74+ RangeSensorConnectThread connect_thread_;
75+ bool draw_intensity_;
76+ Lock urg_mutex_;
7777
78- QTimer capture_timer_;
79- long last_timestamp_;
80- QDateTime last_record_time_;
78+ QTimer capture_timer_;
79+ long last_timestamp_;
80+ QDateTime last_record_time_;
8181
82- RangeSensorParameter parameter_;
83- CaptureSettings* settings_;
82+ RangeSensorParameter parameter_;
83+ CaptureSettings* settings_;
8484
85- bool set_length_view_;
86- vector<int> draw_line_indexes_;
87- vector<Point<long> > draw_line_points_;
85+ bool set_length_view_;
86+ vector<int> draw_line_indexes_;
87+ vector<Point<long> > draw_line_points_;
8888
8989
90- pImpl(int argc, char *argv[], UrgViewerWindow* widget)
91- : widget_(widget), urg_(argc, argv), serial_connection_(NULL),
92- capture_setting_widget_(urg_), connect_thread_(urg_),
93- draw_intensity_(false), last_timestamp_(InvalidTimestamp),
94- last_record_time_(QDateTime::currentDateTime()),
95- settings_(NULL), set_length_view_(false)
96- {
97- com_finder_.addBaseName("/dev/ttyACM");
98- com_finder_.addBaseName("/dev/tty.usbmodem");
90+ pImpl(int argc, char *argv[], UrgViewerWindow* widget)
91+ : widget_(widget), urg_(argc, argv), serial_connection_(NULL),
92+ capture_setting_widget_(urg_), connect_thread_(urg_),
93+ draw_intensity_(false), last_timestamp_(InvalidTimestamp),
94+ last_record_time_(QDateTime::currentDateTime()),
95+ settings_(NULL), set_length_view_(false)
96+ {
97+ com_finder_.addBaseName("/dev/ttyACM");
98+ com_finder_.addBaseName("/dev/tty.usbmodem");
9999
100- com_finder_.addDriverName("URG Series USB Device Driver");
101- com_finder_.addDriverName("URG-X002 USB Device Driver");
100+ com_finder_.addDriverName("URG Series USB Device Driver");
101+ com_finder_.addDriverName("URG-X002 USB Device Driver");
102102
103- ethernet_connection_widget_.setPort(UrgDefaultPort);
103+ ethernet_connection_widget_.setPort(UrgDefaultPort);
104104
105- for (int i = 1; i < argc; ++i) {
106- if (! strcmp("-i", argv[i])) {
107- draw_intensity_ = true;
108- }
105+ for (int i = 1; i < argc; ++i) {
106+ if (! strcmp("-i", argv[i])) {
107+ draw_intensity_ = true;
108+ }
109+ }
110+
111+ if (draw_intensity_) {
112+ capture_setting_widget_.setIntensityMode();
113+ }
109114 }
110115
111- if (draw_intensity_) {
112- capture_setting_widget_.setIntensityMode();
116+
117+ ~pImpl(void)
118+ {
119+ delete settings_;
113120 }
114- }
115121
116122
117- ~pImpl(void)
118- {
119- delete settings_;
120- }
123+ void initializeForm(void)
124+ {
125+ // タイトルにバージョン情報を付加
126+ const QString title = widget_->windowTitle() + " " + Version;
127+ widget_->setWindowTitle(title);
121128
129+ // ウィジットの配置
130+ widget_->dummy_label_2_->hide();
131+ widget_->main_layout_->addWidget(&urg_draw_widget_);
132+ widget_->connect_layout_->addWidget(&serial_connection_widget_);
133+ widget_->connect_layout_->addWidget(&ethernet_connection_widget_);
122134
123- void initializeForm(void)
124- {
125- // タイトルにバージョン情報を付加
126- const QString title = widget_->windowTitle() + " " + Version;
127- widget_->setWindowTitle(title);
135+ // メニュー項目
136+ connect(widget_->action_quit_, SIGNAL(triggered()),
137+ widget_, SLOT(close()));
138+ connect(widget_->action_about_, SIGNAL(triggered()),
139+ widget_, SLOT(aboutApplication()));
140+ connect(widget_->action_zoomIn_, SIGNAL(triggered()),
141+ widget_, SLOT(zoomLarger()));
142+ connect(widget_->action_zoomOut_, SIGNAL(triggered()),
143+ widget_, SLOT(zoomSmaller()));
144+ connect(widget_->action_capture_setting_, SIGNAL(triggered()),
145+ widget_, SLOT(showCaptureSettingWidget()));
146+ connect(widget_->action_length_view_, SIGNAL(triggered()),
147+ widget_, SLOT(showLengthViewWidget()));
148+ connect(widget_->action_serial_, SIGNAL(triggered()),
149+ widget_, SLOT(selectSerial()));
150+ connect(widget_->action_ethernet_, SIGNAL(triggered()),
151+ widget_, SLOT(selectEthernet()));
128152
129- // ウィジットの配置
130- widget_->dummy_label_2_->hide();
131- widget_->main_layout_->addWidget(&urg_draw_widget_);
132- widget_->connect_layout_->addWidget(&serial_connection_widget_);
133- widget_->connect_layout_->addWidget(&ethernet_connection_widget_);
153+ // URG デバイス
154+ connect(&capture_timer_, SIGNAL(timeout()),
155+ widget_, SLOT(captureHandler()));
134156
135- // メニュー項目
136- connect(widget_->action_quit_, SIGNAL(triggered()),
137- widget_, SLOT(close()));
138- connect(widget_->action_about_, SIGNAL(triggered()),
139- widget_, SLOT(aboutApplication()));
140- connect(widget_->action_zoomIn_, SIGNAL(triggered()),
141- widget_, SLOT(zoomLarger()));
142- connect(widget_->action_zoomOut_, SIGNAL(triggered()),
143- widget_, SLOT(zoomSmaller()));
144- connect(widget_->action_capture_setting_, SIGNAL(triggered()),
145- widget_, SLOT(showCaptureSettingWidget()));
146- connect(widget_->action_length_view_, SIGNAL(triggered()),
147- widget_, SLOT(showLengthViewWidget()));
148- connect(widget_->action_serial_, SIGNAL(triggered()),
149- widget_, SLOT(selectSerial()));
150- connect(widget_->action_ethernet_, SIGNAL(triggered()),
151- widget_, SLOT(selectEthernet()));
157+ // Serial 接続
158+ connect(&serial_connection_widget_, SIGNAL(rescanRequest()),
159+ widget_, SLOT(rescanPressed()));
160+ connect(&serial_connection_widget_,
161+ SIGNAL(connectRequest(bool, const std::string&)),
162+ widget_, SLOT(connectPressed(bool, const std::string&)));
163+ connect(&connect_thread_, SIGNAL(connected(bool)),
164+ widget_, SLOT(connectDevice(bool)));
152165
153- // URG デバイス
154- connect(&capture_timer_, SIGNAL(timeout()),
155- widget_, SLOT(captureHandler()));
166+ // Ethernet 接続
167+ connect(&ethernet_connection_widget_,
168+ SIGNAL(connectRequest(bool, const std::string&,
169+ unsigned short)),
170+ widget_, SLOT(connectPressed(bool, const std::string&,
171+ unsigned short)));
156172
157- // Serial 接続
158- connect(&serial_connection_widget_, SIGNAL(rescanRequest()),
159- widget_, SLOT(rescanPressed()));
160- connect(&serial_connection_widget_,
161- SIGNAL(connectRequest(bool, const std::string&)),
162- widget_, SLOT(connectPressed(bool, const std::string&)));
163- connect(&connect_thread_, SIGNAL(connected(bool)),
164- widget_, SLOT(connectDevice(bool)));
173+ // ステータスバー表示
174+ connect(&urg_draw_widget_, SIGNAL(position(bool, long, long)),
175+ widget_, SLOT(updateStatusBar(bool, long, long)));
165176
166- // Ethernet 接続
167- connect(&ethernet_connection_widget_,
168- SIGNAL(connectRequest(bool, const std::string&, unsigned short)),
169- widget_,
170- SLOT(connectPressed(bool, const std::string&, unsigned short)));
177+ // キー割り付け
178+ (void) new QShortcut(Qt::Key_Return, widget_, SLOT(initializeView()));
179+ (void) new QShortcut(Qt::Key_Less, widget_, SLOT(zoomSmaller()));
180+ (void) new QShortcut(Qt::Key_Comma, widget_, SLOT(zoomSmaller()));
181+ (void) new QShortcut(Qt::Key_Greater, widget_, SLOT(zoomLarger()));
182+ (void) new QShortcut(Qt::Key_Period, widget_, SLOT(zoomLarger()));
171183
172- // ステータスバー表示
173- connect(&urg_draw_widget_, SIGNAL(position(bool, long, long)),
174- widget_, SLOT(updateStatusBar(bool, long, long)));
184+ // 外部 Widget からのシグナル
185+ connect(&capture_setting_widget_,
186+ SIGNAL(setCaptureSettings(const qrk::CaptureSettings&)),
187+ widget_,
188+ SLOT(receiveCaptureSettings(const qrk::CaptureSettings&)));
189+ connect(&capture_setting_widget_, SIGNAL(reconnectRequest()),
190+ widget_, SLOT(receiveReconnectRequest()));
191+ connect(&length_view_widget_, SIGNAL(lengthViewRequest()),
192+ widget_, SLOT(receiveLengthViewRequest()));
175193
176- // キー割り付け
177- (void) new QShortcut(Qt::Key_Return, widget_, SLOT(initializeView()));
178- (void) new QShortcut(Qt::Key_Less, widget_, SLOT(zoomSmaller()));
179- (void) new QShortcut(Qt::Key_Comma, widget_, SLOT(zoomSmaller()));
180- (void) new QShortcut(Qt::Key_Greater, widget_, SLOT(zoomLarger()));
181- (void) new QShortcut(Qt::Key_Period, widget_, SLOT(zoomLarger()));
194+ connect(&capture_setting_widget_,
195+ SIGNAL(widgetClose(const std::string&)),
196+ widget_, SLOT(receiveWidgetClose(const std::string&)));
197+ connect(&length_view_widget_, SIGNAL(widgetClose(const std::string&)),
198+ widget_, SLOT(receiveWidgetClose(const std::string&)));
199+ connect(&length_view_widget_, SIGNAL(quit()), widget_, SLOT(close()));
200+ connect(&capture_setting_widget_, SIGNAL(quit()),
201+ widget_, SLOT(close()));
182202
183- // 外部 Widget からのシグナル
184- connect(&capture_setting_widget_,
185- SIGNAL(setCaptureSettings(const qrk::CaptureSettings&)),
186- widget_, SLOT(receiveCaptureSettings(const qrk::CaptureSettings&)));
187- connect(&capture_setting_widget_, SIGNAL(reconnectRequest()),
188- widget_, SLOT(receiveReconnectRequest()));
189- connect(&length_view_widget_, SIGNAL(lengthViewRequest()),
190- widget_, SLOT(receiveLengthViewRequest()));
203+ connect(&length_view_widget_,
204+ SIGNAL(drawLineRequest(const std::vector<int>&)),
205+ widget_, SLOT(receiveDrawLine(const std::vector<int>&)));
191206
192- connect(&capture_setting_widget_, SIGNAL(widgetClose(const std::string&)),
193- widget_, SLOT(receiveWidgetClose(const std::string&)));
194- connect(&length_view_widget_, SIGNAL(widgetClose(const std::string&)),
195- widget_, SLOT(receiveWidgetClose(const std::string&)));
196- connect(&length_view_widget_, SIGNAL(quit()), widget_, SLOT(close()));
197- connect(&capture_setting_widget_, SIGNAL(quit()), widget_, SLOT(close()));
207+ connect(widget_, SIGNAL(reconnectCompleted()),
208+ &capture_setting_widget_, SLOT(reconnectCompleted()));
198209
199- connect(&length_view_widget_,
200- SIGNAL(drawLineRequest(const std::vector<int>&)),
201- widget_, SLOT(receiveDrawLine(const std::vector<int>&)));
210+ // キー割り付け
211+ (void) new QShortcut(Qt::CTRL + Qt::Key_W, widget_, SLOT(close()));
202212
203- connect(widget_, SIGNAL(reconnectCompleted()),
204- &capture_setting_widget_, SLOT(reconnectCompleted()));
213+ widget_->rescanPressed();
214+ }
205215
206- // キー割り付け
207- (void) new QShortcut(Qt::CTRL + Qt::Key_W, widget_, SLOT(close()));
208216
209- widget_->rescanPressed();
210- }
217+ void saveSettings(void)
218+ {
219+ QSettings settings(Organization, Application);
211220
221+ settings.setValue("geometry", widget_->saveGeometry());
222+ settings.setValue("LengthView_geometry",
223+ length_view_widget_.saveGeometry());
224+ settings.setValue("CaptureSetting_geometry",
225+ capture_setting_widget_.saveGeometry());
212226
213- void saveSettings(void)
214- {
215- QSettings settings(Organization, Application);
227+ if (MonitorModeManager::object()->mode() != MonitorModeManager::Play) {
228+ settings.setValue("LengthView_showed",
229+ widget_->action_length_view_->isChecked());
230+ settings.setValue("CaptureSetting_showed",
231+ widget_->action_capture_setting_->isChecked());
232+ }
216233
217- settings.setValue("geometry", widget_->saveGeometry());
218- settings.setValue("LengthView_geometry",
219- length_view_widget_.saveGeometry());
220- settings.setValue("CaptureSetting_geometry",
221- capture_setting_widget_.saveGeometry());
234+ bool use_serial = serial_connection_widget_.isVisible();
235+ settings.setValue("serial_connection", use_serial);
222236
223- if (MonitorModeManager::object()->mode() != MonitorModeManager::Play) {
224- settings.setValue("LengthView_showed",
225- widget_->action_length_view_->isChecked());
226- settings.setValue("CaptureSetting_showed",
227- widget_->action_capture_setting_->isChecked());
237+ settings.setValue("address",
238+ ethernet_connection_widget_.address().c_str());
239+ settings.setValue("port", ethernet_connection_widget_.port());
240+
228241 }
229242
230- bool use_serial = serial_connection_widget_.isVisible();
231- settings.setValue("serial_connection", use_serial);
232243
233- settings.setValue("address", ethernet_connection_widget_.address().c_str());
234- settings.setValue("port", ethernet_connection_widget_.port());
244+ void loadSettings(void)
245+ {
246+ QSettings settings(Organization, Application);
235247
236- }
248+ widget_->restoreGeometry(settings.value("geometry").toByteArray());
249+ length_view_widget_.
250+ restoreGeometry(settings.value("LengthView_geometry").toByteArray());
251+ capture_setting_widget_.
252+ restoreGeometry(settings.value("CaptureSetting_geometry").toByteArray());
237253
254+ if (MonitorModeManager::object()->mode() != MonitorModeManager::Play) {
255+ if (settings.value("LengthView_showed", false).toBool() == true) {
256+ activateWidget(&length_view_widget_,
257+ widget_->action_length_view_);
258+ }
259+ if (settings.value("CaptureSetting_showed",
260+ false).toBool() == true) {
261+ activateWidget(&capture_setting_widget_,
262+ widget_->action_capture_setting_);
263+ }
264+ }
238265
239- void loadSettings(void)
240- {
241- QSettings settings(Organization, Application);
266+ bool use_serial = settings.value("serial_connection", true).toBool();
267+ if (use_serial) {
268+ widget_->selectSerial();
269+ } else {
270+ widget_->selectEthernet();
271+ }
242272
243- widget_->restoreGeometry(settings.value("geometry").toByteArray());
244- length_view_widget_.
245- restoreGeometry(settings.value("LengthView_geometry").toByteArray());
246- capture_setting_widget_.
247- restoreGeometry(settings.value("CaptureSetting_geometry").toByteArray());
248-
249- if (MonitorModeManager::object()->mode() != MonitorModeManager::Play) {
250- if (settings.value("LengthView_showed", false).toBool() == true) {
251- activateWidget(&length_view_widget_,
252- widget_->action_length_view_);
253- }
254- if (settings.value("CaptureSetting_showed", false).toBool() == true) {
255- activateWidget(&capture_setting_widget_,
256- widget_->action_capture_setting_);
257- }
273+ string address =
274+ settings.value("address",
275+ UrgDefaultAddress).toString().toStdString();
276+ ethernet_connection_widget_.setAddress(address);
277+ unsigned short port = settings.value("port", UrgDefaultPort).toInt();
278+ ethernet_connection_widget_.setPort(port);
258279 }
259280
260- bool use_serial = settings.value("serial_connection", true).toBool();
261- if (use_serial) {
262- widget_->selectSerial();
263- } else {
264- widget_->selectEthernet();
265- }
266281
267- string address =
268- settings.value("address", UrgDefaultAddress).toString().toStdString();
269- ethernet_connection_widget_.setAddress(address);
270- unsigned short port = settings.value("port", UrgDefaultPort).toInt();
271- ethernet_connection_widget_.setPort(port);
272- }
282+ void connectDevice(bool connected)
283+ {
284+ last_timestamp_ = InvalidTimestamp;
285+ serial_connection_widget_.setConnected(connected);
286+ ethernet_connection_widget_.setConnected(connected);
287+ capture_setting_widget_.setConnected(connected);
288+ if (! connected) {
289+ // エラーメッセージのポップアップ表示
290+ QString error_message = localedToUnicode(urg_.what());
291+ QMessageBox::warning(widget_,
292+ tr("Connection error"), error_message);
293+ return;
294+ }
273295
296+ // パラメータ情報が与えられていない場合、センサ情報を反映させる
297+ parameter_ = urg_.parameter();
298+ if (! settings_) {
299+ settings_ = initializeCaptureSettings(parameter_.area_min,
300+ parameter_.area_max);
301+ capture_setting_widget_.loadPressed();
302+ }
274303
275- void connectDevice(bool connected)
276- {
277- last_timestamp_ = InvalidTimestamp;
278- serial_connection_widget_.setConnected(connected);
279- ethernet_connection_widget_.setConnected(connected);
280- capture_setting_widget_.setConnected(connected);
281- if (! connected) {
282- // エラーメッセージのポップアップ表示
283- QString error_message = localedToUnicode(urg_.what());
284- QMessageBox::warning(widget_, tr("Connection error"), error_message);
285- return;
286- }
304+ size_t type_length = parameter_.model.find('(');
305+ string urg_type = parameter_.model.substr(0, type_length);
306+ bool cluster_enable =
307+ ! (draw_intensity_ && urg_type.compare("UTM-30LX"));
308+ if (draw_intensity_) {
309+ capture_setting_widget_.setIntensityMode(cluster_enable);
310+ }
287311
288- // パラメータ情報が与えられていない場合、センサ情報を反映させる
289- parameter_ = urg_.parameter();
290- if (! settings_) {
291- settings_ = initializeCaptureSettings(parameter_.area_min,
292- parameter_.area_max);
293- capture_setting_widget_.loadPressed();
294- }
312+ receiveReconnectRequest();
313+ length_view_widget_.setMinDistance(urg_.minDistance());
295314
296- size_t type_length = parameter_.model.find('(');
297- string urg_type = parameter_.model.substr(0, type_length);
298- bool cluster_enable = ! (draw_intensity_ && urg_type.compare("UTM-30LX"));
299- if (draw_intensity_) {
300- capture_setting_widget_.setIntensityMode(cluster_enable);
315+ // URG 設定
316+ urg_.setTimestamp(ticks());
317+ int scan_msec = urg_.scanMsec();
318+ urg_draw_widget_.setDrawPeriod(scan_msec);
319+
320+ // データの取得開始
321+ capture_timer_.setInterval(scan_msec / 2);
322+ capture_timer_.start();
301323 }
302324
303- receiveReconnectRequest();
304- length_view_widget_.setMinDistance(urg_.minDistance());
305325
306- // URG 設定
307- urg_.setTimestamp(ticks());
308- int scan_msec = urg_.scanMsec();
309- urg_draw_widget_.setDrawPeriod(scan_msec);
326+ CaptureSettings* initializeCaptureSettings(int first_index, int last_index)
327+ {
328+ CaptureSettings* settings = new CaptureSettings;
329+ settings->type = MD;
330+ settings->capture_first = first_index;
331+ settings->capture_last = last_index;
332+ settings->skip_lines = 1;
333+ settings->skip_frames = 0;
334+ settings->remain_times = 0;
335+ settings->data_byte = 3;
310336
311- // データの取得開始
312- capture_timer_.setInterval(scan_msec / 2);
313- capture_timer_.start();
314- }
337+ return settings;
338+ }
315339
340+ void receiveReconnectRequest(void)
341+ {
342+ capture_timer_.stop();
343+ urg_draw_widget_.clear();
316344
317- CaptureSettings* initializeCaptureSettings(int first_index, int last_index)
318- {
319- CaptureSettings* settings = new CaptureSettings;
320- settings->type = MD;
321- settings->capture_first = first_index;
322- settings->capture_last = last_index;
323- settings->skip_lines = 1;
324- settings->skip_frames = 0;
325- settings->remain_times = 0;
326- settings->data_byte = 3;
345+ if (draw_intensity_) {
346+ urg_.setCaptureMode(IntensityCapture);
327347
328- return settings;
329- }
348+ } else if (settings_->type == MD) {
349+ urg_.setCaptureMode(AutoCapture);
330350
331- void receiveReconnectRequest(void)
332- {
333- capture_timer_.stop();
334- urg_draw_widget_.clear();
351+ } else if (settings_->type == GD) {
352+ urg_.setCaptureMode(ManualCapture);
353+ }
335354
336- if (draw_intensity_) {
337- urg_.setCaptureMode(IntensityCapture);
355+ urg_.setCaptureRange(settings_->capture_first, settings_->capture_last);
356+ urg_.setCaptureSkipLines(settings_->skip_lines);
338357
339- } else if (settings_->type == MD) {
340- urg_.setCaptureMode(AutoCapture);
358+ if (settings_->type != GD) {
359+ urg_.setCaptureFrameInterval(settings_->skip_frames);
360+ urg_.setCaptureTimes(settings_->remain_times);
361+ }
341362
342- } else if (settings_->type == GD) {
343- urg_.setCaptureMode(ManualCapture);
363+ if (! urg_.isConnected()) {
364+ // 未接続ならば再開させない
365+ return;
366+ }
367+
368+ setConnectionMenuEnabled(false);
369+ capture_timer_.start();
344370 }
345371
346- urg_.setCaptureRange(settings_->capture_first, settings_->capture_last);
347- urg_.setCaptureSkipLines(settings_->skip_lines);
348372
349- if (settings_->type != GD) {
350- urg_.setCaptureFrameInterval(settings_->skip_frames);
351- urg_.setCaptureTimes(settings_->remain_times);
352- }
373+ void disconnectDevice(void)
374+ {
375+ // データの取得停止
376+ widget_->scans_label_->setText("");
377+ capture_timer_.stop();
378+ urg_draw_widget_.clear();
379+ capture_setting_widget_.setApplyEnabled(true);
353380
354- if (! urg_.isConnected()) {
355- // 未接続ならば再開させない
356- return;
381+ serial_connection_widget_.setConnected(false);
382+ ethernet_connection_widget_.setConnected(false);
383+ capture_setting_widget_.setConnected(false);
384+ setConnectionMenuEnabled(true);
357385 }
358386
359- setConnectionMenuEnabled(false);
360- capture_timer_.start();
361- }
362387
388+ void setConnectionMenuEnabled(bool enabled)
389+ {
390+ widget_->action_serial_->setEnabled(enabled);
391+ widget_->action_ethernet_->setEnabled(enabled);
392+ }
363393
364- void disconnectDevice(void)
365- {
366- // データの取得停止
367- widget_->scans_label_->setText("");
368- capture_timer_.stop();
369- urg_draw_widget_.clear();
370- capture_setting_widget_.setApplyEnabled(true);
371394
372- serial_connection_widget_.setConnected(false);
373- ethernet_connection_widget_.setConnected(false);
374- capture_setting_widget_.setConnected(false);
375- setConnectionMenuEnabled(true);
376- }
395+ void captureHandler(void)
396+ {
397+ LockGuard guard(urg_mutex_);
377398
399+ vector<long> data;
400+ vector<long> intensity_data;
401+ long timestamp = 0;
378402
379- void setConnectionMenuEnabled(bool enabled)
380- {
381- widget_->action_serial_->setEnabled(enabled);
382- widget_->action_ethernet_->setEnabled(enabled);
383- }
403+ RangeCaptureMode capture_mode = urg_.captureMode();
404+ int n = 0;
405+ if (capture_mode != IntensityCapture) {
406+ n = urg_.capture(data, &timestamp);
384407
408+ } else {
409+ n = urg_.captureWithIntensity(data, intensity_data, &timestamp);
410+ }
411+ if (n <= 0) {
412+ return;
413+ }
385414
386- void captureHandler(void)
387- {
388- LockGuard guard(urg_mutex_);
389-
390- vector<long> data;
391- vector<long> intensity_data;
392- long timestamp = 0;
393-
394- RangeCaptureMode capture_mode = urg_.captureMode();
395- int n = 0;
396- if (capture_mode != IntensityCapture) {
397- n = urg_.capture(data, &timestamp);
398-
399- } else {
400- n = urg_.captureWithIntensity(data, intensity_data, &timestamp);
401- }
402- if (n <= 0) {
403- return;
404- }
405-
406415 #if 0
407- // !!! debug message
408- QDateTime current = QDateTime::currentDateTime();
409- if (last_record_time_.secsTo(current) >= 60) {
410- log_printf("%s\n", current.toString(Qt::ISODate).toStdString().c_str());
411- last_record_time_ = current;
412- }
416+ // !!! debug message
417+ QDateTime current = QDateTime::currentDateTime();
418+ if (last_record_time_.secsTo(current) >= 60) {
419+ log_printf("%s\n",
420+ current.toString(Qt::ISODate).toStdString().c_str());
421+ last_record_time_ = current;
422+ }
413423 #endif
414424
415- // update "scans interval"
416- int interval_msec = timestamp - last_timestamp_;
417- if (last_timestamp_ != InvalidTimestamp) {
418- widget_->updateScansInterval(interval_msec);
419- }
420- last_timestamp_ = timestamp;
425+ // update "scans interval"
426+ int interval_msec = timestamp - last_timestamp_;
427+ if (last_timestamp_ != InvalidTimestamp) {
428+ widget_->updateScansInterval(interval_msec);
429+ }
430+ last_timestamp_ = timestamp;
421431
422- // setUrgData() を呼び出すとデータは空になるので、
423- // ここで LengthView 用のデータ格納を行う
424- if (set_length_view_) {
425- set_length_view_ = false;
432+ // setUrgData() を呼び出すとデータは空になるので、
433+ // ここで LengthView 用のデータ格納を行う
434+ if (set_length_view_) {
435+ set_length_view_ = false;
426436
427- length_view_widget_.setLength(data);
428- if (capture_mode == IntensityCapture) {
429- length_view_widget_.setIntensity(intensity_data);
430- }
431- }
437+ length_view_widget_.setLength(data);
438+ if (capture_mode == IntensityCapture) {
439+ length_view_widget_.setIntensity(intensity_data);
440+ }
441+ }
432442
433- // 補助線の登録
434- for (vector<int>::iterator it = draw_line_indexes_.begin();
435- it != draw_line_indexes_.end(); ++it) {
436- double radian = urg_.index2rad(*it) + (M_PI/2.0);
437- int x = static_cast<int>(100 * 1000 * cos(radian));
438- int y = static_cast<int>(100 * 1000 * sin(radian));
439- draw_line_points_.push_back(Point<long>(x, y));
440- }
441- urg_draw_widget_.setDrawColor(Color(0.0, 1.0, 0.0, 1.0));
442- urg_draw_widget_.setUrgData(draw_line_points_, timestamp);
443+ // 補助線の登録
444+ for (vector<int>::iterator it = draw_line_indexes_.begin();
445+ it != draw_line_indexes_.end(); ++it) {
446+ double radian = urg_.index2rad(*it) + (M_PI/2.0);
447+ int x = static_cast<int>(100 * 1000 * cos(radian));
448+ int y = static_cast<int>(100 * 1000 * sin(radian));
449+ draw_line_points_.push_back(Point<long>(x, y));
450+ }
451+ urg_draw_widget_.setDrawColor(Color(0.0, 1.0, 0.0, 1.0));
452+ urg_draw_widget_.setUrgData(draw_line_points_, timestamp);
443453
444- // 描画データの登録
445- if (capture_mode == IntensityCapture) {
446- urg_draw_widget_.setUrgIntensityData(intensity_data, &urg_, timestamp);
447- }
448- urg_draw_widget_.setDrawColor(Color(0.2f, 0.2f, 1.0f, 0.6f));
449- urg_draw_widget_.setUrgData(data, &urg_, timestamp);
454+ // 描画データの登録
455+ if (capture_mode == IntensityCapture) {
456+ urg_draw_widget_.setUrgIntensityData(intensity_data,
457+ &urg_, timestamp);
458+ }
459+ urg_draw_widget_.setDrawColor(Color(0.2f, 0.2f, 1.0f, 0.6f));
460+ urg_draw_widget_.setUrgData(data, &urg_, timestamp);
450461
451- // 一定間隔での描画
452- // !!! FPS を定義する
453- // !!! 可能ならば、URG のタイムスタンプを利用する
454- urg_draw_widget_.redraw();
462+ // 一定間隔での描画
463+ // !!! FPS を定義する
464+ // !!! 可能ならば、URG のタイムスタンプを利用する
465+ urg_draw_widget_.redraw();
455466
456- if (settings_->type != GD) {
457- if ((settings_->remain_times > 0) && (urg_.remainCaptureTimes() == 0)) {
458- // 回数指定のデータ取得のときは、指定回数後に取得を終了する
459- capture_timer_.stop();
460- capture_setting_widget_.setApplyEnabled(true);
461- }
467+ if (settings_->type != GD) {
468+ if ((settings_->remain_times > 0) &&
469+ (urg_.remainCaptureTimes() == 0)) {
470+ // 回数指定のデータ取得のときは、指定回数後に取得を終了する
471+ capture_timer_.stop();
472+ capture_setting_widget_.setApplyEnabled(true);
473+ }
474+ }
462475 }
463- }
464476
465477
466- void setPlayConnection(void)
467- {
468- // 接続操作を disable にする
469- serial_connection_widget_.setEnabled(false);
470- ethernet_connection_widget_.setEnabled(false);
478+ void setPlayConnection(void)
479+ {
480+ // 接続操作を disable にする
481+ serial_connection_widget_.setEnabled(false);
482+ ethernet_connection_widget_.setEnabled(false);
471483
472- // 接続処理
473- QTimer::singleShot(1000, widget_, SLOT(autoPlay()));
474- }
484+ // 接続処理
485+ QTimer::singleShot(1000, widget_, SLOT(autoPlay()));
486+ }
475487
476488
477- void activateWidget(QWidget* widget, QAction* action)
478- {
479- widget->show();
480- widget->raise();
481- action->setChecked(true);
482- }
489+ void activateWidget(QWidget* widget, QAction* action)
490+ {
491+ widget->show();
492+ widget->raise();
493+ action->setChecked(true);
494+ }
483495
484496
485- void useSerialConnection(bool checked)
486- {
487- // メニューのチェックボックスの変更
488- widget_->action_serial_->setChecked(checked);
489- widget_->action_ethernet_->setChecked(! checked);
497+ void useSerialConnection(bool checked)
498+ {
499+ // メニューのチェックボックスの変更
500+ widget_->action_serial_->setChecked(checked);
501+ widget_->action_ethernet_->setChecked(! checked);
490502
491- // 接続用 Widget の変更
492- // ウィンドウが広がらないように、表示されている方を消してから追加する
493- if (checked) {
494- ethernet_connection_widget_.setEnabled(false);
495- ethernet_connection_widget_.hide();
496- serial_connection_widget_.show();
497- } else {
498- serial_connection_widget_.setEnabled(false);
499- serial_connection_widget_.hide();
500- ethernet_connection_widget_.show();
501- ethernet_connection_widget_.setEnabled(true);
503+ // 接続用 Widget の変更
504+ // ウィンドウが広がらないように、表示されている方を消してから追加する
505+ if (checked) {
506+ ethernet_connection_widget_.setEnabled(false);
507+ ethernet_connection_widget_.hide();
508+ serial_connection_widget_.show();
509+ } else {
510+ serial_connection_widget_.setEnabled(false);
511+ serial_connection_widget_.hide();
512+ ethernet_connection_widget_.show();
513+ ethernet_connection_widget_.setEnabled(true);
514+ }
502515 }
503- }
504516 };
505517
506518
507519 UrgViewerWindow::UrgViewerWindow(int argc, char *argv[])
508- : pimpl(new pImpl(argc, argv, this))
520+ : pimpl(new pImpl(argc, argv, this))
509521 {
510- setupUi(this);
511- pimpl->initializeForm();
512- pimpl->loadSettings();
522+ setupUi(this);
523+ pimpl->initializeForm();
524+ pimpl->loadSettings();
513525
514- if (MonitorModeManager::object()->mode() == MonitorModeManager::Play) {
515- // 接続操作を disable にして、接続を行っておく
516- pimpl->setPlayConnection();
526+ if (MonitorModeManager::object()->mode() == MonitorModeManager::Play) {
527+ // 接続操作を disable にして、接続を行っておく
528+ pimpl->setPlayConnection();
517529
518- // 取得範囲の設定ウィンドウは表示させない
519- menu_Window_->setEnabled(false);
520- }
530+ // 取得範囲の設定ウィンドウは表示させない
531+ menu_Window_->setEnabled(false);
532+ }
521533 }
522534
523535
524536 UrgViewerWindow::~UrgViewerWindow(void)
525537 {
526- pimpl->saveSettings();
538+ pimpl->saveSettings();
527539 }
528540
529541
530542 void UrgViewerWindow::rescanPressed(void)
531543 {
532- vector<string> devices;
533- pimpl->com_finder_.find(devices);
544+ vector<string> devices;
545+ pimpl->com_finder_.find(devices);
534546
535- for (vector<string>::iterator it = devices.begin();
536- it != devices.end(); ++it) {
537- if (pimpl->urg_usb_.isUsbCom(it->c_str())) {
538- *it = *it + " [URG]";
547+ for (vector<string>::iterator it = devices.begin();
548+ it != devices.end(); ++it) {
549+ if (pimpl->urg_usb_.isUsbCom(it->c_str())) {
550+ *it = *it + " [URG]";
551+ }
539552 }
540- }
541- pimpl->serial_connection_widget_.setDevices(devices);
542- if (! devices.empty()) {
543- pimpl->serial_connection_widget_.setFocus();
544- }
553+ pimpl->serial_connection_widget_.setDevices(devices);
554+ if (! devices.empty()) {
555+ pimpl->serial_connection_widget_.setFocus();
556+ }
545557 }
546558
547559
@@ -548,25 +560,25 @@
548560 void UrgViewerWindow::connectPressed(bool connection,
549561 const string& device)
550562 {
551- LockGuard guard(pimpl->urg_mutex_);
563+ LockGuard guard(pimpl->urg_mutex_);
552564
553- if (connection) {
554- // URG との接続
555- pimpl->connect_thread_.setConnectSettings(device, 115200);
556- pimpl->connect_thread_.start();
565+ if (connection) {
566+ // URG との接続
567+ pimpl->connect_thread_.setConnectSettings(device, 115200);
568+ pimpl->connect_thread_.start();
557569
558- vector<string> tokens;
559- size_t n = split(tokens, device, "/");
560- if (n > 0) {
561- string base_name = tokens[n - 1] + "_error_log.txt";
562- log_setName(base_name.c_str());
570+ vector<string> tokens;
571+ size_t n = split(tokens, device, "/");
572+ if (n > 0) {
573+ string base_name = tokens[n - 1] + "_error_log.txt";
574+ log_setName(base_name.c_str());
575+ }
576+
577+ } else {
578+ // 切断
579+ pimpl->disconnectDevice();
580+ pimpl->urg_.disconnect();
563581 }
564-
565- } else {
566- // 切断
567- pimpl->disconnectDevice();
568- pimpl->urg_.disconnect();
569- }
570582 }
571583
572584
@@ -574,177 +586,177 @@
574586 const std::string& address,
575587 unsigned short port)
576588 {
577- LockGuard guard(pimpl->urg_mutex_);
589+ LockGuard guard(pimpl->urg_mutex_);
578590
579- if (connection) {
580- // URG との接続
581- pimpl->connect_thread_.setConnectSettings(address, port);
582- pimpl->connect_thread_.start();
591+ if (connection) {
592+ // URG との接続
593+ pimpl->connect_thread_.setConnectSettings(address, port);
594+ pimpl->connect_thread_.start();
583595
584- } else {
585- // 切断
586- pimpl->disconnectDevice();
587- pimpl->urg_.disconnect();
588- }
596+ } else {
597+ // 切断
598+ pimpl->disconnectDevice();
599+ pimpl->urg_.disconnect();
600+ }
589601 }
590602
591603
592604 void UrgViewerWindow::connectDevice(bool connection)
593605 {
594- pimpl->connectDevice(connection);
606+ pimpl->connectDevice(connection);
595607 }
596608
597609
598610 void UrgViewerWindow::captureHandler(void)
599611 {
600- pimpl->captureHandler();
612+ pimpl->captureHandler();
601613 }
602614
603615
604616 void UrgViewerWindow::initializeView(void)
605617 {
606- pimpl->urg_draw_widget_.initializeView();
618+ pimpl->urg_draw_widget_.initializeView();
607619 }
608620
609621
610622 void UrgViewerWindow::updateStatusBar(bool active, long x_mm, long y_mm)
611623 {
612- if (! active) {
613- statusBar()->clearMessage();
614- return;
615- }
624+ if (! active) {
625+ statusBar()->clearMessage();
626+ return;
627+ }
616628
617- QString message = QString("X: %1 [mm], Y: %2 [mm]").arg(x_mm).arg(y_mm);
618- statusBar()->showMessage(message, 60 * 1000);
629+ QString message = QString("X: %1 [mm], Y: %2 [mm]").arg(x_mm).arg(y_mm);
630+ statusBar()->showMessage(message, 60 * 1000);
619631 }
620632
621633
622634 void UrgViewerWindow::updateScansInterval(int msec)
623635 {
624- scans_label_->setText(QString(tr("%1 [msec] (scans interval)")).arg(msec));
636+ scans_label_->setText(QString(tr("%1 [msec] (scans interval)")).arg(msec));
625637 }
626638
627639
628640 void UrgViewerWindow::aboutApplication(void)
629641 {
630- QString message =
631- "<h2>URG Viewer " + QString(Version) + "</h2>"
632- "<p>Demo Application for URG sensor</p>"
633- "<p>Report bugs to &lt;satofumi@users.sourceforge.jp&gt;</p>";
642+ QString message =
643+ "<h2>URG Viewer " + QString(Version) + "</h2>"
644+ "<p>Demo Application for URG sensor</p>"
645+ "<p>Report bugs to &lt;satofumi@users.sourceforge.jp&gt;</p>";
634646
635- QMessageBox::about(this, tr("About URG Viewer"), message);
647+ QMessageBox::about(this, tr("About URG Viewer"), message);
636648 }
637649
638650
639651 void UrgViewerWindow::autoPlay(void)
640652 {
641- pimpl->connect_thread_.start();
653+ pimpl->connect_thread_.start();
642654 }
643655
644656
645657 void UrgViewerWindow::zoomSmaller(void)
646658 {
647- pimpl->urg_draw_widget_.updateZoomRatio(+1);
659+ pimpl->urg_draw_widget_.updateZoomRatio(+1);
648660 }
649661
650662
651663 void UrgViewerWindow::zoomLarger(void)
652664 {
653- pimpl->urg_draw_widget_.updateZoomRatio(-1);
665+ pimpl->urg_draw_widget_.updateZoomRatio(-1);
654666 }
655667
656668
657669 void UrgViewerWindow::closeEvent(QCloseEvent* event)
658670 {
659- pimpl->capture_setting_widget_.hide();
660- pimpl->length_view_widget_.hide();
671+ pimpl->capture_setting_widget_.hide();
672+ pimpl->length_view_widget_.hide();
661673
662- pimpl->capture_timer_.stop();
674+ pimpl->capture_timer_.stop();
663675
664- LockGuard guard(pimpl->urg_mutex_);
665- pimpl->urg_.disconnect();
666- pimpl->connect_thread_.terminate();
667- pimpl->connect_thread_.wait(100);
676+ LockGuard guard(pimpl->urg_mutex_);
677+ pimpl->urg_.disconnect();
678+ pimpl->connect_thread_.terminate();
679+ pimpl->connect_thread_.wait(100);
668680
669- event->accept();
681+ event->accept();
670682
671- // デストラクタ内で呼び出したいが、
672- // exit() を呼ぶとデストラクタが呼び出されないのでここで呼び出す
673- pimpl->saveSettings();
683+ // デストラクタ内で呼び出したいが、
684+ // exit() を呼ぶとデストラクタが呼び出されないのでここで呼び出す
685+ pimpl->saveSettings();
674686
675- exit(0);
687+ exit(0);
676688 }
677689
678690
679691 void UrgViewerWindow::showCaptureSettingWidget(void)
680692 {
681- pimpl->activateWidget(&pimpl->capture_setting_widget_,
682- action_capture_setting_);
693+ pimpl->activateWidget(&pimpl->capture_setting_widget_,
694+ action_capture_setting_);
683695 }
684696
685697
686698 void UrgViewerWindow::receiveCaptureSettings(const CaptureSettings& settings)
687699 {
688- if (! pimpl->settings_) {
689- int dummy = -1;
690- pimpl->settings_ = pimpl->initializeCaptureSettings(dummy, dummy);
691- }
692- *pimpl->settings_ = settings;
700+ if (! pimpl->settings_) {
701+ int dummy = -1;
702+ pimpl->settings_ = pimpl->initializeCaptureSettings(dummy, dummy);
703+ }
704+ *pimpl->settings_ = settings;
693705 }
694706
695707
696708 void UrgViewerWindow::receiveReconnectRequest(void)
697709 {
698- pimpl->receiveReconnectRequest();
699- emit reconnectCompleted();
710+ pimpl->receiveReconnectRequest();
711+ emit reconnectCompleted();
700712 }
701713
702714
703715 void UrgViewerWindow::showLengthViewWidget(void)
704716 {
705- pimpl->activateWidget(&pimpl->length_view_widget_,
706- action_length_view_);
717+ pimpl->activateWidget(&pimpl->length_view_widget_,
718+ action_length_view_);
707719 }
708720
709721
710722 void UrgViewerWindow::receiveLengthViewRequest(void)
711723 {
712- pimpl->set_length_view_ = true;
724+ pimpl->set_length_view_ = true;
713725 }
714726
715727
716728 void UrgViewerWindow::receiveWidgetClose(const string& widget_name)
717729 {
718- if (! widget_name.compare("CaptureSettingWidget")) {
719- action_capture_setting_->setChecked(false);
730+ if (! widget_name.compare("CaptureSettingWidget")) {
731+ action_capture_setting_->setChecked(false);
720732
721- } else if (! widget_name.compare("LengthViewWidget")) {
722- action_length_view_->setChecked(false);
723- }
733+ } else if (! widget_name.compare("LengthViewWidget")) {
734+ action_length_view_->setChecked(false);
735+ }
724736 }
725737
726738
727739 void UrgViewerWindow::receiveDrawLine(const vector<int>& indexes)
728740 {
729- pimpl->draw_line_indexes_ = indexes;
741+ pimpl->draw_line_indexes_ = indexes;
730742 }
731743
732744
733745 void UrgViewerWindow::selectSerial(void)
734746 {
735- pimpl->useSerialConnection(true);
747+ pimpl->useSerialConnection(true);
736748
737- // Serial 用の Connection を登録
738- if (pimpl->serial_connection_) {
739- pimpl->urg_.setConnection(pimpl->serial_connection_);
740- }
749+ // Serial 用の Connection を登録
750+ if (pimpl->serial_connection_) {
751+ pimpl->urg_.setConnection(pimpl->serial_connection_);
752+ }
741753 }
742754
743755
744756 void UrgViewerWindow::selectEthernet(void)
745757 {
746- pimpl->useSerialConnection(false);
758+ pimpl->useSerialConnection(false);
747759
748- // Ethernet 用の Connection を登録
749- pimpl->urg_.setConnection(&pimpl->ethernet_connection_);
760+ // Ethernet 用の Connection を登録
761+ pimpl->urg_.setConnection(&pimpl->ethernet_connection_);
750762 }
--- trunk/programs/UrgViewer/CaptureSettingWidget.h (revision 1816)
+++ trunk/programs/UrgViewer/CaptureSettingWidget.h (revision 1817)
@@ -16,7 +16,7 @@
1616
1717 namespace qrk
1818 {
19- class RangeSensor;
19+ class RangeSensor;
2020 }
2121
2222
@@ -24,55 +24,55 @@
2424 \brief データ取得設定ウィジット
2525 */
2626 class CaptureSettingWidget
27- : public QWidget, private Ui::CaptureSettingWidgetForm
27+ : public QWidget, private Ui::CaptureSettingWidgetForm
2828 {
29- Q_OBJECT;
29+ Q_OBJECT;
3030
3131 public:
32- enum {
33- InfinityTimes = 100,
34- };
32+ enum {
33+ InfinityTimes = 100,
34+ };
3535
36- CaptureSettingWidget(const qrk::RangeSensor& sensor, QWidget* parent = 0);
37- ~CaptureSettingWidget(void);
36+ CaptureSettingWidget(const qrk::RangeSensor& sensor, QWidget* parent = 0);
37+ ~CaptureSettingWidget(void);
3838
39- void setIntensityMode(bool enable_cluster = true);
39+ void setIntensityMode(bool enable_cluster = true);
4040
41- void setMode(qrk::CaptureType type);
42- void setTimes(size_t times);
43- void setApplyEnabled(bool enable);
44- void setConnected(bool connection);
41+ void setMode(qrk::CaptureType type);
42+ void setTimes(size_t times);
43+ void setApplyEnabled(bool enable);
44+ void setConnected(bool connection);
4545
4646 public slots:
47- void loadPressed(void);
48- void reconnectCompleted(void);
47+ void loadPressed(void);
48+ void reconnectCompleted(void);
4949
5050 signals:
51- void setCaptureSettings(const qrk::CaptureSettings& settings);
52- void reconnectRequest(void);
53- void widgetClose(const std::string& widget_name);
54- void quit(void);
55- void rangeChanged(int first_index, int last_index);
51+ void setCaptureSettings(const qrk::CaptureSettings& settings);
52+ void reconnectRequest(void);
53+ void widgetClose(const std::string& widget_name);
54+ void quit(void);
55+ void rangeChanged(int first_index, int last_index);
5656
5757 protected slots:
58- void applyPressed(void);
59- void firstFinished(void);
60- void lastFinished(void);
61- void isRangeChanged(void);
62- void modeChanged(int type);
63- void timesChanged(void);
64- void quitPressed(void);
65- void closeEvent(QCloseEvent* event);
66- void lineGroupsChanged(void);
67- void frameSkipsChanged(void);
68- void captureTimesChanged(void);
58+ void applyPressed(void);
59+ void firstFinished(void);
60+ void lastFinished(void);
61+ void isRangeChanged(void);
62+ void modeChanged(int type);
63+ void timesChanged(void);
64+ void quitPressed(void);
65+ void closeEvent(QCloseEvent* event);
66+ void lineGroupsChanged(void);
67+ void frameSkipsChanged(void);
68+ void captureTimesChanged(void);
6969
7070 private:
71- CaptureSettingWidget(const CaptureSettingWidget& rhs);
72- CaptureSettingWidget& operator = (const CaptureSettingWidget& rhs);
71+ CaptureSettingWidget(const CaptureSettingWidget& rhs);
72+ CaptureSettingWidget& operator = (const CaptureSettingWidget& rhs);
7373
74- struct pImpl;
75- std::auto_ptr<pImpl> pimpl;
74+ struct pImpl;
75+ std::auto_ptr<pImpl> pimpl;
7676 };
7777
7878 #endif /* !CAPTURE_SETTING_WIDGET_H */
--- trunk/programs/UrgViewer/UrgViewerWindow.h (revision 1816)
+++ trunk/programs/UrgViewer/UrgViewerWindow.h (revision 1817)
@@ -15,7 +15,7 @@
1515
1616 namespace qrk
1717 {
18- class CaptureSettings;
18+ class CaptureSettings;
1919 }
2020
2121
@@ -24,46 +24,46 @@
2424 */
2525 class UrgViewerWindow : public QMainWindow, private Ui::UrgViewerWindowForm
2626 {
27- Q_OBJECT;
27+ Q_OBJECT;
2828
2929 public:
30- UrgViewerWindow(int argc, char *argv[]);
31- ~UrgViewerWindow(void);
30+ UrgViewerWindow(int argc, char *argv[]);
31+ ~UrgViewerWindow(void);
3232
3333 signals:
34- void reconnectCompleted(void);
34+ void reconnectCompleted(void);
3535
3636 private slots:
37- void rescanPressed(void);
38- void connectPressed(bool connection, const std::string& device);
39- void connectPressed(bool connection,
40- const std::string& address, unsigned short port);
41- void connectDevice(bool);
42- void captureHandler(void);
43- void initializeView(void);
44- void updateStatusBar(bool active, long x_mm, long y_mm);
45- void updateScansInterval(int msec);
46- void aboutApplication(void);
47- void autoPlay(void);
48- void zoomSmaller(void);
49- void zoomLarger(void);
50- void closeEvent(QCloseEvent* event);
51- void showCaptureSettingWidget(void);
52- void receiveCaptureSettings(const qrk::CaptureSettings& settings);
53- void receiveReconnectRequest(void);
54- void showLengthViewWidget(void);
55- void receiveLengthViewRequest(void);
56- void receiveWidgetClose(const std::string& widget_name);
57- void receiveDrawLine(const std::vector<int>& indexes);
58- void selectSerial(void);
59- void selectEthernet(void);
37+ void rescanPressed(void);
38+ void connectPressed(bool connection, const std::string& device);
39+ void connectPressed(bool connection,
40+ const std::string& address, unsigned short port);
41+ void connectDevice(bool);
42+ void captureHandler(void);
43+ void initializeView(void);
44+ void updateStatusBar(bool active, long x_mm, long y_mm);
45+ void updateScansInterval(int msec);
46+ void aboutApplication(void);
47+ void autoPlay(void);
48+ void zoomSmaller(void);
49+ void zoomLarger(void);
50+ void closeEvent(QCloseEvent* event);
51+ void showCaptureSettingWidget(void);
52+ void receiveCaptureSettings(const qrk::CaptureSettings& settings);
53+ void receiveReconnectRequest(void);
54+ void showLengthViewWidget(void);
55+ void receiveLengthViewRequest(void);
56+ void receiveWidgetClose(const std::string& widget_name);
57+ void receiveDrawLine(const std::vector<int>& indexes);
58+ void selectSerial(void);
59+ void selectEthernet(void);
6060
6161 private:
62- UrgViewerWindow(const UrgViewerWindow& rhs);
63- UrgViewerWindow& operator = (const UrgViewerWindow& rhs);
62+ UrgViewerWindow(const UrgViewerWindow& rhs);
63+ UrgViewerWindow& operator = (const UrgViewerWindow& rhs);
6464
65- struct pImpl;
66- std::auto_ptr<pImpl> pimpl;
65+ struct pImpl;
66+ std::auto_ptr<pImpl> pimpl;
6767 };
6868
6969 #endif /* !URG_VIEWER_WINDOW_H */
--- trunk/programs/UrgViewer/LengthViewWidget.cpp (revision 1816)
+++ trunk/programs/UrgViewer/LengthViewWidget.cpp (revision 1817)
@@ -23,80 +23,84 @@
2323
2424 struct LengthViewWidget::pImpl
2525 {
26- LengthViewWidget* widget_;
27- size_t min_distance_;
26+ LengthViewWidget* widget_;
27+ size_t min_distance_;
2828
29- pImpl(LengthViewWidget* widget) : widget_(widget), min_distance_(0)
30- {
31- }
29+ pImpl(LengthViewWidget* widget) : widget_(widget), min_distance_(0)
30+ {
31+ }
3232
3333
34- void initializeForm(void)
35- {
36- widget_->length_table_->setEditTriggers(QAbstractItemView::NoEditTriggers);
34+ void initializeForm(void)
35+ {
36+ widget_->length_table_->
37+ setEditTriggers(QAbstractItemView::NoEditTriggers);
3738
38- // コンテナ
39- for (int i = 0; i < 2; ++i) {
40- widget_->length_table_->
41- horizontalHeader()->setResizeMode(i, QHeaderView::Stretch);
42- }
39+ // コンテナ
40+ for (int i = 0; i < 2; ++i) {
41+ widget_->length_table_->
42+ horizontalHeader()->setResizeMode(i, QHeaderView::Stretch);
43+ }
4344
44- // イベント
45- connect(widget_->update_button_, SIGNAL(clicked()),
46- widget_, SLOT(updatePressed()));
47- connect(widget_->save_button_, SIGNAL(clicked()),
48- widget_, SLOT(savePressed()));
49- connect(widget_->close_button_, SIGNAL(clicked()), widget_, SLOT(close()));
50- connect(widget_->length_table_, SIGNAL(itemSelectionChanged()),
51- widget_, SLOT(itemSelectionChanged()));
45+ // イベント
46+ connect(widget_->update_button_, SIGNAL(clicked()),
47+ widget_, SLOT(updatePressed()));
48+ connect(widget_->save_button_, SIGNAL(clicked()),
49+ widget_, SLOT(savePressed()));
50+ connect(widget_->close_button_, SIGNAL(clicked()),
51+ widget_, SLOT(close()));
52+ connect(widget_->length_table_, SIGNAL(itemSelectionChanged()),
53+ widget_, SLOT(itemSelectionChanged()));
5254
53- // キー割り付け
54- (void) new QShortcut(Qt::CTRL + Qt::Key_Q, widget_, SLOT(quitPressed()));
55- (void) new QShortcut(Qt::CTRL + Qt::Key_W, widget_, SLOT(close()));
56- }
55+ // キー割り付け
56+ (void) new QShortcut(Qt::CTRL + Qt::Key_Q, widget_,
57+ SLOT(quitPressed()));
58+ (void) new QShortcut(Qt::CTRL + Qt::Key_W, widget_, SLOT(close()));
59+ }
5760
5861
59- void setData(int index, const vector<long>& data)
60- {
61- size_t row_count = widget_->length_table_->rowCount();
62- size_t data_size = data.size();
63- if (data_size == 0) {
64- return;
65- }
66- widget_->save_button_->setEnabled(true);
62+ void setData(int index, const vector<long>& data)
63+ {
64+ size_t row_count = widget_->length_table_->rowCount();
65+ size_t data_size = data.size();
66+ if (data_size == 0) {
67+ return;
68+ }
69+ widget_->save_button_->setEnabled(true);
6770
68- if (data_size > row_count) {
69- widget_->length_table_->setRowCount(data_size);
71+ if (data_size > row_count) {
72+ widget_->length_table_->setRowCount(data_size);
7073
71- QStringList labels;
72- for (size_t i = 0; i < data_size; ++i) {
73- labels.push_back(tr("%1").arg(i));
74- }
75- widget_->length_table_->setVerticalHeaderLabels(labels);
76- }
74+ QStringList labels;
75+ for (size_t i = 0; i < data_size; ++i) {
76+ labels.push_back(tr("%1").arg(i));
77+ }
78+ widget_->length_table_->setVerticalHeaderLabels(labels);
79+ }
7780
78- const QBrush error_brush(QColor(255, 0, 0));
79- for (size_t i = 0; i < data_size; ++i) {
80- long length = data[i];
81- QTableWidgetItem *new_item = new QTableWidgetItem(tr("%1").arg(length));
82- new_item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
81+ const QBrush error_brush(QColor(255, 0, 0));
82+ for (size_t i = 0; i < data_size; ++i) {
83+ long length = data[i];
84+ QTableWidgetItem *new_item =
85+ new QTableWidgetItem(tr("%1").arg(length));
86+ new_item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
8387
84- if ((index == 0) && (length < static_cast<long>(min_distance_))) {
85- // エラーデータであることを強調するために、色を変える
86- new_item->setForeground(error_brush);
87- }
88- widget_->length_table_->setItem(i, index, new_item);
88+ if ((index == 0) && (length < static_cast<long>(min_distance_))) {
89+ // エラーデータであることを強調するために、色を変える
90+ new_item->setForeground(error_brush);
91+ }
92+ widget_->length_table_->setItem(i, index, new_item);
93+ }
94+ widget_->length_table_->setRowCount(data_size);
8995 }
90- widget_->length_table_->setRowCount(data_size);
91- }
9296 };
9397
9498
9599 LengthViewWidget::LengthViewWidget(QWidget* parent)
96- : QWidget(parent), pimpl(new pImpl(this))
100+ : QWidget(parent), pimpl(new pImpl(this))
97101 {
98- setupUi(this);
99- pimpl->initializeForm();
102+ setupUi(this);
103+ pimpl->initializeForm();
100104 }
101105
102106
@@ -107,95 +111,95 @@
107111
108112 void LengthViewWidget::clear(void)
109113 {
110- length_table_->clearContents();
114+ length_table_->clearContents();
111115 }
112116
113117
114118 void LengthViewWidget::setMinDistance(size_t min_distance)
115119 {
116- pimpl->min_distance_ = min_distance;
120+ pimpl->min_distance_ = min_distance;
117121 }
118122
119123
120124 void LengthViewWidget::setLength(const vector<long>& length_data)
121125 {
122- pimpl->setData(0, length_data);
126+ pimpl->setData(0, length_data);
123127 }
124128
125129
126130 void LengthViewWidget::setIntensity(const vector<long>& intensity_data)
127131 {
128- pimpl->setData(1, intensity_data);
132+ pimpl->setData(1, intensity_data);
129133 }
130134
131135
132136 void LengthViewWidget::updatePressed(void)
133137 {
134- emit lengthViewRequest();
138+ emit lengthViewRequest();
135139 }
136140
137141
138142 void LengthViewWidget::savePressed(void)
139143 {
140- // 保存処理
141- QString default_file_name = "length_data.csv";
142- QString file_name =
143- QFileDialog::getSaveFileName(this, tr("Save length data."),
144- default_file_name, tr("CSV (*.csv)"));
145- if (file_name.isEmpty()) {
146- return;
147- }
144+ // 保存処理
145+ QString default_file_name = "length_data.csv";
146+ QString file_name =
147+ QFileDialog::getSaveFileName(this, tr("Save length data."),
148+ default_file_name, tr("CSV (*.csv)"));
149+ if (file_name.isEmpty()) {
150+ return;
151+ }
148152
149- QFile save_file(file_name);
150- if (! save_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
151- return;
152- }
153- QTextStream fout(&save_file);
153+ QFile save_file(file_name);
154+ if (! save_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
155+ return;
156+ }
157+ QTextStream fout(&save_file);
154158
155- size_t row_count = length_table_->rowCount();
156- for (size_t y = 0; y < row_count; ++y) {
159+ size_t row_count = length_table_->rowCount();
160+ for (size_t y = 0; y < row_count; ++y) {
157161
158- fout << y << ',';
162+ fout << y << ',';
159163
160- for (int x = 0; x < 2; ++x) {
161- QTableWidgetItem* item = length_table_->item(y, x);
162- if (! item) {
163- continue;
164- }
165- long value = item->text().toLong();
164+ for (int x = 0; x < 2; ++x) {
165+ QTableWidgetItem* item = length_table_->item(y, x);
166+ if (! item) {
167+ continue;
168+ }
169+ long value = item->text().toLong();
166170
167- fout << value << ',';
171+ fout << value << ',';
172+ }
173+ fout << '\n';
168174 }
169- fout << '\n';
170- }
171175 }
172176
173177
174178 void LengthViewWidget::closeEvent(QCloseEvent* event)
175179 {
176- static_cast<void>(event);
180+ static_cast<void>(event);
177181
178- emit widgetClose("LengthViewWidget");
179- close();
182+ emit widgetClose("LengthViewWidget");
183+ close();
180184 }
181185
182186
183187 void LengthViewWidget::quitPressed(void)
184188 {
185- emit quit();
189+ emit quit();
186190 }
187191
188192
189193 void LengthViewWidget::itemSelectionChanged(void)
190194 {
191- vector<int> indexes;
195+ vector<int> indexes;
192196
193- QList<QTableWidgetItem*> selected_list = length_table_->selectedItems();
194- for (QList<QTableWidgetItem*>::iterator it = selected_list.begin();
195- it != selected_list.end(); ++it) {
196- if (*it) {
197- indexes.push_back((*it)->row());
197+ QList<QTableWidgetItem*> selected_list = length_table_->selectedItems();
198+ for (QList<QTableWidgetItem*>::iterator it = selected_list.begin();
199+ it != selected_list.end(); ++it) {
200+ if (*it) {
201+ indexes.push_back((*it)->row());
202+ }
198203 }
199- }
200- emit drawLineRequest(indexes);
204+ emit drawLineRequest(indexes);
201205 }
--- trunk/programs/UrgViewer/LengthViewWidget.h (revision 1816)
+++ trunk/programs/UrgViewer/LengthViewWidget.h (revision 1817)
@@ -19,37 +19,37 @@
1919 */
2020 class LengthViewWidget : public QWidget, private Ui::LengthViewWidgetForm
2121 {
22- Q_OBJECT;
22+ Q_OBJECT;
2323
2424 public:
25- LengthViewWidget(QWidget* parent = 0);
26- ~LengthViewWidget(void);
25+ LengthViewWidget(QWidget* parent = 0);
26+ ~LengthViewWidget(void);
2727
28- void clear(void);
29- void setMinDistance(size_t min_distance);
28+ void clear(void);
29+ void setMinDistance(size_t min_distance);
3030
31- void setLength(const std::vector<long>& length_data);
32- void setIntensity(const std::vector<long>& intensity_data);
31+ void setLength(const std::vector<long>& length_data);
32+ void setIntensity(const std::vector<long>& intensity_data);
3333
3434 signals:
35- void lengthViewRequest(void);
36- void drawLineRequest(const std::vector<int>& indexes);
37- void widgetClose(const std::string& widget_name);
38- void quit(void);
35+ void lengthViewRequest(void);
36+ void drawLineRequest(const std::vector<int>& indexes);
37+ void widgetClose(const std::string& widget_name);
38+ void quit(void);
3939
4040 protected slots:
41- void closeEvent(QCloseEvent* event);
42- void updatePressed(void);
43- void savePressed(void);
44- void quitPressed(void);
45- void itemSelectionChanged(void);
41+ void closeEvent(QCloseEvent* event);
42+ void updatePressed(void);
43+ void savePressed(void);
44+ void quitPressed(void);
45+ void itemSelectionChanged(void);
4646
4747 private:
48- LengthViewWidget(const LengthViewWidget& rhs);
49- LengthViewWidget& operator = (const LengthViewWidget& rhs);
48+ LengthViewWidget(const LengthViewWidget& rhs);
49+ LengthViewWidget& operator = (const LengthViewWidget& rhs);
5050
51- struct pImpl;
52- std::auto_ptr<pImpl> pimpl;
51+ struct pImpl;
52+ std::auto_ptr<pImpl> pimpl;
5353 };
5454
5555 #endif /* !LENGTH_VIEW_WIDGET_H */
旧リポジトリブラウザで表示