106 } |
106 } |
107 |
107 |
108 QColor LDColor::edgeColor() const |
108 QColor LDColor::edgeColor() const |
109 { |
109 { |
110 if (isDirect()) |
110 if (isDirect()) |
111 return Luma (faceColor()) < 48 ? Qt::white : Qt::black; |
111 return luma() < 48 ? Qt::white : Qt::black; |
112 else if (isLDConfigColor()) |
112 else if (isLDConfigColor()) |
113 return ColorData[index()].edgeColor; |
113 return ColorData[index()].edgeColor; |
114 else |
114 else |
115 return Qt::black; |
115 return Qt::black; |
116 } |
116 } |
117 |
117 |
118 int LDColor::luma() const |
118 int LDColor::luma() const |
119 { |
119 { |
120 return Luma (faceColor()); |
120 return ::luma (faceColor()); |
121 } |
121 } |
122 |
122 |
123 int LDColor::edgeLuma() const |
123 int LDColor::edgeLuma() const |
124 { |
124 { |
125 return Luma (edgeColor()); |
125 return ::luma (edgeColor()); |
126 } |
126 } |
127 |
127 |
128 qint32 LDColor::index() const |
128 qint32 LDColor::index() const |
129 { |
129 { |
130 return m_index; |
130 return m_index; |
141 bool LDColor::isDirect() const |
141 bool LDColor::isDirect() const |
142 { |
142 { |
143 return index() >= 0x02000000; |
143 return index() >= 0x02000000; |
144 } |
144 } |
145 |
145 |
146 int Luma (const QColor& col) |
146 int luma (const QColor& col) |
147 { |
147 { |
148 return (0.2126f * col.red()) + (0.7152f * col.green()) + (0.0722f * col.blue()); |
148 return (0.2126f * col.red()) + (0.7152f * col.green()) + (0.0722f * col.blue()); |
149 } |
|
150 |
|
151 int CountLDConfigColors() |
|
152 { |
|
153 return countof (ColorData); |
|
154 } |
149 } |
155 |
150 |
156 void parseLDConfig() |
151 void parseLDConfig() |
157 { |
152 { |
158 QFile* fp = OpenLDrawFile ("LDConfig.ldr", false); |
153 QFile* fp = OpenLDrawFile ("LDConfig.ldr", false); |