~charon-developers/charon-utils/trunk

« back to all changes in this revision

Viewing changes to include/charon-utils/DrawBoxes.hxx

  • Committer: Moritz Becker
  • Date: 2014-06-20 14:05:33 UTC
  • Revision ID: moritz.becker@pallas-ludens.com-20140620140533-4et6kuse3u8yd7ib
modified draw boxes which now paint according to task state

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
                "Otherwise, only images with boxes are saved.", false);
57
57
 
58
58
        ParameteredObject::_addParameter(
59
 
                drawDiagonal, "drawDiagonal",
60
 
                "Draw diagonal for final results", true);
61
 
 
62
 
        ParameteredObject::_addParameter(
63
59
                resultsFinal, "resultsFinal",
64
60
                "draw final results", true);
65
61
 
66
62
        ParameteredObject::_addParameter(
67
 
                resultsNormal, "resultsNormal",
68
 
                "draw normal results", true);
69
 
 
70
 
        ParameteredObject::_addParameter(
71
 
                resultsDeleted, "resultsDeleted",
72
 
                "draw deleted results", true);
73
 
 
74
 
        ParameteredObject::_addParameter(
75
 
                colorR, "colorR", "Color: red (0-255)", 0u);
76
 
        ParameteredObject::_addParameter(
77
 
                colorG, "colorG", "Color: green (0-255)", 0u);
78
 
        ParameteredObject::_addParameter(
79
 
                colorB, "colorB", "Color: blue (0-255)", 255u);
 
63
                resultsAdd, "resultsAdd",
 
64
                "draw add results", true);
 
65
 
 
66
        ParameteredObject::_addParameter(
 
67
                resultsDone, "resultsDone",
 
68
                "draw done results", true);
 
69
 
 
70
        ParameteredObject::_addParameter(
 
71
                resultsFailed, "resultsFailed",
 
72
                "draw failed results", true);
 
73
 
 
74
        ParameteredObject::_addParameter(
 
75
                resultsEdit, "resultsEdit",
 
76
                "draw edit results", true);
 
77
 
 
78
        ParameteredObject::_addParameter(
 
79
                colorR, "colorR", "Color: red (0-255)", 255u);
 
80
        ParameteredObject::_addParameter(
 
81
                colorG, "colorG", "Color: green (0-255)", 255u);
 
82
        ParameteredObject::_addParameter(
 
83
                colorB, "colorB", "Color: blue (0-255)", 0u);
80
84
 
81
85
        ParameteredObject::_addParameter(
82
86
                colorRWrong, "colorRWrong", "Wrong Color: red (0-255)", 255u);
93
97
                colorBFinal, "colorBFinal", "Final Color: blue (0-255)", 0u);
94
98
 
95
99
        ParameteredObject::_addParameter(
96
 
                colorRFinalWrong, "colorRFinalWrong", "Final Wrong Color: red (0-255)", 255u);
97
 
        ParameteredObject::_addParameter(
98
 
                colorGFinalWrong, "colorGFinalWrong", "Final Wrong Color: green (0-255)", 255u);
99
 
        ParameteredObject::_addParameter(
100
 
                colorBFinalWrong, "colorBFinalWrong", "Final Wrong Color: blue (0-255)", 0u);
 
100
                colorRFinalWrong, "colorREdit", "Final Wrong Color: red (0-255)", 0u);
 
101
        ParameteredObject::_addParameter(
 
102
                colorGFinalWrong, "colorGEdit", "Final Wrong Color: green (0-255)", 0u);
 
103
        ParameteredObject::_addParameter(
 
104
                colorBFinalWrong, "colorBEdit", "Final Wrong Color: blue (0-255)", 255u);
101
105
}
102
106
 
103
107
std::string getFilepath( std::string filename, const std::vector<std::string> &list ){
124
128
        assert (colorB() < 256u);
125
129
 
126
130
        // paint color
127
 
        const unsigned char color[] = {
 
131
        unsigned char color[] = {
128
132
                (unsigned char) this->colorR(),
129
133
                (unsigned char) this->colorG(),
130
134
                (unsigned char) this->colorB()
131
135
        };
132
136
 
133
137
        // paint wrong color
134
 
        const unsigned char color2[] = {
 
138
        unsigned char color2[] = {
135
139
                (unsigned char) this->colorRWrong(),
136
140
                (unsigned char) this->colorGWrong(),
137
141
                (unsigned char) this->colorBWrong()
138
142
        };
139
143
 
140
144
        // paint final color
141
 
        const unsigned char color3[] = {
 
145
        unsigned char color3[] = {
142
146
                (unsigned char) this->colorRFinal(),
143
147
                (unsigned char) this->colorGFinal(),
144
148
                (unsigned char) this->colorBFinal()
145
149
        };
146
150
 
147
151
        // paint final color
148
 
        const unsigned char colorDeletedFinal[] = {
 
152
        unsigned char color4[] = {
149
153
                (unsigned char) this->colorRFinalWrong(),
150
154
                (unsigned char) this->colorGFinalWrong(),
151
155
                (unsigned char) this->colorBFinalWrong()
193
197
                        int y1 = std::max(0, std::min(h - 1, (int)box->y1));
194
198
                        int x2 = std::max(0, std::min(w - 1, (int)box->x2));
195
199
                        int y2 = std::max(0, std::min(h - 1, (int)box->y2));
196
 
 
197
 
                        if (
198
 
                                (box->deleted && this->resultsDeleted()) ||
199
 
                                (box->finalized && this->resultsFinal()) ||
200
 
                                (!box->finalized && !box->deleted && this->resultsNormal())
201
 
                                )
202
 
                        {                       
203
 
 
204
 
                                nBoxes++;
205
 
 
206
 
                                // diagonal for final results
207
 
                                if (box->finalized && !box->deleted && this->drawDiagonal()){
208
 
                                        img.draw_line(x1, y1, x2, y2, color3);
209
 
                                        img.draw_line(x2, y1, x1, y2, color3);
210
 
                                }
211
 
 
212
 
                                img.draw_line(x1, y1, x2, y1, (box->finalized && box->deleted ? colorDeletedFinal : (box->finalized ? color3 : (box->deleted ? color2 : color))));      // top
213
 
                                img.draw_line(x2, y1, x2, y2, (box->finalized && box->deleted ? colorDeletedFinal : (box->finalized ? color3 : (box->deleted ? color2 : color))));      // right
214
 
                                img.draw_line(x1, y2, x2, y2, (box->finalized && box->deleted ? colorDeletedFinal : (box->finalized ? color3 : (box->deleted ? color2 : color))));      // bottom
215
 
                                img.draw_line(x1, y1, x1, y2, (box->finalized && box->deleted ? colorDeletedFinal : (box->finalized ? color3 : (box->deleted ? color2 : color))));      // left                         
216
 
 
217
 
                        }
 
200
                        
 
201
                        nBoxes++;
 
202
 
 
203
                        unsigned char *col = &color[0];
 
204
 
 
205
                        if (box->taskResultState == "Done" && this->resultsDone())
 
206
                                col = &color3[0];
 
207
                        else if (box->taskResultState == "Edit" && this->resultsEdit())
 
208
                                col = &color4[0];
 
209
                        else if (box->taskResultState == "Add" && this->resultsAdd())
 
210
                                col = &color[0];
 
211
                        else if (box->taskResultState == "Failed" && this->resultsFailed())
 
212
                                col = &color2[0];
 
213
                        else if (box->taskResultState == "Final" && this->resultsFinal()){
 
214
                                col = &color3[0];
 
215
                                img.draw_line(x1, y1, x2, y2, col);
 
216
                                img.draw_line(x2, y1, x1, y2, col);
 
217
                        }
 
218
                        else{
 
219
                                continue;
 
220
                        }
 
221
 
 
222
                        img.draw_line(x1, y1, x2, y1, col);     // top
 
223
                        img.draw_line(x2, y1, x2, y2, col);     // right
 
224
                        img.draw_line(x1, y2, x2, y2, col);     // bottom
 
225
                        img.draw_line(x1, y1, x1, y2, col);     // left                         
 
226
 
218
227
 
219
228
                }
220
229