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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1