• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1825 (tree)
日時2010-05-15 19:50:09
作者satofumi

ログメッセージ

adjust indent

変更サマリ

差分

--- trunk/libs/gui/TextRubiFadeSurface.cpp (revision 1824)
+++ trunk/libs/gui/TextRubiFadeSurface.cpp (revision 1825)
@@ -37,7 +37,7 @@
3737 {
3838 TextFadeSurface text_;
3939 Surfaces rubi_text_;
40- vector<int> rubi_x_;
40+ vector<long> rubi_x_;
4141 Rect<long> rect_;
4242 int rubi_pixel_size_;
4343 float base_alpha_;
@@ -84,6 +84,10 @@
8484 rubi_x_.push_back(x);
8585 }
8686 }
87+
88+ if (! rubi_x_.empty()) {
89+ rect_.w = max(text_.rect().w, rubi_x_.back() + rubi_pixel_size_);
90+ }
8791 }
8892
8993
--- trunk/libs/range_sensor/UrgDevice.h (revision 1824)
+++ trunk/libs/range_sensor/UrgDevice.h (revision 1825)
@@ -16,249 +16,249 @@
1616
1717 namespace qrk
1818 {
19- class Connection;
19+ class Connection;
2020
2121
22- //! URG sensor control
23- class UrgDevice : public Coordinate, public RangeSensor
24- {
25- public:
22+ //! URG sensor control
23+ class UrgDevice : public Coordinate, public RangeSensor
24+ {
25+ public:
2626
27- //! Parameter of options
28- enum {
29- DefaultBaudrate = 115200, //!< [bps]
30- DefaultRetryTimes = 8,
31- Infinity = 0,
27+ //! Parameter of options
28+ enum {
29+ DefaultBaudrate = 115200, //!< [bps]
30+ DefaultRetryTimes = 8,
31+ Infinity = 0,
3232
33- Off = 0, //!< Laser is off
34- On = 1, //!< Laser is on
35- };
33+ Off = 0, //!< Laser is off
34+ On = 1, //!< Laser is on
35+ };
3636
37- UrgDevice(void);
38- virtual ~UrgDevice(void);
37+ UrgDevice(void);
38+ virtual ~UrgDevice(void);
3939
40- const char* what(void) const;
40+ const char* what(void) const;
4141
42- bool connect(const char* device, long baudrate = DefaultBaudrate);
43- void setConnection(Connection* con);
44- Connection* connection(void);
45- void disconnect(void);
46- bool isConnected(void) const;
42+ bool connect(const char* device, long baudrate = DefaultBaudrate);
43+ void setConnection(Connection* con);
44+ Connection* connection(void);
45+ void disconnect(void);
46+ bool isConnected(void) const;
4747
48- long minDistance(void) const;
49- long maxDistance(void) const;
50- int maxScanLines(void) const;
48+ long minDistance(void) const;
49+ long maxDistance(void) const;
50+ int maxScanLines(void) const;
5151
5252
53- /*!
54- \brief Set number of retry times when connection failed
53+ /*!
54+ \brief Set number of retry times when connection failed
5555
56- The retry counter is cleared when connect normaly.
56+ The retry counter is cleared when connect normaly.
5757
58- \param[in] times retry times
58+ \param[in] times retry times
5959
60- \attention Data acquisition mode is valid only at #AutoCapture
61- */
62- void setRetryTimes(size_t times);
60+ \attention Data acquisition mode is valid only at #AutoCapture
61+ */
62+ void setRetryTimes(size_t times);
6363
6464
65- /*!
66- \brief Set number of scan data stored internally
65+ /*!
66+ \brief Set number of scan data stored internally
6767
68- \param[in] size Number of scanning data to be stored
69- */
70- void setCapturesSize(size_t size);
68+ \param[in] size Number of scanning data to be stored
69+ */
70+ void setCapturesSize(size_t size);
7171
7272
73- /*!
74- \brief Time taken for 1scan.
73+ /*!
74+ \brief Time taken for 1scan.
7575
76- \return Time taken for 1scan.[msec]
77- */
78- int scanMsec(void) const;
76+ \return Time taken for 1scan.[msec]
77+ */
78+ int scanMsec(void) const;
7979
8080
81- /*!
82- \brief Specification of data acquisition mode
81+ /*!
82+ \brief Specification of data acquisition mode
8383
84- \param[in] mode The mode defined by #RangeCaptureMode can be specified
84+ \param[in] mode The mode defined by #RangeCaptureMode can be specified
8585
86- \see captureMode()
87- */
88- void setCaptureMode(RangeCaptureMode mode);
86+ \see captureMode()
87+ */
88+ void setCaptureMode(RangeCaptureMode mode);
8989
9090
91- /*!
92- \brief Data acquisition mode
91+ /*!
92+ \brief Data acquisition mode
9393
94- \return Present data acquisition mode
94+ \return Present data acquisition mode
9595
96- \see setCaptureMode()
97- */
98- RangeCaptureMode captureMode(void);
96+ \see setCaptureMode()
97+ */
98+ RangeCaptureMode captureMode(void);
9999
100100
101- /*!
102- \brief Specifies the range of data acquisition
101+ /*!
102+ \brief Specifies the range of data acquisition
103103
104- \ref Refer to scip_capture_parameter_section.
104+ \ref Refer to scip_capture_parameter_section.
105105
106- \param[in] begin_index Measurement beginning position
107- \param[in] end_index Measurement end position
108- */
109- void setCaptureRange(int begin_index, int end_index);
106+ \param[in] begin_index Measurement beginning position
107+ \param[in] end_index Measurement end position
108+ */
109+ void setCaptureRange(int begin_index, int end_index);
110110
111111
112- /*!
113- \brief Acquisition interval of scanning data
112+ /*!
113+ \brief Acquisition interval of scanning data
114114
115- The data traffic between URG and the library can be decreased by lowering the frequency of data acquisition.
116- \ref refer to scip_capture_parameter_section
115+ The data traffic between URG and the library can be decreased by lowering the frequency of data acquisition.
116+ \ref refer to scip_capture_parameter_section
117117
118- \param[in] interval capture interval
119- */
120- void setCaptureFrameInterval(size_t interval);
118+ \param[in] interval capture interval
119+ */
120+ void setCaptureFrameInterval(size_t interval);
121121
122122
123- /*!
124- \brief Specify the frequency of data acquisition
123+ /*!
124+ \brief Specify the frequency of data acquisition
125125
126- \ref Refer to scip_capture_parameter_section
126+ \ref Refer to scip_capture_parameter_section
127127
128- \param[in] times Frequency of data acquisition
128+ \param[in] times Frequency of data acquisition
129129
130- \attention Data acquisition mode is valid only at #AutoCapture, #IntensityCapture
131- */
132- void setCaptureTimes(size_t times);
130+ \attention Data acquisition mode is valid only at #AutoCapture, #IntensityCapture
131+ */
132+ void setCaptureTimes(size_t times);
133133
134134
135- /*!
136- \brief Get number of remaining capture times
135+ /*!
136+ \brief Get number of remaining capture times
137137
138- \return number of remaining capture times
138+ \return number of remaining capture times
139139
140- \attention Data acquisition mode is valid only at #AutoCapture, #IntensityCapture
141- */
142- size_t remainCaptureTimes(void);
140+ \attention Data acquisition mode is valid only at #AutoCapture, #IntensityCapture
141+ */
142+ size_t remainCaptureTimes(void);
143143
144144
145- /*!
146- \brief Specify the number of scanline to be skipped.
145+ /*!
146+ \brief Specify the number of scanline to be skipped.
147147
148- The number of thinning out of acquisition data in one scanning is specified.
148+ The number of thinning out of acquisition data in one scanning is specified.
149149
150- \param[in] skip_lines number of scanline to be skipped.
150+ \param[in] skip_lines number of scanline to be skipped.
151151
152- For example, if number of scan lines to be skipped = 1 , then will be
153- \verbatim
154-100, 101, 103, 104, 105, 100, ... \endverbatim
152+ For example, if number of scan lines to be skipped = 1 , then will be
153+ \verbatim
154+ 100, 101, 103, 104, 105, 100, ... \endverbatim
155155
156- In case, number of scanlines to be skipped = 2, then acquired data will be
157- \verbatim
158-100, 103, 100, ... \endverbatim
156+ In case, number of scanlines to be skipped = 2, then acquired data will be
157+ \verbatim
158+ 100, 103, 100, ... \endverbatim
159159
160- (The shortest distance data is returned. )\n
161- As a result, the data traffic between URG and the library can be decreased.
162- However, the volume of data that capture() returns doesnot change.
163- Returns \verbatim
164-100, 100, 103, 103, 100, 100, ... \endverbatim
160+ (The shortest distance data is returned. )\n
161+ As a result, the data traffic between URG and the library can be decreased.
162+ However, the volume of data that capture() returns doesnot change.
163+ Returns \verbatim
164+ 100, 100, 103, 103, 100, 100, ... \endverbatim
165165
166- To guarantee the operation of rad2index() and index2rad(), volume of data does not changing :.
167- */
168- void setCaptureSkipLines(size_t skip_lines);
166+ To guarantee the operation of rad2index() and index2rad(), volume of data does not changing :.
167+ */
168+ void setCaptureSkipLines(size_t skip_lines);
169169
170170
171- int capture(std::vector<long>& data, long* timestamp = NULL);
171+ int capture(std::vector<long>& data, long* timestamp = NULL);
172172
173173
174- /*
175- \brief Get intensity data and distance data.
174+ /*
175+ \brief Get intensity data and distance data.
176176
177- \attention Only Top-URG and Classic-URG supports this fuction (2008-12-24)
178- */
179- int captureWithIntensity(std::vector<long>& data,
180- std::vector<long>& intensity_data,
181- long* timestamp = NULL);
177+ \attention Only Top-URG and Classic-URG supports this fuction (2008-12-24)
178+ */
179+ int captureWithIntensity(std::vector<long>& data,
180+ std::vector<long>& intensity_data,
181+ long* timestamp = NULL);
182182
183183
184- /*!
185- \brief Stop data acquisition
184+ /*!
185+ \brief Stop data acquisition
186186
187- \attention Data acquisition mode is valid only at #AutoCapture, #IntensityCapture
188- */
189- void stop(void);
187+ \attention Data acquisition mode is valid only at #AutoCapture, #IntensityCapture
188+ */
189+ void stop(void);
190190
191191
192- bool setTimestamp(int timestamp = 0, int* response_msec = NULL,
193- int* force_delay_msec = NULL);
192+ bool setTimestamp(int timestamp = 0, int* response_msec = NULL,
193+ int* force_delay_msec = NULL);
194194
195- long recentTimestamp(void) const;
195+ long recentTimestamp(void) const;
196196
197197
198- /*!
199- \brief Laser turn Off/ turn On
198+ /*!
199+ \brief Laser turn Off/ turn On
200200
201- \param[in] on true to turn On , false to turn off
202- */
203- bool setLaserOutput(bool on);
201+ \param[in] on true to turn On , false to turn off
202+ */
203+ bool setLaserOutput(bool on);
204204
205- double index2rad(const int index) const;
206- int rad2index(const double radian) const;
205+ double index2rad(const int index) const;
206+ int rad2index(const double radian) const;
207207
208- void setParameter(const RangeSensorParameter& parameter);
209- RangeSensorParameter parameter(void) const;
208+ void setParameter(const RangeSensorParameter& parameter);
209+ RangeSensorParameter parameter(void) const;
210210
211211
212- /*!
213- \brief Again read the URG parameter
212+ /*!
213+ \brief Again read the URG parameter
214214
215- \retval true success
216- \retval false error
217- */
218- bool loadParameter(void);
215+ \retval true success
216+ \retval false error
217+ */
218+ bool loadParameter(void);
219219
220220
221- /*!
222- \brief Get version information
221+ /*!
222+ \brief Get version information
223223
224- \param[out] lines Storage location of version information
224+ \param[out] lines Storage location of version information
225225
226- \retval true success
227- \retval false error
226+ \retval true success
227+ \retval false error
228228
229- <b>Example</b>
230- - \ref viewVvSample.cpp
231- */
232- bool versionLines(std::vector<std::string>& lines);
229+ <b>Example</b>
230+ - \ref viewVvSample.cpp
231+ */
232+ bool versionLines(std::vector<std::string>& lines);
233233
234234
235- /*!
236- \brief Reboot URG
235+ /*!
236+ \brief Reboot URG
237237
238- \attention Only Top-URG (2010-02-04)
239- */
240- bool reboot(void);
238+ \attention Only Top-URG (2010-02-04)
239+ */
240+ bool reboot(void);
241241
242242
243- /*!
244- \brief Reboot URG
243+ /*!
244+ \brief Reboot URG
245245
246- \deprecated use reboot() function.
247- */
248- bool reset(void);
246+ \deprecated use reboot() function.
247+ */
248+ bool reset(void);
249249
250250
251- protected:
252- virtual void captureReceived(void);
251+ protected:
252+ virtual void captureReceived(void);
253253
254254
255- private:
256- UrgDevice(const UrgDevice& rhs);
257- UrgDevice& operator = (const UrgDevice& rhs);
255+ private:
256+ UrgDevice(const UrgDevice& rhs);
257+ UrgDevice& operator = (const UrgDevice& rhs);
258258
259- struct pImpl;
260- std::auto_ptr<pImpl> pimpl;
261- };
259+ struct pImpl;
260+ std::auto_ptr<pImpl> pimpl;
261+ };
262262 }
263263
264264 #endif /* !QRK_URG_DEVICE_H */
--- trunk/libs/range_sensor/RangeCaptureMode.h (revision 1824)
+++ trunk/libs/range_sensor/RangeCaptureMode.h (revision 1825)
@@ -12,20 +12,20 @@
1212
1313 namespace qrk
1414 {
15- /*!
16- \brief The type in which data is acquired.
15+ /*!
16+ \brief The type in which data is acquired.
1717
18- There are 2 types of data acquistion. One is "Automatic acquisition" in which data is transmitted continuously once the command is sent to sensor. Other type is "sequential acquisition" in which only one set of data is transmitted when command is sent to sensor.
18+ There are 2 types of data acquistion. One is "Automatic acquisition" in which data is transmitted continuously once the command is sent to sensor. Other type is "sequential acquisition" in which only one set of data is transmitted when command is sent to sensor.
1919
20- \image html gd_md_sequence.png "sequential acquisition(GD/GS) and Automatic acquisition(MD/MS)
20+ \image html gd_md_sequence.png "sequential acquisition(GD/GS) and Automatic acquisition(MD/MS)
2121
22- High intensity data is acquired by "automatic acquisition" type
23- */
24- typedef enum {
25- ManualCapture, //!< sequential acquisition
26- AutoCapture, //!< Automatic acquisition
27- IntensityCapture, //!< High intensity acquisition
28- } RangeCaptureMode;
22+ High intensity data is acquired by "automatic acquisition" type
23+ */
24+ typedef enum {
25+ ManualCapture, //!< sequential acquisition
26+ AutoCapture, //!< Automatic acquisition
27+ IntensityCapture, //!< High intensity acquisition
28+ } RangeCaptureMode;
2929 }
3030
3131 #endif /* !QRK_RANGE_CAPTURE_MODE_H */
--- trunk/libs/input/rubi_parse.cpp (revision 1824)
+++ trunk/libs/input/rubi_parse.cpp (revision 1825)
@@ -20,6 +20,11 @@
2020
2121 namespace
2222 {
23+ extern bool parse(vector<rubi_t>& rubi_positions,
24+ const char* kanji_text, size_t kanji_offset,
25+ const char* kana_text, size_t kana_offset);
26+
27+
2328 bool isKana(unsigned long code)
2429 {
2530 //fprintf(stderr, " [code: %04lx, %d], ", code, ((code >= 0x8181) && (code <= 0x83b6)) ? true : false);
@@ -41,7 +46,33 @@
4146 }
4247
4348
49+ bool register_rubi(vector<rubi_t>& rubi_positions,
50+ Utf8& kanji, Utf8& kana,
51+ size_t kanji_offset, size_t kana_offset,
52+ size_t kana_index,
53+ size_t same_size, size_t rubi_size)
54+ {
55+ // ルビの登録
56+ rubi_positions.
57+ push_back(create_rubi(kanji_offset + same_size,
58+ kana_index - same_size,
59+ kana_offset + same_size,
60+ rubi_size));
4461
62+ size_t next_kanji_offset = kana_index + 1;
63+ size_t next_kana_offset = same_size + rubi_size + 1;
64+ const string next_kanji =
65+ kanji.substr(next_kanji_offset,
66+ kanji.size() - next_kanji_offset).toStdString();
67+ const string next_kana =
68+ kana.substr(next_kana_offset,
69+ kana.size() - next_kana_offset).toStdString();
70+ return parse(rubi_positions,
71+ next_kanji.c_str(), kanji_offset + next_kanji_offset,
72+ next_kana.c_str(), kana_offset + next_kana_offset);
73+ }
74+
75+
4576 bool parse(vector<rubi_t>& rubi_positions,
4677 const char* kanji_text, size_t kanji_offset,
4778 const char* kana_text, size_t kana_offset)
@@ -54,7 +85,7 @@
5485
5586 if (kana.size() < kanji.size()) {
5687 // 平仮名の方が短ければ、戻る
57- //fprintf(stderr, "\n");
88+ //fprintf(stderr, " false! \n");
5889 return false;
5990 }
6091
@@ -62,7 +93,7 @@
6293 size_t same_size = 0;
6394 size_t n = min(kanji.size(), kana.size());
6495 for (size_t i = 0; i < n; ++i, ++same_size) {
65- // !!! 範囲外にアクセスしないかのチェックをすべきp
96+ // !!! 範囲外にアクセスしないかのチェックをすべき
6697 //fprintf(stderr, " <%04lx,%04lx>,", kanji.ch(i), kana.ch(i));
6798 if (kanji.ch(i) != kana.ch(i)) {
6899 break;
@@ -70,7 +101,6 @@
70101 }
71102 //fprintf(stderr, " [same_size: %d],", same_size);
72103
73- // !!! kana.size() も使うべきかを検討する
74104 if (kanji.size() - same_size == 0) {
75105 // 文字列がなくなったら、処理を終了する
76106 //fprintf(stderr, "\n");
@@ -77,6 +107,11 @@
77107 return true;
78108 }
79109
110+ // kanji の最初の1文字が平仮名だったら、戻る
111+ if (isKana(kanji.ch(same_size))) {
112+ return false;
113+ }
114+
80115 // 漢字の次の文字を探す
81116 // !!! 1 byte 文字なども適切に処理できることを保証すべき
82117 size_t kana_index = 0;
@@ -102,33 +137,27 @@
102137
103138 unsigned long found_kana = kanji.ch(kana_index);
104139
105- // !!! 以下を、ループで順に繰り返すようにする
106140 size_t rubi_size = 1;
107- for (size_t i = same_size + 1;
108- (i < kana.size()) && (found_kana != kana.ch(i)); ++i) {
141+ for (size_t i = same_size + 1; i < kana.size(); ++i) {
142+ if (found_kana == kana.ch(i)) {
143+ //fprintf(stderr, " [rubi_size = %d],", rubi_size);
144+ bool ret = register_rubi(rubi_positions,
145+ kanji, kana,
146+ kanji_offset, kana_offset,
147+ kana_index,
148+ same_size, rubi_size);
149+ //fprintf(stderr, " %s!\n", ret ? "true" : "false");
150+ if (ret) {
151+ return true;
152+ }
153+ rubi_positions.pop_back();
154+ }
109155 //fprintf(stderr, " [i = %d],", i);
110156 ++rubi_size;
111157 }
112- //fprintf(stderr, " [rubi_size: %d],", rubi_size);
113158
114- // ルビの登録
115- rubi_positions.
116- push_back(create_rubi(kanji_offset + same_size,
117- kana_index - same_size,
118- kana_offset + same_size,
119- rubi_size));
120-
121- size_t next_kanji_offset = kana_index + 1;
122- size_t next_kana_offset = same_size + rubi_size + 1;
123- const string next_kanji =
124- kanji.substr(next_kanji_offset,
125- kanji.size() - next_kanji_offset).toStdString();
126- const string next_kana =
127- kana.substr(next_kana_offset,
128- kana.size() - next_kana_offset).toStdString();
129- return parse(rubi_positions,
130- next_kanji.c_str(), kanji_offset + next_kanji_offset,
131- next_kana.c_str(), kana_offset + next_kana_offset);
159+ //fprintf(stderr, " false!\n");
160+ return false;
132161 }
133162 }
134163
--- trunk/libs/input/TestRubiParse.cpp (revision 1824)
+++ trunk/libs/input/TestRubiParse.cpp (revision 1825)
@@ -123,4 +123,15 @@
123123 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(12), rubi[0].kanji_size);
124124 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].rubi_first);
125125 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(28), rubi[0].rubi_size);
126+
127+
128+ rubi.clear();
129+ bool ret = rubi_parse(rubi, "吉野のさとに", "よしののさとに");
130+ CPPUNIT_ASSERT_EQUAL(true, ret);
131+
132+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi.size());
133+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].kanji_first);
134+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].kanji_size);
135+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].rubi_first);
136+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), rubi[0].rubi_size);
126137 }
旧リポジトリブラウザで表示