PSPixelCanvas.h

Go to the documentation of this file.
00001 //# PSPixelCanvas.h: implementation of PixelCanvas for PostScript devices
00002 //# Copyright (C) 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 TRIALDISPLAY_PSPIXELCANVAS_H
00029 #define TRIALDISPLAY_PSPIXELCANVAS_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Arrays/Vector.h>
00033 #include <casa/Arrays/Matrix.h>
00034 #include <display/Display/DisplayEnums.h>
00035 #include <display/DisplayEvents/PCMotionEH.h>
00036 #include <display/DisplayEvents/PCPositionEH.h>
00037 #include <display/DisplayEvents/PCRefreshEH.h>
00038 #include <display/Display/PCVGBuffer.h>
00039 #include <display/Display/PSPixelCanvasColorTable.h>
00040 #include <display/Display/PixelCanvas.h>
00041 #include <display/Display/DLFont.h>
00042 
00043 namespace casa { //# NAMESPACE CASA - BEGIN
00044 
00045 // <summary>
00046 // Implementation of the PixelCanvas for PostScript devices.
00047 // </summary>
00048 //
00049 // <prerequisite>
00050 // <ol>
00051 // <li> <linkto class="PixelCanvas">PixelCanvas</linkto>
00052 // <li> <linkto class="PSPixelCanvasColorTable">PSPixelCanvasColorTable</linkto>
00053 // <li> <linkto class="PSDriver">PSDriver</linkto>
00054 // </ol>
00055 // </prerequisite>
00056 // <use visibility=export>
00057 //
00058 // <etymology>
00059 // PSPixelCanvas is a mechanism for drawing on paper.
00060 // </etymology>
00061 //
00062 
00063 //
00064 // <motivation>
00065 // </motivation>
00066 //
00067 // <synopsis>
00068 // PSPixelCanvas implements <linkto class="PixelCanvas">PixelCanvas</linkto>
00069 // for PostScript output. See
00070 // <linkto class="PSPixelCanvas#Example">Example</linkto> for example
00071 // usage.
00072 // </synopsis>
00073 
00074 //<a name="Example"></a>
00075 // <example>
00076 // <ol>
00077 // <li> Create an output stream.
00078 // <li> Create a PSDriver choosing a page type (letter, A4, etc.).
00079 //      (PSDriver can take a filename as an argument instead of an ostream).
00080 // See: <linkto class="PSDriver#Synopsis">PSDriver</linkto> for more on
00081 //      creating PSDrivers..
00082 // <li> Create PSPixelCanvasColorTable
00083 // <li> Create PSPixelCanvas
00084 // <li> Draw something pretty.
00085 // <li> Delete everything and close the stream.
00086 // <note role=tip>Neither PSPixelCanvasColorTable nor PSPixelCanvas delete
00087 //      their PSDriver.</note>
00088 // </ol>
00089 // <srcblock>
00090 //
00091 // PSDriver *psd = new PSDriver("test.ps", PSDriver::LETTER);
00092 // PSPixelCanvasColorTable *pscct = new PSPixelCanvasColorTable(psd);
00093 // PSPixelCanvas psc = new PSPixelCanvas( psd, pscct);
00094 //  ... (a miracle happens).
00095 // delete psc;
00096 // delete pscct;
00097 // delete psd;
00098 // </srcblock>
00099 //
00100 // <note role=tip>Since PostScript does not deal in in pixels, PSPixelCanvas
00101 // assumes an adjustable number of pixels per inch. (Currently 1200dpi).
00102 // Use the setResolution function to change this if the calling progam
00103 // can't handle a 128M pixel display.</note>
00104 // </example>
00105 //
00106 // <todo>
00107 // <ol>
00108 // <li> Lots of 'get' functions. Some don't make sense for PostScript.
00109 //      Others haven't been done yet.
00110 // <li> Events.
00111 // <li> Partial support for X11 color names is hacked in. Doing it
00112 //      'correctly' would require changing the constructors.
00113 // <li> No display list support.
00114 // <li> Foreground/background/clear color support is in. However, these
00115 //      and many other routines don't really support RGB mode yet.
00116 // <li> See: <linkto class="PSDriver#ToDo">PSDriver</linkto> for another list.
00117 // </ol>
00118 // </todo>
00119         class PSPixelCanvas : public PixelCanvas {
00120         public:
00121                 PSPixelCanvas(PSDriver *ps, PSPixelCanvasColorTable * );
00122                 virtual ~PSPixelCanvas();
00123 
00124                 // enabling/disabling of event tracking
00125                 // <group>
00126                 virtual void enableMotionEvents();
00127                 virtual void disableMotionEvents();
00128                 virtual void enablePositionEvents();
00129                 virtual void disablePositionEvents();
00130                 // </group>
00131 
00132                 // Does this canvas support cached display lists?  The user of the
00133                 // canvas should always check this, because undefined behaviour can
00134                 // result when an attempt is made to use a list on a PixelCanvas
00135                 // which does not support lists.
00136                 virtual Bool supportsLists() {
00137                         return False;
00138                 }
00139 
00140                 // begin caching display commands - return list ID
00141                 virtual uInt newList();
00142                 // end caching display commands
00143                 virtual void endList();
00144                 // (Cacheable) recall cached display commands
00145                 virtual void drawList(uInt list);
00146                 // translate all lists
00147                 virtual void translateAllLists(Int xt, Int yt);
00148                 // translate the list
00149                 virtual void translateList(uInt list, Int xt, Int yt);
00150                 // remove list from cache
00151                 virtual void deleteList(uInt list);
00152                 // flush all lists from the cache
00153                 virtual void deleteLists();
00154                 // return True if the list exists
00155                 virtual Bool validList(uInt list);
00156 
00157                 // (Cacheable) Set the font to the PostScript font name and size.
00158                 virtual Bool setFont(const String &fontName, const Int size);
00159                 virtual Bool setFont(DLFont* font) {
00160                         return setFont(font->getPSValue(), font->getSize());
00161                 }
00162 
00163                 // (Cacheable) Set the font to the PostScript font name.
00164                 virtual Bool setFont(const String &fontName);
00165                 // (Cacheable) Draw text using that font aligned in some way to the
00166                 // position
00167                 virtual void drawText(Int x, Int y, const String &text,
00168                                       Display::TextAlign alignment = Display::AlignCenter);
00169                 virtual void drawText(Int x, Int y, const String &text, const Float& angle,
00170                                       Display::TextAlign alignment = Display::AlignCenter);
00171                 // (Cacheable) Draw an array of 2D color data as a raster image for zoom = <1,1>
00172                 // <group>
00173                 virtual void drawImage(const Matrix<uInt> &data, Int x, Int y);
00174                 virtual void drawImage(const Matrix<Int> &data, Int x, Int y);
00175                 virtual void drawImage(const Matrix<uLong> &data, Int x, Int y);
00176                 virtual void drawImage(const Matrix<Float> &data, Int x, Int y);
00177                 virtual void drawImage(const Matrix<Double> &data, Int x, Int y);
00178                 // </group>
00179                 // <group>
00180                 // Draw a 2D color image with masking.
00181                 // (opaqueMask ignored; (unfortunately,) PSPixelcanvas always draws
00182                 // _opaque_ masks).
00183                 virtual void drawImage(const Int &x, const Int &y,
00184                                        const Matrix<uInt> &data,
00185                                        const Matrix<Bool> &mask,
00186                                        Bool opaqueMask=False);
00187                 // </group>
00188 
00189                 // (Cacheable) Draw an array of 2D color data as a raster image for any positive integer zoom
00190                 // <group>
00191                 virtual void drawImage(const Matrix<uInt> &data, Int x, Int y,
00192                                        uInt xzoom, uInt yzoom);
00193                 virtual void drawImage(const Matrix<Int> &data, Int x, Int y,
00194                                        uInt xzoom, uInt yzoom);
00195                 virtual void drawImage(const Matrix<uLong> &data, Int x, Int y,
00196                                        uInt xzoom, uInt yzoom);
00197                 virtual void drawImage(const Matrix<Float> &data, Int x, Int y,
00198                                        uInt xzoom, uInt yzoom);
00199                 virtual void drawImage(const Matrix<Double> &data, Int x, Int y,
00200                                        uInt xzoom, uInt yzoom);
00201                 // </group>
00202 
00203                 // (Cacheable) Draw a component of a multi-channel image, storing it
00204                 // in buffers until flushComponentImages() is called.
00205                 virtual void drawImage(const Matrix<uInt> &data, const Int &x, const Int &y,
00206                                        const Display::ColorComponent &colorcomponent);
00207 
00208                 // Fill one of the channel buffers.
00209                 void bufferComponent(const Matrix<uInt> &data,
00210                                      const Int &x, const Int &y,
00211                                      const Display::ColorComponent &colorcomponent);
00212 
00213                 // (NOT CACHEABLE!) Flush the component buffers.
00214                 void flushComponentBuffers();
00215 
00216                 // (Cacheable) Draw a single point using current color
00217                 // <group>
00218                 virtual void drawPoint(Int x1, Int y1);
00219                 virtual void drawPoint(Float x1, Float y1);
00220                 virtual void drawPoint(Double x1, Double y1);
00221                 // </group>
00222 
00223                 // (Cacheable) Draw N points specified as a Nx2 matrix
00224                 // <group>
00225                 virtual void drawPoints(const Matrix<Int> &verts);
00226                 virtual void drawPoints(const Matrix<Float> &verts);
00227                 virtual void drawPoints(const Matrix<Double> &verts);
00228                 // </group>
00229 
00230                 // (Cacheable) Draw a bunch of points using current color
00231                 // <group>
00232                 virtual void drawPoints(const Vector<Int> &x1, const Vector<Int> &y1);
00233                 virtual void drawPoints(const Vector<Float> &x1, const Vector<Float> &y1);
00234                 virtual void drawPoints(const Vector<Double> &x1,
00235                                         const Vector<Double> &y1);
00236                 // </group>
00237 
00238                 // (Cacheable) Draw a single line using current color
00239                 // <group>
00240                 virtual void drawLine(Int x1, Int y1, Int x2, Int y2);
00241                 virtual void drawLine(Float x1, Float y1, Float x2, Float y2);
00242                 virtual void drawLine(Double x1, Double y1, Double x2, Double y2);
00243                 // </group>
00244 
00245                 // (Cacheable) Draw N/2 lines from an Nx2 matrix
00246                 // <group>
00247                 virtual void drawLines(const Matrix<Int> &verts);
00248                 virtual void drawLines(const Matrix<Float> &verts);
00249                 virtual void drawLines(const Matrix<Double> &verts);
00250                 // </group>
00251 
00252                 // (Cacheable) Draw a bunch of unrelated lines using current color
00253                 // <group>
00254                 virtual void drawLines(const Vector<Int> &x1, const Vector<Int> &y1,
00255                                        const Vector<Int> &x2, const Vector<Int> &y2);
00256                 virtual void drawLines(const Vector<Float> &x1, const Vector<Float> &y1,
00257                                        const Vector<Float> &x2, const Vector<Float> &y2);
00258                 virtual void drawLines(const Vector<Double> &x1, const Vector<Double> &y1,
00259                                        const Vector<Double> &x2, const Vector<Double> &y2);
00260                 // </group>
00261 
00262                 // (Cacheable) Draw a single connected line between the points given
00263                 // <group>
00264                 virtual void drawPolyline(const Vector<Int> &x1, const Vector<Int> &y1);
00265                 virtual void drawPolyline(const Vector<Float> &x1,
00266                                           const Vector<Float> &y1);
00267                 virtual void drawPolyline(const Vector<Double> &x1,
00268                                           const Vector<Double> &y1);
00269                 // </group>
00270                 // <group>
00271                 virtual void drawPolylines(const Vector<Int> &x1, const Vector<Int> &y1,
00272                                            const int close=0, const int fill=0);
00273                 virtual void drawPolylines(const Vector<Float> &x1,
00274                                            const Vector<Float> &y1,
00275                                            const int close=0, const int fill=0);
00276                 virtual void drawPolylines(const Vector<Double> &x1,
00277                                            const Vector<Double> &y1,
00278                                            const int close=0, const int fill=0);
00279                 // </group>
00280 
00281                 // (Cacheable) Draw N-1 connected lines from Nx2 matrix of vertices
00282                 // <group>
00283                 virtual void drawPolyline(const Matrix<Int> &verts);
00284                 virtual void drawPolyline(const Matrix<Float> &verts);
00285                 virtual void drawPolyline(const Matrix<Double> &verts);
00286                 // </group>
00287 
00288                 // (Cacheable) Draw N-1 connected lines from Nx2 matrix of vertices
00289                 // <group>
00290                 virtual void drawPolylines(const Matrix<Int> &verts,
00291                                            const int close=0, const int fill=0);
00292                 virtual void drawPolylines(const Matrix<Float> &verts,
00293                                            const int close=0, const int fill=0);
00294                 virtual void drawPolylines(const Matrix<Double> &verts,
00295                                            const int close=0, const int fill=0);
00296                 // </group>
00297 
00298                 // (Cacheable) Draw a closed polygon
00299                 // <group>
00300                 virtual void drawPolygon(const Vector<Int> &x1, const Vector<Int> &y1);
00301                 virtual void drawPolygon(const Vector<Float> &x1, const Vector<Float> &y1);
00302                 virtual void drawPolygon(const Vector<Double> &x1,
00303                                          const Vector<Double> &y1);
00304                 // </group>
00305 
00306                 // (Cacheable) Draw and fill a closed polygon
00307                 // <group>
00308                 virtual void drawFilledPolygon(const Vector<Int> &x1,
00309                                                const Vector<Int> &y1);
00310                 virtual void drawFilledPolygon(const Vector<Float> &x1,
00311                                                const Vector<Float> &y1);
00312                 virtual void drawFilledPolygon(const Vector<Double> &x1,
00313                                                const Vector<Double> &y1);
00314                 // </group>
00315 
00316                 // (Cacheable) Draw a closed N-sided polygon from Nx2 matrix of vertices
00317                 // <group>
00318                 virtual void drawPolygon(const Matrix<Int> &verts);
00319                 virtual void drawPolygon(const Matrix<Float> &verts);
00320                 virtual void drawPolygon(const Matrix<Double> &verts);
00321                 // </group>
00322 
00323                 // (Cacheable) Draw a rectangle
00324                 // <group>
00325                 virtual void drawRectangle(Int x1, Int y1, Int x2, Int y2, const int fill);
00326                 virtual void drawRectangle(Float x1, Float y1, Float x2, Float y2,
00327                                            const int fill);
00328                 virtual void drawRectangle(Double x1, Double y1, Double x2, Double y2,
00329                                            const int fill);
00330                 // </group>
00331 
00332                 // (Cacheable) Draw a rectangle
00333                 // <group>
00334                 virtual void drawRectangle(Int x1, Int y1, Int x2, Int y2);
00335                 virtual void drawRectangle(Float x1, Float y1, Float x2, Float y2);
00336                 virtual void drawRectangle(Double x1, Double y1, Double x2, Double y2);
00337                 // </group>
00338 
00339                 // (Cacheable) Draw a filled rectangle
00340                 // <group>
00341                 virtual void drawFilledRectangle(Int x1, Int y1, Int x2, Int y2);
00342                 virtual void drawFilledRectangle(Float x1, Float y1, Float x2, Float y2);
00343                 virtual void drawFilledRectangle(Double x1, Double y1, Double x2,
00344                                                  Double y2);
00345                 // </group>
00346 
00347                 // (Cacheable) Draw a set of points, specifying a color per point to be drawn.
00348                 // <group>
00349                 virtual void drawColoredPoints(const Vector<Int> &x1,
00350                                                const Vector<Int> &y1,
00351                                                const Vector<uInt> &colors);
00352                 virtual void drawColoredPoints(const Vector<Float> &x1,
00353                                                const Vector<Float> &y1,
00354                                                const Vector<uInt> &colors);
00355                 virtual void drawColoredPoints(const Vector<Double> &x1,
00356                                                const Vector<Double> &y1,
00357                                                const Vector<uInt> &colors);
00358                 virtual void drawColoredPoints(const Matrix<Int> &xy,
00359                                                const Vector<uInt> &colors);
00360                 virtual void drawColoredPoints(const Matrix<Float> &xy,
00361                                                const Vector<uInt> &colors);
00362                 virtual void drawColoredPoints(const Matrix<Double> &xy,
00363                                                const Vector<uInt> &colors);
00364                 // </group>
00365 
00366                 // (Cacheable) Draw a set of lines, specifying a color per line to be drawn.
00367                 // <group>
00368                 virtual void drawColoredLines(const Vector<Int> &x1,
00369                                               const Vector<Int> &y1,
00370                                               const Vector<Int> &x2,
00371                                               const Vector<Int> &y2,
00372                                               const Vector<uInt> &colors);
00373                 virtual void drawColoredLines(const Vector<Float> &x1,
00374                                               const Vector<Float> &y1,
00375                                               const Vector<Float> &x2,
00376                                               const Vector<Float> &y2,
00377                                               const Vector<uInt> &colors);
00378                 virtual void drawColoredLines(const Vector<Double> &x1,
00379                                               const Vector<Double> &y1,
00380                                               const Vector<Double> &x2,
00381                                               const Vector<Double> &y2,
00382                                               const Vector<uInt> &colors);
00383                 // </group>
00384 
00385                 // Set Graphics Attributes
00386                 // Options for functions with enum argument
00387                 // listed in <linkto class=Display>DisplayEnums</linkto>
00388                 // <group>
00389                 virtual void setDrawFunction(Display::DrawFunction function);
00390                 virtual void setForeground(uLong color);
00391                 virtual void setBackground(uLong color);
00392                 //virtual void setLineWidth(uInt width);
00393                 virtual void setLineWidth(Float width);
00394                 void lineWidth(Float width);
00395                 float lineWidth()const {
00396                         return lineWidth_;
00397                 }
00398                 virtual void setLineStyle(Display::LineStyle style);
00399                 virtual void setCapStyle(Display::CapStyle style);
00400                 virtual void setJoinStyle(Display::JoinStyle style);
00401                 virtual void setFillStyle(Display::FillStyle style);
00402                 virtual void setFillRule(Display::FillRule rule);
00403                 virtual void setArcMode(Display::ArcMode mode);
00404                 // </group>
00405 
00406                 // Get Graphics Attributes
00407                 // <group>
00408                 virtual Display::DrawFunction getDrawFunction() const;
00409                 virtual uLong                 getForeground()   const;
00410                 virtual uLong                 getBackground()   const;
00411                 //#virtual uInt                getLineWidth()    const;
00412                 virtual Float                 getLineWidth()    const;
00413                 virtual Display::LineStyle    getLineStyle()    const;
00414                 virtual Display::CapStyle     getCapStyle()     const;
00415                 virtual Display::JoinStyle    getJoinStyle()    const;
00416                 virtual Display::FillStyle    getFillStyle()    const;
00417                 virtual Display::FillRule     getFillRule()     const;
00418                 virtual Display::ArcMode      getArcMode()      const;
00419                 // </group>
00420 
00421                 // (Cacheable) Option Control
00422                 // Options listed in <linkto class=Display>DisplayEnums</linkto>
00423                 // <group>
00424                 virtual Bool enable(Display::Option option);
00425                 virtual Bool disable(Display::Option option);
00426                 // </group>
00427 
00428                 // Control the image-caching strategy
00429                 virtual void setImageCacheStrategy(Display::ImageCacheStrategy strategy);
00430                 virtual Display::ImageCacheStrategy imageCacheStrategy() const;
00431 
00432                 // (Cacheable) Setup the clip window.  The clip window, when enabled, allows
00433                 // a user to clip all graphics output to a rectangular region on
00434                 // the screen.
00435                 // Once set, it is only possible to REDUCE the size of the current clip
00436                 // window, not increase it.
00437                 // <group>
00438                 virtual void setClipWindow(Int x1, Int y1, Int x2, Int y2);
00439                 virtual void getClipWindow(Int &x1, Int &y1, Int &x2, Int &y2);
00440                 // </group>
00441 
00442                 // (Not Cacheable) Redraw the window
00443                 // <group>
00444                 virtual void refresh(const Display::RefreshReason &reason =
00445                                          Display::UserCommand,
00446                                      const Bool &explicitrequest = True);
00447                 // </group>
00448 
00449                 // Cause display to flush any graphics commands not yet drawn
00450                 virtual void flush();
00451 
00452                 // (Cacheable) Clear the window using the background color
00453                 // <group>
00454                 virtual void clear();
00455                 virtual void clear(Int x1, Int y1, Int x2, Int y2);
00456                 // </group>
00457 
00458                 // (Cacheable) Set the color to use for clearing the display
00459                 // <group>
00460                 virtual void setClearColor(uInt colorIndex);
00461                 virtual void setClearColor(const String &colorname);
00462                 virtual void setClearColor(float r, float g, float b);
00463                 // </group>
00464 
00465                 // (Not Cacheable) Get the current color to use for clearing the display.
00466                 virtual uInt clearColor() const;
00467                 virtual void getClearColor(float &r, float &g, float &b) const;
00468 
00469                 // Return the width of the PSPixelCanvas in pixels
00470                 virtual uInt width() const;
00471                 // Return the height of the PSPixelCanvas in pixels
00472                 virtual uInt height() const;
00473                 // Return the depth of the PSPixelCanvas in bits
00474                 virtual uInt depth() const;
00475 
00476                 // Get the pixel density (in dots per inch [dpi]) of the PixelCanvas
00477                 virtual void pixelDensity(Float &xdpi, Float &ydpi) const;
00478 
00479                 // (Cacheable) Set current color (works in RGB or colormap mode)
00480                 // <group>
00481                 virtual void setColor(uInt colorIndex);
00482                 virtual void setColor(const String &colorname);
00483                 virtual void setRGBColor(float r, float g, float b);
00484                 virtual void setHSVColor(float h, float s, float v);
00485                 // </group>
00486 
00487                 // (Not Cacheable) Returns the current color as a color index
00488                 virtual uInt color() const;
00489 
00490                 // (Not Cacheable) Retuns the current color as an RGB triple
00491                 virtual void getColor(float &r, float &g, float &b) const;
00492                 virtual Bool getColorComponents(const String &colorname,
00493                                                 Float &r, Float &g, Float &b);
00494                 // (Not Cacheable) Get color index value (works in RGB or colormap mode)
00495                 // <group>
00496                 virtual Bool getColor(Int x, Int y, uInt &color);
00497                 virtual Bool getRGBColor(Int x, Int y, float &r, float &g, float &b);
00498                 virtual Bool getHSVColor(Int x, Int y, float &h, float &s, float &v);
00499                 // </group>
00500                 // Get/set the current foreground/background colors.  These colors
00501                 // should be used when the special Strings "foreground" and "background"
00502                 // are given for a color.
00503                 // <group>
00504                 virtual void setDeviceForegroundColor(const String colorname);
00505                 virtual String deviceForegroundColor() const;
00506                 virtual void setDeviceBackgroundColor(const String colorname);
00507                 virtual String deviceBackgroundColor() const;
00508                 // </group>
00509 
00510                 // <group>
00511                 // (Not Cacheable) resize request.  returns true if window was resized.
00512                 // Will refresh if doCallbacks is True.
00513                 virtual Bool resize(uInt reqXSize, uInt reqYSize, Bool doCallbacks = True);
00514 
00515                 // (Not Cacheable) resize the colortable by requesting a new number of cells
00516                 virtual Bool resizeColorTable(uInt newSize);
00517 
00518                 // (Not Cacheable) resize the colortable by requesting a new RGB/HSV cube
00519                 virtual Bool resizeColorTable(uInt nReds, uInt nGreens, uInt nBlues);
00520 
00521                 // Need a mechanism to return the PSPixelCanvasColorTable so
00522                 // drawing functions within classes can operate.
00523                 virtual PixelCanvasColorTable * pcctbl() const;
00524 
00525                 virtual void setPcctbl(PixelCanvasColorTable * pcctbl);
00526                 PSPixelCanvasColorTable *PSpcctbl()const {
00527                         return pcct_;
00528                 }
00529                 // </group>
00530 
00531                 // save/restore the current translation.  This is called pushMatrix because
00532                 // eventually we may want scaling or rotation to play a modest
00533                 // role here.
00534                 // <group>
00535                 virtual void pushMatrix();
00536                 virtual void popMatrix();
00537                 // </group>
00538                 // zero the current translation
00539                 virtual void loadIdentity();
00540 
00541                 // translation functions
00542                 // translate applies a relative translation to the current matrix and
00543                 // can be used to position graphics.  Together with pushMatrix and
00544                 // popMatrix it can be used to build heirarchical scenes.
00545                 // <group>
00546                 virtual void translate(Int xt, Int yt);
00547                 virtual void getTranslation(Int &xt, Int &yt) const;
00548                 virtual Int xTranslation() const;
00549                 virtual Int yTranslation() const;
00550                 // </group>
00551 
00552                 // (Not cacheable) set the draw buffer
00553                 // None of the buffer routines are supported.
00554                 virtual void setDrawBuffer(Display::DrawBuffer buf);
00555                 // buffer memory exchanges
00556                 // (Not cacheable)
00557                 // <group>
00558                 virtual void copyBackBufferToFrontBuffer();
00559                 virtual void copyFrontBufferToBackBuffer();
00560                 virtual void swapBuffers();
00561                 // </group>
00562 
00563                 // partial buffer memory exchanges.  (x1,y1 are blc, x2,y2 are trc)
00564                 // <group>
00565                 virtual void copyBackBufferToFrontBuffer(Int x1, Int y1, Int x2, Int y2);
00566                 virtual void copyFrontBufferToBackBuffer(Int x1, Int y1, Int x2, Int y2);
00567                 virtual void swapBuffers(Int x1, Int y1, Int x2, Int y2);
00568                 // </group>
00569 
00570 //#  ////////////////////////////////////////////////////////////////
00571                 //              PSPixelCanvas specific misc. functions.
00572 
00573 //#  // Converts from "pixels" to points.
00574 //# //<group>
00575 //#   inline float xToPoints(const double x)const{return (float)(x*xppp_);}
00576 //#   inline float yToPoints(const double y)const{return (float)(y*yppp_);}
00577 //# //</group>
00578 //#   // Convert from points to pixels.
00579 //# //<group>
00580 //#   inline double pointsToX(const float x)const{return (double)(x/xppp_);}
00581 //#   inline double pointsToY(const float y)const{return (double)(y/yppp_);}
00582 //# //</group>
00583 
00584                 // Draw a scaled image on PostScript canvas.
00585                 void drawPSImage(const int x, const int y,
00586                                  const int iwidth, const int iheight,
00587                                  const float xzoom, const float yzoom,
00588                                  const uShort *data, const int bpc,
00589                                  const Display::ColorModel=Display::Index);
00590                 // Set/get declared resolution in pixels per supplied dimension.
00591 //<group>
00592                 void setResolution(const float xres, const float yres,
00593                                    const PSDriver::Dimension = PSDriver::INCHES);
00594                 void getResolution(float &xres, float &yres,
00595                                    const PSDriver::Dimension = PSDriver::INCHES)const;
00596 //</group>
00597                 // Whether to enable pixel interpolation for drawImage().
00598 //<group>
00599                 void smooth(const Bool smth) {
00600                         smooth_ = smth;
00601                 }
00602                 Bool smooth()const {
00603                         return smooth_;
00604                 }
00605 //</group>
00606                 // Whether to put tracing comments in the output.
00607 //<group>
00608                 Bool annotate()const {
00609                         return annotate_;
00610                 }
00611                 void annotate(const Bool a) {
00612                         annotate_ = a;
00613                 }
00614 //</group>
00615 
00616                 virtual Float pixelScaling() const;
00617 
00618 //#  ////////////////////////////////////////////////////////////////
00619 
00620         protected:
00621 
00622 
00623         private:
00624                 void pspcinit(PSDriver *ps, PSPixelCanvasColorTable * );
00625                 void clearRectangle(const float x0, const float y0,
00626                                     const float x1, const float y1);
00627 // Used in annotating output file.
00628 //<group>
00629                 void note(const char *);
00630                 void note(const char *, const uLong);
00631 //</group>
00632         private:
00633                 PSPixelCanvasColorTable *pcct_;
00634                 PSDriver                *ps;
00635                 float                   xppp_, yppp_; // # Of points per pixel.
00636                 float                   lineWidth_;
00637                 Display::LineStyle      lineStyle_;
00638                 Display::CapStyle       capStyle_;
00639                 Display::JoinStyle      joinStyle_;
00640                 Display::FillStyle      fillStyle_;
00641                 Display::FillRule       fillRule_;
00642                 Display::ArcMode        arcMode_;
00643                 String                  defaultForegroundColorName_;
00644                 String                  defaultBackgroundColorName_;
00645                 // Color indexes the three colors we know about.
00646                 uLong                   foreground_, background_, clearColor_;
00647                 float                   xt_, yt_;
00648                 float                   clipx0_, clipy0_, clipx1_, clipy1_;
00649                 Bool                    haveClipInfo_;
00650                 Bool                    clipEnabled_;
00651                 Bool                    smooth_;
00652                 Bool                    annotate_;
00653                 // Component support
00654                 Float itsComponentX, itsComponentY;
00655                 uLong itsComponentWidth, itsComponentHeight;
00656                 Int itsComponentBPC;
00657                 uShort *itsComponents; // Length = 3*width*height.
00658         };
00659 
00660 
00661 } //# NAMESPACE CASA - END
00662 
00663 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1