PixelCanvas.h

Go to the documentation of this file.
00001 //# PixelCanvas.h: Base class defining interface to PixelCanvases
00002 //# Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
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 
00028 #ifndef DISPLAY_PIXELCANVAS_H
00029 #define DISPLAY_PIXELCANVAS_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Containers/List.h>
00033 #include <display/Display/DisplayEnums.h>
00034 #include <display/Display/PixelCanvasColorTable.h>
00035 #include <display/Display/PCVGBuffer.h>
00036 #include <display/Display/DLFont.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040         template <class T> class Vector;
00041         template <class T> class Matrix;
00042         class Colormap;
00043         class PCMotionEH;
00044         class PCPositionEH;
00045         class PCRefreshEH;
00046 
00047 
00048 // <summary>
00049 // Base class defining interface to pixel-based output devices.
00050 // </summary>
00051 //
00052 // <prerequisite>
00053 // <li> <linkto class="Colormap">Colormap</linkto>
00054 // <li> <linkto class="PixelCanvasColorTable">PixelCanvasColorTable</linkto>
00055 // <li> <linkto class="PCMotionEH">PCMotionEH</linkto>
00056 // <li> <linkto class="PCRefreshEH">PCRefreshEH</linkto>
00057 // <li> <linkto class="PCPositionEH">PCPositionEH</linkto>
00058 // </prerequisite>
00059 //
00060 // <etymology>
00061 // PixelCanvas is the mechanism for drawing on the screen.
00062 // </etymology>
00063 //
00064 // <synopsis>
00065 // The philosophy of the PixelCanvas is to provide flexible fast interface to
00066 // an underlying graphics system in terms of integer pixel positions and
00067 // color values.  The interface should be as simple as possible and not demand
00068 // complicated structures on its interface.
00069 //
00070 // The PixelCanvas performs minimal management, leaving up to the derived classes
00071 // for most of the work required to interface to the underlying graphics library.
00073 //
00074 // To make it flexible, the fundamental interface accepts pointers to arrays of all
00075 // the scalar AIPS++ types.  The Bool type is not acceptable at the PixelCanvas
00076 // level because it cannot be used to represent a color index, as are the two
00077 // complex number types.
00078 //
00079 // To make it fast, a caching mechanism is used to allow display lists to be
00080 // created in the format native to the underlying graphics library.
00081 // The caching works like OpenGL display lists.
00082 //
00083 // To create a display list:
00084 //
00085 // <ol>
00086 // <li> Call the function newList() which will return a list id.  You need to
00087 //      store the returned id somewhere so that it may be recalled later.
00088 // <li> Perform some drawing commands.  These commands are output-only commands
00089 //      that change the state of the PixelCanvas or draw some graphics or other
00090 //      function that affects the canvas.
00091 // <li> Call the function endList()
00092 // </ol>
00093 //
00094 // To recall the drawing commands:
00095 //
00096 // <ol>
00097 // <li> Call drawList(), passing the list id as the parameter
00098 // </ol>
00099 //
00100 // To delete the list, call deleteList(), with the id
00101 //
00102 // The PixelCanvas maintains a translation stack which may be driven by
00103 // calls to translate and calls to pushMatrix, popMatrix.
00104 //
00105 // The translation stack is an effective way to draw the same graphic in different
00106 // places:
00107 // <srcblock>
00108 //
00109 // uInt myGraphic = newList();
00110 // ...
00111 // endList();
00112 // Matrix m(n,2);
00113 // for (uInt i = 0; i < n; i++)
00114 //   {
00115 //     pc->pushMatrix();
00116 //     pc->translate(m(i,0), m(i,1));
00117 //     pc->drawList(myGraphic);
00118 //     pc->popMatrix();
00119 //   }
00120 //
00121 // </srcblock>
00122 //
00123 // Images are most correctly drawn through the following sequence of operations
00124 //
00125 // <ol>
00126 // <li> Obtain the size of the current colormap with getColormapSize()
00127 // <li> scale your data to fit in the range of [0,size-1];
00128 // <li> call mapToColor() to get a proper color image (which you may consider
00129 //      saving).
00130 // <li> call drawImage()
00131 // </ol>
00132 //
00133 // You may find that a class derived from
00134 // <linkto class="WCDataScaleHandler">WCDataScaleHandler</linkto>, such as
00135 // <linkto class="WCLinearScaleHandler">WCLinearScaleHandler</linkto>
00136 // may be useful in step #2 above.
00137 //
00138 // mapToColor is also useful for transforming values that are associated with
00139 // vector graphics as well (e.g., contour lines).
00140 //
00141 //
00142 // The PixelCanvas layer is quite thin.  Most functionality is implemented
00143 // in the derived classes.
00144 //
00145 // </synopsis>
00146 //
00147 // <motivation>
00148 // Want a generic interface to possibly a variety of graphics hardware types.
00149 // Want base class to maintain callback lists
00150 // </motivation>
00151 //
00152 // <example>
00153 // see the Display test directory
00154 // </example>
00155 //
00156 
00157         class PixelCanvas {
00158         public:
00159                 virtual ~PixelCanvas();
00160 
00161                 // add event handlers
00162                 // <group>
00163                 void addRefreshEventHandler(const PCRefreshEH &eh);
00164                 void addMotionEventHandler(const PCMotionEH &eh);
00165                 void addPositionEventHandler(const PCPositionEH &eh);
00166                 // </group>
00167 
00168                 // remove event handlers
00169                 // <group>
00170                 void removeRefreshEventHandler(const PCRefreshEH &eh);
00171                 void removeMotionEventHandler(const PCMotionEH &eh);
00172                 void removePositionEventHandler(const PCPositionEH &eh);
00173                 // </group>
00174 
00175                 // call event handlers
00176                 // <group>
00177                 void callRefreshEventHandlers(Display::RefreshReason reason);
00178                 void callMotionEventHandlers(Int x, Int y, uInt state);
00179                 void callPositionEventHandlers(Display::KeySym keysym, Bool keystate,
00180                                                Int x, Int y, uInt state);
00181                 // </group>
00182 
00183                 // enabling/disabling of event tracking
00184                 // <group>
00185                 virtual void enableMotionEvents() = 0;
00186                 virtual void disableMotionEvents() = 0;
00187                 virtual void enablePositionEvents() = 0;
00188                 virtual void disablePositionEvents() = 0;
00189                 // </group>
00190 
00191                 // Does this canvas support cached display lists?  The user of the
00192                 // canvas should always check this, because undefined behaviour can
00193                 // result when an attempt is made to use a list on a PixelCanvas
00194                 // which does not support lists.
00195                 virtual Bool supportsLists() = 0;
00196 
00197                 // begin caching display commands - return list ID
00198                 virtual uInt newList() = 0;
00199                 // end caching display commands
00200                 virtual void endList() = 0;
00201                 // (Cacheable) recall cached display commands
00202                 virtual void drawList(uInt list) = 0;
00203                 // translate all lists
00204                 virtual void translateAllLists(Int xt, Int yt) = 0;
00205                 // translate the list
00206                 virtual void translateList(uInt list, Int xt, Int yt) = 0;
00207                 // remove list from cache
00208                 virtual void deleteList(uInt list) = 0;
00209                 // flush all lists from the cache
00210                 virtual void deleteLists() = 0;
00211                 // return True if the list exists
00212                 virtual Bool validList(uInt list) = 0;
00213 
00214                 // (Cacheable) Set the font to the recognizable font name
00215                 virtual Bool setFont(const String &fontName) = 0;
00216 
00217                 // TODO: These should become abstract
00218                 // Set the font via the DisplayLibrary Font class
00219                 virtual Bool setFont(DLFont* /*font*/) {
00220                         return False;
00221                 }
00222 
00223                 // Set the font to font name / size
00224                 virtual Bool setFont(const String& /*fontName*/, const Int /*fontSize*/) {
00225                         return False;
00226                 }
00227 
00228                 // (Cacheable) Draw text using that font aligned in some way to the
00229                 // position
00230                 virtual void drawText(Int x, Int y, const String &text,
00231                                       Display::TextAlign alignment = Display::AlignCenter) = 0;
00232 
00233                 // TODO This should become abstract - NYI in GLPixelCanvas currently
00234                 // Draw text at a specified angle.
00235                 virtual void drawText(Int /*x*/, Int /*y*/, const String &/*text*/,
00236                                       const Float& /*angle*/,
00237                                       Display::TextAlign /*alignment*/ = Display::AlignCenter)
00238                 { }
00239 
00240                 // TODO : This should become abstract
00241                 // Determine the width / height of a string of text based on
00242                 // current settings.
00243                 // <group>
00244                 virtual Int textWidth(const String& /*text*/) {
00245                         return -1;
00246                 }
00247                 virtual Int textHeight(const String& /*text*/) {
00248                         return -1;
00249                 }
00250                 // </group>
00251 
00252                 // (Cacheable) Draw an array of 2D color data as a raster image for zoom = <1,1>
00253                 // <group>
00254                 virtual void drawImage(const Matrix<uInt> &data, Int x, Int y) = 0;
00255                 virtual void drawImage(const Matrix<Int> &data, Int x, Int y) = 0;
00256                 virtual void drawImage(const Matrix<uLong> &data, Int x, Int y) = 0;
00257                 virtual void drawImage(const Matrix<Float> &data, Int x, Int y) = 0;
00258                 virtual void drawImage(const Matrix<Double> &data, Int x, Int y) = 0;
00259                 // </group>
00260 
00261                 // (Cacheable) Draw an array of 2D color data as a raster image,
00262                 // taking note of the <src>Bool</src> mask.
00263                 // Set opaqueMask to True to draw masked pixels in the background color;
00264                 // otherwise they will be transparent (letting whatever was drawn
00265                 // previously at that point show through).
00266                 // <group>
00267                 virtual void drawImage(const Int &/*x*/, const Int &/*y*/,
00268                                        const Matrix<uInt> &/*data*/,
00269                                        const Matrix<Bool> &/*mask*/,
00270                                        Bool /*opaqueMask*/=False) {
00271                         return;
00272                 }
00273                 // </group>
00274 
00275                 // (Cacheable) Draw an array of 2D color data as a raster image for any positive integer zoom
00276                 // <group>
00277                 virtual void drawImage(const Matrix<uInt> &data, Int x, Int y,
00278                                        uInt xzoom, uInt yzoom) = 0;
00279                 virtual void drawImage(const Matrix<Int> &data, Int x, Int y,
00280                                        uInt xzoom, uInt yzoom) = 0;
00281                 virtual void drawImage(const Matrix<uLong> &data, Int x, Int y,
00282                                        uInt xzoom, uInt yzoom) = 0;
00283                 virtual void drawImage(const Matrix<Float> &data, Int x, Int y,
00284                                        uInt xzoom, uInt yzoom) = 0;
00285                 virtual void drawImage(const Matrix<Double> &data, Int x, Int y,
00286                                        uInt xzoom, uInt yzoom) = 0;
00287                 // </group>
00288 
00289                 // (Cacheable) Draw a component of a multi-channel image, storing it
00290                 // in buffers until flushComponentImages() is called.
00291                 virtual void drawImage(const Matrix<uInt> &data, const Int &x, const Int &y,
00292                                        const Display::ColorComponent &colorcomponent) = 0;
00293 
00294                 // Fill one of the channel buffers.
00295                 virtual void bufferComponent(const Matrix<uInt> &data,
00296                                              const Int &x, const Int &y,
00297                                              const Display::ColorComponent
00298                                              &colorcomponent) = 0;
00299 
00300                 // (NOT CACHEABLE!) Flush the component buffers.
00301                 virtual void flushComponentBuffers() = 0;
00302 
00303                 // (Cacheable) Draw a single point using current color
00304                 // <group>
00305                 virtual void drawPoint(Int x1, Int y1) = 0;
00306                 virtual void drawPoint(Float x1, Float y1) = 0;
00307                 virtual void drawPoint(Double x1, Double y1) = 0;
00308                 // </group>
00309 
00310                 // (Cacheable) Draw N points specified as a Nx2 matrix
00311                 // <group>
00312                 virtual void drawPoints(const Matrix<Int> &verts) = 0;
00313                 virtual void drawPoints(const Matrix<Float> &verts) = 0;
00314                 virtual void drawPoints(const Matrix<Double> &verts) = 0;
00315                 // </group>
00316 
00317                 // (Cacheable) Draw a bunch of points using current color
00318                 // <group>
00319                 virtual void drawPoints(const Vector<Int> &x1, const Vector<Int> &y1) = 0;
00320                 virtual void drawPoints(const Vector<Float> &x1,
00321                                         const Vector<Float> &y1) = 0;
00322                 virtual void drawPoints(const Vector<Double> &x1,
00323                                         const Vector<Double> &y1) = 0;
00324                 // </group>
00325 
00326                 // (Cacheable) Draw a single line using current color
00327                 // <group>
00328                 virtual void drawLine(Int x1, Int y1, Int x2, Int y2) = 0;
00329                 virtual void drawLine(Float x1, Float y1, Float x2, Float y2) = 0;
00330                 virtual void drawLine(Double x1, Double y1, Double x2, Double y2) = 0;
00331                 // </group>
00332 
00333                 // (Cacheable) Draw N/2 lines from an Nx2 matrix
00334                 // <group>
00335                 virtual void drawLines(const Matrix<Int> &verts) = 0;
00336                 virtual void drawLines(const Matrix<Float> &verts) = 0;
00337                 virtual void drawLines(const Matrix<Double> &verts) = 0;
00338                 // </group>
00339 
00340                 // (Cacheable) Draw a bunch of unrelated lines using current color
00341                 // <group>
00342                 virtual void drawLines(const Vector<Int> &x1, const Vector<Int> &y1,
00343                                        const Vector<Int> &x2, const Vector<Int> &y2) = 0;
00344                 virtual void drawLines(const Vector<Float> &x1, const Vector<Float> &y1,
00345                                        const Vector<Float> &x2,
00346                                        const Vector<Float> &y2) = 0;
00347                 virtual void drawLines(const Vector<Double> &x1, const Vector<Double> &y1,
00348                                        const Vector<Double> &x2,
00349                                        const Vector<Double> &y2) = 0;
00350                 // </group>
00351 
00352                 // (Cacheable) Draw a single connected line between the points given
00353                 // <group>
00354                 virtual void drawPolyline(const Vector<Int> &x1,
00355                                           const Vector<Int> &y1) = 0;
00356                 virtual void drawPolyline(const Vector<Float> &x1,
00357                                           const Vector<Float> &y1) = 0;
00358                 virtual void drawPolyline(const Vector<Double> &x1,
00359                                           const Vector<Double> &y1) = 0;
00360                 // </group>
00361 
00362                 // (Cacheable) Draw N-1 connected lines from Nx2 matrix of vertices
00363                 // <group>
00364                 virtual void drawPolyline(const Matrix<Int> &verts) = 0;
00365                 virtual void drawPolyline(const Matrix<Float> &verts) = 0;
00366                 virtual void drawPolyline(const Matrix<Double> &verts) = 0;
00367                 // </group>
00368 
00369                 // Draw a "marker". See <linkto class="Display">Display</linkto>
00370                 // for a list of available markers.
00371                 // <group>
00372                 virtual void drawMarker(const Int& x1, const Int& y1,
00373                                         const Display::Marker& marker,
00374                                         const Int& pixelHeight);
00375                 virtual void drawMarker(const Float& x1, const Float& y1,
00376                                         const Display::Marker& marker,
00377                                         const Int& pixelHeight);
00378                 virtual void drawMarker(const Double& x1, const Double& y1,
00379                                         const Display::Marker& marker,
00380                                         const Int& pixelHeight);
00381                 // </group>
00382 
00383                 // (Cacheable) Draw a closed polygon
00384                 // <group>
00385                 virtual void drawPolygon(const Vector<Int> &x1, const Vector<Int> &y1) = 0;
00386                 virtual void drawPolygon(const Vector<Float> &x1,
00387                                          const Vector<Float> &y1) = 0;
00388                 virtual void drawPolygon(const Vector<Double> &x1,
00389                                          const Vector<Double> &y1) = 0;
00390                 // </group>
00391 
00392                 // (Cacheable) Draw and fill a closed polygon
00393                 // <group>
00394                 virtual void drawFilledPolygon(const Vector<Int> &x1,
00395                                                const Vector<Int> &y1) = 0;
00396                 virtual void drawFilledPolygon(const Vector<Float> &x1,
00397                                                const Vector<Float> &y1) = 0;
00398                 virtual void drawFilledPolygon(const Vector<Double> &x1,
00399                                                const Vector<Double> &y1) = 0;
00400                 // </group>
00401 
00402                 // (Cacheable) Draw a closed N-sided polygon from Nx2 matrix of vertices
00403                 // <group>
00404                 virtual void drawPolygon(const Matrix<Int> &verts) = 0;
00405                 virtual void drawPolygon(const Matrix<Float> &verts) = 0;
00406                 virtual void drawPolygon(const Matrix<Double> &verts) = 0;
00407                 // </group>
00408 
00409                 // (Cacheable) Draw a rectangle
00410                 // <group>
00411                 virtual void drawRectangle(Int x1, Int y1, Int x2, Int y2) = 0;
00412                 virtual void drawRectangle(Float x1, Float y1, Float x2, Float y2) = 0;
00413                 virtual void drawRectangle(Double x1, Double y1, Double x2, Double y2) = 0;
00414                 // </group>
00415 
00416                 // (Cacheable) Draw a filled rectangle
00417                 // <group>
00418                 virtual void drawFilledRectangle(Int x1, Int y1, Int x2, Int y2) = 0;
00419                 virtual void drawFilledRectangle(Float x1, Float y1, Float x2, Float y2) = 0;
00420                 virtual void drawFilledRectangle(Double x1, Double y1, Double x2,
00421                                                  Double y2) = 0;
00422                 // </group>
00423 
00424                 // (Cacheable) Draw a set of points, specifying a color per point to be drawn.
00425                 // <group>
00426                 virtual void drawColoredPoints(const Vector<Int> &x1,
00427                                                const Vector<Int> &y1,
00428                                                const Vector<uInt> &colors) = 0;
00429                 virtual void drawColoredPoints(const Vector<Float> &x1,
00430                                                const Vector<Float> &y1,
00431                                                const Vector<uInt> &colors) = 0;
00432                 virtual void drawColoredPoints(const Vector<Double> &x1,
00433                                                const Vector<Double> &y1,
00434                                                const Vector<uInt> &colors) = 0;
00435                 virtual void drawColoredPoints(const Matrix<Int> &xy,
00436                                                const Vector<uInt> &colors) {
00437                         drawColoredPoints(xy.column(0), xy.column(1), colors);
00438                 }
00439                 virtual void drawColoredPoints(const Matrix<Float> &xy,
00440                                                const Vector<uInt> &colors) {
00441                         drawColoredPoints(xy.column(0), xy.column(1), colors);
00442                 }
00443                 virtual void drawColoredPoints(const Matrix<Double> &xy,
00444                                                const Vector<uInt> &colors) {
00445                         drawColoredPoints(xy.column(0), xy.column(1), colors);
00446                 }
00447                 // </group>
00448 
00449                 // (Cacheable) Draw a set of lines, specifying a color per line to be drawn.
00450                 // <group>
00451                 virtual void drawColoredLines(const Vector<Int> &x1,
00452                                               const Vector<Int> &y1,
00453                                               const Vector<Int> &x2,
00454                                               const Vector<Int> &y2,
00455                                               const Vector<uInt> &colors) = 0;
00456                 virtual void drawColoredLines(const Vector<Float> &x1,
00457                                               const Vector<Float> &y1,
00458                                               const Vector<Float> &x2,
00459                                               const Vector<Float> &y2,
00460                                               const Vector<uInt> &colors) = 0;
00461                 virtual void drawColoredLines(const Vector<Double> &x1,
00462                                               const Vector<Double> &y1,
00463                                               const Vector<Double> &x2,
00464                                               const Vector<Double> &y2,
00465                                               const Vector<uInt> &colors) = 0;
00466                 // </group>
00467 
00468                 // Draw a single ellipse using the current pen (ie. color,
00469                 // thickness, style).  The x and y location must be given, along
00470                 // with the semi-major and -minor axis lengths, and the position
00471                 // angle measured in degrees positive from the x axis in a
00472                 // counter-clockwise direction. If outline is False, the
00473                 // ellipse is solid filled, else it is just outlined.
00474                 // xstretch, ystretch should be left defaulted to 1 in most cases;
00475                 // see usage example in WorldCanvas::drawBeamEllipse(), where they are
00476                 // used to stretch a beam ellipse when the display is also linearly
00477                 // stretched away from the aspect ratio natural to the sky projection.
00478                 // They multiply the relative x and y screen coordinates of ellipse
00479                 // points, _before_ they are added to cx and cy.  xstretch, ystretch
00480                 // can be negative (though smajor, sminor normally would not be).
00481                 virtual void drawEllipse(const Float &cx, const Float &cy,
00482                                          const Float &smajor, const Float &sminor,
00483                                          const Float &pangle, Bool outline = True,
00484                                          Float xstretch = 1., Float ystretch = 1.);
00485 
00486                 // Draw a set of colored ellipses, possibly with borders.  The x and
00487                 // y locations must given, along with semi-major and semi-minor
00488                 // axes, and position angle measured in degrees positive from the x
00489                 // axis in a counter-clockwise direction.  The size of the ellipses
00490                 // is globally scaled by the scale factor, and if <src>outline</src>
00491                 // is <src>True</src>, then each ellipse will have an outline in the
00492                 // current pen color.  <group>
00493                 virtual void drawColoredEllipses(const Matrix<Float> &centres,
00494                                                  const Vector<Float> &smajor,
00495                                                  const Vector<Float> &sminor,
00496                                                  const Vector<Float> &pangle,
00497                                                  const Vector<uInt> &colors,
00498                                                  const Float &scale = 1.0,
00499                                                  const Bool &outline = True);
00500                 // </group>
00501 
00502                 // vector primitive buffering
00503                 /*
00504                 void bufferPoint(Int x, Int y)
00505                   { vgbuf_.accumPoint(x,y); }
00506                 void bufferLine(Int x1, Int y1, Int x2, Int y2)
00507                   { vgbuf_.accumLine(x1,y1,x2,y2); }
00508                 void bufferPolylinePoint(Int x, Int y)
00509                   { vgbuf_.accumPolylinePoint(x,y); }
00510                 void bufferPolygonPoint(Int x, Int y)
00511                   { vgbuf_.accumPolygonPoint(x,y); }
00512                 */
00513                 void bufferPoint(Float x, Float y) {
00514                         vgbuf_.accumPoint(x,y);
00515                 }
00516                 void bufferLine(Float x1, Float y1, Float x2, Float y2) {
00517                         vgbuf_.accumLine(x1,y1,x2,y2);
00518                 }
00519                 void bufferPolylinePoint(Float x, Float y) {
00520                         vgbuf_.accumPolylinePoint(x,y);
00521                 }
00522                 void bufferPolygonPoint(Float x, Float y) {
00523                         vgbuf_.accumPolygonPoint(x,y);
00524                 }
00525                 void flushBuffer() {
00526                         vgbuf_.flush();
00527                 }
00528 
00529                 // Set Graphics Attributes
00530                 // Options for functions with enum argument
00531                 // listed in <linkto class=Display>DisplayEnums</linkto>
00532                 // <group>
00533                 virtual void setDrawFunction(Display::DrawFunction function) = 0;
00534                 virtual void setForeground(uLong color) = 0;
00535                 virtual void setBackground(uLong color) = 0;
00536                 //virtual void setLineWidth(uInt width) = 0;
00537                 virtual void setLineWidth(Float width) = 0;
00538                 virtual void setLineStyle(Display::LineStyle style) = 0;
00539                 virtual void setCapStyle(Display::CapStyle style) = 0;
00540                 virtual void setJoinStyle(Display::JoinStyle style) = 0;
00541                 virtual void setFillStyle(Display::FillStyle style) = 0;
00542                 virtual void setFillRule(Display::FillRule rule) = 0;
00543                 virtual void setArcMode(Display::ArcMode mode) = 0;
00544                 // </group>
00545 
00546                 // Get Graphics Attributes
00547                 // <group>
00548                 virtual Display::DrawFunction getDrawFunction() const = 0;
00549                 virtual uLong                 getForeground()   const = 0;
00550                 virtual uLong                 getBackground()   const = 0;
00551                 //virtual uInt                  getLineWidth()    const = 0;
00552                 virtual Float                 getLineWidth()    const = 0;
00553                 virtual Display::LineStyle    getLineStyle()    const = 0;
00554                 virtual Display::CapStyle     getCapStyle()     const = 0;
00555                 virtual Display::JoinStyle    getJoinStyle()    const = 0;
00556                 virtual Display::FillStyle    getFillStyle()    const = 0;
00557                 virtual Display::FillRule     getFillRule()     const = 0;
00558                 virtual Display::ArcMode      getArcMode()      const = 0;
00559                 // </group>
00560 
00561                 // (Cacheable) Option Control
00562                 // Options listed in <linkto class=Display>DisplayEnums</linkto>
00563                 // <group>
00564                 virtual Bool enable(Display::Option option) = 0;
00565                 virtual Bool disable(Display::Option option) = 0;
00566                 // </group>
00567 
00568                 // Control the image-caching strategy
00569                 virtual void setImageCacheStrategy(Display::ImageCacheStrategy strategy) = 0;
00570                 virtual Display::ImageCacheStrategy imageCacheStrategy() const = 0;
00571 
00572                 // (Cacheable) Setup the clip window.  The clip window, when enabled, allows
00573                 // a user to clip all graphics output to a rectangular region on
00574                 // the screen.
00575                 // <group>
00576                 virtual void setClipWindow(Int x1, Int y1, Int x2, Int y2) = 0;
00577                 virtual void getClipWindow(Int &x1, Int &y1, Int &x2, Int &y2) = 0;
00578                 // </group>
00579 
00580                 // (Not Cacheable) Redraw the window
00581                 // <group>
00582                 void redraw() {
00583                         refresh();
00584                 }
00585                 virtual void refresh(const Display::RefreshReason &reason =
00586                                          Display::UserCommand,
00587                                      const Bool &explicitrequest = True) = 0;
00588                 // </group>
00589 
00590                 // Cause display to flush any graphics commands not yet drawn
00591                 virtual void flush() = 0;
00592 
00593                 // (Cacheable) Clear the window using the background color
00594                 // <group>
00595                 virtual void clear() = 0;
00596                 virtual void clear(Int x1, Int y1, Int x2, Int y2) = 0;
00597                 // </group>
00598 
00599                 // (Cacheable) Set the color to use for clearing the display
00600                 // <group>
00601                 virtual void setClearColor(uInt colorIndex) = 0;
00602                 virtual void setClearColor(const String &colorname) = 0;
00603                 virtual void setClearColor(float r, float g, float b) = 0;
00604                 // </group>
00605 
00606                 // (Not Cacheable) Get the current color to use for clearing the display.
00607                 virtual uInt clearColor() const = 0;
00608                 virtual void getClearColor(float &r, float &g, float &b) const = 0;
00609 
00610                 // Get/set the current foreground/background colors.  These colors
00611                 // should be used when the special Strings "foreground" and "background"
00612                 // are given for a color.
00613                 // <group>
00614                 virtual void setDeviceForegroundColor(const String colorname) = 0;
00615                 virtual String deviceForegroundColor() const = 0;
00616                 virtual void setDeviceBackgroundColor(const String colorname) = 0;
00617                 virtual String deviceBackgroundColor() const = 0;
00618                 // </group>
00619 
00620                 // Return the width of the PixelCanvas in pixels
00621                 virtual uInt width() const = 0;
00622                 // Return the height of the PixelCanvas in pixels
00623                 virtual uInt height() const = 0;
00624                 // Return the depth of the PixelCanvas in bits
00625                 virtual uInt depth() const = 0;
00626                 // Get the pixel density (in dots per inch [dpi]) of the PixelCanvas
00627                 virtual void pixelDensity(Float &xdpi, Float &ydpi) const = 0;
00628 
00629                 // (Cacheable) Set current color (works in RGB or colormap mode)
00630                 // <group>
00631                 virtual void setColor(uInt colorIndex) = 0;
00632                 virtual void setColor(const String &colorname) = 0;
00633                 virtual void setRGBColor(float r, float g, float b) = 0;
00634                 virtual void setHSVColor(float h, float s, float v);
00635                 // </group>
00636 
00637                 // Get color components in range 0 to 1 without actually
00638                 // allocating the color.  This is needed to set up other
00639                 // devices, for example PgPlot.
00640                 virtual Bool getColorComponents(const String &colorname, Float &r,
00641                                                 Float &g, Float &b) = 0;
00642 
00643                 // (Not Cacheable) Returns the current color as a color index
00644                 virtual uInt color() const = 0;
00645 
00646                 // (Not Cacheable) Retuns the current color as an RGB triple
00647                 virtual void getColor(float &r, float &g, float &b) const = 0;
00648 
00649                 // (Not Cacheable) Get color index value (works in RGB or colormap mode)
00650                 // <group>
00651                 virtual Bool getColor(Int x, Int y, uInt &color) = 0;
00652                 virtual Bool getRGBColor(Int x, Int y, float &r, float &g, float &b) = 0;
00653                 virtual Bool getHSVColor(Int x, Int y, float &h, float &s, float &v);
00654                 // </group>
00655 
00656                 // (Not Cacheable) resize request.  returns true if window was resized.
00657                 // Will refresh if doCallbacks is True.
00658                 //#dk virtual Bool resize(uInt reqXSize, uInt reqYSize, Bool doCallbacks = True) = 0;
00659                 virtual Bool resize(uInt /*reqXSize*/, uInt /*reqYSize*/, Bool /*doCallbacks*/ = True) {
00660                         return False;
00661                 }
00662 
00663                 // (Not Cacheable) resize the colortable by requesting a new number of cells
00664                 virtual Bool resizeColorTable(uInt newSize) = 0;
00665 
00666                 // (Not Cacheable) resize the colortable by requesting a new RGB/HSV cube
00667                 virtual Bool resizeColorTable(uInt nReds, uInt nGreens, uInt nBlues) = 0;
00668 
00669                 // Need a mechanism to return the PixelCanvasColorTable so
00670                 // drawing functions within classes can operate.
00671                 virtual PixelCanvasColorTable * pcctbl() const = 0;
00672 
00673                 virtual void setPcctbl(PixelCanvasColorTable * pcctbl) = 0;
00674 
00675                 // (Not Cacheable) set/get the current colormap.  Undefined behavior results from
00676                 // setting the colormap to a map that is not registered.  This cannot be cached
00677                 // because it affects the result of getColormapSize().  Remember that once data
00678                 // is mapped with mapToColor, it is no longer important to worry about which
00679                 // colormap is active for purposes of drawing the image or vectors.
00680                 // colormapRegistered() can be used to determine whether the currently set
00681                 // colormap() is indeed registered/installed (i.e., color cells have been
00682                 // allocated within the pcctbl).
00683                 // <group>
00684                 void setColormap(Colormap * map);
00685                 Colormap * colormap() const {
00686                         return colormap_;
00687                 }
00688                 Bool colormapRegistered() {
00689                         return pcctbl()->member(colormap_);
00690                 }
00691                 // </group>
00692 
00693                 // register a colormap to the pixelcanvas.  Registration counts are
00694                 // remembered, so that map A is guaranteed to be available as long as
00695                 // the number of register(A)'s exceed the number of unregister(A)'s.
00696                 // Requests are forwarded to the PixelCanvas' PixelCanvasColorTable.
00697                 void registerColormap(Colormap * dcmap, Float weight = 1.0);
00698 
00699                 // Register the <src>cmap</src> Colormap on the PixelCanvas,
00700                 // replacing the <src>cmapToReplace</src> Colormap if possible.
00701                 void registerColormap(Colormap *cmap, Colormap *cmapToReplace);
00702 
00703                 // unregister a colormap from a pixelcanvas.  Unregistering the
00704                 // current map may result in undefined behavior.
00705                 void unregisterColormap(Colormap * dcmap);
00706 
00707                 // return the size of the current colormap
00708                 uInt getColormapSize() const {
00709                         return pcctbl()->getColormapSize(colormap_);
00710                 }
00711 
00712                 // map [0,N-1] into colorpixels, where N is the current colormap size
00713                 // The values are returned as unsigned integers in their respective
00714                 // array.
00715                 // <note role="tip">The choice of what type to use should be guided by
00716                 // the number of graphics bitplanes available.  For most systems with
00717                 // 8-bit color, uChar is optimal.  Some systems with 12 bits per pixel
00718                 // with an alpha channel may require using the uLong. </note>
00719                 //
00720                 // <note role="warning">uChar type may not have enough bits
00721                 // to hold the pixel index on some high-end graphics systems </note>
00722                 // <note role="warning">uShort type may not have enough bits
00723                 // to hold the pixel index on some high-end graphics systems </note>
00724                 // <group>
00725 
00726                 void mapToColor(Array<uChar> &outArray,
00727                                 const Array<uChar> &inArray, Bool rangeCheck = False) {
00728                         pcctbl()->mapToColor(colormap_, outArray, inArray, rangeCheck);
00729                 }
00730                 void mapToColor(Array<uShort> &outArray,
00731                                 const Array<uShort> &inArray, Bool rangeCheck = False) {
00732                         pcctbl()->mapToColor(colormap_, outArray, inArray, rangeCheck);
00733                 }
00734                 void mapToColor(Array<uInt> &outArray,
00735                                 const Array<uInt> &inArray, Bool rangeCheck = False) {
00736                         pcctbl()->mapToColor(colormap_, outArray, inArray, rangeCheck);
00737                 }
00738                 void mapToColor(Array<uLong> &outArray,
00739                                 const Array<uLong> &inArray, Bool rangeCheck = False) {
00740                         pcctbl()->mapToColor(colormap_, outArray, inArray, rangeCheck);
00741                 }
00742                 // </group>
00743 
00744                 // same as above except the matrix is operated on in place.  Only unsigned
00745                 // values make sense here.
00746                 // <group>
00747                 void mapToColor(Array<uChar> &inOutArray, Bool rangeCheck = False) {
00748                         pcctbl()->mapToColor(colormap_, inOutArray, rangeCheck);
00749                 }
00750                 void mapToColor(Array<uShort> &inOutArray, Bool rangeCheck = False) {
00751                         pcctbl()->mapToColor(colormap_, inOutArray, rangeCheck);
00752                 }
00753                 void mapToColor(Array<uInt> &inOutArray, Bool rangeCheck = False) {
00754                         pcctbl()->mapToColor(colormap_, inOutArray, rangeCheck);
00755                 }
00756                 void mapToColor(Array<uLong> &inOutArray, Bool rangeCheck = False) {
00757                         pcctbl()->mapToColor(colormap_, inOutArray, rangeCheck);
00758                 }
00759                 // </group>
00760 
00761 
00762 
00763                 void mapToColor(Array<uInt> &outArray,
00764                                 const Array<uInt> &inArrayRed, const Array<uInt> &inArrayGreen, const Array<uInt>& inArrayBlue) {
00765                         pcctbl()->mapToColorRGB(colormap_, outArray, inArrayRed, inArrayGreen, inArrayBlue);
00766                 }
00767 
00768 
00769                 // Multi-Channel functions that combine separate array channels into
00770                 // a single array of output colors for use with functions that take
00771                 // color values.
00772                 // These two functions accept color values from [0-1] for each channel.
00773                 // The colorModel is compared with the model of the PixelCanvasColorTable
00774                 // and is used to perform the correct mapping.
00775                 // <group>
00776                 void mapToColor3(Array<uLong> &out,
00777                                  const Array<Float> &chan1in,
00778                                  const Array<Float> &chan2in,
00779                                  const Array<Float> &chan3in);
00780                 void mapToColor3(Array<uLong> &out,
00781                                  const Array<Double> &chan1in,
00782                                  const Array<Double> &chan2in,
00783                                  const Array<Double> &chan3in);
00784                 // </group>
00785 
00786                 // This one maps values between 0 and the integer maximum value for
00787                 // each channel into a single output image suitable for
00788                 // PixelCanvas::drawImage.
00789                 // <group>
00790                 virtual void mapToColor3(Array<uLong> &out,
00791                                          const Array<uInt> &chan1in,
00792                                          const Array<uInt> &chan2in,
00793                                          const Array<uInt> &chan3in);
00794                 // </group>
00795 
00796 
00797                 // save/restore the current translation.  This is called pushMatrix because
00798                 // eventually we may want scaling or rotation to play a modest
00799                 // role here.
00800                 // <group>
00801                 virtual void pushMatrix() = 0;
00802                 virtual void popMatrix() = 0;
00803                 // </group>
00804                 // zero the current translation
00805                 virtual void loadIdentity() = 0;
00806 
00807                 // translation functions
00808                 // translate applies a relative translation to the current matrix and
00809                 // can be used to position graphics.  Together with pushMatrix and
00810                 // popMatrix it can be used to build heirarchical scenes.
00811                 // <group>
00812                 virtual void translate(Int xt, Int yt) = 0;
00813                 virtual void getTranslation(Int &xt, Int &yt) const = 0;
00814                 virtual Int xTranslation() const = 0;
00815                 virtual Int yTranslation() const = 0;
00816                 // </group>
00817 
00818                 // return the drawing buffer, the target destination for graphics
00819                 Display::DrawBuffer drawBuffer() const {
00820                         return drawBuffer_;
00821                 }
00822                 // (Not cacheable) set the draw buffer
00823                 virtual void setDrawBuffer(Display::DrawBuffer buf) = 0;
00824                 // buffer memory exchanges
00825                 // (Not cacheable)
00826                 // <group>
00827                 virtual void copyBackBufferToFrontBuffer() = 0;
00828                 virtual void copyFrontBufferToBackBuffer() = 0;
00829                 virtual void swapBuffers() = 0;
00830                 // </group>
00831 
00832                 // partial buffer memory exchanges.  (x1,y1 are blc, x2,y2 are trc)
00833                 // <group>
00834                 virtual void copyBackBufferToFrontBuffer(Int x1, Int y1, Int x2, Int y2) = 0;
00835                 virtual void copyFrontBufferToBackBuffer(Int x1, Int y1, Int x2, Int y2) = 0;
00836                 virtual void swapBuffers(Int x1, Int y1, Int x2, Int y2) = 0;
00837                 // </group>
00838 
00839                 // return the drawmode (Compile or Draw)
00840                 // Compile drawmode means that a display list is currently being built
00841                 // Draw drawmode means that drawing commands are not cached but
00842                 // instead are sent to the display.  This command is controlled by
00843                 // the caching state using newList()
00844                 Display::DrawMode drawMode() const {
00845                         return drawMode_;
00846                 }
00847 
00848                 // return the colorModel used for multichannel color
00849                 Display::ColorModel colorModel() const {
00850                         return colorModel_;
00851                 }
00852                 // Set the input color model for multichannel color
00853                 void setColorModel(Display::ColorModel colorModel);
00854 
00855 
00856                 // return True if the refresh is active (Added for X11PixelCanvas DefaultBuffer)
00857                 Bool refreshActive() const {
00858                         return refreshActive_;
00859                 }
00860 
00861                 // return True if refresh is allowed right now...
00862                 virtual Bool refreshAllowed() const {
00863                         return True;
00864                 }
00865 
00866                 virtual Float pixelScaling() const {
00867                         return 1.0;
00868                 }
00869 
00870         protected:
00871 
00872                 // Abstract base class idiom
00873                 PixelCanvas();
00874                 PixelCanvas( const PixelCanvas * );
00875                 PixelCanvas(PixelCanvasColorTable * pcctbl);
00876 
00877                 // Only allowed by derived classes
00878                 void setDrawMode(Display::DrawMode mode) {
00879                         drawMode_ = mode;
00880                 }
00881 
00882                 // Also allowed only by derived classes
00883                 void setDrawBuffer_(Display::DrawBuffer buf) {
00884                         drawBuffer_ = buf;
00885                 }
00886 
00887                 // True if the PixelCanvas was the one who
00888                 // registered the existing colortable
00889                 Bool defaultColormapActive_;
00890 
00891         private:
00892                 Matrix<Float> getMarker(const Display::Marker& marker, const Float& pixelHeight);
00893 
00894                 // This is the current colormap.
00895                 Colormap * colormap_;
00896 
00897 
00898                 // This is the current drawing mode
00899                 Display::DrawMode drawMode_;
00900 
00901                 // The current drawing buffer
00902                 Display::DrawBuffer drawBuffer_;
00903 
00904                 // The current color cube model to be used for all
00905                 // multichannel color mapping.
00906                 Display::ColorModel colorModel_;
00907 
00908                 // True if refresh is active
00909                 Bool refreshActive_;
00910 
00911                 // Number of colormaps registered by external clients
00912                 uInt nRegisteredColormaps_;
00913 
00914                 // This is the list of registered refresh EventHandlers
00915                 List<void *> refreshEHList_;
00916                 // This is the list of registered motion EventHandlers
00917                 List<void *> motionEHList_;
00918                 // This is the list of registered position EventHandlers
00919                 List<void *> positionEHList_;
00920 
00921                 // The PCVGBuffer is used to accumulate lines and points until
00922                 // flushed (or the buffer is full)
00923                 PCVGBuffer vgbuf_;
00924         };
00925 
00926 
00927 } //# NAMESPACE CASA - END
00928 
00929 #endif
00930 
00931 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1