ctkTransferFunctionItem.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 
00021 #ifndef __ctkTransferFunctionItem_h
00022 #define __ctkTransferFunctionItem_h
00023 
00025 #include <QGraphicsObject>
00026 
00028 #include "CTKWidgetsExport.h"
00029 #include "ctkPimpl.h"
00030 #include "ctkTransferFunction.h"
00031 
00032 class ctkControlPoint;
00033 class ctkTransferFunctionItemPrivate;
00034 
00037 class CTK_WIDGETS_EXPORT ctkTransferFunctionItem: public QGraphicsObject
00038 {
00039   Q_OBJECT
00040 public:
00041   ctkTransferFunctionItem(QGraphicsItem* parent = 0);
00042   ctkTransferFunctionItem(ctkTransferFunction* transferFunction, 
00043                                   QGraphicsItem* parent = 0);
00044   virtual ~ctkTransferFunctionItem();
00045 
00046   void setTransferFunction(ctkTransferFunction* transferFunction);
00047   ctkTransferFunction* transferFunction()const;
00048 
00049   inline void setRect(qreal x, qreal y, qreal width, qreal height);
00050   void setRect(const QRectF& rectangle);
00051   QRectF rect()const;
00052 
00053   qreal rangeXDiff();
00054   qreal rangeXOffSet();
00055 
00056   qreal rangeYDiff();
00057   qreal rangeYOffSet();
00058 
00059   QPointF transferFunction2ScreenCoordinates( qreal x, qreal y);
00060   QPointF screen2TransferFunctionCoordinates( qreal x, qreal y);
00061 
00062   virtual QRectF boundingRect()const;
00063 protected:
00064   qreal y(const QVariant& value)const;
00065   inline qreal y(const ctkPoint& point)const;
00066 
00067   QColor color(const QVariant& value)const;
00068   inline QColor color(const ctkPoint& point)const;
00069 
00070   QList<ctkPoint> bezierParams(ctkControlPoint* start, ctkControlPoint* end)const;
00071   QList<ctkPoint> nonLinearPoints(ctkControlPoint* start, ctkControlPoint* end)const;
00072 
00073 private:
00074   CTK_DECLARE_PRIVATE(ctkTransferFunctionItem);
00075 };
00076 
00077 void ctkTransferFunctionItem::setRect(qreal x, qreal y, qreal width, qreal height)
00078 {
00079   this->setRect(QRectF(x,y,width,height));
00080 }
00081 
00082 qreal ctkTransferFunctionItem::y(const ctkPoint& p)const
00083 {
00084   return this->y(p.Value);
00085 }
00086 
00087 QColor ctkTransferFunctionItem::color(const ctkPoint& p)const
00088 {
00089   return this->color(p.Value);
00090 }
00091 
00092 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 21 May 2010 for CTK by  doxygen 1.6.1