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

qsaxes3d.h

00001 /***************************************************************************
00002                                   qsaxes3d.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 QSAXES3D_H
00020 #define QSAXES3D_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025 
00026 #include"qsaxes.h"
00027 #include"qsprojection3d.h"
00028 
00029 
00030 
00031 
00037 class QSAxes3D : public QSAxes
00038   {
00039    Q_OBJECT
00040     Q_PROPERTY( bool openGL READ openGL WRITE setOpenGL )
00041     Q_PROPERTY( bool glTransparency READ glTransparency WRITE glSetTransparency )
00042     Q_PROPERTY( int glGlobalTransparency READ glGlobalTransparency WRITE glSetGlobalTransparency )
00043     Q_PROPERTY( bool glShadeWalls READ glShadeWalls WRITE glSetShadeWalls )
00044     Q_PROPERTY( bool glMeshAutoStroke READ glMeshAutoStroke WRITE glSetMeshAutoStroke )
00045     Q_PROPERTY( int glAutoStrokeLightness READ glAutoStrokeLightness WRITE glSetAutoStrokeLightness )
00046     
00047     Q_PROPERTY( double xEdgeLength READ xEdgeLength WRITE setXEdgeLength )
00048     Q_PROPERTY( double yEdgeLength READ yEdgeLength WRITE setYEdgeLength )
00049     Q_PROPERTY( double zEdgeLength READ zEdgeLength WRITE setZEdgeLength )
00050     Q_PROPERTY( double xyWallThickness READ xyWallThickness WRITE setXYWallThickness )
00051     Q_PROPERTY( double xzWallThickness READ xzWallThickness WRITE setXZWallThickness )  
00052     Q_PROPERTY( double yzWallThickness READ yzWallThickness WRITE setYZWallThickness )
00053     
00054     Q_PROPERTY( int azimuth READ azimuth WRITE setAzimuth )
00055     Q_PROPERTY( int elevation READ elevation WRITE setElevation )
00056     Q_PROPERTY( int distance READ distance WRITE setDistance )
00057     Q_PROPERTY( int focusDistance READ focusDistance WRITE setFocusDistance )
00058     Q_PROPERTY( int lightAzimuth READ lightAzimuth WRITE setLightAzimuth )
00059     Q_PROPERTY( int lightElevation READ lightElevation WRITE setLightElevation )
00060     Q_PROPERTY( int directLight READ directLight WRITE setDirectLight )
00061     Q_PROPERTY( int ambientLight READ ambientLight WRITE setAmbientLight )
00062 
00063     Q_PROPERTY( bool perspective READ perspective WRITE setPerspective )
00064     Q_PROPERTY( bool autoscale READ autoscale WRITE setAutoscale )
00065     Q_PROPERTY( bool light READ light WRITE setLight )
00066 
00067 
00068    public:
00072      QSAxes3D(QObject* parent=0, const char * name=0);
00076      virtual ~QSAxes3D();
00080      void stop();
00084      void setOpenGL( bool enabled );
00088      bool openGL() const { return m_gl.enabled; }
00092      void glSetTransparency( bool enabled );
00096      void glSetGlobalTransparency( int value );
00100      void glSetShadeWalls( bool enabled );
00104      void glSetMeshAutoStroke( bool enable );
00108      void glSetAutoStrokeLightness( int value );
00112      bool glTransparency() const { return m_gl.transparency; }
00116      bool glShadeWalls() const { return m_gl.shadewalls; }
00120      int glGlobalTransparency() const { return m_gl.globaltr; }
00124      bool glMeshAutoStroke() const { return m_gl.autostroke; }
00128      int glAutoStrokeLightness() const { return m_gl.autostrokel; }
00132      void setEdgeLength( double xEdge, double yEdge, double zEdge );
00136      void setXEdgeLength( double lenght );
00140      void setYEdgeLength( double lenght );
00144      void setZEdgeLength( double lenght );
00148      double xEdgeLength() const { return m_view.xEdge; }
00152      double yEdgeLength() const { return m_view.yEdge; }
00156      double zEdgeLength() const { return m_view.zEdge; }
00160      void setWallThickness( double xy, double xz, double yz );
00164      void setXYWallThickness( double thickness );
00168      void setXZWallThickness( double thickness );
00172      void setYZWallThickness( double thickness );
00176      double xyWallThickness() const { return m_view.xyThick; }
00180      double xzWallThickness() const { return m_view.xzThick; }
00184      double yzWallThickness() const { return m_view.yzThick; }
00188      int azimuth() const { return m_view.azimuth; }
00192      int elevation() const { return m_view.elevation; }
00196      int distance() const { return m_view.distance; }
00200      int focusDistance() const { return m_view.focus; }
00204        int lightAzimuth() const { return m_view.lightAzimuth; }
00208        int lightElevation() const { return m_view.lightElevation; }
00212      int directLight() const { return m_view.directLight; }
00216      int ambientLight() const { return m_view.ambientLight; }
00220      void setPerspective( bool enabled );
00227      void setAutoscale( bool enabled );
00231      void setLight( bool enabled );
00235      bool light() const { return m_view.lighted; }
00239      bool perspective() const { return m_view.perspective; }
00243      bool autoscale() const { return m_view.autoscale; }
00247      void defaultSettings();
00251      const QSProjection3D *p3D() const { return &t; }
00255      virtual void initMappings( QSDrv *drv );
00260      virtual QSPt3f mixedToCanvas( const QSPt3f& pos, CoordinateSystem in_coords[3], double dpi, QSAxis *xAxis, QSAxis *yAxis, QSAxis *zAxis ) const;
00265      virtual QSPt3f canvasToMixed( const QSPt3f& pos, CoordinateSystem out_coords[3], double dpi, QSAxis *xAxis, QSAxis *yAxis, QSAxis *zAxis ) const;
00269      virtual void paintPlot( QPainter *p, double dpi=72.0, bool blocking=true, bool transparent=true );
00273      virtual void drawPlot( QSDrv *drv, bool blocking=true, bool transparent=true );
00277      virtual void paintSkeleton( QPainter *p, double dpi=72.0, bool reallyFast=false );
00281      enum FillElement {
00282                         BWallFill,
00283                         RWallFill,
00284             XYWallFill,
00285             XZWallFill,
00286             YZWallFill
00287                        };
00291      enum LineElement { BoxLine   = 0,
00292                         TicsLine,
00293             XYWallLine,
00294             XZWallLine,
00295             YZWallLine
00296                       };
00297 
00298     virtual void loadStateFromStream( QDataStream& stream, QSObjectFactory *factory );
00299     virtual void saveStateToStream( QDataStream& stream, QSObjectFactory *factory );
00300 
00301    public slots:
00305      void setAzimuth( int angle );
00309      void setElevation( int angle );
00316      void setDistance( int d );
00324      void setFocusDistance( int d );
00331      void setLightAzimuth( int azimuth );
00337      void setLightElevation( int elevation );
00343      void setDirectLight( int lightness );
00348      void setAmbientLight( int lightness );
00349 
00350     protected:
00351      virtual void axisRangesCalculated();
00352      virtual void allocRuntimeData();
00353      virtual void freeRuntimeData();
00354      virtual void drawAxis( QSAxis *axis );
00355      virtual void drawGrid( QSAxis *axis, bool major );
00356 
00357     private:
00358      // drawing parameters
00359      struct view_t {
00360 
00361            int  azimuth;
00362            int  elevation;
00363            int  distance;
00364            int  focus;
00365            int  lightAzimuth;
00366            int  lightElevation;
00367            int  directLight;
00368            int  ambientLight;
00369            bool lighted;
00370            bool perspective;
00371            bool autoscale;
00372        double xEdge;
00373        double yEdge;
00374        double zEdge;
00375        double xyThick;
00376        double xzThick;
00377        double yzThick;
00378           } m_view;
00379 
00380      struct gl_t {
00381          bool enabled;
00382          bool transparency;
00383          bool autostroke;
00384          bool shadewalls;
00385          int autostrokel;
00386          int globaltr;
00387         } m_gl;
00388 
00389      QSProjection3D t;
00390      QSDrv::CNormals  m_cnormals;
00391      QSDrv::CColors   m_ccolors;
00392      QSDrv::COrdering m_corder;
00393 
00394     class qsaxes3d_runtime_data;
00395      qsaxes3d_runtime_data *d;
00396 
00397      bool m_is_graphics_active;
00398      void init_3dtr();
00399      void draw_arrow();
00400      void draw_box();
00401      void draw_grid( QSAxis *axis, bool major, QSPt3f p[4], QSPt3f norm[5] );
00402      void draw_line( QSPt3f p1, QSPt3f p2, QSPt3f *normals = NULL );
00403      void get_side_wall( const QSPt3f& p1, const QSPt3f& p2, int side_nr, QSPt3f result_pts[4], QSPt3f result_norm[5] );
00404      void get_axis_wall( int wall_nr, QSPt3f *p1, QSPt3f *p2, bool *visible );
00405      void get_axis_lengths( double *xaxis_scale, double *yaxis_scale, double *zaxis_scale );
00406      void get_cube_min_max( QSPt3f* min, QSPt3f *max );
00407      int get_label_align( const QSPt3f& p1, const QSPt3f& p2, int axis );
00408      bool visible( const QSPt3f& p, const QSPt3f& norm );
00409      double opposite_side( double value );
00410      QSPt3f thickness( int wall_nr );
00411      bool point_on_side( const QSPt3f& p, int side );
00412 
00413   };
00414 
00421 #endif
00422 
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430 
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00446 
00447 
00448 
00449 
00450 
00451 
00452 
00453 
00454 
00455 
00456 
00457 
00458 
00459 
00460 
00461 
00462 
00463 
00464 
00465 
00466 
00467 
00468 
00469 
00470 
00471 
00472 
00473 
00474 
00475 
00476 
00477 
00478 
00479 
00480 
00481 
00482 
00483 
00484 
00485 
00486 
00487 
00488 
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 
00530 
00531 
00532 
00533 
00534 
00535 
00536 
00537 
00538 
00539 
00540 
00541 
00542 
00543 
00544 
00545 
00546 
00547 
00548 
00549 
00550 
00551 
00552 
00553 
00554 
00555 
00556 
00557 
00558 
00559 
00560 
00561 
00562 

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