1 /** @file line_window_t.cpp
2 @package snark14Display
3 @author Bruno M. Carvalho and Deniz Sarioz
4 licensed under (open-source) QPL v1.0
5 which accompanies this distribution in the file QPL
13 #include "sd_line_t.hpp"
14 #include "line_window_t.hpp"
16 void line_window_t::add(int x, int y) {
17 point_window_t mypoint = {x, y};
18 data.push_back(mypoint);
19 } // --line_window_t::add/2
21 void line_window_t::add(point_window_t& ptw) {
23 } // --line_window_t::add/1
25 bool line_window_t::empty() { return data.empty(); } // --line_window_t::empty()
27 void line_window_t::clear() { data.clear(); } // --line_window_t::clear()
29 /** pre: all coordinates are within paint's win */
30 /* (i.e., all points in data ought to be within window.) */
31 void line_window_t::plot(QPainter& P, QColor& C, Qt::PenStyle & Ps) {
32 // modify P somehow: just a point if single line, bunch of segments otherwise.
33 data_window_t::const_iterator it = data.begin();
46 if(it == data.end()) {
47 // 'line' has just a single point: plot blotch @ (x1, y1)
48 sd_line_t::drawBigPoint(P, x1 , y1);
50 // draw segments between consecutive pixel pairs in list
51 for(; it!=data.end(); it++) {
54 P.drawLine(x1, y1, x2, y2);
59 } // --line_window_t::plot()
62 void line_window_t::show() {
63 for(data_window_t::const_iterator it = data.begin(); it != data.end(); it++) {
64 std::cerr << "(" << (it->x) << "," << (it->y) << ") ";
67 } // --line_window_t::show()