1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
/*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2008 Scientific Computing and Imaging Institute,
University of Utah.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
//! File : Q1DTransferFunction.h
//! Author : Jens Krueger
//! SCI Institute
//! University of Utah
//! Date : July 2008
//
//! Copyright (C) 2008 SCI Institute
#pragma once
#ifndef Q1DTRANSFERFUNCTION
#define Q1DTRANSFERFUNCTION
#include "QTransferFunction.h"
#include "../Tuvok/IO/TransferFunction1D.h"
class Q1DTransferFunction : public QTransferFunction
{
Q_OBJECT
public:
enum paintMode { PAINT_NONE=0, PAINT_RED=1, PAINT_GREEN=2,
PAINT_BLUE=4, PAINT_ALPHA=8, PAINT_UNDEF=16 };
Q1DTransferFunction(MasterController& masterController, QWidget *parent=0);
virtual ~Q1DTransferFunction(void);
void SetData(const Histogram1D* vHistogram,
unsigned int iMaxValue, TransferFunction1D* Trans);
const TransferFunction1D* GetTrans() {return m_pTrans;}
void SetPaintMode(paintMode iPaintMode) {
if (iPaintMode < PAINT_UNDEF) m_iPaintMode = iPaintMode;
}
virtual void ApplyFunction();
public slots:
bool LoadFromFile(const QString& strFilename);
bool SaveToFile(const QString& strFilename);
bool AddFromFile(const QString& strFilename);
bool SubtractFromFile(const QString& strFilename);
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void changeEvent(QEvent * event);
private:
NormalizedHistogram1D m_vHistogram;
TransferFunction1D* m_pTrans;
unsigned int m_iPaintMode;
// cached image of the backdrop
unsigned int m_iCachedHeight;
unsigned int m_iCachedWidth;
QPixmap* m_pBackdropCache;
QImage* m_pPreviewBack;
QImage* m_pPreviewColor;
// borders, may be changed in the constructor
unsigned int m_iLeftBorder;
unsigned int m_iBottomBorder;
unsigned int m_iTopPreviewHeight;
unsigned int m_iTopPreviewDist;
// automatically computed borders (computed by DrawCoordinateSystem)
unsigned int m_iRightBorder;
unsigned int m_iTopBorder;
// colors, may be changed in the setcolor
QColor m_colorHistogram;
QColor m_colorBack;
QColor m_colorBorder;
QColor m_colorScale;
QColor m_colorLargeScale;
QColor m_colorRedLine;
QColor m_colorGreenLine;
QColor m_colorBlueLine;
QColor m_colorAlphaLine;
void SetColor(bool bIsEnabled);
// scale apearance, defaults can be changed in the constructor
unsigned int m_iMarkersX;
unsigned int m_iMarkersY;
unsigned int m_iBigMarkerSpacingX;
unsigned int m_iBigMarkerSpacingY;
unsigned int m_iMarkerLength;
unsigned int m_iBigMarkerLength;
// mouse motion handling
int m_iLastIndex;
float m_fLastValue;
bool m_bMouseLeft;
bool m_bMouseRight;
// drawing routines
void DrawCoordinateSystem(QPainter& painter);
void DrawHistogram(QPainter& painter);
void DrawFunctionPlots(QPainter& painter);
void PreparePreviewData();
void RedrawPreviewBarBack();
};
#endif // Q1DTRANSFERFUNCTION
|