Skip to content

Commit 012a372

Browse files
committed
Text3D: changed config map usage to new api
1 parent 3f5f01c commit 012a372

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

plugins/Text3D/src/Text3D.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace mars {
7373
map = ConfigMap::fromYamlFile("Text3DConfig.yml", true);
7474
ConfigVector::iterator it;
7575
osg_text::TextInterface *text;
76-
if(map.find("Labels") != map.end()) {
76+
if(map.hasKey("Labels")) {
7777
TextData *td;
7878
double fixedWidth, fixedHeight;
7979
bool drawFrame;
@@ -82,50 +82,50 @@ namespace mars {
8282

8383
for(it = map["Labels"].begin(); it!=map["Labels"].end(); ++it) {
8484
td = new TextData;
85-
td->name = (std::string)it->children["name"][0];
86-
td->value = (std::string)it->children["value"][0];
87-
td->posX = it->children["posX"][0];
88-
td->posY = it->children["posY"][0];
85+
td->name = (std::string)(*it)["name"];
86+
td->value = (std::string)(*it)["value"];
87+
td->posX = (*it)["posX"];
88+
td->posY = (*it)["posY"];
8989
fixedWidth = fixedHeight = -1;
9090
drawFrame = false;
9191
fontsize = 30;
9292
align = osg_text::ALIGN_LEFT;
9393
osg_text::Color c, bgColor(0.0, 0.5, 0.0, 0.5);
9494
osg_text::Color borderColor(1.0, 1.0, 1.0, 0.5);
95-
if(it->children.find("fixedWidth") != it->children.end()) {
96-
fixedWidth = it->children["fixedWidth"][0];
95+
if(it->hasKey("fixedWidth")) {
96+
fixedWidth = (*it)["fixedWidth"];
9797
}
98-
if(it->children.find("fixedHeight") != it->children.end()) {
99-
fixedHeight = it->children["fixedHeight"][0];
98+
if(it->hasKey("fixedHeight")) {
99+
fixedHeight = (*it)["fixedHeight"];
100100
}
101-
if(it->children.find("frame") != it->children.end()) {
102-
drawFrame = it->children["frame"][0];
101+
if(it->hasKey("frame")) {
102+
drawFrame = (*it)["frame"];
103103
}
104-
if(it->children.find("fontsize") != it->children.end()) {
105-
fontsize = it->children["fontsize"][0];
104+
if(it->hasKey("fontsize")) {
105+
fontsize = (*it)["fontsize"];
106106
}
107-
if(it->children.find("align") != it->children.end()) {
108-
std::string sAlign = (std::string)it->children["align"][0];
107+
if(it->hasKey("align")) {
108+
std::string sAlign = (std::string)(*it)["align"];
109109
if(sAlign == "right") align = osg_text::ALIGN_RIGHT;
110110
else if(sAlign == "center") align = osg_text::ALIGN_CENTER;
111111
}
112-
if(it->children.find("color") != it->children.end()) {
113-
c.a = it->children["color"][0]["a"][0];
114-
c.r = it->children["color"][0]["r"][0];
115-
c.g = it->children["color"][0]["g"][0];
116-
c.b = it->children["color"][0]["b"][0];
112+
if(it->hasKey("color")) {
113+
c.a = (*it)["color"]["a"];
114+
c.r = (*it)["color"]["r"];
115+
c.g = (*it)["color"]["g"];
116+
c.b = (*it)["color"]["b"];
117117
}
118-
if(it->children.find("bgColor") != it->children.end()) {
119-
bgColor.a = it->children["bgColor"][0]["a"][0];
120-
bgColor.r = it->children["bgColor"][0]["r"][0];
121-
bgColor.g = it->children["bgColor"][0]["g"][0];
122-
bgColor.b = it->children["bgColor"][0]["b"][0];
118+
if(it->hasKey("bgColor")) {
119+
bgColor.a = (*it)["bgColor"]["a"];
120+
bgColor.r = (*it)["bgColor"]["r"];
121+
bgColor.g = (*it)["bgColor"]["g"];
122+
bgColor.b = (*it)["bgColor"]["b"];
123123
}
124-
if(it->children.find("borderColor") != it->children.end()) {
125-
borderColor.a = it->children["borderColor"][0]["a"][0];
126-
borderColor.r = it->children["borderColor"][0]["r"][0];
127-
borderColor.g = it->children["borderColor"][0]["g"][0];
128-
borderColor.b = it->children["borderColor"][0]["b"][0];
124+
if(it->hasKey("borderColor")) {
125+
borderColor.a = (*it)["borderColor"]["a"];
126+
borderColor.r = (*it)["borderColor"]["r"];
127+
borderColor.g = (*it)["borderColor"]["g"];
128+
borderColor.b = (*it)["borderColor"]["b"];
129129
}
130130
td->text = textFactory->createText(td->value, fontsize,
131131
c, td->posX, td->posY, align);
@@ -154,7 +154,7 @@ namespace mars {
154154
td->name+"/posY",
155155
td->posY, this);
156156
td->pyId = example.paramId;
157-
int mask = it->children["mask"][0].getInt();
157+
int mask = (*it)["mask"];
158158
example = control->cfg->getOrCreateProperty("Text3D",
159159
td->name+"/mask",
160160
mask, this);

0 commit comments

Comments
 (0)