2 * psychlops_g_canvas.cpp
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2006/02/11 by Kenchi HOSOKAWA
6 * (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
16 #include "../math/psychlops_math.h"
17 #include "psychlops_g_canvas.h"
18 #include "psychlops_g_image.h"
19 #include "../devices/psychlops_io_hid.h"
21 #define PSYCHLOPS_WINDOW_API_PLATFORM
22 #include "../../platform/psychlops_platform_selector.h"
23 #include "../../extension/standard/widgets/psychlops_widget.h"
24 #include "../../extension/standard/widgets/psychlops_widgets.h"
30 //////// Construct and Destruct ////////
32 Canvas::Canvas(const Canvas&)
33 : has_instance_(false), not_time_critical_(false), APIsetColor(0)
37 : has_instance_(false), not_time_critical_(false), APIsetColor(0)
40 Canvas::Canvas(CanvasMode mode, const Display disp)
41 : has_instance_(false), not_time_critical_(false), APIsetColor(0)
45 Canvas::Canvas(int d_width, int d_height, CanvasMode mode, const Display disp)
46 : has_instance_(false), not_time_critical_(false),APIsetColor(0)
48 set(d_width, d_height, mode, disp);
50 Canvas::Canvas(Rectangle d_rect, CanvasMode mode)
51 : has_instance_(false), not_time_critical_(false), APIsetColor(0)
55 Canvas::Canvas(int d_width, int d_height, int d_colordepth, double d_refreshrate, const Display disp)
56 : has_instance_(false), not_time_critical_(false), APIsetColor(0)
58 set(d_width, d_height, d_colordepth, d_refreshrate, disp);
66 void Canvas::set(CanvasMode mode, const Display disp) {
67 if(has_instance_) throw RESET;
70 api = new APICanvasPropertiesFullscreen(disp);
74 api = new APICanvasPropertiesWindow(800,600,disp);
81 void Canvas::set(int d_width, int d_height, CanvasMode mode, const Display disp) {
82 api = new APICanvasPropertiesWindow(d_width,d_height, disp);
87 void Canvas::set(Rectangle d_rect, CanvasMode mode) {
88 api = new APICanvasPropertiesWindow((int)d_rect.getLeft(), (int)d_rect.getTop(), (int)d_rect.getWidth(), (int)d_rect.getHeight());
93 void Canvas::set(int d_width, int d_height, int d_colordepth, double d_refreshrate, const Display disp) {
94 if(has_instance_) throw RESET;
95 api = new APICanvasPropertiesFullscreen(d_width, d_height, d_colordepth, d_refreshrate, disp);
99 void Canvas::initProperties() {
100 not_time_critical_ = false;
102 setDefaultCanvas(this);
105 Height = api->height_;
106 colordepth = api->colordepth_;
107 refreshrate = api->refreshrate_;
108 frameIntervalAccurate = 1000.0/refreshrate;
109 center.x.set(Width/2.0);
110 center.y.set(Height/2.0);
111 RefreshRate.set(getRefreshRate());
113 //// Initialize peripheral properties
115 setClearColor( Color::black );
116 clear_area_.set(Width, Height);
121 if(!api->vsync_available_) {
122 Rectangle *rect = new Rectangle(600, 20);
123 rect->centering(getCenter().x, getHeight()-20);
124 rect->fill = Color::red;
125 Letters *let = new Letters(L"Executing without synchronization with Monitor Vsync", Font(12));
126 let->datum = rect->getCenter();
128 let->align = Letters::TEXT_ALIGN_CENTER;
129 let->fill = Color::white;
130 internal_billboard.push_back(rect);
131 internal_billboard.push_back(let);
132 billboard.push_back(rect);
133 billboard.push_back(let);
135 APICanvasPropertiesWindow* iswindow = dynamic_cast<APICanvasPropertiesWindow*>(api);
137 Widgets::TitleBar::default_titlebar = new Widgets::TitleBar(*this);
138 billboard.push_back(Widgets::TitleBar::default_titlebar);
140 eventroot.root = this;
142 void Canvas::initCounters() {
143 DISPLAYED_FRAMES=0, FAILED_FRAMES=0, LAST_FAILED_FRAMES = 0, TOTAL_REFRESH=0, FAILED_FLIPS=0, displayedFrames=0, failedFrames=0, lastFailedFrames_=0;
144 frameInterval=0.0, frameIntervalAccurate=0.0, frameAccuracy = 0.0;
145 rest_wating_vsyncs_=0; time_lastFrame.update(); time_lastFrame_before_flip_.update(); time_init_.update(); checkingFPS=false; checkingFPS_last=false; displayingFPS=false;
146 progressbarrect.set(102,12);
147 progressbarbordercolor=Color::gray;
148 progressbarfillcolor=Color::blue;
149 progressbarerrorcolor=Color::magenta;
150 progressbaremptycolor.set(0.25,0.25,0.25);
153 void Canvas::initPrimitives() {
156 setFillOvalPrimitives();
159 void Canvas::setGammaValue(const double gamma_r, const double gamma_g, const double gamma_b) {
160 if(has_instance_) api->setGammaValue(gamma_r, gamma_g, gamma_b);
162 void Canvas::setGammaTable(const std::vector<double> &table_r,const std::vector<double> &table_g, const std::vector<double> &table_b) {
163 if(has_instance_) api->setGammaTable(table_r, table_g, table_b);
165 /*void Canvas::setGammaTable(const Matrix &table_all) {
168 int k=0, num_steps=table_all.getCols();
169 for(int i=0; i<3; i++) {
170 table[i] = new double[num_steps];
172 for(int j=0; j<num_steps; j++) table[0][j] = (double)table_all(j,i);
174 api->setGammaTable(table[0], table[1], table[2], num_steps);
175 for(int i=0; i<3; i++) delete [] table[i];
178 void Canvas::loadFontMinimum() {
179 if(!Font::initialized) Font::initializeFontMinimum();
180 for(int i=0; i<Font::ASCII_NUM; i++) {
181 Font::font_minimum[i].cache(*this);
188 void Canvas::release() {
190 if(!internal_billboard.empty()) {
191 for(std::vector<Figure*>::iterator i = internal_billboard.begin(); i!=internal_billboard.end(); i++) {
195 if(!letter_cache.empty()) for(std::list<Letters *>::iterator it=letter_cache.begin(); it!=letter_cache.end(); it++) delete *it;
196 if(!img_caches.empty()) {
197 for(ImageCache::iterator it=img_caches.begin(); it!=img_caches.end(); it++) {
198 uncacheImageBody(*(it->first));
202 if(!let_caches.empty()) {
203 for(LettersCache::iterator it=let_caches.begin(); it!=let_caches.end(); it++) {
204 //api->uncacheLetters(*(it->first));
205 api->uncache(*(it->first));
213 resetDefaultCanvas(this);
214 has_instance_ = false;
219 void Canvas::setPhysicalSettings(double width, double height, double distance, int horizontalpixs, int varticalpixs) {
220 DisplayWidthCentimeter_ = width;
221 DisplayHeightCentimeter_ = height;
222 DisplayDistanceCentimeter_ = distance;
223 DisplayHorizontalPixelNumber_ = horizontalpixs;
224 DisplayVerticalPixelNumber_ = varticalpixs;
226 int Canvas::horizontalArcdegToPixel(double angle) {
227 return (int)( ((double)DisplayHorizontalPixelNumber_/DisplayWidthCentimeter_) //h_pixels_a_millimeter
228 *DisplayDistanceCentimeter_
229 *tan(angle*PI/360.0) // == tan( (width/2) * (2*PI/360.0) )
232 int Canvas::varticalArcdegToPixel(double angle) {
233 return (int)( ((double)DisplayVerticalPixelNumber_/DisplayHeightCentimeter_) //v_pixels_a_millimeter
234 *DisplayDistanceCentimeter_
235 *tan(angle*PI/360.0) // == tan( (width/2) * (2*PI/360.0) )
238 int Canvas::getDisplayHorizontalPixelNumber() {
239 return DisplayHorizontalPixelNumber_;
241 int Canvas::getDisplayVerticalPixelNumber() {
242 return DisplayVerticalPixelNumber_;
248 //////// Drawing Graphical Elements ////////
250 Canvas& Canvas::drawPixel(double x, double y, const Color &col) { pix(x,y,col); return *this; }
251 Canvas& Canvas::drawPixel(const Point &po, const Color &col) { return pix(po,col); }
252 void Canvas::drawPixel(int dotsCnt, double x[], double y[], const Color col[]) { pix(dotsCnt,x,y,col); }
253 void Canvas::drawPixel(int dotsCnt, double x[], double y[], const Color &col=Color::white) { pix(dotsCnt,x,y,col); }
254 void Canvas::drawPixel(int dotsCnt, const Point po[], const Color col[]) { pix(dotsCnt,po,col); }
255 void Canvas::drawLine(double x1, double y1, double x2, double y2, const Color &col) { line(x1, y1, x2, y2, col); }
256 void Canvas::drawLine(const Point &po1, const Point &po2, const Color &col) { line(po1,po2,col); }
257 Canvas& Canvas::fillRect(const Rectangle &rec, const Color &col) { return rect(rec,col); }
258 Canvas& Canvas::fillRect(const int nRects, const Rectangle *rec, const Color &col) { return rect(nRects,rec,col); }
259 Canvas& Canvas::fillRect(const int nRects, const Rectangle *rec, const Color *col) { return rect(nRects,rec,col); }
260 Canvas& Canvas::fillRect(const unsigned int nRectsBegin, const unsigned int nRectsEnd, const Rectangle *rec, const Color *col) { return rect(nRectsBegin,nRectsEnd,rec,col); }
261 Canvas& Canvas::fillOval(const Rectangle &rect, const Color &col) { return ellipse(rect,col); }
262 Canvas& Canvas::oval(const Ellipse &drawee, const Color &col) { return ellipse(drawee, col); }
263 Canvas& Canvas::oval(const Ellipse &drawee, const Stroke &strk) { return ellipse(drawee, strk); }
264 Canvas& Canvas::oval(const Rectangle &rect, const Color &col) { return ellipse(rect, col); }
265 Canvas& Canvas::oval(const Rectangle &rect, const Stroke &strk) { return ellipse(rect, strk); }
266 void Canvas::drawPolygon(Point *vertices, unsigned int nVertices, const Color &col) { polygon(vertices, nVertices, col); }
269 template void Canvas::var<int>(int val, double x, double y, const Color &col, bool fillForward);
270 template void Canvas::var<double>(double val, double x, double y, const Color &col, bool fillForward);
271 int Canvas::msg(const std::string &string, const double x, const double y, const Color &col, const int horiz_align, const int vertical_align, const double max__width) { return msg(string.c_str(),x,y,col,horiz_align,vertical_align,max__width); }
272 int Canvas::showMessage(const char* string, const double x, const double y, const Color &col, const int horiz_align, const int vertical_align, const double max__width) { return msg(string,x,y,col,horiz_align,vertical_align,max__width); }
273 int Canvas::showMessage(const std::string &string, const double x, const double y, const Color &col, const int horiz_align, const int vertical_align, const double max__width) { return msg(string.c_str(),x,y,col,horiz_align,vertical_align,max__width); }
275 void Canvas::message(const char* string, const double x, const double y, const Color &col) { msg(string,x,y,col); } // obsolete
276 int Canvas::msg(const std::wstring &string, const double x, const double y, const Color &col, const int horiz_align, const int vertical_align, const double max_width) {
278 std::list<Letters *>::iterator it;
279 for(it=letter_cache.begin(); it!=letter_cache.end(); it++) {
280 if((**it).str==string) {
282 //letter_cache.erase(it);
283 //letter_cache.push_front(out);
287 out = new Letters(string);
288 letter_cache.push_front(out);
289 if(letter_cache.size()>10) {
290 delete letter_cache.back();
291 letter_cache.pop_back();
294 return msg(*out,x,y,col,horiz_align,max_width);
296 Canvas& Canvas::letters(Letters &letters, const Color &col) {
297 if(let_caches.count(&letters)==0) cacheLetters(letters);
298 msg(letters, letters.getDatum().x, letters.getDatum().y, col, letters.align);
301 void Canvas::cacheLetters(Letters &letters) {
302 //api->cacheLetters(letters);
304 if(let_caches.count(&letters)==0) let_caches.insert(std::pair<Letters*, Letters::Cache*>(&letters, &(letters.caches[this]) ));
306 void Canvas::uncacheLetters(Letters &letters) {
307 //api->uncacheLetters(letters);
308 api->uncache(letters);
309 if(let_caches.count(&letters)!=0) let_caches.erase(&letters);
311 void Canvas::cacheImage(Image &img) {
313 if(img_caches.count(&img)==0) img_caches.insert(std::pair<Image*, ImageCache_*>(&img, &(img.caches[this]) ));
315 void Canvas::uncacheImage(Image &img) {
316 uncacheImageBody(img);
317 if(img_caches.count(&img)!=0) img_caches.erase(&img);
322 int Canvas::msg(const std::string &string, const double x, const double y, const double max_width, const int align, const Color col) {
323 return msg(string.c_str(), x, y, max_width, align, col);
325 void Canvas::showMessage(const char* string, const double x, const double y, const Color col) { msg(string,x,y,col); }
326 void Canvas::showMessage(const std::string &string, const double x, const double y, const Color col) { msg(string,x,y,col); }
327 int Canvas::showMessage(const char* string, const double x, const double y, const double max_width, const int align, const Color col) { return msg(string,x,y,max_width,align,col); }
328 int Canvas::showMessage(const std::string &string, const double x, const double y, const double max_width, const int align, const Color col) { return msg(string,x,y,max_width,align,col); }
330 //void Canvas::varcheck(const int number, const double x, const double y, const Color col, const bool fillForward) { var(number,x,y,col,fillForward); } // obsolete
331 void Canvas::message(const char* string, const double x, const double y, const Color col) { msg(string,x,y,col); } // obsolete
337 Canvas& Canvas::image(const Image &img) {
338 drawImage(img, img.targetarea_.getLeft(), img.targetarea_.getTop());
341 void Canvas::drawImage(const Image &img) {
342 drawImage(img, img.targetarea_.getLeft(), img.targetarea_.getTop());
344 Canvas& Canvas::image(const Image &img, const double left, const double top) {
345 drawImage(img, left, top);
350 //////// Critical Operations ////////
351 void Canvas::flipAndWait(const int frame_duration_by_vsyncs) {
352 flip(frame_duration_by_vsyncs);
354 void Canvas::flipAfter(const int frame_duration_by_vsyncs) {
355 rest_wating_vsyncs_ += frame_duration_by_vsyncs-1;
358 void Canvas::flip(float N) { throw Exception(typeid(*this), "Specification Error", "Canvas::flip can not accept float point number."); }
359 void Canvas::flip(double N) { throw Exception(typeid(*this), "Specification Error", "Canvas::flip can not accept float point number."); }
361 void Canvas::displayFrame(void) { flip(1); }
362 void Canvas::displayFrameWithWait(int nextframe) { flip(nextframe); }
363 void Canvas::displayFrameWithWait(double N) { flip(N); }
365 Canvas& Canvas::clear(const Color &col) {
366 return clear(col, BACK);
368 Canvas& Canvas::clear(TargetSurface target) {
369 return clear(bgcolor_, target);
371 void Canvas::setClearColor(Color col) {
377 //////// Utilities ////////
378 void Canvas::progressbar(Rectangle &inrect, Color fillcol, Color empcol) {
379 progressbarrect = inrect;
380 progressbarfillcolor = fillcol;
381 progressbaremptycolor = empcol;
383 void Canvas::progressbar(double l, double t, double r, double b, Color fillcol, Color empcol) {
384 Rectangle tmprect(l,t,r,b);
385 progressbar(tmprect, fillcol, empcol);
392 //////// DISPLAY UTILITIES ////////
393 void Canvas::displayFPS() {
394 int line_height = font_LCD_height+3, line_offset = 20;
395 Rectangle baserect(Width-100, 1, Width-2, (int)(line_height*3.5));
396 APICanvasPropertiesWindow* iswindow = dynamic_cast<APICanvasPropertiesWindow*>(api);
398 baserect.shift(0, 20);
400 //glPushAttrib(GL_ALL_ATTRIB_BITS);
401 //glEnable(GL_BLEND);
402 Color fgcol(1.0,1.0,1.0), bgcol(0.0,0.0,0.0,0.5);
403 fillRect(baserect, bgcol);
404 //glDisable(GL_BLEND);
409 sprintf(digit, "%li", FAILED_FRAMES);
410 var_(digit, (double)(baserect.right-10.0), (double)(baserect.top+line_offset), Color::red, false);
411 sprintf(digit, "%li", (TOTAL_REFRESH));
412 var_(digit, baserect.right-10, baserect.top+line_height+line_offset, Color::white, false);
413 if(LAST_FAILED_FRAMES>0) fgcol=Color::red;
414 else if(frameInterval>frameIntervalAccurate) fgcol=Color::cyan;
415 else fgcol=Color::white;
416 sprintf(digit, "%i", (int)(frameInterval));
417 var_(digit, baserect.right-10, baserect.top+line_height*2+line_offset, fgcol, false);
419 void Canvas::initFPS() {
423 DISPLAYED_FRAMES = 0;
426 void Canvas::watchFPS() {
428 time_lastFrame.update();
430 void Canvas::ignoreFPS() {
432 checkingFPS_last = false;
434 void Canvas::showFPS() {
435 displayingFPS = true;
437 void Canvas::hideFPS() {
438 displayingFPS = false;
440 int Canvas::lastFailedFrames() {
441 return lastFailedFrames_;
444 void Canvas::enableFPSChecker() { watchFPS(); }
445 void Canvas::disableFPSChecker() { ignoreFPS(); }
446 void Canvas::enableDisplayingFPS() { showFPS(); }
447 void Canvas::disableDisplayingFPS() { hideFPS(); }
451 //////// AUX ////////
452 void Canvas::makeTimeCritical(bool b) { not_time_critical_ = !b; }
453 bool Canvas::isTimeCritical() const { return !(not_time_critical_); }
456 //////// GET ELEMENT ////////
457 int Canvas::getWidth() const { return Width; }
458 int Canvas::getHeight() const { return Height; }
459 int Canvas::getColorDepth() const { return colordepth; }
460 double Canvas::getRefreshRate() const { return refreshrate; }
461 double Canvas::getHcenter() const { return Width/2 - 0.5; }
462 double Canvas::getVcenter() const { return Height/2 - 0.5; }
463 const Point Canvas::getCenter() const {
464 Point po(getHcenter(), getVcenter());
467 Canvas::READ_ONLY_POINT_::READ_ONLY_POINT_() {}
468 Canvas::READ_ONLY_POINT_::operator Point() const { return Point(x,y); }
471 void Canvas::setDefaultCanvas(Canvas *cnvs) {
472 if(Display::the_canvas==0) Display::the_canvas = cnvs;
473 if(Drawable::prime==Drawable::dummy) Drawable::prime = cnvs;
474 if(DrawableWithCache::prime==0) DrawableWithCache::prime = cnvs;
475 if(!Drawable::billboard.contents.empty()) {
476 cnvs->billboard.push_back(&Drawable::billboard);
479 void Canvas::resetDefaultCanvas(Canvas *cnvs) {
480 if(Display::the_canvas==cnvs) Display::the_canvas = 0;
481 if(Drawable::prime==cnvs) Drawable::prime = const_cast<Drawable*>(Drawable::dummy);
482 if(DrawableWithCache::prime==cnvs) DrawableWithCache::prime = 0;
485 Point Canvas::mouse() const {
486 Point p = api->left_top();
487 return Point(Mouse::uniX-p.x, Mouse::uniY-p.y);
489 Point Canvas::mouse(const Point &pp) const {
491 p = p + api->left_top();
492 return Mouse::uniPosition = p;
497 void Canvas::getBubble(const char* ev)
499 if(ev==Events::Focus::name) ;
503 Canvas * Display::the_canvas;
507 Canvas::Geometry::Geometry() {}
508 Canvas::Geometry::Geometry(double dist, double horiz, double vert, Canvas &cnvs) {
512 horiz_pix = cnvs.getWidth();
513 vert_pix = cnvs.getHeight();
514 horiz_pix_per_cm = horiz_pix / horiz_cm;
515 vert_pix_per_cm = vert_pix / vert_pix;
517 const double Canvas::Geometry::pixels(double visual_angle) {
518 return tan(visual_angle/360.0*2.0*PI) * dist_cm * horiz_pix_per_cm;
523 // void Display::flip(void) { the_canvas->flip(); }
524 void Display::flip(int and_wait_N_vsyncs) { the_canvas->flip(and_wait_N_vsyncs); }
525 void Display::flipAndWait(int and_wait_N_vsyncs) { the_canvas->flip(and_wait_N_vsyncs); }
526 void Display::flipAfter(int frame) { the_canvas->flipAfter(frame); }
529 void Display::displayFrame() { the_canvas->flip(); }
530 void Display::displayFrameWithWait(int num_frames_to_wait) { the_canvas->flip(num_frames_to_wait); }
531 // void Display::clear(Color col, Canvas::TargetSurface target) { the_canvas->clear(col, target); }
532 // void Display::clear(Canvas::TargetSurface target) { the_canvas->clear(target); }
533 void Display::clear(Color col, TargetSurface target) { the_canvas->clear(col, (Canvas::TargetSurface)target); }
534 void Display::clear(TargetSurface target) { the_canvas->clear((Canvas::TargetSurface)target); }
535 void Display::setClearColor(Color col) { the_canvas->setClearColor(col); }
537 //////// DISPLAY GRAPHIC ELEMENT ////////
538 void Display::copy(Rectangle &source, const Rectangle &target, bool doesdeletesource, const Color &delcol) { the_canvas->copy(source, target, doesdeletesource, delcol); }
539 void Display::pix(const double x, const double y, const Color &col) { the_canvas->pix(x, y, col); }
540 void Display::pix(const Point &po, const Color &col) { the_canvas->pix(po, col); }
541 void Display::pix(int dotsCnt, double x[], double y[], const Color col[]) { the_canvas->pix(dotsCnt, x, y, col); }
542 void Display::pix(int dotsCnt, double x[], double y[], const Color &col) { the_canvas->pix(dotsCnt, x,y, col); }
543 void Display::pix(int dotsCnt, const Point po[], const Color col[]) { the_canvas->pix(dotsCnt, po, col); }
544 void Display::line(double x1, double y1, double x2, double y2, const Color &col) { the_canvas->line(x1, y1, x2, y2, col); }
545 void Display::line(const Point &po1, const Point &po2, const Color &col) { the_canvas->line(po1, po2, col); }
546 void Display::line(double x1, double y1, double x2, double y2, const Stroke &strk) { the_canvas->line(x1, y1, x2, y2, strk); }
547 void Display::line(const Point &po1, const Point &po2, const Stroke &strk) { the_canvas->line(po1, po2, strk); }
548 void Display::rect(const Rectangle &rect, const Color &col) { the_canvas->rect(rect, col); }
549 void Display::rect(const int nRects, const Rectangle *rec, const Color &col) { the_canvas->rect(nRects,rec,col); }
550 void Display::rect(const int nRects, const Rectangle *rec, const Color *col) { the_canvas->rect(nRects,rec,col); }
551 void Display::rect(const unsigned int nRectsBegin, const unsigned int nRectsEnd, const Rectangle *rec, const Color *col) { the_canvas->rect(nRectsBegin,nRectsEnd,rec,col); }
552 void Display::rect(const Rectangle &rect, const Stroke &strk) { the_canvas->rect(rect, strk); }
553 void Display::rect(const int nRects, const Rectangle *rec, const Stroke &strk) { the_canvas->rect(nRects,rec,strk); }
554 void Display::rect(const int nRects, const Rectangle *rec, const Stroke *strk) { the_canvas->rect(nRects,rec,strk); }
555 void Display::rect(const unsigned int nRectsBegin, const unsigned int nRectsEnd, const Rectangle *rec, const Stroke *strk) { the_canvas->rect(nRectsBegin,nRectsEnd,rec,strk); }
556 void Display::oval(Rectangle &rect, const Color &col) { the_canvas->ellipse(rect, col); }
557 void Display::oval(Rectangle &rect, const Stroke &strk) { the_canvas->ellipse(rect, strk); }
558 void Display::ellipse(Rectangle &rect, const Color &col) { the_canvas->ellipse(rect, col); }
559 void Display::ellipse(Rectangle &rect, const Stroke &strk) { the_canvas->ellipse(rect, strk); }
560 void Display::ellipse(Ellipse &ell, const Color &col) { the_canvas->ellipse(ell, col); }
561 void Display::ellipse(Ellipse &ell, const Stroke &strk) { the_canvas->ellipse(ell, strk); }
562 void Display::polygon(Point *vertices, unsigned int nVertices, const Color &col) { the_canvas->polygon(vertices, nVertices, col); }
563 void Display::polygon(Point *vertices, unsigned int nVertices, const Stroke &strk) { the_canvas->polygon(vertices, nVertices, strk); }
564 void Display::drawPixel(double x, double y, const Color &col) { the_canvas->pix(x, y, col); }
565 void Display::drawPixel(const Point &po, const Color &col){ the_canvas->pix(po,col); }
566 void Display::drawPixel(int dotsCnt, double x[], double y[], const Color col[]) { the_canvas->pix(dotsCnt, x, y, col); }
567 void Display::drawPixel(int dotsCnt, double x[], double y[], const Color &col) { the_canvas->pix(dotsCnt, x, y, col); }
568 void Display::drawPixel(int dotsCnt, const Point po[], const Color col[]) { the_canvas->pix(dotsCnt, po, col); }
569 void Display::drawLine(double x1, double y1, double x2, double y2, const Color &col) { the_canvas->line(x1, y1, x2, y2, col); }
570 void Display::drawLine(const Point &po1, const Point &po2, const Color &col) { the_canvas->line(po1, po2, col); }
571 void Display::fillRect(const Rectangle &rect, const Color &col) { the_canvas->rect(rect, col); }
572 void Display::fillRect(const int nRects, const Rectangle *rec, const Color &col) { the_canvas->rect(nRects,rec,col); }
573 void Display::fillRect(const int nRects, const Rectangle *rec, const Color *col) { the_canvas->rect(nRects,rec,col); }
574 void Display::fillRect(const unsigned int nRectsBegin, const unsigned int nRectsEnd, const Rectangle *rec, const Color *col) { the_canvas->rect(nRectsBegin,nRectsEnd,rec,col); }
575 void Display::fillOval(Rectangle &rect, const Color &col) { the_canvas->oval(rect, col); }
576 void Display::drawPolygon(Point *vertices, unsigned int nVertices, const Color &col) { the_canvas->polygon(vertices, nVertices, col); }
578 void Display::copy(const Rectangle &source, const Rectangle &target, bool doesdeletesource, const Color &delcol) { the_canvas->copy(source, target, doesdeletesource, delcol); }
579 void Display::to(Image &img, const Rectangle &srcrect) { the_canvas->to(img, srcrect); }
580 // void Display::to(Image &img, const Rectangle &srcrect, const Rectangle &tgtrect) { the_canvas->to(img, srcrect, tgtrect); }
581 void Display::drawImage(const Image &img) { the_canvas->drawImage(img); }
582 void Display::drawImage(const Image &img, const double left, const double top) { the_canvas->drawImage(img, left, top); }
584 //////// DISPLAY UTILITIES ////////
586 void Display::initFPS() { the_canvas->initFPS(); }
587 void Display::watchFPS() { the_canvas->watchFPS(); }
588 void Display::ignoreFPS() { the_canvas->ignoreFPS(); }
589 void Display::showFPS() { the_canvas->showFPS(); }
590 void Display::hideFPS() { the_canvas->hideFPS(); }
591 int Display::lastFailedFrames() { return the_canvas->lastFailedFrames(); }
593 void Display::enableFPSChecker() { the_canvas->enableFPSChecker(); } // obsolete
594 void Display::disableFPSChecker() { the_canvas->disableFPSChecker(); } // obsolete
595 void Display::enableDisplayingFPS() { the_canvas->enableDisplayingFPS(); } // obsolete
596 void Display::disableDisplayingFPS() { the_canvas->disableDisplayingFPS(); } // obsolete
598 void Display::progressbar(Rectangle &inrect, Color fillcol, Color empcol) { the_canvas->progressbar(inrect, fillcol, empcol); }
599 void Display::progressbar(double l, double t, double r, double b, Color fillcol, Color empcol) { the_canvas->progressbar(l, t, r, b, fillcol, empcol); }
600 void Display::progressbar(double percentage) { the_canvas->progressbar(percentage); }
602 //void Display::var(const int number, const double x, const double y, const Color col, const bool fillForward) { the_canvas->var(number, x, y, col, fillForward); }
603 void Display::var_(const std::string number, const double x, const double y, const Color &col, const bool fillForward) { the_canvas->var_(number, x, y, col, fillForward); }
604 int Display::msg(const char* string, const double x, const double y, const Color col, const int horiz_align, const double max_width) { return the_canvas->msg(string, x, y, col, horiz_align, max_width); }
605 int Display::msg(const std::string &string, const double x, const double y, const Color col, const int horiz_align, const double max_width) { return the_canvas->msg(string, x, y, col, horiz_align, max_width); }
606 //void Display::checkVar(const int number, const double x, const double y, const Color col, const bool fillForward) { the_canvas->var(number, x, y, col, fillForward); }
607 int Display::showMessage(const char* string, const double x, const double y, const Color col, const int align, const double max_width) { return the_canvas->msg(string, x, y, col, align, max_width); }
608 int Display::showMessage(const std::string &string, const double x, const double y, const Color col, const int align, const double max_width) { return the_canvas->msg(string, x, y, col, align, max_width); }
610 //void Display::varcheck(int number, double x, double y, Color col, bool fillForward) { the_canvas->var(number, x, y, col, fillForward); } // obsolete
611 void Display::message(const char* string, const double x, const double y, const Color col) { the_canvas->msg(string, x, y, col); } // obsolete
612 int Display::msg(Letters &letters, const double x, const double y, const Color &col, const int horiz_align, const double max_width) { return the_canvas->msg(letters, x, y, col, horiz_align, max_width); }
613 int Display::msg(const std::wstring &string, const double x, const double y, const Color &col, const int horiz_align, const double max_width) { return the_canvas->msg(string, x, y, col, horiz_align, max_width); }
616 void Display::setGammaValue(const double gamma_r, const double gamma_g, const double gamma_b) { the_canvas->setGammaValue(gamma_r, gamma_g, gamma_b); }
617 void Display::setGammaTable(const std::vector<double> &table_r,const std::vector<double> &table_g, const std::vector<double> &table_b) { the_canvas->setGammaTable(table_r, table_g, table_b); }
619 //////// GET DISPLAY PROPERTY ////////
620 int Display::getWidth() { return the_canvas->getWidth();}
621 int Display::getHeight() { return the_canvas->getHeight(); }
622 int Display::getColorDepth() { return the_canvas->getColorDepth();}
623 double Display::getRefreshRate() { return the_canvas->getRefreshRate(); }
624 double Display::getHcenter() { return the_canvas->getHcenter(); }
625 double Display::getVcenter() { return the_canvas->getVcenter(); }
626 Point Display::getCenter() { return the_canvas->getCenter(); }
629 Display::READ_ONLY_X_::operator double() { return getHcenter(); };
630 Display::READ_ONLY_Y_::operator double() { return getVcenter(); };
631 Display::READ_ONLY_CENTER_::operator Point() { return Point(getHcenter(),getVcenter()); };
632 Display::READ_ONLY_CENTER_ Display::center;
633 Display::READ_ONLY_REFRESH_::operator double() { return getRefreshRate(); }
634 Display::READ_ONLY_REFRESH_ Display::RefreshRate;
639 } /* <- namespace Psycholops */