Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/painter.h
00001 /**********************************************************************
00002   Painter - drawing spheres, cylinders and text
00003 
00004   Copyright (C) 2007 Benoit Jacob
00005   Copyright (C) 2007 Donald Ephraim Curtis
00006   Copyright (C) 2007-2008 Marcus D. Hanwell
00007   Copyright (C) 2010 Konstantin Tokarev
00008   Copyright (C) 2011 David C. Lonie
00009 
00010   This file is part of the Avogadro molecular editor project.
00011   For more information, see <http://avogadro.openmolecules.net/>
00012 
00013   Avogadro is free software; you can redistribute it and/or modify
00014   it under the terms of the GNU General Public License as published by
00015   the Free Software Foundation; either version 2 of the License, or
00016   (at your option) any later version.
00017 
00018   Avogadro is distributed in the hope that it will be useful,
00019   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021   GNU General Public License for more details.
00022 
00023   You should have received a copy of the GNU General Public License
00024   along with this program; if not, write to the Free Software
00025   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00026   02110-1301, USA.
00027  **********************************************************************/
00028 
00029 #ifndef PAINTER_H
00030 #define PAINTER_H
00031 
00032 #include <avogadro/global.h>
00033 #include <avogadro/primitive.h>
00034 
00035 class QColor;
00036 class QFont;
00037 
00038 namespace Avogadro
00039 {
00051   class Color;
00052   class Mesh;
00053   class A_EXPORT Painter
00054   {
00055   public:
00059     Painter();
00060 
00064     virtual ~Painter();
00065 
00071     virtual bool initialize();
00072 
00077     virtual bool finalize();
00078 
00082     virtual int quality() const = 0;
00083 
00088     virtual void setName(const Primitive *primitive) = 0;
00089 
00095     virtual void setName(Primitive::Type type, int id) = 0;
00096 
00101     virtual void setColor(const Color *color) = 0;
00102 
00107     virtual void setColor(const QColor *color) = 0;
00108 
00117     virtual void setColor(float red, float green, float blue, float alpha = 1.0) = 0;
00118 
00123     virtual void setColor(QString name) = 0;
00124 
00131     virtual void drawSphere(const Eigen::Vector3d &center, double radius) = 0;
00132 
00140     virtual void drawSphere(const Eigen::Vector3d *center, double radius);
00141 
00149     virtual void drawCylinder(const Eigen::Vector3d &end1,
00150                               const Eigen::Vector3d &end2,
00151                               double radius) = 0;
00152 
00175     virtual void drawMultiCylinder(const Eigen::Vector3d &end1,
00176                                    const Eigen::Vector3d &end2,
00177                                    double radius, int order, double shift) = 0;
00178 
00186     virtual void drawCone(const Eigen::Vector3d &base,
00187                           const Eigen::Vector3d &cap,
00188                           double baseRadius,
00189                           double capRadius = 0.0) = 0;
00190 
00197     virtual void drawLine(const Eigen::Vector3d &start,
00198                           const Eigen::Vector3d &end,
00199                           double lineWidth) = 0;
00200 
00213     virtual void drawMultiLine(const Eigen::Vector3d &start,
00214                                const Eigen::Vector3d &end, double lineWidth,
00215                                int order, short stipple) = 0;
00216 
00225     virtual void drawTriangle(const Eigen::Vector3d &p1,
00226                               const Eigen::Vector3d &p2,
00227                               const Eigen::Vector3d &p3) = 0;
00228 
00237     virtual void drawTriangle(const Eigen::Vector3d &p1,
00238                               const Eigen::Vector3d &p2,
00239                               const Eigen::Vector3d &p3,
00240                               const Eigen::Vector3d &n) = 0;
00241 
00248     virtual void drawSpline(const QVector<Eigen::Vector3d>& pts,
00249                             double radius) = 0;
00250 
00265     virtual void drawShadedSector(const Eigen::Vector3d & origin,
00266                                   const Eigen::Vector3d & direction1,
00267                                   const Eigen::Vector3d & direction2,
00268                                   double radius,
00269                                   bool alternateAngle = false) = 0;
00270 
00285     virtual void drawArc(const Eigen::Vector3d & origin,
00286                          const Eigen::Vector3d & direction1,
00287                          const Eigen::Vector3d & direction2, double radius,
00288                          double lineWidth, bool alternateAngle = false) = 0;
00289 
00298     virtual void drawShadedQuadrilateral(const Eigen::Vector3d & point1,
00299                                          const Eigen::Vector3d & point2,
00300                                          const Eigen::Vector3d & point3,
00301                                          const Eigen::Vector3d & point4) = 0;
00302 
00317     virtual void drawQuadrilateral(const Eigen::Vector3d & point1,
00318                                    const Eigen::Vector3d & point2,
00319                                    const Eigen::Vector3d & point3,
00320                                    const Eigen::Vector3d & point4,
00321                                    double lineWidth);
00322 
00334     virtual void drawLineLoop(const QList<Eigen::Vector3d> & points,
00335                               const double lineWidth);
00336 
00342     virtual void drawMesh(const Mesh & mesh, int mode = 0) = 0;
00343 
00349     virtual void drawColorMesh(const Mesh & mesh, int mode = 0) = 0;
00350 
00365     virtual int drawText(int x, int y, const QString &string) = 0;
00366 
00381     virtual int drawText(const QPoint& pos, const QString &string) = 0;
00382 
00397     virtual int drawText(const Eigen::Vector3d & pos,
00398                          const QString &string) = 0;
00399 
00413     virtual int drawText(const Eigen::Vector3d & /*pos*/,
00414                           const QString & /*string*/, const QFont & /*font*/) {
00415       return 0; }
00416 
00423     virtual void drawBox(const Eigen::Vector3d &corner1,
00424                          const Eigen::Vector3d &corner2) = 0;
00425 
00450     virtual void drawBoxEdges(const Eigen::Vector3d &offset,
00451                               const Eigen::Vector3d &v1,
00452                               const Eigen::Vector3d &v2,
00453                               const Eigen::Vector3d &v3,
00454                               const double linewidth);
00455 
00485     virtual void drawBoxEdges(const Eigen::Vector3d &c1,
00486                               const Eigen::Vector3d &c2,
00487                               const Eigen::Vector3d &c3,
00488                               const Eigen::Vector3d &c4,
00489                               const Eigen::Vector3d &c5,
00490                               const Eigen::Vector3d &c6,
00491                               const Eigen::Vector3d &c7,
00492                               const Eigen::Vector3d &c8,
00493                               const double linewidth);
00494 
00502     virtual void drawTorus(const Eigen::Vector3d &pos,
00503                            double majorRadius, double minorRadius) = 0;
00504 
00511     virtual void drawEllipsoid(const Eigen::Vector3d &position,
00512                                const Eigen::Matrix3d &matrix) = 0;
00513 
00521   };
00522 } // end namespace Avogadro
00523 
00524 #endif