1 #include "LDObiInfo.h"
2 #include <LDLoader/LDLCommentLine.h>
3 #include <LDLoader/LDLModel.h>
4
5 #ifdef WIN32
6 #if defined(_MSC_VER) && _MSC_VER >= 1400 && defined(_DEBUG)
7 #define new DEBUG_CLIENTBLOCK
8 #endif // _DEBUG
9 #endif // WIN32
10
getColor(int defaultColor) const11 TCULong LDObiInfo::getColor(int defaultColor) const
12 {
13 if (m_colors.size() > 0)
14 {
15 return m_colors.top();
16 }
17 return defaultColor;
18 }
19
getEdgeColor(int defaultColor) const20 TCULong LDObiInfo::getEdgeColor(int defaultColor) const
21 {
22 if (m_edgeColors.size() > 0)
23 {
24 return m_edgeColors.top();
25 }
26 return defaultColor;
27 }
28
checkConditional(LDLCommentLine * commentLine,const StringSet & tokens)29 bool LDObiInfo::checkConditional(
30 LDLCommentLine *commentLine,
31 const StringSet &tokens)
32 {
33 if (commentLine->hasOBIConditional())
34 {
35 bool set = commentLine->getOBIConditional();
36 std::string token = commentLine->getOBIToken();
37 StringSet::const_iterator it;
38
39 convertStringToLower(&token[0]);
40 it = tokens.find(token);
41 if (it == tokens.end())
42 {
43 return !set;
44 }
45 else
46 {
47 return set;
48 }
49 }
50 return true;
51 }
52
start(LDLCommentLine * commentLine,const StringSet & tokens)53 void LDObiInfo::start(LDLCommentLine *commentLine, const StringSet &tokens)
54 {
55 LDLModel *model = commentLine->getParentModel();
56
57 if (model && checkConditional(commentLine, tokens))
58 {
59 int colorNumber = commentLine->getOBIColorNumber();
60 int edgeColorNumber = 0;
61
62 start(model->getPackedRGBA(colorNumber),
63 model->getPackedRGBA(edgeColorNumber),
64 commentLine->getOBICommand() == LDLCommentLine::OBICStart);
65 }
66 }
67
start(TCULong color,TCULong edgeColor,bool sticky)68 void LDObiInfo::start(TCULong color, TCULong edgeColor, bool sticky)
69 {
70 m_colors.push(color);
71 m_edgeColors.push(edgeColor);
72 m_stickies.push(sticky);
73 }
74
end(void)75 void LDObiInfo::end(void)
76 {
77 if (m_colors.size() > 0)
78 {
79 m_colors.pop();
80 m_edgeColors.pop();
81 m_stickies.pop();
82 }
83 }
84
actionHappened(void)85 void LDObiInfo::actionHappened(void)
86 {
87 if (m_stickies.size() > 0 && !m_stickies.top())
88 {
89 end();
90 }
91 }
92