Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

qsdrv.h

00001 /***************************************************************************
00002                                 qsdrv.h
00003                              -------------------                                         
00004     begin                : 01-January-2000
00005     copyright            : (C) 2000 by Kamil Dobkowski                         
00006     email                : kamildobk@poczta.onet.pl                                     
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   * 
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #ifndef QSGDRIVER_H
00020 #define QSGDRIVER_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025 
00026 #include "qscoord.h"
00027 #include "qsgattr.h"
00028 #include "qsprojection.h"
00029 
00030 //------------------------------------------------------------------------------------------------//
00031 
00040 class QSCanvasDrv : public Qt
00041  {
00042   public:
00043 
00044    double dpi;
00048    inline double toPixels( double points ) { return QSCoord::pointsToPixels(points,dpi); }
00052    inline double toPoints( double pixels ) { return QSCoord::pixelsToPoints(pixels,dpi); }
00056    QSCanvasDrv();
00060    virtual ~QSCanvasDrv();
00064     virtual QSCanvasDrv *copy() = 0;
00069     virtual void startDrawing();
00073     virtual void stopDrawing();
00077     virtual void drawLine( const QSPt2f &one, const QSPt2f &two ) = 0;
00081     virtual void drawRect( const QSPt2f &p1, const QSPt2f &p2 ) = 0;
00086     virtual void drawPoly( const QSPt2f pts[], int npoints, const bool edges[] = NULL, int edgesAutoColor = 0 ) = 0;
00090     virtual void drawEllipse( const QSPt2f& p1, const QSPt2f& p2 ) = 0;
00094     virtual void drawText( const QSPt2f &pos, const QString& text, int align = AlignLeft | AlignBottom ) = 0;
00099     virtual QSPt2f textSize( const QString& text ) = 0;
00103     virtual void drawRText( const QSPt2f &pos, int angle, const QString& text, int align = AlignLeft | AlignBottom ) = 0;
00107     virtual void drawRTextBox( const QSPt2f &pos, int angle, const QString& text, int align = AlignLeft | AlignBottom );
00111     virtual void getRTextBoundingPoly(  QSPt2f outPts[4], const QSPt2f &pos, int angle, const QString& text, int align = AlignLeft | AlignBottom ) = 0;
00115     virtual QSPt2f rTextSize(  int angle, const QString& text );
00121     virtual void drawPoint( const QSPt2f& pos, const QSGPoint& style );
00126     virtual void drawDart( const QSPt2f& pos, double angle, const QSGArrow& style );
00131     virtual void drawArrow( const QSPt2f& p1, const QSPt2f& p2, const QSGArrow& p1style, const QSGArrow& p2style );
00135     virtual void setFill( const QSGFill &f ) = 0;
00139     virtual void setFont( const QSGFont &f ) = 0;
00143     virtual void setLine( const QSGLine &l ) = 0;
00147     virtual QSGFont currentFont() { return QSGFont(); }
00151     virtual QSGFill currentFill() { return QSGFill(); }
00155     virtual QSGLine currentLine() { return QSGLine(); }
00156 
00157     //----------------------------------------------------------------------//
00158     // 2D DRIVER
00162     virtual void beginPolyline( const QSPt2f& pos ) = 0;
00166     virtual void drawPolylineTo( const QSPt2f& pos ) = 0;
00170     virtual void endPolyline() {}
00174     virtual QSPt2f currPolylinePos() { return QSPt2f(); }
00178     struct PixmapBuffer {
00191          unsigned char *ptr;
00196          int lo;
00200          int po;
00204          int co;
00209          int lines;
00210         };
00217     virtual void getPixmapBuffer( PixmapBuffer *buff, int pwidth, int pheight );
00223     virtual void drawPixmap( const QSPt2f& pos, PixmapBuffer *data );
00224  };
00225 
00226 
00227 //------------------------------------------------------------------------------------------------//
00228 
00240 class QSDrv : public QSCanvasDrv
00241   {
00242    public:
00246     enum CNormals { VertexNormals, MeshNormal, NoNormals };
00250     enum CColors { VertexColors, MeshColor };
00254     enum COrdering { FurtherFirst, NearerFirst, NoOrdering };
00258    QSDrv();
00262    virtual ~QSDrv();
00266     virtual QSDrv *copy() = 0;
00270     void copySettingsFrom( const QSDrv *drv );
00275     virtual void setProjection( const QSProjection *t );
00279     const QSProjection *projection() const { return m_t; }
00283    virtual void startDrawing();
00287     virtual void stopDrawing();
00292     virtual void setClipping( bool enabled );
00296     bool clipping() const { return m_clipping ; }
00304     virtual void setCurrentElement( int category, int element );
00308     int currentElement() const { return m_element; }
00312     int currentCategory() const { return m_category; }
00316     virtual void setTopBottom( bool enabled );
00320     bool topBottom() const { return m_top_bottom; }
00324     virtual void setBottomFill( const QSGFill& fill );
00328     QSGFill bottomFill() const { return m_bottom_fill; }
00332     virtual CNormals cNormals() const { return MeshNormal; }
00336     virtual CColors cColors() const { return MeshColor; }
00340     virtual COrdering cOrdering() const { return FurtherFirst; }
00341 
00342     //----------------------------------------------------------------------//
00343     // 2D DRIVER
00347     virtual void clearCanvas( const QSGFill& f, const QSPt2f& pos, const QSPt2f& size );
00351     virtual void drawLine2( const QSPt2f &one, const QSPt2f &two );
00355     virtual void drawRect2( const QSPt2f &p1, const QSPt2f &p2 );
00360     virtual void drawPoly2( const QSPt2f pts[], int npoints, const bool edges[] = NULL, int edgeAutoColor = 0 );
00364     virtual void drawEllipse2( const QSPt2f& p1, const QSPt2f& p2 );
00368     virtual void drawText2( const QSPt2f &pos, const QString& text, int align = AlignLeft | AlignBottom );
00372     virtual void drawRText2( const QSPt2f &pos, int angle, const QString& text, int align = AlignLeft | AlignBottom );
00376     virtual void drawRTextBox2( const QSPt2f &pos, int angle, const QString& text, int align = AlignLeft | AlignBottom );
00382     virtual void drawPoint2( const QSPt2f& pos, const QSGPoint& style );
00387     virtual void drawDart2( const QSPt2f& pos, double angle, const QSGArrow& style );
00392     virtual void drawArrow2( const QSPt2f& p1, const QSPt2f& p2, const QSGArrow& p1style, const QSGArrow& p2style );
00396     virtual void beginPolyline2( const QSPt2f& pos );
00400     virtual void setPolylineLabelPlace2( const QString& label, const QSPt2f& label_place, int label_angle );
00404     virtual void drawPolylineTo2( const QSPt2f& pos );
00408     virtual void endPolyline2();
00412     virtual QSPt2f currPolylinePos2();
00413 
00414     //----------------------------------------------------------------------//
00415     // 3D DRIVER
00416 
00431     virtual void drawPoly3( const QSPt3f pts[], int npoints,
00432                             const QSPt3f *norm, const QSGFill *colors,
00433                 const bool edges[] = NULL, int edgeAutoColor = 0 );
00438     virtual void drawLine3( const QSPt3f& begin, const QSPt3f& end, const QSPt3f norm[2] );
00443     virtual void drawText3( const QSPt3f& pos, const QString& text, int align = AlignLeft | AlignBottom );
00447     virtual void drawPoint3( const QSPt3f& pos, const QSGPoint& point );
00448 
00449 
00450    protected:
00451 
00452      int m_element;
00453      int m_category;    
00454      bool m_top_bottom;
00455      QSGFill m_bottom_fill;
00456 
00457      const QSProjection *m_t;
00458      bool      m_clipping;
00459      QSPt2f    m_curr_polyline_pos;
00460 
00461      // clipped 2d coordinates
00462      QSPt2f *m_cpts2;
00463      int     m_ncpts2;
00464      int     m_max_cpts2;
00465      QSProjection::ClipResult clip_poly( const QSPt2f *pts, int npoints, const bool edges[] );
00466 
00467      // clipped 3d coordinated
00468      QSPt3f *m_cpts3;
00469      int     m_ncpts3;
00470      int     m_max_cpts3;
00471      QSProjection::ClipResult clip_poly( const QSPt3f *pts, int npoints, const bool edges[] );
00472 
00473      // buffer for screen coordinates
00474      QSPt2f    *m_pts;
00475      int       m_max_pts;
00476      void map_to_screen( const QSPt2f *pts, int npoints );
00477      void map_to_screen( const QSPt3f *pts, int npoints );
00478 
00479      // clipped edges
00480      bool   *m_cedges;
00481      int    m_max_cedges;
00482 
00483      QSPt2f m_polyline_label_pos;
00484      QSPt2f m_polyline_label_size;
00485 
00486  };
00487 
00488 #endif
00489 
00490 
00491 
00492 
00493 
00494 
00495 
00496 
00497 
00498 
00499 
00500 
00501 
00502 
00503 
00504 
00505 
00506 
00507 
00508 
00509 
00510 
00511 
00512 
00513 
00514 
00515 
00516 
00517 
00518 
00519 
00520 
00521 
00522 
00523 
00524 
00525 
00526 
00527 
00528 
00529 

Generated on Mon Mar 18 19:16:32 2002 for KMatplot library by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002