casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtPixelCanvas.qo.h
Go to the documentation of this file.
00001 //# QtPixelCanvas.qo.h: (barebones) Qt implementation of PixelCanvas
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 #ifndef QTPIXELCANVAS_H
00028 #define QTPIXELCANVAS_H
00029 
00030 #include <casa/aips.h>
00031 #include <casa/Arrays/Matrix.h>
00032 #include <display/Display/DisplayEnums.h>
00033 #include <display/Display/PixelCanvas.h>
00034 //#include <display/DisplayEvents/PCMotionEH.h>
00035 #include <casa/BasicMath/Math.h>
00036 #include <display/QtViewer/QtPCColorTable.h>
00037 //#include "PCEventDispatcher.h"
00038 #include <list>
00039 
00040 #include <graphics/X11/X_enter.h>
00041 #  include <QWidget>
00042 #  include <QPainter>
00043 #  include <QPixmap>
00044 #  include <QPicture>
00045 #  include <QImage>
00046 #  include <QPen>
00047 #include <graphics/X11/X_exit.h>
00048 
00049 
00050 namespace casa {
00051 
00052 class q_draw;
00053 
00054 class QtPixelCanvas : public QWidget, public PixelCanvas {
00055 
00056  //# (Note: derivation from QWidget must be first above, for Qt's
00057  //# 'meta-object compiler' to correctly process the following macro).
00058 
00059   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00060                 //# implement/.../*.h files; also, makefile must include
00061                 //# name of this file in 'mocs' section.
00062 
00063  public:
00064 
00065 //# RELEVANT (OR ALREADY-IMPLEMENTED) METHODS
00066   
00067   
00068   QtPixelCanvas(QWidget *parent=0);
00069   ~QtPixelCanvas();
00070 
00071   void beginLabelAndAxisCaching( ) { cache_label_and_axis = True; }
00072   void endLabelAndAxisCaching( QPainter &qp );
00073  
00074  protected:
00075 
00076   std::list<q_draw*> label_and_axis_cache;
00077 
00078   // QT EVENT HANDLERS -- these create PixelCanvas events.
00079   // <group>
00080   void paintEvent(QPaintEvent* e);
00081   void resizeEvent(QResizeEvent* e);
00082   void mouseMoveEvent(QMouseEvent* e);
00083   void mousePressEvent(QMouseEvent* e);
00084   void mouseReleaseEvent(QMouseEvent* e);
00085   void keyPressEvent(QKeyEvent* e ); 
00086   void enterEvent( QEvent* e );
00087   // </group>
00088   
00089   Bool cache_label_and_axis;
00090   
00091  public:
00092 
00093   //# OTHER QWIDGET DERIVED METHODS.
00094   
00095   // Returns a reasonable suggestion for canvas size; it will
00096   // be used initially unless overridden by a resize/setGeometry
00097   // call, on this widget or a parent.
00098   virtual QSize sizeHint() const { return QSize(400, 300);  }
00099 
00100   
00101   
00102   
00103   //#     PIXELCANVAS METHODS 
00104    
00105  
00106   //#     Refresh Cycle Methods -- not to be called by
00107   //#     refresh / drawing handlers (rather the reverse).
00108   //#     Not cacheable.
00109     
00110   
00111   virtual void refresh(const Display::RefreshReason &reason = 
00112                        Display::UserCommand,
00113                        const Bool &explicitrequest = True);
00114 
00115   static void colorTableResizeCB(PixelCanvasColorTable *, uInt,
00116                           QtPixelCanvas * qtpc,
00117                           Display::RefreshReason reason);
00118 
00119   
00120   // set the draw buffer
00121   // Only 'FrontBuffer' and 'BackBuffer' are supported; This value
00122   // will be 'Display::BackBuffer', unless explicitly set to 
00123   // 'Display::FrontBuffer'.
00124   virtual void setDrawBuffer(Display::DrawBuffer buf) {
00125     if(buf==Display::FrontBuffer) setDrawBuffer_(buf);
00126     else setDrawBuffer_(Display::BackBuffer);
00127     p_begin_();  }      // Refocus painter on new buffer if necessary.
00128   
00129 
00130  // buffer memory exchanges
00131   // <group>
00132   virtual void copyBackBufferToFrontBuffer();
00133   virtual void copyFrontBufferToBackBuffer();
00134   virtual void swapBuffers();
00135   // </group>
00136 
00137   // partial buffer memory exchanges.  (x1,y1 are blc, x2,y2 are trc)
00138   // <group>
00139   virtual void copyBackBufferToFrontBuffer(Int x1, Int y1, Int x2, Int y2);
00140   virtual void copyFrontBufferToBackBuffer(Int x1, Int y1, Int x2, Int y2);
00141   virtual void swapBuffers(Int x1, Int y1, Int x2, Int y2);
00142   // </group>
00143   
00144   
00145 
00146     
00147   //#    Drawing Methods.  (Buffer and draw mode should already be set.
00148   //#    QPainter p_ should (and will) be open on current paint device).
00149   //#    cacheable.
00150 
00151     
00152   // Clear the window using the background color
00153   // <group>
00154   virtual void clear();
00155   virtual void clear(Int x1, Int y1, Int x2, Int y2);
00156   // </group>
00157 
00158   // Draw an array of 2D color data as a raster image
00159   //#dk note:   Color data Arrays passed to draw*()
00160   //#           are produced by maptoColor[3] (see below).
00161   virtual void drawImage(const Matrix<uInt> &data, Int x, Int y);
00162   
00163   // The version used with masks.
00164   //# (the one with the gratuitously transposed arguments...)
00165   // Set opaqueMask to True to draw masked pixels in the background color;
00166   // otherwise they will be transparent, letting whatever was drawn
00167   // previously at that point show through.
00168   virtual void drawImage(const Int &x, const Int &y, 
00169                          const Matrix<uInt> &data,
00170                          const Matrix<Bool> &mask,
00171                          Bool opaqueMask=False) ;
00172 
00173 
00174   virtual void drawLines(const Matrix<Float> &verts);
00175   
00176   virtual void drawRectangle(Int x1, Int y1,  Int x2, Int y2);
00177   
00178   virtual void drawFilledRectangle(Int x1, Int y1,  Int x2, Int y2);
00179   
00180   virtual void drawPolygon(const Vector<Float> &x, 
00181                            const Vector<Float> &y);
00182   
00183   virtual void drawFilledPolygon(const Vector<Float> &x, 
00184                                  const Vector<Float> &y);
00185 
00186   
00187 //# (This routine was cut in favor of the PixelCanvas one, mainly
00188 //# because Qt's method of implementing stretch (transformation QMatrix)
00189 //# affects drawing line widths as well, which is not what was wanted
00190 //# in the case of beam ellipses.  dk  6/07).
00191 //#
00192 //#   // Draw a single ellipse using the current pen (ie. color,
00193 //#   // thickness, style).  The x and y location must be given, along
00194 //#   // with the semi-major and -minor axis lengths, and the position
00195 //#   // angle measured in degrees positive from the x axis in a
00196 //#   // counter-clockwise direction. If outline is False, the
00197 //#   // ellipse is solid filled, else it is just outlined.
00198 //#   // xstretch, ystretch should be left defaulted to 1 in most cases; 
00199 //#   // see usage example in WorldCanvas::drawBeamEllipse(), where they are
00200 //#   // used to stretch a beam ellipse when the display is also linearly
00201 //#   // stretched away from the aspect ratio natural to the sky projection.
00202 //#   // They multiply the relative x and y screen coordinates of ellipse
00203 //#   // points, _before_ they are added to cx and cy.  xstretch, ystretch
00204 //#   // can be negative (though smajor, sminor normally would not be).
00205 //#   virtual void drawEllipse(const Float &cx, const Float &cy,
00206 //#                        const Float &smajor, const Float &sminor,
00207 //#                        const Float &pangle, Bool outline = True,
00208 //#                        Float xstretch = 1.0, Float ystretch = 1.0);
00209 
00210 
00211   
00212   
00213 
00214   
00215   //# (...That's it?... all that's really used??   (!!))
00216 
00217     
00218   //#dk Note: mapToColor[3] are implemented in the base class; they just
00219   //#   pass the chore to [Qt]PCCT.  The ones actually used are:
00220   //#
00221   //#  virtual void mapToColor(const Colormap * map, 
00222   //#                     Array<uInt> & outArray, 
00223   //#                     const Array<uInt> & inArray, 
00224   //#                     Bool rangeCheck = True) const;
00225   //#
00226   //#  
00227   //#   [and, when/if non-Index (3-channel)  ColorModels
00228   //#   are implemented for QtPixelCanvas]:
00229   //#  
00230   //#  virtual void mapToColor3(Array<uLong> & out,
00231   //#                      const Array<uInt> & chan1in,
00232   //#                      const Array<uInt> & chan2in,
00233   //#                      const Array<uInt> & chan3in) {  }
00234   //#
00235   //#   The color data output matrix is passed to drawImage, above
00236 
00237 
00238   
00239   
00240   
00241     
00242   //#    Graphics Context Methods
00243    
00244    
00245   // Get/set the current foreground/background colors.  These colors
00246   // should be used when the special Strings "foreground" and "background"
00247   // are given for a color.
00248   // <group>
00249   virtual void setDeviceForegroundColor(const String colorname);
00250   virtual String deviceForegroundColor() const;
00251   virtual void setDeviceBackgroundColor(const String colorname);
00252   virtual String deviceBackgroundColor() const;
00253   // </group>
00254 
00255   virtual void setColor(const String &colorname);
00256   virtual void setRGBColor(float r, float g, float b);
00257 
00258   // Set/enable/disable clip window.  'ClipWindow' is the only
00259   // Display::Option supported at present.  Clip window must be
00260   // enabled as well as set, to operate.
00261   // <group>
00262   virtual void setClipWindow(Int x1, Int y1, Int x2, Int y2);
00263   virtual Bool enable(Display::Option option);
00264   virtual Bool disable(Display::Option option);
00265   // </group>
00266 
00267   
00268     
00269   //#    Informational Methods
00270   
00271   
00272   // Return the width of the PixelCanvas in pixels
00273   virtual uInt width() const{ return uInt(QWidget::width());  }
00274   
00275   // Return the height of the PixelCanvas in pixels
00276   virtual uInt height() const { return uInt(QWidget::height());  }
00277   
00278   // Return the depth of the PixelCanvas in bits
00279   virtual uInt depth() const { return itspcctbl->depth();  }
00280   
00281   // Return the pixel density (in dots per inch [dpi]) of the PixelCanvas
00282   virtual void pixelDensity(Float &xdpi, Float &ydpi) const;
00283 
00284   
00285   // Get color components in range 0 to 1 without actually 
00286   // allocating the color.  This is needed to set up other
00287   // devices, for example PgPlot.
00288   virtual Bool getColorComponents(const String &colorname, 
00289                                         Float &r,
00290                                         Float &g, Float &b);
00291 
00292   // return the PixelCanvasColorTable
00293   virtual PixelCanvasColorTable * pcctbl() const {
00294     return itspcctbl;  };
00295 
00296   
00297   
00298   // drawlist caching
00299   //# (uses QPictures)
00300   
00301   // <group>
00302   virtual Bool supportsLists();
00303   virtual uInt newList();
00304   virtual void endList();
00305   virtual void drawList(uInt list);
00306   virtual void deleteList(uInt list);
00307   virtual void deleteLists();
00308   virtual Bool validList(uInt list);
00309   // </group>
00310 
00311 
00312   
00313 
00314 
00315   //# METHODS OF QTPIXELCANVAS AND DERIVATIONS ONLY -- NOT GENERIC PIXELCANVAS
00316   
00317   // Return a QPixmap* with a copy of current widget contents.
00318   // Caller is responsible for deleting.
00319   virtual QPixmap* contents() { return new QPixmap(*frontBuffer_);  }
00320   virtual QPixmap* getBackBuffer() {return backBuffer_;  }
00321 
00322   
00323   /*//#dk 
00324   //# Hold and release of refresh.  Counted; releaseAll() to release them all.
00325   //# Note: NOT REALLY IMPLEMENTED yet (holdcount_ test disabled) -- check
00326   //# interaction with (new) allowBackToFront_ first.
00327   // <group>
00328   virtual void hold() { holdcount_++;  }
00329   
00330   virtual void release() { 
00331     holdcount_ = (holdcount_>0)? holdcount_-1 : 0;
00332     if(holdcount_==0 && needsRefresh_) {
00333       refresh();
00334       needsRefresh_ = False;  }
00335       
00336   virtual void releaseAll() { holdcount_=0; release();  }
00337   // </group>
00338   //*/
00339  
00340   
00341   
00342   // Hold / release of display widget/pixmap painting (used during
00343   // printing and graphics file saving.)  Be sure to return to unblocked
00344   // state when done.
00345   // <group>
00346   virtual void setAllowBackToFront(Bool allowed=True) {
00347     allowBackToFront_ = allowed;  }
00348 
00349   virtual void setUpdateAllowed(Bool allowed=True) {
00350     if(allowed) {
00351       if(saveBuf_!=0) { delete saveBuf_; saveBuf_ = 0;  }  }
00352     else if(saveBuf_==0) saveBuf_ = contents();  }
00353   // </group>
00354 
00355 
00356 
00357  signals: 
00358   
00359   // Emitted in resizeEvent().
00360   void resizing(QResizeEvent* ev);
00361      
00362  
00363  
00364  private:
00365    
00366   // Versions of p_.begin(currentPaintDevice_()) and p_.end() ,that just
00367   // put p_ in desired state, without complaining if it was already there.
00368   // (In general, p_ will be active (on the current PaintDevice) between
00369   // calls to QtPixelCanvas methods...).
00370   // (A certain amount of painter 'state' ('graphics context') is
00371   // also preserved over p_end_ -- p_begin_ -- still determining this).
00372   // <group>
00373   void p_end_();
00374   void p_begin_();
00375   // </group>
00376 
00377   
00378   // PixelCanvas coordinate (0,0) is the bottom-left corner;
00379   // in Qt it is the top-left.  This translates the y coordinate.
00380   // (converts either way).
00381   Int    q_(Int pY)    { return QWidget::height()-1 - pY;  }
00382   Float  q_(Float pY)  { return QWidget::height()-1 - pY;  }
00383   Double q_(Double pY) { return QWidget::height()-1 - pY;  }
00384 
00385   // Translates PC rectangle pixel coords x1,y1,x2,y2 to Qt coords qx,qy,qw,qh
00386   void qFromPC_(Int  x1, Int  y1,   Int x2,  Int y2,
00387                 Int& qx, Int& qy,   Int& qw, Int& qh) {
00388     qw = abs(x2-x1)+1;  qh = abs(y2-y1)+1;
00389     qx = min(x1,x2);    qy = q_(max(y1,y2));  }
00390   
00391   // returns QRect from PC rectangle (corner) pixel coordinates.
00392   QRect qrect_(Int x1, Int y1, Int x2, Int y2) {
00393     Int qx,qy,qw,qh;
00394     qFromPC_(x1,y1,x2,y2, qx,qy,qw,qh);
00395     return QRect(qx,qy,qw,qh);  }
00396 
00397       
00398   // translate color component in the range [0., 1.]
00399   // to clrByte, with 0 <= clrByte < 256
00400   Int clrByte_(Float f) { return Int(min( max(0.f,f)*256.f, 255.f ));  }
00401 
00402   Bool inDrawMode_() { return (drawMode()!=Display::Compile);  }
00403   
00404   QPixmap* currentBuffer_() {
00405     return (drawBuffer() == Display::FrontBuffer)?
00406                        frontBuffer_ : backBuffer_;  }
00407   
00408   void clearBuffer_() { p_.eraseRect(0,0, currentBuffer_()->width(),
00409                                           currentBuffer_()->height());  }
00410   
00411   QPaintDevice* currentPaintDevice_() {
00412     if(inDrawMode_()) return currentBuffer_();
00413     else              return drawList_;  }
00414     
00415   
00416   
00417   // Translate Qt KeyboardModifiers and MouseButtons to 
00418   // mask of Display Library KeyModifiers.
00419   // <group>
00420   uInt dlKeyMods_(Qt::KeyboardModifiers);
00421   uInt dlKeyMods_(QMouseEvent* e);
00422  // </group>
00423 
00424   
00425   
00426    
00427   //#     Data / State
00428 
00429     
00430   QPixmap* frontBuffer_;        // The actual buffers.  (Qt4's elimination
00431   QPixmap* backBuffer_;         // of resize() requires these to replaced
00432                                 // often on the heap...).
00433   
00434   
00435   QPainter p_;          // This Painter is used for the drawing commands, and
00436                         // paints either to the Buffer Pixmaps ('Draw' mode)
00437                         // or to a drawlist QPicture ('Compile' DrawMode).
00438                         // It will remain open (painting 'begun', active) on
00439                         // the currentPaintDevice_() between PC method calls.
00440   
00441   QPainter pw_;         // This painter is used only to copy the front buffer
00442                         // to the widget during paintEvents.
00443 
00444   
00445   QPicture* drawList_;          // Will point to drawlist currently
00446                                 // under construction, in Compile mode.
00447   uInt drawListNo_;             // Number of drawlist currently being compiled.
00448  
00449   SimpleOrderedMap<uInt, void*> drawlists_;
00450                                 // cache of all current draw lists.  
00451   
00452   
00453   
00454   String itsDeviceForegroundColor, itsDeviceBackgroundColor;
00455   
00456   //# 'painter state' or 'graphics context'
00457   
00458   QPen itsPen;
00459   
00460   QFont itsFont;
00461   
00462   QRect clipRect_;
00463   Bool clipEnabled_;
00464   
00465   QtPCColorTable* itspcctbl;
00466   
00467   
00468   
00469   //# Hold/release of refresh.  (Note: not yet used)
00470   //<group>
00471   Int holdcount_;
00472   Bool needsRefresh_;
00473   //</group>
00474   
00475 
00476   // other hold / release of widget/pixmap painting (used during
00477   // printing / graphics file saving.)
00478   //<group>
00479   bool allowBackToFront_;
00480   QPixmap* saveBuf_;
00481         //# If non-zero, saveBuf_ holds a 'frozen' state for painting the
00482         //# PC's widget when the rendering on frontBuffer_ is being used
00483         //# for another purpose (notably, when a .jpg, etc. of the PC is
00484         //# being saved at a  larger scale.  (It isn't effective for smaller
00485         //# scales; probably wasn't worth the effort, but it's there now....))
00486   //<group>
00487   
00488   
00489   
00490  
00491 //############################################################################
00492 //############################################################################
00493 //############################################################################
00494 //############################################################################
00495 //################   End of the Useful Stuff   ###############################
00496 //############################################################################
00497 //############################################################################
00498 //############################################################################
00499 //############################################################################
00500 
00501 
00502 
00503 
00504 
00505 //#       POSSIBLY USEFUL TO IMPLEMENT IN THE FUTURE
00506    
00507  
00508  public:
00509   
00510   
00511   
00512 //# (for 3-channel drawing)
00513   
00514   // return the colorModel
00515   Display::ColorModel colorModel() const { return Display::Index;  }
00516 
00517   // (Cacheable) Draw a component of a multi-channel image, storing it
00518   // in buffers until flushComponentImages() is called.
00519   virtual void drawImage(const Matrix<uInt> &/*data*/, const Int &/*x*/, const Int &/*y*/,
00520                          const Display::ColorComponent &/*colorcomponent*/) {  }
00521 
00522 
00523   
00524   
00525   // Set the input color model for multichannel color
00526   void setColorModel(Display::ColorModel colorModel);
00527 
00528   // Fill one of the channel buffers.
00529   virtual void bufferComponent(const Matrix<uInt> &/*data*/,
00530                                const Int &/*x*/,
00531                                const Int &/*y*/,
00532                                const Display::ColorComponent &/*colorcomponent*/)
00533   {  }
00534 
00535   // (NOT CACHEABLE!) Flush the component buffers.
00536   virtual void flushComponentBuffers() {  }
00537 
00538 
00539 
00540 
00541 
00542   
00543 //#        RELEVANCE TO BE DETERMINED
00544 
00545   
00546   
00547   // return True if the refresh is active.
00548   //#dk PC probably can't determine this usefully, since individual
00549   //#   WCs may initiate their own refresh/drawing cycles....
00550   Bool refreshActive() const;
00551 
00552   // return True if refresh is allowed right now...
00553   virtual Bool refreshAllowed() const;
00554  
00555   // Draw a set of points, specifying a color per point to
00556   // be drawn.  
00557   // <group>
00558   virtual void drawColoredPoints(const Vector<Int> &/*x1*/, const Vector<Int> &/*y1*/,
00559                                  const Vector<uInt> &/*colors*/) {
00560      // cout << "WYSISWYN " << __FILE__ << " " << __LINE__ << endl;
00561   }
00562   virtual void drawColoredPoints(const Matrix<Int> &xy,
00563                                  const Vector<uInt> &colors) {
00564     drawColoredPoints(xy.column(0), xy.column(1), colors); }
00565   // </group>
00566 
00567   // Cause display to flush any graphics commands not yet drawn
00568   virtual void flush();
00569   
00570   static void drawText(QPainter& painter, const QPoint& p, const QFont& font,
00571            const QPen& pen, const String& text, double angle,
00572            Display::TextAlign alignment);
00573   virtual void drawText(Int x, Int y, const String &text, const Float& angle,
00574                Display::TextAlign alignment = Display::AlignCenter);
00575   virtual void drawText(Int x, Int y, const String &text, 
00576                Display::TextAlign alignment = Display::AlignCenter);
00577   
00578   virtual Int textWidth(const String& text);
00579   
00580   virtual Int textHeight(const String& text);
00581   
00582   virtual void setHSVColor(float /*h*/, float /*s*/, float /*v*/) {  }
00583  
00584 
00585   // (Cacheable) Draw a single point using current color
00586   // <group>
00587   virtual void drawPoint(Int x1, Int y1);
00588   virtual void drawPoint(Float x1, Float y1);
00589   virtual void drawPoint(Double x1, Double y1);
00590   // </group>
00591   
00592   // (Cacheable) Draw N points specified as a Nx2 matrix
00593   // <group>
00594   virtual void drawPoints(const Matrix<Int> &verts);
00595   virtual void drawPoints(const Matrix<Float> &verts);
00596   virtual void drawPoints(const Matrix<Double> &verts);
00597   // </group>
00598 
00599   // (Cacheable) Draw a bunch of points using current color
00600   // <group>
00601   virtual void drawPoints(const Vector<Int> &x1, 
00602                           const Vector<Int> &y1);
00603   virtual void drawPoints(const Vector<Float> &x1, 
00604                           const Vector<Float> &y1);
00605   virtual void drawPoints(const Vector<Double> &x1, 
00606                           const Vector<Double> &y1);
00607   // </group>
00608 
00609   // (Cacheable) Draw a single line using current color
00610   // <group>
00611   virtual void drawLine(Int x1, Int y1,
00612                         Int x2, Int y2);
00613   virtual void drawLine(Float x1, Float y1, 
00614                         Float x2, Float y2);
00615   virtual void drawLine(Double x1, Double y1, 
00616                         Double x2, Double y2);
00617   // </group>
00618 
00619   // (Cacheable) Draw N/2 lines from an Nx2 matrix
00620   // <group>
00621   virtual void drawLines(const Matrix<Int> &verts);
00622   virtual void drawLines(const Matrix<Double> &verts);
00623   // </group>
00624 
00625   // (Cacheable) Draw a bunch of unrelated lines using current color
00626   // <group>
00627   virtual void drawLines(const Vector<Int> &x1, 
00628                          const Vector<Int> &y1, 
00629                          const Vector<Int> &x2, 
00630                          const Vector<Int> &y2);
00631   virtual void drawLines(const Vector<Float> &x1, 
00632                          const Vector<Float> &y1, 
00633                          const Vector<Float> &x2, 
00634                          const Vector<Float> &y2);
00635   virtual void drawLines(const Vector<Double> &x1,
00636                          const Vector<Double> &y1, 
00637                          const Vector<Double> &x2, 
00638                          const Vector<Double> &y2);
00639   // </group>
00640   
00641   // (Cacheable) Draw a single connected line between the points given
00642   // <group>
00643   virtual void drawPolyline(const Vector<Int> &x1, 
00644                             const Vector<Int> &y1);
00645   virtual void drawPolyline(const Vector<Float> &x1, 
00646                             const Vector<Float> &y1);
00647   virtual void drawPolyline(const Vector<Double> &x1, 
00648                             const Vector<Double> &y1);
00649   // </group>
00650   
00651   // (Cacheable) Draw N-1 connected lines from Nx2 matrix of vertices
00652   // <group>
00653   virtual void drawPolyline(const Matrix<Int> &verts);
00654   virtual void drawPolyline(const Matrix<Float> &verts);
00655   virtual void drawPolyline(const Matrix<Double> &verts);
00656   // </group>
00657 
00658   // Let PixelCanvas::drawMarker take care of this.
00659   /*
00660   // Draw a "marker". See <linkto class="Display">Display</linkto> 
00661   // for a list of available markers.
00662   // <group>
00663 
00664    virtual void drawMarker(const Int& x1, const Int& y1,
00665                           const Display::Marker& marker, 
00666                           const Int& pixelHeight);
00667   virtual void drawMarker(const Float& x1, const Float& y1,
00668                           const Display::Marker& marker, 
00669                           const Int& pixelHeight);
00670   virtual void drawMarker(const Double& x1, const Double& y1,
00671                           const Display::Marker& marker, 
00672                           const Int& pixelHeight);
00673   
00674   // </group>
00675   */
00676       
00677   // (Cacheable) Draw a closed polygon
00678   // <group>
00679   virtual void drawPolygon(const Vector<Int> &x1, 
00680                            const Vector<Int> &y1);
00681   virtual void drawPolygon(const Vector<Double> &x1, 
00682                            const Vector<Double> &y1);
00683   // </group>
00684 
00685   // (Cacheable) Draw a closed N-sided polygon from Nx2 matrix of vertices
00686   // <group>
00687   virtual void drawPolygon(const Matrix<Int> &verts);
00688   virtual void drawPolygon(const Matrix<Float> &verts);
00689   virtual void drawPolygon(const Matrix<Double> &verts);
00690   // </group>
00691 
00692   // (Cacheable) Draw and fill a closed polygon
00693   // <group>
00694   virtual void drawFilledPolygon(const Vector<Int> &x1, 
00695                                  const Vector<Int> &y1);
00696   virtual void drawFilledPolygon(const Vector<Double> &x1, 
00697                                  const Vector<Double> &y1);
00698   // </group>
00699 
00700   // (Cacheable) Draw a rectangle
00701   // <group>
00702   virtual void drawRectangle(Float x1, Float y1, 
00703                              Float x2, Float y2);
00704   virtual void drawRectangle(Double x1, Double y1, 
00705                              Double x2, Double y2);
00706   // </group>
00707 
00708   // (Cacheable) Draw a filled rectangle
00709   // <group>
00710   virtual void drawFilledRectangle(Float x1, Float y1,
00711                                    Float x2, Float y2);
00712   virtual void drawFilledRectangle(Double x1, Double y1, 
00713                                    Double x2, Double y2);
00714   // </group>  
00715 
00716 
00717   // (Cacheable) Draw a set of lines, specifying a color per line to be drawn.
00718   // <group>
00719   virtual void drawColoredLines(const Vector<Int> &x1, 
00720                                 const Vector<Int> &y1, 
00721                                 const Vector<Int> &x2, 
00722                                 const Vector<Int> &y2, 
00723                                 const Vector<uInt> &colors);
00724   virtual void drawColoredLines(const Vector<Float> &x1, 
00725                                 const Vector<Float> &y1, 
00726                                 const Vector<Float> &x2, 
00727                                 const Vector<Float> &y2, 
00728                                 const Vector<uInt> &colors);
00729   virtual void drawColoredLines(const Vector<Double> &x1, 
00730                                 const Vector<Double> &y1, 
00731                                 const Vector<Double> &x2, 
00732                                 const Vector<Double> &y2, 
00733                                 const Vector<uInt> &colors);
00734   // </group>
00735 
00736   // vector primitive buffering
00737   
00738   // Set Graphics Attributes
00739   // Options for functions with enum argument
00740   // listed in <linkto class=Display>DisplayEnums</linkto>
00741   // <group>
00742   virtual void setDrawFunction(Display::DrawFunction function);
00743   virtual void setForeground(uLong color);
00744   virtual void setBackground(uLong color);
00745   virtual void setLineWidth(Float width);
00746   virtual void setLineStyle(Display::LineStyle style);
00747   virtual void setCapStyle(Display::CapStyle style);
00748   virtual void setJoinStyle(Display::JoinStyle style);
00749   virtual void setFillStyle(Display::FillStyle style);
00750   virtual void setFillRule(Display::FillRule rule);
00751   virtual void setArcMode(Display::ArcMode mode);
00752   // </group>
00753   
00754   // This method is NOT in PixelCanvas.
00755   virtual void setQtLineStyle(Qt::PenStyle style);
00756 
00757   // Get Graphics Attributes
00758   // <group>
00759   virtual Display::DrawFunction getDrawFunction() const;
00760   virtual uLong                 getForeground()   const;
00761   virtual uLong                 getBackground()   const;
00762   virtual Float                 getLineWidth()    const;
00763   virtual Display::LineStyle    getLineStyle()    const;
00764   virtual Display::CapStyle     getCapStyle()     const;
00765   virtual Display::JoinStyle    getJoinStyle()    const;
00766   virtual Display::FillStyle    getFillStyle()    const;
00767   virtual Display::FillRule     getFillRule()     const;
00768   virtual Display::ArcMode      getArcMode()      const;
00769   // </group>
00770 
00771 
00772   // Control the image-caching strategy
00773   virtual void setImageCacheStrategy(Display::ImageCacheStrategy strategy);
00774   virtual Display::ImageCacheStrategy imageCacheStrategy() const;
00775 
00776   // (Cacheable) Set the color to use for clearing the display
00777   // <group>
00778   
00779   //#dk probably unneeded -- can clear using deviceBkgd(?)
00780   //#  (what _else_ is deviceBkgd for?...)
00781   virtual void setClearColor(uInt colorIndex);
00782   virtual void setClearColor(const String &colorname);
00783   virtual void setClearColor(float r, float g, float b);
00784   // </group>
00785 
00786   // (Not Cacheable) Get the current color to use for clearing the display.
00787   virtual uInt clearColor() const;
00788   virtual void getClearColor(float &r, float &g, float &b) const;
00789 
00790   virtual void enableMotionEvents() {  }
00791   virtual void disableMotionEvents() {  }
00792   virtual void enablePositionEvents() {  }
00793   virtual void disablePositionEvents() {  }
00794   
00795   virtual void translateAllLists(Int /*xt*/, Int /*yt*/) {  }
00796   virtual void translateList(uInt /*list*/, Int /*xt*/, Int /*yt*/) {  }
00797   
00798   virtual Bool setFont(const String &fontName);
00799   virtual Bool setFont(DLFont* /*font*/) { return False; }
00800   virtual Bool setFont(const String& fontName, const Int fontSize);
00801   
00802   // These setFont methods are NOT in PixelCanvas.
00803   // <group>
00804   virtual Bool setFont(const String& fontName, bool bold, bool italic);
00805   virtual Bool setFont(const String& fontName, const Int fontSize, bool bold,
00806                        bool italic);
00807   // </group>
00808   
00809   virtual void drawImage(const Matrix<Int> &/*data*/, Int /*x*/, Int /*y*/) {  }
00810   virtual void drawImage(const Matrix<uLong> &/*data*/, Int /*x*/, Int /*y*/) {  }
00811   virtual void drawImage(const Matrix<Float> &data, Int x, Int y);
00812   virtual void drawImage(const Matrix<Double> &/*data*/, Int /*x*/, Int /*y*/) {  }
00813   
00814   virtual void drawImage(const Matrix<uInt> &/*data*/, Int /*x*/, Int /*y*/,
00815                          uInt /*xzoom*/, uInt /*yzoom*/) {  }
00816   virtual void drawImage(const Matrix<Int> &/*data*/, Int /*x*/, Int /*y*/,
00817                          uInt /*xzoom*/, uInt /*yzoom*/) {  }
00818   virtual void drawImage(const Matrix<uLong> &/*data*/, Int /*x*/, Int /*y*/,
00819                          uInt /*xzoom*/, uInt /*yzoom*/) {  }
00820   virtual void drawImage(const Matrix<Float> &/*data*/, Int /*x*/, Int /*y*/,
00821                          uInt /*xzoom*/, uInt /*yzoom*/) {  }
00822   virtual void drawImage(const Matrix<Double> &/*data*/, Int /*x*/, Int /*y*/,
00823                          uInt /*xzoom*/, uInt /*yzoom*/) {  }
00824 
00825 
00826   // (Cacheable) Set current color (works in RGB or colormap mode)
00827   // <group>
00828   virtual void setColor(uInt colorIndex);
00829   // </group>
00830 
00831   // (Not Cacheable) Returns the current color as a color index
00832   virtual uInt color() const;
00833 
00834   // (Not Cacheable) Retuns the current color as an RGB triple
00835   virtual void getColor(float &r, float &g, float &b) const;
00836 
00837   // (Not Cacheable) Get color index value (works in RGB or colormap mode)
00838   // <group>
00839   virtual Bool getColor(Int x, Int y, uInt &color);
00840   virtual Bool getRGBColor(Int x, Int y, 
00841                                  float &r, float &g, float &b);
00842   virtual Bool getHSVColor(Int x, Int y, 
00843                                  float &h, float &s, float &v);
00844   // </group>
00845 
00846   // (Not Cacheable) resize request.  returns true if window was resized. 
00847   // Will refresh if doCallbacks is True.
00848   //virtual Bool resize(uInt reqXSize, uInt reqYSize, 
00849   //Bool doCallbacks = True);
00850   
00851   // (Not Cacheable) resize the colortable by requesting a new number of cells
00852   virtual Bool resizeColorTable(uInt newSize);
00853 
00854   // (Not Cacheable) resize the colortable by requesting a new RGB/HSV cube
00855   virtual Bool resizeColorTable(uInt nReds, 
00856                                       uInt nGreens, uInt nBlues);
00857   
00858   // save/restore the current translation.  This is called pushMatrix because
00859   // eventually we may want scaling or rotation to play a modest
00860   // role here.
00861   // <group>
00862   virtual void pushMatrix() {  }
00863   virtual void popMatrix() {  }
00864   // </group>
00865   // zero the current translation
00866   virtual void loadIdentity() {  }
00867 
00868   // translation functions
00869   // translate applies a relative translation to the current matrix and
00870   // can be used to position graphics.  Together with pushMatrix and
00871   // popMatrix it can be used to build heirarchical scenes.
00872   // <group>
00873   virtual void translate(Int /*xt*/, Int /*yt*/) {  }
00874   virtual void getTranslation(Int &/*xt*/, Int &/*yt*/) const {  }
00875   virtual Int xTranslation() const { return 0;  }
00876   virtual Int yTranslation() const { return 0;  }
00877   // </group>
00878 
00879 
00880 
00881 
00882 //#         CONFIRMED IRRELEVANT / UNUSED
00883 
00884   
00885     
00886   virtual void drawColoredEllipses(const Matrix<Float> &/*centres*/,
00887         const Vector<Float> &/*smajor*/, const Vector<Float> &/*sminor*/,
00888         const Vector<Float> &/*pangle*/, const Vector<uInt> &/*colors*/,
00889         const Float &/*scale*/ = 1.0, const Bool &/*outline*/ = True) {  }
00890   
00891   virtual void drawColoredPoints(const Vector<Float> &/*x1*/,
00892           const Vector<Float> &/*y1*/, const Vector<uInt> &/*colors*/) {  }
00893   virtual void drawColoredPoints(const Vector<Double> &/*x1*/,
00894           const Vector<Double> &/*y1*/, const Vector<uInt> &/*colors*/) {  }
00895   virtual void drawColoredPoints(const Matrix<Float> &xy,
00896                                  const Vector<uInt> &colors) {
00897     drawColoredPoints(xy.column(0), xy.column(1), colors);  }
00898   virtual void drawColoredPoints(const Matrix<Double> &xy,
00899                                  const Vector<uInt> &colors) {
00900     drawColoredPoints(xy.column(0), xy.column(1), colors);  }
00901   
00902   
00903   virtual void getClipWindow(Int &/*x1*/, Int &/*y1*/, Int &/*x2*/, Int &/*y2*/) {  }
00904   
00905   virtual void setPcctbl(PixelCanvasColorTable * /*pcctbl*/) {  }
00906 
00907 };      // class QtPixelCanvas
00908 
00909 }       // namespace casa
00910 
00911 #endif