casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtPixelCanvas.qo.h
Go to the documentation of this file.
1 //# QtPixelCanvas.qo.h: (barebones) Qt implementation of PixelCanvas
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 #ifndef QTPIXELCANVAS_H
28 #define QTPIXELCANVAS_H
29 
30 #include <casa/aips.h>
31 #include <casa/Arrays/Matrix.h>
34 //#include <display/DisplayEvents/PCMotionEH.h>
35 #include <casa/BasicMath/Math.h>
37 //#include "PCEventDispatcher.h"
38 #include <list>
39 
40 #include <graphics/X11/X_enter.h>
41 # include <QWidget>
42 # include <QPainter>
43 # include <QPixmap>
44 # include <QPicture>
45 # include <QImage>
46 # include <QPen>
47 #include <graphics/X11/X_exit.h>
48 
49 
50 namespace casa {
51 
52  class q_draw;
53 
54  class QtPixelCanvas : public QWidget, public PixelCanvas {
55 
56 //# (Note: derivation from QWidget must be first above, for Qt's
57 //# 'meta-object compiler' to correctly process the following macro).
58 
59  Q_OBJECT //# Allows slot/signal definition. Must only occur in
60  //# implement/.../*.h files; also, makefile must include
61  //# name of this file in 'mocs' section.
62 
63  public:
64 
65 //# RELEVANT (OR ALREADY-IMPLEMENTED) METHODS
66 
67 
68  QtPixelCanvas(QWidget *parent=0);
69  QtPixelCanvas( const QtPixelCanvas *, QWidget *parent=0 );
70  ~QtPixelCanvas();
71 
72  void beginLabelAndAxisCaching( ) {
73  cache_label_and_axis = true;
74  }
75  void endLabelAndAxisCaching( QPainter &qp );
76 
77  protected:
78 
79  std::list<q_draw*> label_and_axis_cache;
80 
81  // QT EVENT HANDLERS -- these create PixelCanvas events.
82  // <group>
83  void paintEvent(QPaintEvent* e);
84  void resizeEvent(QResizeEvent* e);
85  void mouseMoveEvent(QMouseEvent* e);
86  void mousePressEvent(QMouseEvent* e);
87  void mouseReleaseEvent(QMouseEvent* e);
88  void keyPressEvent(QKeyEvent* e );
89  void enterEvent( QEvent* e );
90  // </group>
91 
92  bool cache_label_and_axis;
93 
94  public:
95 
96  //# OTHER QWIDGET DERIVED METHODS.
97 
98  // Returns a reasonable suggestion for canvas size; it will
99  // be used initially unless overridden by a resize/setGeometry
100  // call, on this widget or a parent.
101  virtual QSize sizeHint() const {
102  return QSize(400, 300);
103  }
104 
105 
106 
107 
108  //# PIXELCANVAS METHODS
109 
110 
111  //# Refresh Cycle Methods -- not to be called by
112  //# refresh / drawing handlers (rather the reverse).
113  //# Not cacheable.
114 
115 
116  virtual void refresh(const Display::RefreshReason &reason =
118  const bool &explicitrequest = true);
119 
120  static void colorTableResizeCB(PixelCanvasColorTable *, casacore::uInt,
121  QtPixelCanvas * qtpc,
122  Display::RefreshReason reason);
123 
124 
125  // set the draw buffer
126  // Only 'FrontBuffer' and 'BackBuffer' are supported; This value
127  // will be 'Display::BackBuffer', unless explicitly set to
128  // 'Display::FrontBuffer'.
129  virtual void setDrawBuffer(Display::DrawBuffer buf) {
130  if(buf==Display::FrontBuffer) setDrawBuffer_(buf);
131  else setDrawBuffer_(Display::BackBuffer);
132  p_begin_();
133  } // Refocus painter on new buffer if necessary.
134 
135 
136 // buffer memory exchanges
137  // <group>
138  virtual void copyBackBufferToFrontBuffer();
139  virtual void copyFrontBufferToBackBuffer();
140  virtual void swapBuffers();
141  // </group>
142 
143  // partial buffer memory exchanges. (x1,y1 are blc, x2,y2 are trc)
144  // <group>
145  virtual void copyBackBufferToFrontBuffer(int x1, int y1, int x2, int y2);
146  virtual void copyFrontBufferToBackBuffer(int x1, int y1, int x2, int y2);
147  virtual void swapBuffers(int x1, int y1, int x2, int y2);
148  // </group>
149 
150 
151 
152 
153  //# Drawing Methods. (Buffer and draw mode should already be set.
154  //# QPainter p_ should (and will) be open on current paint device).
155  //# cacheable.
156 
157 
158  // Clear the window using the background color
159  // <group>
160  virtual void clear();
161  virtual void clear(int x1, int y1, int x2, int y2);
162  // </group>
163 
164  // Draw an array of 2D color data as a raster image
165  //#dk note: Color data Arrays passed to draw*()
166  //# are produced by maptoColor[3] (see below).
167  virtual void drawImage(const casacore::Matrix<casacore::uInt> &data, int x, int y);
168 
169  // The version used with masks.
170  //# (the one with the gratuitously transposed arguments...)
171  // Set opaqueMask to true to draw masked pixels in the background color;
172  // otherwise they will be transparent, letting whatever was drawn
173  // previously at that point show through.
174  virtual void drawImage(const int &x, const int &y,
177  bool opaqueMask=false) ;
178 
179 
180  virtual void drawLines(const casacore::Matrix<float> &verts);
181 
182  virtual void drawRectangle(int x1, int y1, int x2, int y2);
183 
184  virtual void drawFilledRectangle(int x1, int y1, int x2, int y2);
185 
186  virtual void drawPolygon(const casacore::Vector<float> &x,
187  const casacore::Vector<float> &y);
188 
189  virtual void drawFilledPolygon(const casacore::Vector<float> &x,
190  const casacore::Vector<float> &y);
191 
192 
193 //# (This routine was cut in favor of the PixelCanvas one, mainly
194 //# because Qt's method of implementing stretch (transformation QMatrix)
195 //# affects drawing line widths as well, which is not what was wanted
196 //# in the case of beam ellipses. dk 6/07).
197 //#
198 //# // Draw a single ellipse using the current pen (ie. color,
199 //# // thickness, style). The x and y location must be given, along
200 //# // with the semi-major and -minor axis lengths, and the position
201 //# // angle measured in degrees positive from the x axis in a
202 //# // counter-clockwise direction. If outline is false, the
203 //# // ellipse is solid filled, else it is just outlined.
204 //# // xstretch, ystretch should be left defaulted to 1 in most cases;
205 //# // see usage example in WorldCanvas::drawBeamEllipse(), where they are
206 //# // used to stretch a beam ellipse when the display is also linearly
207 //# // stretched away from the aspect ratio natural to the sky projection.
208 //# // They multiply the relative x and y screen coordinates of ellipse
209 //# // points, _before_ they are added to cx and cy. xstretch, ystretch
210 //# // can be negative (though smajor, sminor normally would not be).
211 //# virtual void drawEllipse(const float &cx, const float &cy,
212 //# const float &smajor, const float &sminor,
213 //# const float &pangle, bool outline = true,
214 //# float xstretch = 1.0, float ystretch = 1.0);
215 
216 
217 
218 
219 
220 
221  //# (...That's it?... all that's really used?? (!!))
222 
223 
224  //#dk Note: mapToColor[3] are implemented in the base class; they just
225  //# pass the chore to [Qt]PCCT. The ones actually used are:
226  //#
227  //# virtual void mapToColor(const Colormap * map,
228  //# casacore::Array<casacore::uInt> & outArray,
229  //# const casacore::Array<casacore::uInt> & inArray,
230  //# bool rangeCheck = true) const;
231  //#
232  //#
233  //# [and, when/if non-Index (3-channel) ColorModels
234  //# are implemented for QtPixelCanvas]:
235  //#
236  //# virtual void mapToColor3(casacore::Array<casacore::uLong> & out,
237  //# const casacore::Array<casacore::uInt> & chan1in,
238  //# const casacore::Array<casacore::uInt> & chan2in,
239  //# const casacore::Array<casacore::uInt> & chan3in) { }
240  //#
241  //# The color data output matrix is passed to drawImage, above
242 
243 
244 
245 
246 
247 
248  //# Graphics Context Methods
249 
250 
251  // Get/set the current foreground/background colors. These colors
252  // should be used when the special Strings "foreground" and "background"
253  // are given for a color.
254  // <group>
255  virtual void setDeviceForegroundColor(const casacore::String colorname);
256  virtual casacore::String deviceForegroundColor() const;
257  virtual void setDeviceBackgroundColor(const casacore::String colorname);
258  virtual casacore::String deviceBackgroundColor() const;
259  // </group>
260 
261  virtual void setColor(const casacore::String &colorname);
262  virtual void setRGBColor(float r, float g, float b);
263 
264  // Set/enable/disable clip window. 'ClipWindow' is the only
265  // Display::Option supported at present. Clip window must be
266  // enabled as well as set, to operate.
267  // <group>
268  virtual void setClipWindow(int x1, int y1, int x2, int y2);
269  virtual bool enable(Display::Option option);
270  virtual bool disable(Display::Option option);
271  // </group>
272 
273 
274 
275  //# Informational Methods
276 
277 
278  // Return the width of the PixelCanvas in pixels
279  virtual casacore::uInt width() const {
280  return casacore::uInt(QWidget::width());
281  }
282 
283  // Return the height of the PixelCanvas in pixels
284  virtual casacore::uInt height() const {
285  return casacore::uInt(QWidget::height());
286  }
287 
288  // Return the depth of the PixelCanvas in bits
289  virtual casacore::uInt depth() const {
290  return itspcctbl->depth();
291  }
292 
293  // Return the pixel density (in dots per inch [dpi]) of the PixelCanvas
294  virtual void pixelDensity(float &xdpi, float &ydpi) const;
295 
296 
297  // Get color components in range 0 to 1 without actually
298  // allocating the color. This is needed to set up other
299  // devices, for example PgPlot.
300  virtual bool getColorComponents(const casacore::String &colorname,
301  float &r,
302  float &g, float &b);
303 
304  // return the PixelCanvasColorTable
305  virtual PixelCanvasColorTable * pcctbl() const {
306  return itspcctbl;
307  };
308 
309 
310 
311  // drawlist caching
312  //# (uses QPictures)
313 
314  // <group>
315  virtual bool supportsLists();
316  virtual casacore::uInt newList();
317  virtual void endList();
318  virtual void drawList(casacore::uInt list);
319  virtual void deleteList(casacore::uInt list);
320  virtual void deleteLists();
321  virtual bool validList(casacore::uInt list);
322  // </group>
323 
324 
325 
326 
327 
328  //# METHODS OF QTPIXELCANVAS AND DERIVATIONS ONLY -- NOT GENERIC PIXELCANVAS
329 
330  // Return a QPixmap* with a copy of current widget contents.
331  // Caller is responsible for deleting.
332  virtual QPixmap* contents() {
333  return new QPixmap(*frontBuffer_);
334  }
335  virtual QPixmap* getBackBuffer() {
336  return backBuffer_;
337  }
338 
339 
340  /*//#dk
341  //# Hold and release of refresh. Counted; releaseAll() to release them all.
342  //# Note: NOT REALLY IMPLEMENTED yet (holdcount_ test disabled) -- check
343  //# interaction with (new) allowBackToFront_ first.
344  // <group>
345  virtual void hold() { holdcount_++; }
346 
347  virtual void release() {
348  holdcount_ = (holdcount_>0)? holdcount_-1 : 0;
349  if(holdcount_==0 && needsRefresh_) {
350  refresh();
351  needsRefresh_ = false; }
352 
353  virtual void releaseAll() { holdcount_=0; release(); }
354  // </group>
355  //*/
356 
357 
358 
359  // Hold / release of display widget/pixmap painting (used during
360  // printing and graphics file saving.) Be sure to return to unblocked
361  // state when done.
362  // <group>
363  virtual void setAllowBackToFront(bool allowed=true) {
364  allowBackToFront_ = allowed;
365  }
366 
367  virtual void setUpdateAllowed(bool allowed=true) {
368  if(allowed) {
369  if(saveBuf_!=0) {
370  delete saveBuf_;
371  saveBuf_ = 0;
372  }
373  } else if(saveBuf_==0) saveBuf_ = contents();
374  }
375  // </group>
376 
377 
378 
379  signals:
380 
381  // Emitted in resizeEvent().
382  void resizing(QResizeEvent* ev);
383 
384 
385 
386  private:
390  void construct_( );
391 
392  // Versions of p_.begin(currentPaintDevice_()) and p_.end() ,that just
393  // put p_ in desired state, without complaining if it was already there.
394  // (In general, p_ will be active (on the current PaintDevice) between
395  // calls to QtPixelCanvas methods...).
396  // (A certain amount of painter 'state' ('graphics context') is
397  // also preserved over p_end_ -- p_begin_ -- still determining this).
398  // <group>
399  void p_end_();
400  void p_begin_();
401  // </group>
402 
403 
404  // PixelCanvas coordinate (0,0) is the bottom-left corner;
405  // in Qt it is the top-left. This translates the y coordinate.
406  // (converts either way).
407  int q_(int pY) {
408  return QWidget::height()-1 - pY;
409  }
410  float q_(float pY) {
411  return QWidget::height()-1 - pY;
412  }
413  double q_(double pY) {
414  return QWidget::height()-1 - pY;
415  }
416 
417  // Translates PC rectangle pixel coords x1,y1,x2,y2 to Qt coords qx,qy,qw,qh
418  void qFromPC_(int x1, int y1, int x2, int y2,
419  int& qx, int& qy, int& qw, int& qh) {
420  qw = abs(x2-x1)+1;
421  qh = abs(y2-y1)+1;
422  qx = casacore::min(x1,x2);
423  qy = q_(casacore::max(y1,y2));
424  }
425 
426  // returns QRect from PC rectangle (corner) pixel coordinates.
427  QRect qrect_(int x1, int y1, int x2, int y2) {
428  int qx,qy,qw,qh;
429  qFromPC_(x1,y1,x2,y2, qx,qy,qw,qh);
430  return QRect(qx,qy,qw,qh);
431  }
432 
433 
434  // translate color component in the range [0., 1.]
435  // to clrByte, with 0 <= clrByte < 256
436  int clrByte_(float f) {
437  return int(casacore::min( casacore::max(0.f,f)*256.f, 255.f ));
438  }
439 
440  bool inDrawMode_() {
441  return (drawMode()!=Display::Compile);
442  }
443 
444  QPixmap* currentBuffer_() {
445  return (drawBuffer() == Display::FrontBuffer)?
446  frontBuffer_ : backBuffer_;
447  }
448 
449  void clearBuffer_() {
450  p_.eraseRect(0,0, currentBuffer_()->width(),
451  currentBuffer_()->height());
452  }
453 
454  QPaintDevice* currentPaintDevice_() {
455  if(inDrawMode_()) return currentBuffer_();
456  else return drawList_;
457  }
458 
459 
460 
461  // Translate Qt KeyboardModifiers and MouseButtons to
462  // mask of Display Library KeyModifiers.
463  // <group>
464  casacore::uInt dlKeyMods_(Qt::KeyboardModifiers);
465  casacore::uInt dlKeyMods_(QMouseEvent* e);
466 // </group>
467 
468 
469 
470 
471  //# casacore::Data / State
472 
473 
474  QPixmap* frontBuffer_; // The actual buffers. (Qt4's elimination
475  QPixmap* backBuffer_; // of resize() requires these to replaced
476  // often on the heap...).
477 
478 
479  QPainter p_; // This Painter is used for the drawing commands, and
480  // paints either to the Buffer Pixmaps ('Draw' mode)
481  // or to a drawlist QPicture ('Compile' DrawMode).
482  // It will remain open (painting 'begun', active) on
483  // the currentPaintDevice_() between PC method calls.
484 
485  QPainter pw_; // This painter is used only to copy the front buffer
486  // to the widget during paintEvents.
487 
488 
489  QPicture* drawList_; // Will point to drawlist currently
490  // under construction, in Compile mode.
491  casacore::uInt drawListNo_; // Number of drawlist currently being compiled.
492 
493  std::map<casacore::uInt, void*> drawlists_;
494  // cache of all current draw lists.
495 
496 
497 
498  casacore::String itsDeviceForegroundColor, itsDeviceBackgroundColor;
499 
500  //# 'painter state' or 'graphics context'
501 
502  QPen itsPen;
503 
504  QFont itsFont;
505 
506  QRect clipRect_;
507  bool clipEnabled_;
508 
509  QtPCColorTable* itspcctbl;
510 
511 
512 
513  //# Hold/release of refresh. (Note: not yet used)
514  //<group>
515  int holdcount_;
516  bool needsRefresh_;
517  //</group>
518 
519 
520  // other hold / release of widget/pixmap painting (used during
521  // printing / graphics file saving.)
522  //<group>
523  bool allowBackToFront_;
524  QPixmap* saveBuf_;
525  //# If non-zero, saveBuf_ holds a 'frozen' state for painting the
526  //# PC's widget when the rendering on frontBuffer_ is being used
527  //# for another purpose (notably, when a .jpg, etc. of the PC is
528  //# being saved at a larger scale. (It isn't effective for smaller
529  //# scales; probably wasn't worth the effort, but it's there now....))
530  //<group>
531 
532 
533 
534 
535 //############################################################################
536 //############################################################################
537 //############################################################################
538 //############################################################################
539 //################ End of the Useful Stuff ###############################
540 //############################################################################
541 //############################################################################
542 //############################################################################
543 //############################################################################
544 
545 
546 
547 
548 
549 //# POSSIBLY USEFUL TO IMPLEMENT IN THE FUTURE
550 
551 
552  public:
553 
554 
555 
556 //# (for 3-channel drawing)
557 
558  // return the colorModel
559  Display::ColorModel colorModel() const {
560  return Display::Index;
561  }
562 
563  // (Cacheable) Draw a component of a multi-channel image, storing it
564  // in buffers until flushComponentImages() is called.
565  virtual void drawImage(const casacore::Matrix<casacore::uInt> &/*data*/, const int &/*x*/, const int &/*y*/,
566  const Display::ColorComponent &/*colorcomponent*/) { }
567 
568 
569 
570 
571  // Set the input color model for multichannel color
572  void setColorModel(Display::ColorModel colorModel);
573 
574  // Fill one of the channel buffers.
575  virtual void bufferComponent(const casacore::Matrix<casacore::uInt> &/*data*/,
576  const int &/*x*/,
577  const int &/*y*/,
578  const Display::ColorComponent &/*colorcomponent*/)
579  { }
580 
581  // (NOT CACHEABLE!) Flush the component buffers.
582  virtual void flushComponentBuffers() { }
583 
584 
585 
586 
587 
588 
589 //# RELEVANCE TO BE DETERMINED
590 
591 
592 
593  // return true if the refresh is active.
594  //#dk PC probably can't determine this usefully, since individual
595  //# WCs may initiate their own refresh/drawing cycles....
596  bool refreshActive() const;
597 
598  // return true if refresh is allowed right now...
599  virtual bool refreshAllowed() const;
600 
601  // Draw a set of points, specifying a color per point to
602  // be drawn.
603  // <group>
604  virtual void drawColoredPoints(const casacore::Vector<int> &/*x1*/, const casacore::Vector<int> &/*y1*/,
605  const casacore::Vector<casacore::uInt> &/*colors*/) {
606  // cout << "WYSISWYN " << __FILE__ << " " << __LINE__ << endl;
607  }
608  virtual void drawColoredPoints(const casacore::Matrix<int> &xy,
609  const casacore::Vector<casacore::uInt> &colors) {
610  drawColoredPoints(xy.column(0), xy.column(1), colors);
611  }
612  // </group>
613 
614  // Cause display to flush any graphics commands not yet drawn
615  virtual void flush();
616 
617  static void drawText(QPainter& painter, const QPoint& p, const QFont& font,
618  const QPen& pen, const casacore::String& text, double angle,
619  Display::TextAlign alignment);
620  virtual void drawText(int x, int y, const casacore::String &text, const float& angle,
622  virtual void drawText(int x, int y, const casacore::String &text,
624 
625  virtual int textWidth(const casacore::String& text);
626 
627  virtual int textHeight(const casacore::String& text);
628 
629  virtual void setHSVColor(float /*h*/, float /*s*/, float /*v*/) { }
630 
631 
632  // (Cacheable) Draw a single point using current color
633  // <group>
634  virtual void drawPoint(int x1, int y1);
635  virtual void drawPoint(float x1, float y1);
636  virtual void drawPoint(double x1, double y1);
637  // </group>
638 
639  // (Cacheable) Draw N points specified as a Nx2 matrix
640  // <group>
641  virtual void drawPoints(const casacore::Matrix<int> &verts);
642  virtual void drawPoints(const casacore::Matrix<float> &verts);
643  virtual void drawPoints(const casacore::Matrix<double> &verts);
644  // </group>
645 
646  // (Cacheable) Draw a bunch of points using current color
647  // <group>
648  virtual void drawPoints(const casacore::Vector<int> &x1,
649  const casacore::Vector<int> &y1);
650  virtual void drawPoints(const casacore::Vector<float> &x1,
651  const casacore::Vector<float> &y1);
652  virtual void drawPoints(const casacore::Vector<double> &x1,
653  const casacore::Vector<double> &y1);
654  // </group>
655 
656  // (Cacheable) Draw a single line using current color
657  // <group>
658  virtual void drawLine(int x1, int y1,
659  int x2, int y2);
660  virtual void drawLine(float x1, float y1,
661  float x2, float y2);
662  virtual void drawLine(double x1, double y1,
663  double x2, double y2);
664  // </group>
665 
666  // (Cacheable) Draw N/2 lines from an Nx2 matrix
667  // <group>
668  virtual void drawLines(const casacore::Matrix<int> &verts);
669  virtual void drawLines(const casacore::Matrix<double> &verts);
670  // </group>
671 
672  // (Cacheable) Draw a bunch of unrelated lines using current color
673  // <group>
674  virtual void drawLines(const casacore::Vector<int> &x1,
675  const casacore::Vector<int> &y1,
676  const casacore::Vector<int> &x2,
677  const casacore::Vector<int> &y2);
678  virtual void drawLines(const casacore::Vector<float> &x1,
679  const casacore::Vector<float> &y1,
680  const casacore::Vector<float> &x2,
681  const casacore::Vector<float> &y2);
682  virtual void drawLines(const casacore::Vector<double> &x1,
683  const casacore::Vector<double> &y1,
684  const casacore::Vector<double> &x2,
685  const casacore::Vector<double> &y2);
686  // </group>
687 
688  // (Cacheable) Draw a single connected line between the points given
689  // <group>
690  virtual void drawPolyline(const casacore::Vector<int> &x1,
691  const casacore::Vector<int> &y1);
692  virtual void drawPolyline(const casacore::Vector<float> &x1,
693  const casacore::Vector<float> &y1);
694  virtual void drawPolyline(const casacore::Vector<double> &x1,
695  const casacore::Vector<double> &y1);
696  // </group>
697 
698  // (Cacheable) Draw N-1 connected lines from Nx2 matrix of vertices
699  // <group>
700  virtual void drawPolyline(const casacore::Matrix<int> &verts);
701  virtual void drawPolyline(const casacore::Matrix<float> &verts);
702  virtual void drawPolyline(const casacore::Matrix<double> &verts);
703  // </group>
704 
705  // Let PixelCanvas::drawMarker take care of this.
706  /*
707  // Draw a "marker". See <linkto class="Display">Display</linkto>
708  // for a list of available markers.
709  // <group>
710 
711  virtual void drawMarker(const int& x1, const int& y1,
712  const Display::Marker& marker,
713  const int& pixelHeight);
714  virtual void drawMarker(const float& x1, const float& y1,
715  const Display::Marker& marker,
716  const int& pixelHeight);
717  virtual void drawMarker(const double& x1, const double& y1,
718  const Display::Marker& marker,
719  const int& pixelHeight);
720 
721  // </group>
722  */
723 
724  // (Cacheable) Draw a closed polygon
725  // <group>
726  virtual void drawPolygon(const casacore::Vector<int> &x1,
727  const casacore::Vector<int> &y1);
728  virtual void drawPolygon(const casacore::Vector<double> &x1,
729  const casacore::Vector<double> &y1);
730  // </group>
731 
732  // (Cacheable) Draw a closed N-sided polygon from Nx2 matrix of vertices
733  // <group>
734  virtual void drawPolygon(const casacore::Matrix<int> &verts);
735  virtual void drawPolygon(const casacore::Matrix<float> &verts);
736  virtual void drawPolygon(const casacore::Matrix<double> &verts);
737  // </group>
738 
739  // (Cacheable) Draw and fill a closed polygon
740  // <group>
741  virtual void drawFilledPolygon(const casacore::Vector<int> &x1,
742  const casacore::Vector<int> &y1);
743  virtual void drawFilledPolygon(const casacore::Vector<double> &x1,
744  const casacore::Vector<double> &y1);
745  // </group>
746 
747  // (Cacheable) Draw a rectangle
748  // <group>
749  virtual void drawRectangle(float x1, float y1,
750  float x2, float y2);
751  virtual void drawRectangle(double x1, double y1,
752  double x2, double y2);
753  // </group>
754 
755  // (Cacheable) Draw a filled rectangle
756  // <group>
757  virtual void drawFilledRectangle(float x1, float y1,
758  float x2, float y2);
759  virtual void drawFilledRectangle(double x1, double y1,
760  double x2, double y2);
761  // </group>
762 
763 
764  // (Cacheable) Draw a set of lines, specifying a color per line to be drawn.
765  // <group>
766  virtual void drawColoredLines(const casacore::Vector<int> &x1,
767  const casacore::Vector<int> &y1,
768  const casacore::Vector<int> &x2,
769  const casacore::Vector<int> &y2,
770  const casacore::Vector<casacore::uInt> &colors);
771  virtual void drawColoredLines(const casacore::Vector<float> &x1,
772  const casacore::Vector<float> &y1,
773  const casacore::Vector<float> &x2,
774  const casacore::Vector<float> &y2,
775  const casacore::Vector<casacore::uInt> &colors);
776  virtual void drawColoredLines(const casacore::Vector<double> &x1,
777  const casacore::Vector<double> &y1,
778  const casacore::Vector<double> &x2,
779  const casacore::Vector<double> &y2,
780  const casacore::Vector<casacore::uInt> &colors);
781  // </group>
782 
783  // vector primitive buffering
784 
785  // Set Graphics Attributes
786  // Options for functions with enum argument
787  // listed in <linkto class=Display>DisplayEnums</linkto>
788  // <group>
789  virtual void setDrawFunction(Display::DrawFunction function);
790  virtual void setForeground(casacore::uLong color);
791  virtual void setBackground(casacore::uLong color);
792  virtual void setLineWidth(float width);
793  virtual void setLineStyle(Display::LineStyle style);
794  virtual void setCapStyle(Display::CapStyle style);
795  virtual void setJoinStyle(Display::JoinStyle style);
796  virtual void setFillStyle(Display::FillStyle style);
797  virtual void setFillRule(Display::FillRule rule);
798  virtual void setArcMode(Display::ArcMode mode);
799  // </group>
800 
801  // These method is NOT in PixelCanvas.
802  virtual void setQtLineStyle(Qt::PenStyle style);
803  virtual void setQtPenColor( QColor c ) {
804  itsPen.setColor(c);
805  }
806  virtual QColor getQtPenColor( ) const {
807  return itsPen.color( );
808  }
809 
810  // Get Graphics Attributes
811  // <group>
812  virtual Display::DrawFunction getDrawFunction() const;
813  virtual casacore::uLong getForeground() const;
814  virtual casacore::uLong getBackground() const;
815  virtual float getLineWidth() const;
816  virtual Display::LineStyle getLineStyle() const;
817  virtual Display::CapStyle getCapStyle() const;
818  virtual Display::JoinStyle getJoinStyle() const;
819  virtual Display::FillStyle getFillStyle() const;
820  virtual Display::FillRule getFillRule() const;
821  virtual Display::ArcMode getArcMode() const;
822  // </group>
823 
824 
825  // Control the image-caching strategy
826  virtual void setImageCacheStrategy(Display::ImageCacheStrategy strategy);
827  virtual Display::ImageCacheStrategy imageCacheStrategy() const;
828 
829  // (Cacheable) Set the color to use for clearing the display
830  // <group>
831 
832  //#dk probably unneeded -- can clear using deviceBkgd(?)
833  //# (what _else_ is deviceBkgd for?...)
834  virtual void setClearColor(casacore::uInt colorIndex);
835  virtual void setClearColor(const casacore::String &colorname);
836  virtual void setClearColor(float r, float g, float b);
837  // </group>
838 
839  // (Not Cacheable) Get the current color to use for clearing the display.
840  virtual casacore::uInt clearColor() const;
841  virtual void getClearColor(float &r, float &g, float &b) const;
842 
843  virtual void enableMotionEvents() { }
844  virtual void disableMotionEvents() { }
845  virtual void enablePositionEvents() { }
846  virtual void disablePositionEvents() { }
847 
848  virtual void translateAllLists(int /*xt*/, int /*yt*/) { }
849  virtual void translateList(casacore::uInt /*list*/, int /*xt*/, int /*yt*/) { }
850 
851  virtual bool setFont(const casacore::String &fontName);
852  virtual bool setFont(DLFont* /*font*/) {
853  return false;
854  }
855  virtual bool setFont(const casacore::String& fontName, const int fontSize);
856 
857  // These setFont methods are NOT in PixelCanvas.
858  // <group>
859  virtual bool setFont(const casacore::String& fontName, bool bold, bool italic);
860  virtual bool setFont(const casacore::String& fontName, const int fontSize, bool bold,
861  bool italic);
862  // </group>
863 
864  virtual void drawImage(const casacore::Matrix<int> &/*data*/, int /*x*/, int /*y*/) { }
865  virtual void drawImage(const casacore::Matrix<casacore::uLong> &/*data*/, int /*x*/, int /*y*/) { }
866  virtual void drawImage(const casacore::Matrix<float> &data, int x, int y);
867  virtual void drawImage(const casacore::Matrix<double> &/*data*/, int /*x*/, int /*y*/) { }
868 
869  virtual void drawImage(const casacore::Matrix<casacore::uInt> &/*data*/, int /*x*/, int /*y*/,
870  casacore::uInt /*xzoom*/, casacore::uInt /*yzoom*/) { }
871  virtual void drawImage(const casacore::Matrix<int> &/*data*/, int /*x*/, int /*y*/,
872  casacore::uInt /*xzoom*/, casacore::uInt /*yzoom*/) { }
873  virtual void drawImage(const casacore::Matrix<casacore::uLong> &/*data*/, int /*x*/, int /*y*/,
874  casacore::uInt /*xzoom*/, casacore::uInt /*yzoom*/) { }
875  virtual void drawImage(const casacore::Matrix<float> &/*data*/, int /*x*/, int /*y*/,
876  casacore::uInt /*xzoom*/, casacore::uInt /*yzoom*/) { }
877  virtual void drawImage(const casacore::Matrix<double> &/*data*/, int /*x*/, int /*y*/,
878  casacore::uInt /*xzoom*/, casacore::uInt /*yzoom*/) { }
879 
880 
881  // (Cacheable) Set current color (works in RGB or colormap mode)
882  // <group>
883  virtual void setColor(casacore::uInt colorIndex);
884  // </group>
885 
886  // (Not Cacheable) Returns the current color as a color index
887  virtual casacore::uInt color() const;
888 
889  // (Not Cacheable) Retuns the current color as an RGB triple
890  virtual void getColor(float &r, float &g, float &b) const;
891 
892  // (Not Cacheable) Get color index value (works in RGB or colormap mode)
893  // <group>
894  virtual bool getColor(int x, int y, casacore::uInt &color);
895  virtual bool getRGBColor(int x, int y,
896  float &r, float &g, float &b);
897  virtual bool getHSVColor(int x, int y,
898  float &h, float &s, float &v);
899  // </group>
900 
901  // (Not Cacheable) resize request. returns true if window was resized.
902  // Will refresh if doCallbacks is true.
903  //virtual bool resize(casacore::uInt reqXSize, casacore::uInt reqYSize,
904  //bool doCallbacks = true);
905 
906  // (Not Cacheable) resize the colortable by requesting a new number of cells
907  virtual bool resizeColorTable(casacore::uInt newSize);
908 
909  // (Not Cacheable) resize the colortable by requesting a new RGB/HSV cube
910  virtual bool resizeColorTable(casacore::uInt nReds,
911  casacore::uInt nGreens, casacore::uInt nBlues);
912 
913  // save/restore the current translation. This is called pushMatrix because
914  // eventually we may want scaling or rotation to play a modest
915  // role here.
916  // <group>
917  virtual void pushMatrix() { }
918  virtual void popMatrix() { }
919  // </group>
920  // zero the current translation
921  virtual void loadIdentity() { }
922 
923  // translation functions
924  // translate applies a relative translation to the current matrix and
925  // can be used to position graphics. Together with pushMatrix and
926  // popMatrix it can be used to build heirarchical scenes.
927  // <group>
928  virtual void translate(int /*xt*/, int /*yt*/) { }
929  virtual void getTranslation(int &/*xt*/, int &/*yt*/) const { }
930  virtual int xTranslation() const {
931  return 0;
932  }
933  virtual int yTranslation() const {
934  return 0;
935  }
936  // </group>
937 
938 
939 
940 
941 //# CONFIRMED IRRELEVANT / UNUSED
942 
943 
944 
945  virtual void drawColoredEllipses(const casacore::Matrix<float> &/*centres*/,
946  const casacore::Vector<float> &/*smajor*/, const casacore::Vector<float> &/*sminor*/,
947  const casacore::Vector<float> &/*pangle*/, const casacore::Vector<casacore::uInt> &/*colors*/,
948  const float &/*scale*/ = 1.0, const bool &/*outline*/ = true) { }
949 
950  virtual void drawColoredPoints(const casacore::Vector<float> &/*x1*/,
951  const casacore::Vector<float> &/*y1*/, const casacore::Vector<casacore::uInt> &/*colors*/) { }
952  virtual void drawColoredPoints(const casacore::Vector<double> &/*x1*/,
953  const casacore::Vector<double> &/*y1*/, const casacore::Vector<casacore::uInt> &/*colors*/) { }
954  virtual void drawColoredPoints(const casacore::Matrix<float> &xy,
955  const casacore::Vector<casacore::uInt> &colors) {
956  drawColoredPoints(xy.column(0), xy.column(1), colors);
957  }
958  virtual void drawColoredPoints(const casacore::Matrix<double> &xy,
959  const casacore::Vector<casacore::uInt> &colors) {
960  drawColoredPoints(xy.column(0), xy.column(1), colors);
961  }
962 
963 
964  virtual void getClipWindow(int &/*x1*/, int &/*y1*/, int &/*x2*/, int &/*y2*/) { }
965 
966  virtual void setPcctbl(PixelCanvasColorTable * /*pcctbl*/) { }
967 
968  }; // class QtPixelCanvas
969 
970 } // namespace casa
971 
972 #endif
Vector< T > column(size_t j)
Returns a reference to the j&#39;th column.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
TextAlign
Text Alignment.
Definition: DisplayEnums.h:181
Option
PixelCanvas Options.
Definition: DisplayEnums.h:290
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
DrawBuffer
PixelCanvas target drawing destination.
Definition: DisplayEnums.h:211
FillRule
Fill Rule Xlib programming guide, pg.132.
Definition: DisplayEnums.h:165
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
CapStyle
Controls the appearance of thick lines near their endpoints.
Definition: DisplayEnums.h:130
reference point aligned to center of text
Definition: DisplayEnums.h:183
ColorComponent
Color components.
Definition: DisplayEnums.h:84
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
Draw only to front buffer.
Definition: DisplayEnums.h:217
Build display list mode.
Definition: DisplayEnums.h:207
Draw only to back buffer.
Definition: DisplayEnums.h:219
unsigned long uLong
Definition: aipstype.h:53
FillStyle
Controls fill style.
Definition: DisplayEnums.h:152
RefreshReason
Callback reasons for PCRefreshEvent and WCRefreshEvent.
Definition: DisplayEnums.h:267
const Double e
e and functions thereof:
const Double c
Fundamental physical constants (SI units):
ArcMode
Arc Mode.
Definition: DisplayEnums.h:173
String: the storage and methods of handling collections of characters.
Definition: String.h:223
ColorIndex mode.
Definition: DisplayEnums.h:76
ImageCacheStrategy
How to cache images when displaying them on client-server graphics systems.
Definition: DisplayEnums.h:297
DrawFunction
PixelCanvas Drawing Logical Functions.
Definition: DisplayEnums.h:227
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
JoinStyle
Controls the appearance of two joined lines.
Definition: DisplayEnums.h:142
ColorModel
Different ways of handling color on the display.
Definition: DisplayEnums.h:74
unsigned int uInt
Definition: aipstype.h:51
User told PixelCanvas to refresh via PixelCanvas refresh()
Definition: DisplayEnums.h:269
LineStyle
Style of line to use.
Definition: DisplayEnums.h:119